From 51a15bf1b9e3f0eb251bee95abbb58a3be8e405a Mon Sep 17 00:00:00 2001 From: paulojamorim Date: Fri, 16 Oct 2009 19:56:12 +0000 Subject: [PATCH] ENH: Add thread to read dicom --- invesalius/control.py | 15 ++++----------- invesalius/reader/dicom_reader.py | 54 ++---------------------------------------------------- 2 files changed, 6 insertions(+), 63 deletions(-) diff --git a/invesalius/control.py b/invesalius/control.py index 66a9b87..9b17f14 100755 --- a/invesalius/control.py +++ b/invesalius/control.py @@ -41,20 +41,15 @@ class Controller(): reader = dcm.ProgressDicomReader() reader.SetWindowEvent(self.frame) - reader.SetDirectoryPath(str(path)) + reader.SetDirectoryPath(path) - self.frame.Bind(dicomgroups.evt_update_progress, self.Progress) - self.frame.Bind(dicomgroups.evt_end_load_file, self.LoadPanel) - #thread.start_new_thread(t.GetDicomGroups, (path,True, lock)) + self.frame.Bind(reader.evt_update_progress, self.Progress) + self.frame.Bind(reader.evt_end_load_file, self.LoadPanel) def Progress(self, evt): print evt.progress - print "AAAAA" - #ps.Publisher().sendMessage("Progress Import") def LoadPanel(self,evt): - print "LoadPanel" - print evt.value patient_series = evt.value if patient_series: ps.Publisher().sendMessage("Load import panel", patient_series) @@ -62,9 +57,7 @@ class Controller(): ps.Publisher().sendMessage("Load dicom preview", first_patient) else: print "No DICOM files on directory" - - - + def OnImportMedicalImages(self, pubsub_evt): directory = pubsub_evt.data self.ImportMedicalImages(directory) diff --git a/invesalius/reader/dicom_reader.py b/invesalius/reader/dicom_reader.py index 29496db..1cb8d2a 100644 --- a/invesalius/reader/dicom_reader.py +++ b/invesalius/reader/dicom_reader.py @@ -133,8 +133,7 @@ class ProgressDicomReader: def SetDirectoryPath(self, path,recursive=True): self.running = True - print "1",path,recursive - thread.start_new_thread(self.GetDicomGroupsIntern,(path,recursive)) + thread.start_new_thread(self.GetDicomGroups,(path,recursive)) def UpdateLoadFileProgress(self,cont_progress): evt = self.LoadFilesProgress(progress = cont_progress) @@ -151,55 +150,6 @@ class ProgressDicomReader: if isinstance(value_progress, float): self.UpdateLoadFileProgress(value_progress) else: - print "____________________" - print value_progress self.EndLoadFile(value_progress) self.running = False - - def GetDicomGroupsOld(self): - """ - Return all full paths to DICOM files inside given directory. - """ - while self.running: - grouper = dicom_grouper.DicomPatientGrouper() - dirpath = directory = self.dirpath - nfiles = 0 - # Find total number of files - if self.recursive: - for dirpath, dirnames, filenames in os.walk(directory): - nfiles += len(filenames) - else: - dirpath, dirnames, filenames = os.walk(directory) - nfiles = len(filenames) - - print "TOTAL FILES:", nfiles - cont_progress = 0 - # Retrieve only DICOM files, splited into groups - if self.recursive: - for dirpath, dirnames, filenames in os.walk(directory): - print "@: ",dirpath - for name in filenames: - filepath = str(os.path.join(dirpath, name)) - parser = dicom.Parser() - - cont_progress += 1 - self.UpdateLoadFileProgress(cont_progress, nfiles) - - if parser.SetFileName(filepath): - dcm = dicom.Dicom() - dcm.SetParser(parser) - grouper.AddFile(dcm) - else: - dirpath, dirnames, filenames = os.walk(directory) - print "@: ",dirpath - for name in filenames: - filepath = str(os.path.join(dirpath, name)) - parser = dicom.Parser() - if parser.SetFileName(filepath): - dcm = dicom.Dicom() - dcm.SetParser(parser) - grouper.AddFile(dcm) - self.running = False - self.EndLoadFile(grouper) - #return grouper.GetPatientsGroups() - + \ No newline at end of file -- libgit2 0.21.2