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