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