Commit cf6af70c6e705d0320cf410daf5927cef076072f
1 parent
03258f78
Exists in
master
and in
68 other branches
FIX: Crash program if open DICOM with Localization None
Showing
2 changed files
with
25 additions
and
16 deletions
Show diff stats
invesalius/reader/dicom_grouper.py
... | ... | @@ -121,6 +121,7 @@ class ivDicomGroups: |
121 | 121 | spacing = parser.GetPixelSpacing() |
122 | 122 | id_study = parser.GetStudyID() |
123 | 123 | tilt = parser.GetAcquisitionGantryTilt() |
124 | + localization = parser.GetImageLocation() | |
124 | 125 | |
125 | 126 | if (parser.GetImageThickness()): |
126 | 127 | spacing.append(parser.GetImageThickness()) |
... | ... | @@ -135,7 +136,7 @@ class ivDicomGroups: |
135 | 136 | image_position, patient_position, |
136 | 137 | image_type,patient_name, |
137 | 138 | image_orientation_label, file, |
138 | - series_description, id_study, tilt]) | |
139 | + series_description, id_study, tilt, localization]) | |
139 | 140 | self.filelist = filelist |
140 | 141 | |
141 | 142 | def __GetInformations(self, ind): |
... | ... | @@ -160,12 +161,14 @@ class ivDicomGroups: |
160 | 161 | series_description = filelist[ind][9] |
161 | 162 | id_study = filelist[ind][10] |
162 | 163 | tilt = filelist[ind][11] |
164 | + localization = filelist[ind][12] | |
163 | 165 | |
164 | 166 | list = [image_number, serie_number, spacing, |
165 | 167 | image_position, patient_position, |
166 | 168 | image_type,patient_name, |
167 | 169 | image_orientation_label, file, |
168 | - series_description, id_study, tilt] | |
170 | + series_description, id_study, tilt, | |
171 | + localization] | |
169 | 172 | |
170 | 173 | return list |
171 | 174 | |
... | ... | @@ -311,6 +314,7 @@ class ivDicomGroups: |
311 | 314 | series_description = groups_dcm[key][0][y][9] |
312 | 315 | id_study = groups_dcm[key][0][y][10] |
313 | 316 | tilt = groups_dcm[key][0][y][11] |
317 | + localization = groups_dcm[key][0][y][12] | |
314 | 318 | |
315 | 319 | #Generate new key to dictionary |
316 | 320 | key_ = (image_pos[0], image_pos[1], image_pos[2]) |
... | ... | @@ -320,7 +324,7 @@ class ivDicomGroups: |
320 | 324 | image_position, patient_position, |
321 | 325 | image_type,patient_name, |
322 | 326 | image_orientation_label, file, |
323 | - series_description, id_study, tilt] | |
327 | + series_description, id_study, tilt, localization] | |
324 | 328 | |
325 | 329 | #If list Null, create dictionary |
326 | 330 | #and add list with information |
... | ... | @@ -379,6 +383,7 @@ class ivDicomGroups: |
379 | 383 | series_description = tmp1[key][9] |
380 | 384 | id_study = tmp1[key][10] |
381 | 385 | tilt = tmp1[key][11] |
386 | + localization = tmp1[key][12] | |
382 | 387 | |
383 | 388 | new_key = (patient_name, None, x, image_orientation_label) |
384 | 389 | |
... | ... | @@ -387,7 +392,8 @@ class ivDicomGroups: |
387 | 392 | image_position, patient_position, |
388 | 393 | image_type,patient_name, |
389 | 394 | image_orientation_label, file, |
390 | - series_description, id_study, tilt] | |
395 | + series_description, id_study, tilt, | |
396 | + localization] | |
391 | 397 | |
392 | 398 | |
393 | 399 | if (new_key in groups_dcm_.keys()): | ... | ... |
invesalius/reader/dicom_reader.py
... | ... | @@ -71,17 +71,20 @@ def LoadImages(dir_): |
71 | 71 | tilt = groups[key][0][x][11] |
72 | 72 | spacing = groups[key][1][14] |
73 | 73 | spacing_z = groups[key][1][30] |
74 | - | |
75 | - | |
76 | - #Organize reversed image | |
77 | - sorter = gdcm.IPPSorter() | |
78 | - sorter.SetComputeZSpacing(True) | |
79 | - sorter.SetZSpacingTolerance(1e-10) | |
80 | - sorter.Sort(file_list) | |
81 | - | |
82 | - #Getting organized image | |
83 | - files = sorter.GetFilenames() | |
84 | - | |
74 | + localization = groups[key][0][x][12] | |
75 | + | |
76 | + files = file_list | |
77 | + #Coronal or Sagital with | |
78 | + #localization None Crash. necessary verify | |
79 | + if (localization): | |
80 | + #Organize reversed image | |
81 | + sorter = gdcm.IPPSorter() | |
82 | + sorter.SetComputeZSpacing(True) | |
83 | + sorter.SetZSpacingTolerance(1e-10) | |
84 | + sorter.Sort(file_list) | |
85 | + #Getting organized image | |
86 | + files = sorter.GetFilenames() | |
87 | + | |
85 | 88 | array = vtk.vtkStringArray() |
86 | 89 | |
87 | 90 | img_app = vtk.vtkImageAppend() |
... | ... | @@ -121,7 +124,7 @@ def LoadImages(dir_): |
121 | 124 | |
122 | 125 | |
123 | 126 | img_axial.Update() |
124 | - | |
127 | + | |
125 | 128 | return img_axial, acquisition_modality, tilt |
126 | 129 | |
127 | 130 | def GetDicomFiles(path, recursive = False): | ... | ... |