diff --git a/invesalius/control.py b/invesalius/control.py index a71c2bf..349c282 100755 --- a/invesalius/control.py +++ b/invesalius/control.py @@ -31,12 +31,16 @@ class Controller(): 'Save raycasting preset') def StartImportPanel(self, pubsub_evt): + # path to directory path = pubsub_evt.data - print path + # retrieve DICOM files splited into groups dicom_series = dcm.GetSeries(path) + # create dictionary with DICOM files' groups with + # information as it will be shown on import panel dict = {} + series_preview = [] for key in dicom_series: patient_name = key[0] @@ -53,29 +57,35 @@ class Controller(): dicom.patient.id, str(dicom.patient.age), dicom.patient.gender, - dicom.acquisition.study_description, + dicom.acquisition.study_description, # per patient dicom.acquisition.modality, date_time, n_images, dicom.acquisition.institution, dicom.patient.birthdate, dicom.acquisition.accession_number, - dicom.patient.physician] + dicom.patient.physician, + dicom.acquisition.protocol_name] # per series + + # Preview data + series_preview.append((dicom.image.file, # Filename + dicom.image.level, # Window level + dicom.image.window, # Window width + dicom.acquisition.series_description, # Title + "%s Images" %(n_images), # Subtitle + )) + try: dict[patient_name].append(exam_data) except KeyError: dict[patient_name] = [exam_data] - #patient_name, patient_id, patient_age, study_description, - #modality, date_acquired, number_images, institution, - #date_of_birth, accession_number, referring_physician, - #performing_physician print dict - # TODO: Load information - #dict = {"Joao": {"Serie 1": (0, 1, 2, 3, 4, 5, 6, 7), - # "Serie 2": (1, 2, 3, 4, 5, 6, 7, 8)} - # } + + ps.Publisher().sendMessage("Load import panel", dict) + ps.Publisher().sendMessage("Load dicom preview", series_preview) + def ImportDirectory(self, pubsub_evt=None, dir_=None): """ diff --git a/invesalius/gui/import_panel.py b/invesalius/gui/import_panel.py index f321d65..d8b68e2 100644 --- a/invesalius/gui/import_panel.py +++ b/invesalius/gui/import_panel.py @@ -3,6 +3,8 @@ import wx.gizmos as gizmos import wx.lib.pubsub as ps import wx.lib.splitter as spl +import dicom_preview_panel as dpp + class Panel(wx.Panel): def __init__(self, parent): wx.Panel.__init__(self, parent, pos=wx.Point(5, 5), @@ -108,7 +110,7 @@ class TextPanel(wx.Panel): tree.SetItemBackgroundColour(parent, (242,246,254)) # Insert patient data into columns based on first series - for item in xrange(1, len(patient_data[0])): + for item in xrange(1, len(patient_data[0])-1): value = patient_data[0][item] # Sum slices of all patient's series if (item == 7): @@ -119,7 +121,6 @@ class TextPanel(wx.Panel): # For each series on patient j = 0 - print patient_data for series in xrange(len(patient_data)): series_title = patient_data[series][0] @@ -128,7 +129,7 @@ class TextPanel(wx.Panel): tree.SetItemBackgroundColour(child, (242,246,254)) # TODO: change description "protocol_name" - description = patient_data[series][4] + description = patient_data[series][-1] modality = patient_data[series][5] # TODO: add to date the time date = patient_data[series][6] @@ -143,10 +144,10 @@ class TextPanel(wx.Panel): j += 1 i += 1 - self.tree.Expand(self.root) + tree.Expand(self.root) - self.tree.GetMainWindow().Bind(wx.EVT_RIGHT_UP, self.OnRightUp) - self.tree.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnActivate) + tree.GetMainWindow().Bind(wx.EVT_RIGHT_UP, self.OnRightUp) + tree.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnActivate) def OnActivate(self, evt): @@ -177,7 +178,7 @@ class ImagePanel(wx.Panel): self.SetSizer(sizer) self.text_panel = SeriesPanel(splitter) - splitter.AppendWindow(self.text_panel, 400) + splitter.AppendWindow(self.text_panel, 600) self.image_panel = SlicePanel(splitter) splitter.AppendWindow(self.image_panel, 250) @@ -185,9 +186,23 @@ class ImagePanel(wx.Panel): class SeriesPanel(wx.Panel): def __init__(self, parent): wx.Panel.__init__(self, parent, -1) - self.SetBackgroundColour((255,255,255)) + self.SetBackgroundColour((0,0,0)) + self.serie_preview = dpp.DicomPreviewSeries(self) + + self.__bind_evt() + + def __bind_evt(self): + ps.Publisher().subscribe(self.ShowDicomSeries, "Load dicom preview") + + def ShowDicomSeries(self, pubsub_evt): + print "---- ShowDicomSeries ----" + list_dicom = pubsub_evt.data + print list_dicom + self.serie_preview.SetDicomSeries(list_dicom) + + class SlicePanel(wx.Panel): def __init__(self, parent): wx.Panel.__init__(self, parent, -1) - self.SetBackgroundColour((0,0,0)) + self.SetBackgroundColour((255,255,255)) -- libgit2 0.21.2