diff --git a/invesalius/control.py b/invesalius/control.py index c56aa29..a02a8f4 100755 --- a/invesalius/control.py +++ b/invesalius/control.py @@ -32,10 +32,49 @@ class Controller(): def StartImportPanel(self, pubsub_evt): path = pubsub_evt.data + print path + + dicom_series = dcm.GetSeries(path) + + dict = {} + + for key in dicom_series: + patient_name = key[0] + dicom = dicom_series[key][0][0] + + # Compute how many images per series: + n_images = str(len(dicom_series[key][0])) + # Add date and time in a single field: + date_time = "%s %s"%(dicom.acquisition.date, + dicom.acquisition.time) + + # Data per series + exam_data = [dicom.acquisition.series_description, + dicom.patient.id, + str(dicom.patient.age), + dicom.patient.gender, + dicom.acquisition.study_description, + dicom.acquisition.modality, + date_time, + n_images, + dicom.acquisition.institution, + dicom.patient.birthdate, + dicom.acquisition.accession_number, + dicom.patient.physician] + 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)} - } + #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) def ImportDirectory(self, pubsub_evt=None, dir_=None): diff --git a/invesalius/gui/default_tasks.py b/invesalius/gui/default_tasks.py index f0bb925..5d5dcf1 100755 --- a/invesalius/gui/default_tasks.py +++ b/invesalius/gui/default_tasks.py @@ -174,7 +174,7 @@ class UpperTaskPanel(wx.Panel): fold_panel.AddFoldPanelWindow(item, importer.TaskPanel(item), Spacing= 0, leftSpacing=0, rightSpacing=0) - #fold_panel.Expand(fold_panel.GetFoldPanel(0)) + fold_panel.Expand(fold_panel.GetFoldPanel(0)) # Fold 2 - Mask for segmentation and edition @@ -185,7 +185,7 @@ class UpperTaskPanel(wx.Panel): fold_panel.AddFoldPanelWindow(item, slice_.TaskPanel(item), Spacing= 0, leftSpacing=0, rightSpacing=0) - fold_panel.Expand(fold_panel.GetFoldPanel(1)) + #fold_panel.Expand(fold_panel.GetFoldPanel(1)) # Fold 3 # select mask - combo @@ -210,4 +210,4 @@ class UpperTaskPanel(wx.Panel): col = style.GetFirstColour() fold_panel.AddFoldPanelWindow(item, exporter.TaskPanel(item), - Spacing= 0, leftSpacing=0, rightSpacing=0) \ No newline at end of file + Spacing= 0, leftSpacing=0, rightSpacing=0) diff --git a/invesalius/gui/import_panel.py b/invesalius/gui/import_panel.py index e61c5f4..f321d65 100644 --- a/invesalius/gui/import_panel.py +++ b/invesalius/gui/import_panel.py @@ -49,7 +49,7 @@ class TextPanel(wx.Panel): self.Bind(wx.EVT_SIZE, self.OnSize) - self.tree = gizmos.TreeListCtrl(self, -1, style = + tree = gizmos.TreeListCtrl(self, -1, style = wx.TR_DEFAULT_STYLE | wx.TR_HIDE_ROOT | wx.TR_ROW_LINES @@ -59,53 +59,89 @@ class TextPanel(wx.Panel): ) - self.tree.AddColumn("Patient name") - self.tree.AddColumn("Patient ID") - self.tree.AddColumn("Age") - self.tree.AddColumn("Study description") - self.tree.AddColumn("Modality") - self.tree.AddColumn("Date acquired") - self.tree.AddColumn("# Images") - self.tree.AddColumn("Institution") - self.tree.AddColumn("Date of birth") - self.tree.AddColumn("Accession Number") - self.tree.AddColumn("Referring physician") - self.tree.AddColumn("Performing") - - self.tree.SetMainColumn(0) # the one with the tree in it... - self.tree.SetColumnWidth(0, 250) # ok - self.tree.SetColumnWidth(1, 80) # ok - self.tree.SetColumnWidth(2, 40) # ok - self.tree.SetColumnWidth(3, 160) # ok - self.tree.SetColumnWidth(4, 80) # ok - self.tree.SetColumnWidth(5, 110) - self.tree.SetColumnWidth(6, 70) - self.tree.SetColumnWidth(7, 90) - self.tree.SetColumnWidth(8, 130) - self.tree.SetColumnWidth(9, 240) - self.tree.SetColumnWidth(10, 120) - - - self.root = self.tree.AddRoot("InVesalius Database") + tree.AddColumn("Patient name") + tree.AddColumn("Patient ID") + tree.AddColumn("Age") + tree.AddColumn("Gender") + tree.AddColumn("Study description") + tree.AddColumn("Modality") + tree.AddColumn("Date acquired") + tree.AddColumn("# Images") + tree.AddColumn("Institution") + tree.AddColumn("Date of birth") + tree.AddColumn("Accession Number") + tree.AddColumn("Referring physician") - def Populate(self, dict): + tree.SetMainColumn(0) # the one with the tree in it... + tree.SetColumnWidth(0, 280) # Patient name + tree.SetColumnWidth(1, 110) # Patient ID + tree.SetColumnWidth(2, 40) # Age + tree.SetColumnWidth(3, 60) # Gender + tree.SetColumnWidth(4, 160) # Study description + tree.SetColumnWidth(5, 70) # Modality + tree.SetColumnWidth(6, 200) # Date acquired + tree.SetColumnWidth(7, 70) # Number Images + tree.SetColumnWidth(8, 130) # Institution + tree.SetColumnWidth(9, 100) # Date of birth + tree.SetColumnWidth(10, 140) # Accession Number + tree.SetColumnWidth(11, 160) # Referring physician - for i in xrange(4): - txt = "Name %d" % i - child = self.tree.AppendItem(self.root, txt) + + self.root = tree.AddRoot("InVesalius Database") + self.tree = tree + + def Populate(self, dict): + tree = self.tree + + i = 0 + + # For each patient on dictionary + for patient_name in dict: + # In spite of the patient name, we'll show number of + # series also + title = patient_name + " (%d series)"%(len(dict[patient_name])) + parent = tree.AppendItem(self.root, title) + patient_data = dict[patient_name] + + # Row background colour if i%2: - self.tree.SetItemBackgroundColour(child, (242,246,254)) - self.tree.SetItemText(child, txt, 1) - self.tree.SetItemText(child, "age", 2) + tree.SetItemBackgroundColour(parent, (242,246,254)) - for j in xrange(4): - txt = "Series name %d" % i - child2 = self.tree.AppendItem(child, txt) - if j%2: - self.tree.SetItemBackgroundColour(child2, (242,246,254)) - self.tree.SetItemText(child2, txt, 1) - self.tree.SetItemText(child2, txt, 2) - + # Insert patient data into columns based on first series + for item in xrange(1, len(patient_data[0])): + value = patient_data[0][item] + # Sum slices of all patient's series + if (item == 7): + value = 0 + for series in xrange(len(patient_data)): + value += int(patient_data[series][7]) + tree.SetItemText(parent, str(value), item) # ID + + # For each series on patient + j = 0 + print patient_data + for series in xrange(len(patient_data)): + series_title = patient_data[series][0] + + child = self.tree.AppendItem(parent, series_title) + if not j%2: + tree.SetItemBackgroundColour(child, (242,246,254)) + + # TODO: change description "protocol_name" + description = patient_data[series][4] + modality = patient_data[series][5] + # TODO: add to date the time + date = patient_data[series][6] + nimages = patient_data[series][7] + + tree.SetItemText(child, series_title, 0) + tree.SetItemText(child, description, 4) + tree.SetItemText(child, modality, 5) + tree.SetItemText(child, date, 6) + tree.SetItemText(child, nimages, 7) + + j += 1 + i += 1 self.tree.Expand(self.root) @@ -154,4 +190,4 @@ class SeriesPanel(wx.Panel): class SlicePanel(wx.Panel): def __init__(self, parent): wx.Panel.__init__(self, parent, -1) - self.SetBackgroundColour((0,0,0)) \ No newline at end of file + self.SetBackgroundColour((0,0,0)) -- libgit2 0.21.2