Commit 546ea0d2bb7cb5358e2c1a8107c904ef30ed1b87
1 parent
fe53df6d
Exists in
master
and in
67 other branches
FIX: Fixed open sagittal study
Showing
1 changed file
with
14 additions
and
27 deletions
Show diff stats
invesalius/reader/dicom_reader.py
@@ -101,9 +101,8 @@ class LoadDicom: | @@ -101,9 +101,8 @@ class LoadDicom: | ||
101 | 101 | ||
102 | grouper = self.grouper | 102 | grouper = self.grouper |
103 | 103 | ||
104 | - reader = gdcm.Reader() | 104 | + reader = gdcm.ImageReader() |
105 | reader.SetFileName(self.filepath) | 105 | reader.SetFileName(self.filepath) |
106 | - | ||
107 | if (reader.Read()): | 106 | if (reader.Read()): |
108 | file = reader.GetFile() | 107 | file = reader.GetFile() |
109 | 108 | ||
@@ -207,8 +206,20 @@ class LoadDicom: | @@ -207,8 +206,20 @@ class LoadDicom: | ||
207 | write_png.SetFileName(thumbnail_path) | 206 | write_png.SetFileName(thumbnail_path) |
208 | write_png.Write() | 207 | write_png.Write() |
209 | 208 | ||
209 | + #------ Verify the orientation -------------------------------- | ||
210 | + | ||
211 | + img = reader.GetImage() | ||
212 | + direc_cosines = img.GetDirectionCosines() | ||
213 | + orientation = gdcm.Orientation() | ||
214 | + try: | ||
215 | + type = orientation.GetType(tuple(direc_cosines)) | ||
216 | + except TypeError: | ||
217 | + type = orientation.GetType(direc_cosines) | ||
218 | + label = orientation.GetLabel(type) | ||
219 | + | ||
220 | + | ||
210 | # ---------- Refactory -------------------------------------- | 221 | # ---------- Refactory -------------------------------------- |
211 | - data_dict['invesalius'] = {'orientation_label' : GetImageOrientationLabel(self.filepath)} | 222 | + data_dict['invesalius'] = {'orientation_label' : label} |
212 | 223 | ||
213 | # ------------------------------------------------------------- | 224 | # ------------------------------------------------------------- |
214 | dict_file[self.filepath] = data_dict | 225 | dict_file[self.filepath] = data_dict |
@@ -240,30 +251,6 @@ class LoadDicom: | @@ -240,30 +251,6 @@ class LoadDicom: | ||
240 | #plistlib.writePlist(main_dict, ".//teste.plist")""" | 251 | #plistlib.writePlist(main_dict, ".//teste.plist")""" |
241 | 252 | ||
242 | 253 | ||
243 | -def GetImageOrientationLabel(filename): | ||
244 | - """ | ||
245 | - Return Label regarding the orientation of | ||
246 | - an image. (AXIAL, SAGITTAL, CORONAL, | ||
247 | - OBLIQUE or UNKNOWN) | ||
248 | - """ | ||
249 | - gdcm_reader = gdcm.ImageReader() | ||
250 | - gdcm_reader.SetFileName(filename) | ||
251 | - | ||
252 | - img = gdcm_reader.GetImage() | ||
253 | - direc_cosines = img.GetDirectionCosines() | ||
254 | - orientation = gdcm.Orientation() | ||
255 | - try: | ||
256 | - type = orientation.GetType(tuple(direc_cosines)) | ||
257 | - except TypeError: | ||
258 | - type = orientation.GetType(direc_cosines) | ||
259 | - label = orientation.GetLabel(type) | ||
260 | - | ||
261 | - if (label): | ||
262 | - return label | ||
263 | - else: | ||
264 | - return "" | ||
265 | - | ||
266 | - | ||
267 | def yGetDicomGroups(directory, recursive=True, gui=True): | 254 | def yGetDicomGroups(directory, recursive=True, gui=True): |
268 | """ | 255 | """ |
269 | Return all full paths to DICOM files inside given directory. | 256 | Return all full paths to DICOM files inside given directory. |