diff --git a/invesalius/reader/dicom_grouper.py b/invesalius/reader/dicom_grouper.py index ddda602..65afcec 100644 --- a/invesalius/reader/dicom_grouper.py +++ b/invesalius/reader/dicom_grouper.py @@ -94,6 +94,7 @@ class DicomGroup: def GetSpacing(self): list_ = self.GetSortedList() + if (len(list_) > 1): dicom = list_[0] axis = ORIENT_MAP[dicom.image.orientation_label] @@ -142,7 +143,7 @@ class PatientGroup: if not slice_added: # If we're here, then Problem 2 occured # TODO: Optimize recursion - self.AddFile(file_path, index+1) + self.AddFile(dicom, index+1) group.GetSpacing() diff --git a/invesalius/reader/dicom_reader.py b/invesalius/reader/dicom_reader.py index 4c3f960..0b90d98 100644 --- a/invesalius/reader/dicom_reader.py +++ b/invesalius/reader/dicom_reader.py @@ -32,19 +32,20 @@ def LoadImages(dir_): # TODO!!! SUPER GAMBIARRA!!! DO THIS BETTER patient_group = GetDicomFiles(dir_) - + #select the series with the largest + #number of slices. + nslices_old = 0 for patient in patient_group: group_list = patient.GetGroups() for group in group_list: - d = group.GetList() - spacing = group.spacing - - #dcm_series = dicom_grouper.DicomGroup() - #dcm_series.SetFileList(dcm_files) - #dcm_series.Update() - + nslices = group.nslices + if (nslices >= nslices_old): + dicoms = group.GetList() + spacing = group.spacing + nslices_old = nslices + file_list = [] - for dicom in d: + for dicom in dicoms: file_list.append(dicom.image.file) #Coronal Crash. necessary verify -- libgit2 0.21.2