Commit 2cfc3302457147bfcebe9bac5168cfc1e8139ffc
1 parent
2a62683e
Exists in
master
and in
6 other branches
ENH: More options on skipping slices on import panel FIX: #168
Showing
2 changed files
with
37 additions
and
30 deletions
Show diff stats
invesalius/constants.py
@@ -85,7 +85,8 @@ ORIENTATION_COLOUR = {'AXIAL': (1,0,0), # Red | @@ -85,7 +85,8 @@ ORIENTATION_COLOUR = {'AXIAL': (1,0,0), # Red | ||
85 | 'SAGITAL': (0,0,1)} # Blue | 85 | 'SAGITAL': (0,0,1)} # Blue |
86 | 86 | ||
87 | IMPORT_INTERVAL = [_("Keep all slices"), _("Skip 1 for each 2 slices"), | 87 | IMPORT_INTERVAL = [_("Keep all slices"), _("Skip 1 for each 2 slices"), |
88 | - _("Skip 2 for each 3 slices")] | 88 | + _("Skip 2 for each 3 slices"), _("Skip 3 for each 4 slices"), |
89 | + _("Skip 4 for each 5 slices"),_("Skip 5 for each 6 slices")] | ||
89 | 90 | ||
90 | # Camera according to slice's orientation | 91 | # Camera according to slice's orientation |
91 | #CAM_POSITION = {"AXIAL":(0, 0, 1), "CORONAL":(0, -1, 0), "SAGITAL":(1, 0, 0)} | 92 | #CAM_POSITION = {"AXIAL":(0, 0, 1), "CORONAL":(0, -1, 0), "SAGITAL":(1, 0, 0)} |
invesalius/gui/import_panel.py
@@ -22,6 +22,7 @@ import wx.lib.pubsub as ps | @@ -22,6 +22,7 @@ import wx.lib.pubsub as ps | ||
22 | import wx.lib.splitter as spl | 22 | import wx.lib.splitter as spl |
23 | 23 | ||
24 | import constants as const | 24 | import constants as const |
25 | +import gui.dialogs as dlg | ||
25 | import dicom_preview_panel as dpp | 26 | import dicom_preview_panel as dpp |
26 | import reader.dicom_grouper as dcm | 27 | import reader.dicom_grouper as dcm |
27 | 28 | ||
@@ -52,16 +53,16 @@ class SelectEvent(wx.PyCommandEvent): | @@ -52,16 +53,16 @@ class SelectEvent(wx.PyCommandEvent): | ||
52 | 53 | ||
53 | def SetItemData(self, data): | 54 | def SetItemData(self, data): |
54 | self.data = data | 55 | self.data = data |
55 | - | 56 | + |
56 | 57 | ||
57 | class Panel(wx.Panel): | 58 | class Panel(wx.Panel): |
58 | def __init__(self, parent): | 59 | def __init__(self, parent): |
59 | wx.Panel.__init__(self, parent, pos=wx.Point(5, 5))#, | 60 | wx.Panel.__init__(self, parent, pos=wx.Point(5, 5))#, |
60 | #size=wx.Size(280, 656)) | 61 | #size=wx.Size(280, 656)) |
61 | - | ||
62 | - sizer = wx.BoxSizer(wx.VERTICAL) | 62 | + |
63 | + sizer = wx.BoxSizer(wx.VERTICAL) | ||
63 | sizer.Add(InnerPanel(self), 1, wx.EXPAND|wx.GROW|wx.ALL, 5) | 64 | sizer.Add(InnerPanel(self), 1, wx.EXPAND|wx.GROW|wx.ALL, 5) |
64 | - | 65 | + |
65 | self.SetSizer(sizer) | 66 | self.SetSizer(sizer) |
66 | sizer.Fit(self) | 67 | sizer.Fit(self) |
67 | 68 | ||
@@ -75,7 +76,7 @@ class InnerPanel(wx.Panel): | @@ -75,7 +76,7 @@ class InnerPanel(wx.Panel): | ||
75 | def __init__(self, parent): | 76 | def __init__(self, parent): |
76 | wx.Panel.__init__(self, parent, pos=wx.Point(5, 5))#, | 77 | wx.Panel.__init__(self, parent, pos=wx.Point(5, 5))#, |
77 | #size=wx.Size(680, 656)) | 78 | #size=wx.Size(680, 656)) |
78 | - | 79 | + |
79 | self.patients = [] | 80 | self.patients = [] |
80 | 81 | ||
81 | self._init_ui() | 82 | self._init_ui() |
@@ -86,7 +87,7 @@ class InnerPanel(wx.Panel): | @@ -86,7 +87,7 @@ class InnerPanel(wx.Panel): | ||
86 | splitter = spl.MultiSplitterWindow(self, style=wx.SP_LIVE_UPDATE) | 87 | splitter = spl.MultiSplitterWindow(self, style=wx.SP_LIVE_UPDATE) |
87 | splitter.SetOrientation(wx.VERTICAL) | 88 | splitter.SetOrientation(wx.VERTICAL) |
88 | self.splitter = splitter | 89 | self.splitter = splitter |
89 | - | 90 | + |
90 | panel = wx.Panel(self) | 91 | panel = wx.Panel(self) |
91 | #button = wx.Button(panel, -1, _("Import medical images"), (20, 20)) | 92 | #button = wx.Button(panel, -1, _("Import medical images"), (20, 20)) |
92 | 93 | ||
@@ -136,7 +137,7 @@ class InnerPanel(wx.Panel): | @@ -136,7 +137,7 @@ class InnerPanel(wx.Panel): | ||
136 | self.btn_ok.Bind(wx.EVT_BUTTON, self.OnClickOk) | 137 | self.btn_ok.Bind(wx.EVT_BUTTON, self.OnClickOk) |
137 | self.btn_cancel.Bind(wx.EVT_BUTTON, self.OnClickCancel) | 138 | self.btn_cancel.Bind(wx.EVT_BUTTON, self.OnClickCancel) |
138 | self.text_panel.Bind(EVT_SELECT_SERIE_TEXT, self.OnDblClickTextPanel) | 139 | self.text_panel.Bind(EVT_SELECT_SERIE_TEXT, self.OnDblClickTextPanel) |
139 | - | 140 | + |
140 | def ShowDicomPreview(self, pubsub_evt): | 141 | def ShowDicomPreview(self, pubsub_evt): |
141 | dicom_groups = pubsub_evt.data | 142 | dicom_groups = pubsub_evt.data |
142 | self.patients.extend(dicom_groups) | 143 | self.patients.extend(dicom_groups) |
@@ -166,16 +167,21 @@ class InnerPanel(wx.Panel): | @@ -166,16 +167,21 @@ class InnerPanel(wx.Panel): | ||
166 | if group: | 167 | if group: |
167 | self.LoadDicom(group) | 168 | self.LoadDicom(group) |
168 | 169 | ||
169 | - def OnClickCancel(self, evt): | 170 | + def OnClickCancel(self, evt): |
170 | ps.Publisher().sendMessage("Cancel DICOM load") | 171 | ps.Publisher().sendMessage("Cancel DICOM load") |
171 | 172 | ||
172 | def LoadDicom(self, group): | 173 | def LoadDicom(self, group): |
173 | interval = self.combo_interval.GetSelection() | 174 | interval = self.combo_interval.GetSelection() |
174 | if not isinstance(group, dcm.DicomGroup): | 175 | if not isinstance(group, dcm.DicomGroup): |
175 | group = max(group.GetGroups(), key=lambda g: g.nslices) | 176 | group = max(group.GetGroups(), key=lambda g: g.nslices) |
176 | - ps.Publisher().sendMessage('Open DICOM group', (group, interval)) | ||
177 | - | ||
178 | - | 177 | + |
178 | + nslices_result = group.nslices / (interval + 1) | ||
179 | + | ||
180 | + if (nslices_result > 1): | ||
181 | + ps.Publisher().sendMessage('Open DICOM group', (group, interval)) | ||
182 | + else: | ||
183 | + dlg.MissingFilesForReconstruction() | ||
184 | + | ||
179 | class TextPanel(wx.Panel): | 185 | class TextPanel(wx.Panel): |
180 | def __init__(self, parent): | 186 | def __init__(self, parent): |
181 | wx.Panel.__init__(self, parent, -1) | 187 | wx.Panel.__init__(self, parent, -1) |
@@ -183,7 +189,7 @@ class TextPanel(wx.Panel): | @@ -183,7 +189,7 @@ class TextPanel(wx.Panel): | ||
183 | self._selected_by_user = True | 189 | self._selected_by_user = True |
184 | self.idserie_treeitem = {} | 190 | self.idserie_treeitem = {} |
185 | self.treeitem_idpatient = {} | 191 | self.treeitem_idpatient = {} |
186 | - | 192 | + |
187 | self.__init_gui() | 193 | self.__init_gui() |
188 | self.__bind_events_wx() | 194 | self.__bind_events_wx() |
189 | self.__bind_pubsub_evt() | 195 | self.__bind_pubsub_evt() |
@@ -203,8 +209,8 @@ class TextPanel(wx.Panel): | @@ -203,8 +209,8 @@ class TextPanel(wx.Panel): | ||
203 | | wx.TR_FULL_ROW_HIGHLIGHT | 209 | | wx.TR_FULL_ROW_HIGHLIGHT |
204 | | wx.TR_SINGLE | 210 | | wx.TR_SINGLE |
205 | ) | 211 | ) |
206 | - | ||
207 | - | 212 | + |
213 | + | ||
208 | tree.AddColumn(_("Patient name")) | 214 | tree.AddColumn(_("Patient name")) |
209 | tree.AddColumn(_("Patient ID")) | 215 | tree.AddColumn(_("Patient ID")) |
210 | tree.AddColumn(_("Age")) | 216 | tree.AddColumn(_("Age")) |
@@ -240,7 +246,7 @@ class TextPanel(wx.Panel): | @@ -240,7 +246,7 @@ class TextPanel(wx.Panel): | ||
240 | 246 | ||
241 | def Populate(self, patient_list): | 247 | def Populate(self, patient_list): |
242 | tree = self.tree | 248 | tree = self.tree |
243 | - | 249 | + |
244 | first = 0 | 250 | first = 0 |
245 | for patient in patient_list: | 251 | for patient in patient_list: |
246 | if not isinstance(patient, dcm.PatientGroup): | 252 | if not isinstance(patient, dcm.PatientGroup): |
@@ -252,7 +258,7 @@ class TextPanel(wx.Panel): | @@ -252,7 +258,7 @@ class TextPanel(wx.Panel): | ||
252 | dicom.acquisition.time) | 258 | dicom.acquisition.time) |
253 | 259 | ||
254 | parent = tree.AppendItem(self.root, title) | 260 | parent = tree.AppendItem(self.root, title) |
255 | - | 261 | + |
256 | if not first: | 262 | if not first: |
257 | parent_select = parent | 263 | parent_select = parent |
258 | first += 1 | 264 | first += 1 |
@@ -347,14 +353,14 @@ class ImagePanel(wx.Panel): | @@ -347,14 +353,14 @@ class ImagePanel(wx.Panel): | ||
347 | self.splitter = splitter | 353 | self.splitter = splitter |
348 | 354 | ||
349 | splitter.ContainingSizer = wx.BoxSizer(wx.HORIZONTAL) | 355 | splitter.ContainingSizer = wx.BoxSizer(wx.HORIZONTAL) |
350 | - | 356 | + |
351 | sizer = wx.BoxSizer(wx.HORIZONTAL) | 357 | sizer = wx.BoxSizer(wx.HORIZONTAL) |
352 | sizer.Add(splitter, 1, wx.EXPAND) | 358 | sizer.Add(splitter, 1, wx.EXPAND) |
353 | self.SetSizer(sizer) | 359 | self.SetSizer(sizer) |
354 | - | 360 | + |
355 | self.text_panel = SeriesPanel(splitter) | 361 | self.text_panel = SeriesPanel(splitter) |
356 | splitter.AppendWindow(self.text_panel, 600) | 362 | splitter.AppendWindow(self.text_panel, 600) |
357 | - | 363 | + |
358 | self.image_panel = SlicePanel(splitter) | 364 | self.image_panel = SlicePanel(splitter) |
359 | splitter.AppendWindow(self.image_panel, 250) | 365 | splitter.AppendWindow(self.image_panel, 250) |
360 | 366 | ||
@@ -379,16 +385,16 @@ class ImagePanel(wx.Panel): | @@ -379,16 +385,16 @@ class ImagePanel(wx.Panel): | ||
379 | def SetSerie(self, serie): | 385 | def SetSerie(self, serie): |
380 | self.image_panel.dicom_preview.SetDicomGroup(serie) | 386 | self.image_panel.dicom_preview.SetDicomGroup(serie) |
381 | 387 | ||
382 | - | 388 | + |
383 | class SeriesPanel(wx.Panel): | 389 | class SeriesPanel(wx.Panel): |
384 | def __init__(self, parent): | 390 | def __init__(self, parent): |
385 | wx.Panel.__init__(self, parent, -1) | 391 | wx.Panel.__init__(self, parent, -1) |
386 | - #self.SetBackgroundColour((0,0,0)) | 392 | + #self.SetBackgroundColour((0,0,0)) |
387 | 393 | ||
388 | self.serie_preview = dpp.DicomPreviewSeries(self) | 394 | self.serie_preview = dpp.DicomPreviewSeries(self) |
389 | self.dicom_preview = dpp.DicomPreviewSlice(self) | 395 | self.dicom_preview = dpp.DicomPreviewSlice(self) |
390 | self.dicom_preview.Show(0) | 396 | self.dicom_preview.Show(0) |
391 | - | 397 | + |
392 | self.sizer = wx.BoxSizer(wx.HORIZONTAL) | 398 | self.sizer = wx.BoxSizer(wx.HORIZONTAL) |
393 | self.sizer.Add(self.serie_preview, 1, wx.EXPAND | wx.ALL, 5) | 399 | self.sizer.Add(self.serie_preview, 1, wx.EXPAND | wx.ALL, 5) |
394 | self.sizer.Add(self.dicom_preview, 1, wx.EXPAND | wx.ALL, 5) | 400 | self.sizer.Add(self.dicom_preview, 1, wx.EXPAND | wx.ALL, 5) |
@@ -422,19 +428,19 @@ class SeriesPanel(wx.Panel): | @@ -422,19 +428,19 @@ class SeriesPanel(wx.Panel): | ||
422 | 428 | ||
423 | def SetPatientSeries(self, pubsub_evt): | 429 | def SetPatientSeries(self, pubsub_evt): |
424 | patient = pubsub_evt.data | 430 | patient = pubsub_evt.data |
425 | - | 431 | + |
426 | self.dicom_preview.Show(0) | 432 | self.dicom_preview.Show(0) |
427 | self.serie_preview.Show(1) | 433 | self.serie_preview.Show(1) |
428 | - | 434 | + |
429 | self.serie_preview.SetPatientGroups(patient) | 435 | self.serie_preview.SetPatientGroups(patient) |
430 | - self.dicom_preview.SetPatientGroups(patient) | ||
431 | - | 436 | + self.dicom_preview.SetPatientGroups(patient) |
437 | + | ||
432 | self.Update() | 438 | self.Update() |
433 | 439 | ||
434 | def OnSelectSerie(self, evt): | 440 | def OnSelectSerie(self, evt): |
435 | serie = evt.GetItemData() | 441 | serie = evt.GetItemData() |
436 | data = evt.GetItemData() | 442 | data = evt.GetItemData() |
437 | - | 443 | + |
438 | my_evt = SelectEvent(myEVT_SELECT_SERIE, self.GetId()) | 444 | my_evt = SelectEvent(myEVT_SELECT_SERIE, self.GetId()) |
439 | my_evt.SetSelectedID(evt.GetSelectID()) | 445 | my_evt.SetSelectedID(evt.GetSelectID()) |
440 | my_evt.SetItemData(evt.GetItemData()) | 446 | my_evt.SetItemData(evt.GetItemData()) |
@@ -455,7 +461,7 @@ class SeriesPanel(wx.Panel): | @@ -455,7 +461,7 @@ class SeriesPanel(wx.Panel): | ||
455 | 461 | ||
456 | def ShowDicomSeries(self, pubsub_evt): | 462 | def ShowDicomSeries(self, pubsub_evt): |
457 | patient = pubsub_evt.data | 463 | patient = pubsub_evt.data |
458 | - if isinstance(patient, dcm.PatientGroup): | 464 | + if isinstance(patient, dcm.PatientGroup): |
459 | self.serie_preview.SetPatientGroups(patient) | 465 | self.serie_preview.SetPatientGroups(patient) |
460 | self.dicom_preview.SetPatientGroups(patient) | 466 | self.dicom_preview.SetPatientGroups(patient) |
461 | 467 | ||
@@ -502,6 +508,6 @@ class SlicePanel(wx.Panel): | @@ -502,6 +508,6 @@ class SlicePanel(wx.Panel): | ||
502 | group = patient.GetGroups()[0] | 508 | group = patient.GetGroups()[0] |
503 | self.dicom_preview.SetDicomGroup(group) | 509 | self.dicom_preview.SetDicomGroup(group) |
504 | self.sizer.Layout() | 510 | self.sizer.Layout() |
505 | - self.Update() | 511 | + self.Update() |
506 | 512 | ||
507 | 513 |