From 2239286d0ac93fe47a469d09cc4c505c23b583d6 Mon Sep 17 00:00:00 2001 From: paulojamorim Date: Tue, 25 Aug 2009 17:00:04 +0000 Subject: [PATCH] ADD:Window & Level default from DICOM --- invesalius/reader/dicom_grouper.py | 22 +++++++++++++++++----- invesalius/reader/dicom_reader.py | 15 +++++++++------ 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/invesalius/reader/dicom_grouper.py b/invesalius/reader/dicom_grouper.py index c5c864f..0dd397b 100644 --- a/invesalius/reader/dicom_grouper.py +++ b/invesalius/reader/dicom_grouper.py @@ -121,6 +121,8 @@ class ivDicomGroups: spacing = parser.GetPixelSpacing() id_study = parser.GetStudyID() tilt = parser.GetAcquisitionGantryTilt() + window = parser.GetImageWindowWidth() + level = parser.GetImageWindowLevel() if (parser.GetImageThickness()): spacing.append(parser.GetImageThickness()) @@ -135,7 +137,9 @@ class ivDicomGroups: image_position, patient_position, image_type,patient_name, image_orientation_label, file, - series_description, id_study, tilt]) + series_description, id_study, tilt, + window, level]) + self.filelist = filelist def __GetInformations(self, ind): @@ -160,12 +164,15 @@ class ivDicomGroups: series_description = filelist[ind][9] id_study = filelist[ind][10] tilt = filelist[ind][11] + window = filelist[ind][12] + level = filelist[ind][13] list = [image_number, serie_number, spacing, image_position, patient_position, image_type,patient_name, image_orientation_label, file, - series_description, id_study, tilt] + series_description, id_study, tilt, + window, level] return list @@ -311,6 +318,8 @@ class ivDicomGroups: series_description = groups_dcm[key][0][y][9] id_study = groups_dcm[key][0][y][10] tilt = groups_dcm[key][0][y][11] + window = groups_dcm[key][0][y][12] + level = groups_dcm[key][0][y][13] #Generate new key to dictionary key_ = (image_pos[0], image_pos[1], image_pos[2]) @@ -320,7 +329,8 @@ class ivDicomGroups: image_position, patient_position, image_type,patient_name, image_orientation_label, file, - series_description, id_study, tilt] + series_description, id_study, tilt, + window, level] #If list Null, create dictionary #and add list with information @@ -379,6 +389,8 @@ class ivDicomGroups: series_description = tmp1[key][9] id_study = tmp1[key][10] tilt = tmp1[key][11] + window = tmp1[key][12] + level = tmp1[key][13] new_key = (patient_name, None, x, image_orientation_label) @@ -387,8 +399,8 @@ class ivDicomGroups: image_position, patient_position, image_type,patient_name, image_orientation_label, file, - series_description, id_study, tilt] - + series_description, id_study, tilt, + window, level] if (new_key in groups_dcm_.keys()): groups_dcm_[new_key][0].append(list) diff --git a/invesalius/reader/dicom_reader.py b/invesalius/reader/dicom_reader.py index 63fbe98..ac57133 100644 --- a/invesalius/reader/dicom_reader.py +++ b/invesalius/reader/dicom_reader.py @@ -72,10 +72,13 @@ def LoadImages(dir_): spacing = groups[key][1][14] spacing_z = groups[key][1][30] orientation = groups[key][0][x][7] + window = groups[key][0][x][12] + level = groups[key][0][x][13] - files = file_list + + files = file_list #Coronal Crash. necessary verify - if (orientation <> "CORONAL"): + if (orientation <> "CORONAL"): #Organize reversed image sorter = gdcm.IPPSorter() sorter.SetComputeZSpacing(True) @@ -83,7 +86,7 @@ def LoadImages(dir_): sorter.Sort(file_list) #Getting organized image files = sorter.GetFilenames() - + array = vtk.vtkStringArray() img_app = vtk.vtkImageAppend() @@ -96,7 +99,7 @@ def LoadImages(dir_): read = vtkgdcm.vtkGDCMImageReader() read.SetFileNames(array) read.Update() - + img_axial = vtk.vtkImageData() img_axial.DeepCopy(read.GetOutput()) img_axial.SetSpacing(spacing, spacing, spacing_z) @@ -123,8 +126,8 @@ def LoadImages(dir_): img_axial.Update() - - return img_axial, acquisition_modality, tilt, orientation + + return img_axial, acquisition_modality, tilt, orientation, window, level def GetDicomFiles(path, recursive = False): # TODO!!! SUPER GAMBIARRA!!! DO THIS BETTER -- libgit2 0.21.2