Commit 862aa895e33d04a7f041cd59203382c23a0c9b60

Authored by tatiana
1 parent 6929d2c7

ADD: Init of importing panel - working pretty well, including series separation.

invesalius/control.py
... ... @@ -32,10 +32,49 @@ class Controller():
32 32  
33 33 def StartImportPanel(self, pubsub_evt):
34 34 path = pubsub_evt.data
  35 + print path
  36 +
  37 + dicom_series = dcm.GetSeries(path)
  38 +
  39 + dict = {}
  40 +
  41 + for key in dicom_series:
  42 + patient_name = key[0]
  43 + dicom = dicom_series[key][0][0]
  44 +
  45 + # Compute how many images per series:
  46 + n_images = str(len(dicom_series[key][0]))
  47 + # Add date and time in a single field:
  48 + date_time = "%s %s"%(dicom.acquisition.date,
  49 + dicom.acquisition.time)
  50 +
  51 + # Data per series
  52 + exam_data = [dicom.acquisition.series_description,
  53 + dicom.patient.id,
  54 + str(dicom.patient.age),
  55 + dicom.patient.gender,
  56 + dicom.acquisition.study_description,
  57 + dicom.acquisition.modality,
  58 + date_time,
  59 + n_images,
  60 + dicom.acquisition.institution,
  61 + dicom.patient.birthdate,
  62 + dicom.acquisition.accession_number,
  63 + dicom.patient.physician]
  64 + try:
  65 + dict[patient_name].append(exam_data)
  66 + except KeyError:
  67 + dict[patient_name] = [exam_data]
  68 + #patient_name, patient_id, patient_age, study_description,
  69 + #modality, date_acquired, number_images, institution,
  70 + #date_of_birth, accession_number, referring_physician,
  71 + #performing_physician
  72 + print dict
  73 +
35 74 # TODO: Load information
36   - dict = {"Joao": {"Serie 1": (0, 1, 2, 3, 4, 5, 6, 7),
37   - "Serie 2": (1, 2, 3, 4, 5, 6, 7, 8)}
38   - }
  75 + #dict = {"Joao": {"Serie 1": (0, 1, 2, 3, 4, 5, 6, 7),
  76 + # "Serie 2": (1, 2, 3, 4, 5, 6, 7, 8)}
  77 + # }
39 78 ps.Publisher().sendMessage("Load import panel", dict)
40 79  
41 80 def ImportDirectory(self, pubsub_evt=None, dir_=None):
... ...
invesalius/gui/default_tasks.py
... ... @@ -174,7 +174,7 @@ class UpperTaskPanel(wx.Panel):
174 174  
175 175 fold_panel.AddFoldPanelWindow(item, importer.TaskPanel(item), Spacing= 0,
176 176 leftSpacing=0, rightSpacing=0)
177   - #fold_panel.Expand(fold_panel.GetFoldPanel(0))
  177 + fold_panel.Expand(fold_panel.GetFoldPanel(0))
178 178  
179 179 # Fold 2 - Mask for segmentation and edition
180 180  
... ... @@ -185,7 +185,7 @@ class UpperTaskPanel(wx.Panel):
185 185  
186 186 fold_panel.AddFoldPanelWindow(item, slice_.TaskPanel(item), Spacing= 0,
187 187 leftSpacing=0, rightSpacing=0)
188   - fold_panel.Expand(fold_panel.GetFoldPanel(1))
  188 + #fold_panel.Expand(fold_panel.GetFoldPanel(1))
189 189  
190 190 # Fold 3
191 191 # select mask - combo
... ... @@ -210,4 +210,4 @@ class UpperTaskPanel(wx.Panel):
210 210 col = style.GetFirstColour()
211 211  
212 212 fold_panel.AddFoldPanelWindow(item, exporter.TaskPanel(item),
213   - Spacing= 0, leftSpacing=0, rightSpacing=0)
214 213 \ No newline at end of file
  214 + Spacing= 0, leftSpacing=0, rightSpacing=0)
... ...
invesalius/gui/import_panel.py
... ... @@ -49,7 +49,7 @@ class TextPanel(wx.Panel):
49 49 self.Bind(wx.EVT_SIZE, self.OnSize)
50 50  
51 51  
52   - self.tree = gizmos.TreeListCtrl(self, -1, style =
  52 + tree = gizmos.TreeListCtrl(self, -1, style =
53 53 wx.TR_DEFAULT_STYLE
54 54 | wx.TR_HIDE_ROOT
55 55 | wx.TR_ROW_LINES
... ... @@ -59,53 +59,89 @@ class TextPanel(wx.Panel):
59 59 )
60 60  
61 61  
62   - self.tree.AddColumn("Patient name")
63   - self.tree.AddColumn("Patient ID")
64   - self.tree.AddColumn("Age")
65   - self.tree.AddColumn("Study description")
66   - self.tree.AddColumn("Modality")
67   - self.tree.AddColumn("Date acquired")
68   - self.tree.AddColumn("# Images")
69   - self.tree.AddColumn("Institution")
70   - self.tree.AddColumn("Date of birth")
71   - self.tree.AddColumn("Accession Number")
72   - self.tree.AddColumn("Referring physician")
73   - self.tree.AddColumn("Performing")
74   -
75   - self.tree.SetMainColumn(0) # the one with the tree in it...
76   - self.tree.SetColumnWidth(0, 250) # ok
77   - self.tree.SetColumnWidth(1, 80) # ok
78   - self.tree.SetColumnWidth(2, 40) # ok
79   - self.tree.SetColumnWidth(3, 160) # ok
80   - self.tree.SetColumnWidth(4, 80) # ok
81   - self.tree.SetColumnWidth(5, 110)
82   - self.tree.SetColumnWidth(6, 70)
83   - self.tree.SetColumnWidth(7, 90)
84   - self.tree.SetColumnWidth(8, 130)
85   - self.tree.SetColumnWidth(9, 240)
86   - self.tree.SetColumnWidth(10, 120)
87   -
88   -
89   - self.root = self.tree.AddRoot("InVesalius Database")
  62 + tree.AddColumn("Patient name")
  63 + tree.AddColumn("Patient ID")
  64 + tree.AddColumn("Age")
  65 + tree.AddColumn("Gender")
  66 + tree.AddColumn("Study description")
  67 + tree.AddColumn("Modality")
  68 + tree.AddColumn("Date acquired")
  69 + tree.AddColumn("# Images")
  70 + tree.AddColumn("Institution")
  71 + tree.AddColumn("Date of birth")
  72 + tree.AddColumn("Accession Number")
  73 + tree.AddColumn("Referring physician")
90 74  
91   - def Populate(self, dict):
  75 + tree.SetMainColumn(0) # the one with the tree in it...
  76 + tree.SetColumnWidth(0, 280) # Patient name
  77 + tree.SetColumnWidth(1, 110) # Patient ID
  78 + tree.SetColumnWidth(2, 40) # Age
  79 + tree.SetColumnWidth(3, 60) # Gender
  80 + tree.SetColumnWidth(4, 160) # Study description
  81 + tree.SetColumnWidth(5, 70) # Modality
  82 + tree.SetColumnWidth(6, 200) # Date acquired
  83 + tree.SetColumnWidth(7, 70) # Number Images
  84 + tree.SetColumnWidth(8, 130) # Institution
  85 + tree.SetColumnWidth(9, 100) # Date of birth
  86 + tree.SetColumnWidth(10, 140) # Accession Number
  87 + tree.SetColumnWidth(11, 160) # Referring physician
92 88  
93   - for i in xrange(4):
94   - txt = "Name %d" % i
95   - child = self.tree.AppendItem(self.root, txt)
  89 +
  90 + self.root = tree.AddRoot("InVesalius Database")
  91 + self.tree = tree
  92 +
  93 + def Populate(self, dict):
  94 + tree = self.tree
  95 +
  96 + i = 0
  97 +
  98 + # For each patient on dictionary
  99 + for patient_name in dict:
  100 + # In spite of the patient name, we'll show number of
  101 + # series also
  102 + title = patient_name + " (%d series)"%(len(dict[patient_name]))
  103 + parent = tree.AppendItem(self.root, title)
  104 + patient_data = dict[patient_name]
  105 +
  106 + # Row background colour
96 107 if i%2:
97   - self.tree.SetItemBackgroundColour(child, (242,246,254))
98   - self.tree.SetItemText(child, txt, 1)
99   - self.tree.SetItemText(child, "age", 2)
  108 + tree.SetItemBackgroundColour(parent, (242,246,254))
100 109  
101   - for j in xrange(4):
102   - txt = "Series name %d" % i
103   - child2 = self.tree.AppendItem(child, txt)
104   - if j%2:
105   - self.tree.SetItemBackgroundColour(child2, (242,246,254))
106   - self.tree.SetItemText(child2, txt, 1)
107   - self.tree.SetItemText(child2, txt, 2)
108   -
  110 + # Insert patient data into columns based on first series
  111 + for item in xrange(1, len(patient_data[0])):
  112 + value = patient_data[0][item]
  113 + # Sum slices of all patient's series
  114 + if (item == 7):
  115 + value = 0
  116 + for series in xrange(len(patient_data)):
  117 + value += int(patient_data[series][7])
  118 + tree.SetItemText(parent, str(value), item) # ID
  119 +
  120 + # For each series on patient
  121 + j = 0
  122 + print patient_data
  123 + for series in xrange(len(patient_data)):
  124 + series_title = patient_data[series][0]
  125 +
  126 + child = self.tree.AppendItem(parent, series_title)
  127 + if not j%2:
  128 + tree.SetItemBackgroundColour(child, (242,246,254))
  129 +
  130 + # TODO: change description "protocol_name"
  131 + description = patient_data[series][4]
  132 + modality = patient_data[series][5]
  133 + # TODO: add to date the time
  134 + date = patient_data[series][6]
  135 + nimages = patient_data[series][7]
  136 +
  137 + tree.SetItemText(child, series_title, 0)
  138 + tree.SetItemText(child, description, 4)
  139 + tree.SetItemText(child, modality, 5)
  140 + tree.SetItemText(child, date, 6)
  141 + tree.SetItemText(child, nimages, 7)
  142 +
  143 + j += 1
  144 + i += 1
109 145  
110 146 self.tree.Expand(self.root)
111 147  
... ... @@ -154,4 +190,4 @@ class SeriesPanel(wx.Panel):
154 190 class SlicePanel(wx.Panel):
155 191 def __init__(self, parent):
156 192 wx.Panel.__init__(self, parent, -1)
157   - self.SetBackgroundColour((0,0,0))
158 193 \ No newline at end of file
  194 + self.SetBackgroundColour((0,0,0))
... ...