Commit 51a15bf1b9e3f0eb251bee95abbb58a3be8e405a
1 parent
69febb42
Exists in
master
and in
68 other branches
ENH: Add thread to read dicom
Showing
2 changed files
with
6 additions
and
63 deletions
Show diff stats
invesalius/control.py
@@ -41,20 +41,15 @@ class Controller(): | @@ -41,20 +41,15 @@ class Controller(): | ||
41 | 41 | ||
42 | reader = dcm.ProgressDicomReader() | 42 | reader = dcm.ProgressDicomReader() |
43 | reader.SetWindowEvent(self.frame) | 43 | reader.SetWindowEvent(self.frame) |
44 | - reader.SetDirectoryPath(str(path)) | 44 | + reader.SetDirectoryPath(path) |
45 | 45 | ||
46 | - self.frame.Bind(dicomgroups.evt_update_progress, self.Progress) | ||
47 | - self.frame.Bind(dicomgroups.evt_end_load_file, self.LoadPanel) | ||
48 | - #thread.start_new_thread(t.GetDicomGroups, (path,True, lock)) | 46 | + self.frame.Bind(reader.evt_update_progress, self.Progress) |
47 | + self.frame.Bind(reader.evt_end_load_file, self.LoadPanel) | ||
49 | 48 | ||
50 | def Progress(self, evt): | 49 | def Progress(self, evt): |
51 | print evt.progress | 50 | print evt.progress |
52 | - print "AAAAA" | ||
53 | - #ps.Publisher().sendMessage("Progress Import") | ||
54 | 51 | ||
55 | def LoadPanel(self,evt): | 52 | def LoadPanel(self,evt): |
56 | - print "LoadPanel" | ||
57 | - print evt.value | ||
58 | patient_series = evt.value | 53 | patient_series = evt.value |
59 | if patient_series: | 54 | if patient_series: |
60 | ps.Publisher().sendMessage("Load import panel", patient_series) | 55 | ps.Publisher().sendMessage("Load import panel", patient_series) |
@@ -62,9 +57,7 @@ class Controller(): | @@ -62,9 +57,7 @@ class Controller(): | ||
62 | ps.Publisher().sendMessage("Load dicom preview", first_patient) | 57 | ps.Publisher().sendMessage("Load dicom preview", first_patient) |
63 | else: | 58 | else: |
64 | print "No DICOM files on directory" | 59 | print "No DICOM files on directory" |
65 | - | ||
66 | - | ||
67 | - | 60 | + |
68 | def OnImportMedicalImages(self, pubsub_evt): | 61 | def OnImportMedicalImages(self, pubsub_evt): |
69 | directory = pubsub_evt.data | 62 | directory = pubsub_evt.data |
70 | self.ImportMedicalImages(directory) | 63 | self.ImportMedicalImages(directory) |
invesalius/reader/dicom_reader.py
@@ -133,8 +133,7 @@ class ProgressDicomReader: | @@ -133,8 +133,7 @@ class ProgressDicomReader: | ||
133 | 133 | ||
134 | def SetDirectoryPath(self, path,recursive=True): | 134 | def SetDirectoryPath(self, path,recursive=True): |
135 | self.running = True | 135 | self.running = True |
136 | - print "1",path,recursive | ||
137 | - thread.start_new_thread(self.GetDicomGroupsIntern,(path,recursive)) | 136 | + thread.start_new_thread(self.GetDicomGroups,(path,recursive)) |
138 | 137 | ||
139 | def UpdateLoadFileProgress(self,cont_progress): | 138 | def UpdateLoadFileProgress(self,cont_progress): |
140 | evt = self.LoadFilesProgress(progress = cont_progress) | 139 | evt = self.LoadFilesProgress(progress = cont_progress) |
@@ -151,55 +150,6 @@ class ProgressDicomReader: | @@ -151,55 +150,6 @@ class ProgressDicomReader: | ||
151 | if isinstance(value_progress, float): | 150 | if isinstance(value_progress, float): |
152 | self.UpdateLoadFileProgress(value_progress) | 151 | self.UpdateLoadFileProgress(value_progress) |
153 | else: | 152 | else: |
154 | - print "____________________" | ||
155 | - print value_progress | ||
156 | self.EndLoadFile(value_progress) | 153 | self.EndLoadFile(value_progress) |
157 | self.running = False | 154 | self.running = False |
158 | - | ||
159 | - def GetDicomGroupsOld(self): | ||
160 | - """ | ||
161 | - Return all full paths to DICOM files inside given directory. | ||
162 | - """ | ||
163 | - while self.running: | ||
164 | - grouper = dicom_grouper.DicomPatientGrouper() | ||
165 | - dirpath = directory = self.dirpath | ||
166 | - nfiles = 0 | ||
167 | - # Find total number of files | ||
168 | - if self.recursive: | ||
169 | - for dirpath, dirnames, filenames in os.walk(directory): | ||
170 | - nfiles += len(filenames) | ||
171 | - else: | ||
172 | - dirpath, dirnames, filenames = os.walk(directory) | ||
173 | - nfiles = len(filenames) | ||
174 | - | ||
175 | - print "TOTAL FILES:", nfiles | ||
176 | - cont_progress = 0 | ||
177 | - # Retrieve only DICOM files, splited into groups | ||
178 | - if self.recursive: | ||
179 | - for dirpath, dirnames, filenames in os.walk(directory): | ||
180 | - print "@: ",dirpath | ||
181 | - for name in filenames: | ||
182 | - filepath = str(os.path.join(dirpath, name)) | ||
183 | - parser = dicom.Parser() | ||
184 | - | ||
185 | - cont_progress += 1 | ||
186 | - self.UpdateLoadFileProgress(cont_progress, nfiles) | ||
187 | - | ||
188 | - if parser.SetFileName(filepath): | ||
189 | - dcm = dicom.Dicom() | ||
190 | - dcm.SetParser(parser) | ||
191 | - grouper.AddFile(dcm) | ||
192 | - else: | ||
193 | - dirpath, dirnames, filenames = os.walk(directory) | ||
194 | - print "@: ",dirpath | ||
195 | - for name in filenames: | ||
196 | - filepath = str(os.path.join(dirpath, name)) | ||
197 | - parser = dicom.Parser() | ||
198 | - if parser.SetFileName(filepath): | ||
199 | - dcm = dicom.Dicom() | ||
200 | - dcm.SetParser(parser) | ||
201 | - grouper.AddFile(dcm) | ||
202 | - self.running = False | ||
203 | - self.EndLoadFile(grouper) | ||
204 | - #return grouper.GetPatientsGroups() | ||
205 | - | 155 | + |
206 | \ No newline at end of file | 156 | \ No newline at end of file |