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 | 41 | |
42 | 42 | reader = dcm.ProgressDicomReader() |
43 | 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 | 49 | def Progress(self, evt): |
51 | 50 | print evt.progress |
52 | - print "AAAAA" | |
53 | - #ps.Publisher().sendMessage("Progress Import") | |
54 | 51 | |
55 | 52 | def LoadPanel(self,evt): |
56 | - print "LoadPanel" | |
57 | - print evt.value | |
58 | 53 | patient_series = evt.value |
59 | 54 | if patient_series: |
60 | 55 | ps.Publisher().sendMessage("Load import panel", patient_series) |
... | ... | @@ -62,9 +57,7 @@ class Controller(): |
62 | 57 | ps.Publisher().sendMessage("Load dicom preview", first_patient) |
63 | 58 | else: |
64 | 59 | print "No DICOM files on directory" |
65 | - | |
66 | - | |
67 | - | |
60 | + | |
68 | 61 | def OnImportMedicalImages(self, pubsub_evt): |
69 | 62 | directory = pubsub_evt.data |
70 | 63 | self.ImportMedicalImages(directory) | ... | ... |
invesalius/reader/dicom_reader.py
... | ... | @@ -133,8 +133,7 @@ class ProgressDicomReader: |
133 | 133 | |
134 | 134 | def SetDirectoryPath(self, path,recursive=True): |
135 | 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 | 138 | def UpdateLoadFileProgress(self,cont_progress): |
140 | 139 | evt = self.LoadFilesProgress(progress = cont_progress) |
... | ... | @@ -151,55 +150,6 @@ class ProgressDicomReader: |
151 | 150 | if isinstance(value_progress, float): |
152 | 151 | self.UpdateLoadFileProgress(value_progress) |
153 | 152 | else: |
154 | - print "____________________" | |
155 | - print value_progress | |
156 | 153 | self.EndLoadFile(value_progress) |
157 | 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 | 156 | \ No newline at end of file | ... | ... |