def ImportMedicalImages(self, directory, gui=True): patients_groups = dcm.GetDicomGroups(directory) name = directory.rpartition('\\')[-1].split('.') print("patients: ", patients_groups) if len(patients_groups): # OPTION 1: DICOM group = dcm.SelectLargerDicomGroup(patients_groups) matrix, matrix_filename, dicom = self.OpenDicomGroup(group, 0, [0, 0], gui=gui) self.CreateDicomProject(dicom, matrix, matrix_filename) else: # OPTION 2: NIfTI, Analyze or PAR/REC if name[-1] == 'gz': name[1] = 'nii.gz' suptype = ('hdr', 'nii', 'nii.gz', 'par') filetype = name[1].lower() if filetype in suptype: group = oth.ReadOthers(directory) else: utils.debug("No medical images found on given directory") return matrix, matrix_filename = self.OpenOtherFiles(group) self.CreateOtherProject(str(name[0]), matrix, matrix_filename) # OPTION 4: Nothing... self.LoadProject() Publisher.sendMessage("Enable state project", state=True)
def OnOpenOtherFiles(self, filepath): filepath = utils.decode(filepath, const.FS_ENCODE) if not (filepath) == None: name = os.path.basename(filepath).split(".")[0] group = oth.ReadOthers(filepath) if group: matrix, matrix_filename = self.OpenOtherFiles(group) self.CreateOtherProject(name, matrix, matrix_filename) self.LoadProject() Publisher.sendMessage("Enable state project", state=True) else: dialog.ImportInvalidFiles(ftype="Others")
def OnOpenOtherFiles(self, pubsub_evt): filepath = utils.decode(pubsub_evt.data, const.FS_ENCODE) if not (filepath) == None: name = filepath.rpartition('\\')[-1].split('.') group = oth.ReadOthers(filepath) if group: matrix, matrix_filename = self.OpenOtherFiles(group) self.CreateOtherProject(str(name[0]), matrix, matrix_filename) self.LoadProject() Publisher.sendMessage("Enable state project", True) else: dialog.ImportInvalidFiles(ftype="Others")
def OnOpenOtherFiles(self, pubsub_evt): filepath = pubsub_evt.data name = filepath.rpartition('\\')[-1].split('.') if name[-1] == 'gz': name[1] = 'nii.gz' suptype = ('hdr', 'nii', 'nii.gz', 'par') filetype = name[1].lower() if filetype in suptype: group = oth.ReadOthers(filepath) else: dialog.ImportInvalidFiles() matrix, matrix_filename = self.OpenOtherFiles(group) self.CreateOtherProject(str(name[0]), matrix, matrix_filename) self.LoadProject() Publisher.sendMessage("Enable state project", True)