Commit 2239286d0ac93fe47a469d09cc4c505c23b583d6
1 parent
3b5cb43a
Exists in
master
and in
68 other branches
ADD:Window & Level default from DICOM
Showing
2 changed files
with
26 additions
and
11 deletions
Show diff stats
invesalius/reader/dicom_grouper.py
... | ... | @@ -121,6 +121,8 @@ class ivDicomGroups: |
121 | 121 | spacing = parser.GetPixelSpacing() |
122 | 122 | id_study = parser.GetStudyID() |
123 | 123 | tilt = parser.GetAcquisitionGantryTilt() |
124 | + window = parser.GetImageWindowWidth() | |
125 | + level = parser.GetImageWindowLevel() | |
124 | 126 | |
125 | 127 | if (parser.GetImageThickness()): |
126 | 128 | spacing.append(parser.GetImageThickness()) |
... | ... | @@ -135,7 +137,9 @@ class ivDicomGroups: |
135 | 137 | image_position, patient_position, |
136 | 138 | image_type,patient_name, |
137 | 139 | image_orientation_label, file, |
138 | - series_description, id_study, tilt]) | |
140 | + series_description, id_study, tilt, | |
141 | + window, level]) | |
142 | + | |
139 | 143 | self.filelist = filelist |
140 | 144 | |
141 | 145 | def __GetInformations(self, ind): |
... | ... | @@ -160,12 +164,15 @@ class ivDicomGroups: |
160 | 164 | series_description = filelist[ind][9] |
161 | 165 | id_study = filelist[ind][10] |
162 | 166 | tilt = filelist[ind][11] |
167 | + window = filelist[ind][12] | |
168 | + level = filelist[ind][13] | |
163 | 169 | |
164 | 170 | list = [image_number, serie_number, spacing, |
165 | 171 | image_position, patient_position, |
166 | 172 | image_type,patient_name, |
167 | 173 | image_orientation_label, file, |
168 | - series_description, id_study, tilt] | |
174 | + series_description, id_study, tilt, | |
175 | + window, level] | |
169 | 176 | |
170 | 177 | return list |
171 | 178 | |
... | ... | @@ -311,6 +318,8 @@ class ivDicomGroups: |
311 | 318 | series_description = groups_dcm[key][0][y][9] |
312 | 319 | id_study = groups_dcm[key][0][y][10] |
313 | 320 | tilt = groups_dcm[key][0][y][11] |
321 | + window = groups_dcm[key][0][y][12] | |
322 | + level = groups_dcm[key][0][y][13] | |
314 | 323 | |
315 | 324 | #Generate new key to dictionary |
316 | 325 | key_ = (image_pos[0], image_pos[1], image_pos[2]) |
... | ... | @@ -320,7 +329,8 @@ class ivDicomGroups: |
320 | 329 | image_position, patient_position, |
321 | 330 | image_type,patient_name, |
322 | 331 | image_orientation_label, file, |
323 | - series_description, id_study, tilt] | |
332 | + series_description, id_study, tilt, | |
333 | + window, level] | |
324 | 334 | |
325 | 335 | #If list Null, create dictionary |
326 | 336 | #and add list with information |
... | ... | @@ -379,6 +389,8 @@ class ivDicomGroups: |
379 | 389 | series_description = tmp1[key][9] |
380 | 390 | id_study = tmp1[key][10] |
381 | 391 | tilt = tmp1[key][11] |
392 | + window = tmp1[key][12] | |
393 | + level = tmp1[key][13] | |
382 | 394 | |
383 | 395 | new_key = (patient_name, None, x, image_orientation_label) |
384 | 396 | |
... | ... | @@ -387,8 +399,8 @@ class ivDicomGroups: |
387 | 399 | image_position, patient_position, |
388 | 400 | image_type,patient_name, |
389 | 401 | image_orientation_label, file, |
390 | - series_description, id_study, tilt] | |
391 | - | |
402 | + series_description, id_study, tilt, | |
403 | + window, level] | |
392 | 404 | |
393 | 405 | if (new_key in groups_dcm_.keys()): |
394 | 406 | groups_dcm_[new_key][0].append(list) | ... | ... |
invesalius/reader/dicom_reader.py
... | ... | @@ -72,10 +72,13 @@ def LoadImages(dir_): |
72 | 72 | spacing = groups[key][1][14] |
73 | 73 | spacing_z = groups[key][1][30] |
74 | 74 | orientation = groups[key][0][x][7] |
75 | + window = groups[key][0][x][12] | |
76 | + level = groups[key][0][x][13] | |
75 | 77 | |
76 | - files = file_list | |
78 | + | |
79 | + files = file_list | |
77 | 80 | #Coronal Crash. necessary verify |
78 | - if (orientation <> "CORONAL"): | |
81 | + if (orientation <> "CORONAL"): | |
79 | 82 | #Organize reversed image |
80 | 83 | sorter = gdcm.IPPSorter() |
81 | 84 | sorter.SetComputeZSpacing(True) |
... | ... | @@ -83,7 +86,7 @@ def LoadImages(dir_): |
83 | 86 | sorter.Sort(file_list) |
84 | 87 | #Getting organized image |
85 | 88 | files = sorter.GetFilenames() |
86 | - | |
89 | + | |
87 | 90 | array = vtk.vtkStringArray() |
88 | 91 | |
89 | 92 | img_app = vtk.vtkImageAppend() |
... | ... | @@ -96,7 +99,7 @@ def LoadImages(dir_): |
96 | 99 | read = vtkgdcm.vtkGDCMImageReader() |
97 | 100 | read.SetFileNames(array) |
98 | 101 | read.Update() |
99 | - | |
102 | + | |
100 | 103 | img_axial = vtk.vtkImageData() |
101 | 104 | img_axial.DeepCopy(read.GetOutput()) |
102 | 105 | img_axial.SetSpacing(spacing, spacing, spacing_z) |
... | ... | @@ -123,8 +126,8 @@ def LoadImages(dir_): |
123 | 126 | |
124 | 127 | |
125 | 128 | img_axial.Update() |
126 | - | |
127 | - return img_axial, acquisition_modality, tilt, orientation | |
129 | + | |
130 | + return img_axial, acquisition_modality, tilt, orientation, window, level | |
128 | 131 | |
129 | 132 | def GetDicomFiles(path, recursive = False): |
130 | 133 | # TODO!!! SUPER GAMBIARRA!!! DO THIS BETTER | ... | ... |