Commit a527b36d8177b4b51a3422b2779d5264c452efd4
1 parent
eed60cd7
Exists in
master
and in
68 other branches
ADD: In process of implementing import panel
Showing
2 changed files
with
45 additions
and
20 deletions
Show diff stats
invesalius/control.py
@@ -31,12 +31,16 @@ class Controller(): | @@ -31,12 +31,16 @@ class Controller(): | ||
31 | 'Save raycasting preset') | 31 | 'Save raycasting preset') |
32 | 32 | ||
33 | def StartImportPanel(self, pubsub_evt): | 33 | def StartImportPanel(self, pubsub_evt): |
34 | + # path to directory | ||
34 | path = pubsub_evt.data | 35 | path = pubsub_evt.data |
35 | - print path | ||
36 | 36 | ||
37 | + # retrieve DICOM files splited into groups | ||
37 | dicom_series = dcm.GetSeries(path) | 38 | dicom_series = dcm.GetSeries(path) |
38 | 39 | ||
40 | + # create dictionary with DICOM files' groups with | ||
41 | + # information as it will be shown on import panel | ||
39 | dict = {} | 42 | dict = {} |
43 | + series_preview = [] | ||
40 | 44 | ||
41 | for key in dicom_series: | 45 | for key in dicom_series: |
42 | patient_name = key[0] | 46 | patient_name = key[0] |
@@ -53,29 +57,35 @@ class Controller(): | @@ -53,29 +57,35 @@ class Controller(): | ||
53 | dicom.patient.id, | 57 | dicom.patient.id, |
54 | str(dicom.patient.age), | 58 | str(dicom.patient.age), |
55 | dicom.patient.gender, | 59 | dicom.patient.gender, |
56 | - dicom.acquisition.study_description, | 60 | + dicom.acquisition.study_description, # per patient |
57 | dicom.acquisition.modality, | 61 | dicom.acquisition.modality, |
58 | date_time, | 62 | date_time, |
59 | n_images, | 63 | n_images, |
60 | dicom.acquisition.institution, | 64 | dicom.acquisition.institution, |
61 | dicom.patient.birthdate, | 65 | dicom.patient.birthdate, |
62 | dicom.acquisition.accession_number, | 66 | dicom.acquisition.accession_number, |
63 | - dicom.patient.physician] | 67 | + dicom.patient.physician, |
68 | + dicom.acquisition.protocol_name] # per series | ||
69 | + | ||
70 | + # Preview data | ||
71 | + series_preview.append((dicom.image.file, # Filename | ||
72 | + dicom.image.level, # Window level | ||
73 | + dicom.image.window, # Window width | ||
74 | + dicom.acquisition.series_description, # Title | ||
75 | + "%s Images" %(n_images), # Subtitle | ||
76 | + )) | ||
77 | + | ||
64 | try: | 78 | try: |
65 | dict[patient_name].append(exam_data) | 79 | dict[patient_name].append(exam_data) |
66 | except KeyError: | 80 | except KeyError: |
67 | dict[patient_name] = [exam_data] | 81 | 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 | 82 | print dict |
73 | 83 | ||
74 | - # TODO: Load information | ||
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 | - # } | 84 | + |
85 | + | ||
78 | ps.Publisher().sendMessage("Load import panel", dict) | 86 | ps.Publisher().sendMessage("Load import panel", dict) |
87 | + ps.Publisher().sendMessage("Load dicom preview", series_preview) | ||
88 | + | ||
79 | 89 | ||
80 | def ImportDirectory(self, pubsub_evt=None, dir_=None): | 90 | def ImportDirectory(self, pubsub_evt=None, dir_=None): |
81 | """ | 91 | """ |
invesalius/gui/import_panel.py
@@ -3,6 +3,8 @@ import wx.gizmos as gizmos | @@ -3,6 +3,8 @@ import wx.gizmos as gizmos | ||
3 | import wx.lib.pubsub as ps | 3 | import wx.lib.pubsub as ps |
4 | import wx.lib.splitter as spl | 4 | import wx.lib.splitter as spl |
5 | 5 | ||
6 | +import dicom_preview_panel as dpp | ||
7 | + | ||
6 | class Panel(wx.Panel): | 8 | class Panel(wx.Panel): |
7 | def __init__(self, parent): | 9 | def __init__(self, parent): |
8 | wx.Panel.__init__(self, parent, pos=wx.Point(5, 5), | 10 | wx.Panel.__init__(self, parent, pos=wx.Point(5, 5), |
@@ -108,7 +110,7 @@ class TextPanel(wx.Panel): | @@ -108,7 +110,7 @@ class TextPanel(wx.Panel): | ||
108 | tree.SetItemBackgroundColour(parent, (242,246,254)) | 110 | tree.SetItemBackgroundColour(parent, (242,246,254)) |
109 | 111 | ||
110 | # Insert patient data into columns based on first series | 112 | # Insert patient data into columns based on first series |
111 | - for item in xrange(1, len(patient_data[0])): | 113 | + for item in xrange(1, len(patient_data[0])-1): |
112 | value = patient_data[0][item] | 114 | value = patient_data[0][item] |
113 | # Sum slices of all patient's series | 115 | # Sum slices of all patient's series |
114 | if (item == 7): | 116 | if (item == 7): |
@@ -119,7 +121,6 @@ class TextPanel(wx.Panel): | @@ -119,7 +121,6 @@ class TextPanel(wx.Panel): | ||
119 | 121 | ||
120 | # For each series on patient | 122 | # For each series on patient |
121 | j = 0 | 123 | j = 0 |
122 | - print patient_data | ||
123 | for series in xrange(len(patient_data)): | 124 | for series in xrange(len(patient_data)): |
124 | series_title = patient_data[series][0] | 125 | series_title = patient_data[series][0] |
125 | 126 | ||
@@ -128,7 +129,7 @@ class TextPanel(wx.Panel): | @@ -128,7 +129,7 @@ class TextPanel(wx.Panel): | ||
128 | tree.SetItemBackgroundColour(child, (242,246,254)) | 129 | tree.SetItemBackgroundColour(child, (242,246,254)) |
129 | 130 | ||
130 | # TODO: change description "protocol_name" | 131 | # TODO: change description "protocol_name" |
131 | - description = patient_data[series][4] | 132 | + description = patient_data[series][-1] |
132 | modality = patient_data[series][5] | 133 | modality = patient_data[series][5] |
133 | # TODO: add to date the time | 134 | # TODO: add to date the time |
134 | date = patient_data[series][6] | 135 | date = patient_data[series][6] |
@@ -143,10 +144,10 @@ class TextPanel(wx.Panel): | @@ -143,10 +144,10 @@ class TextPanel(wx.Panel): | ||
143 | j += 1 | 144 | j += 1 |
144 | i += 1 | 145 | i += 1 |
145 | 146 | ||
146 | - self.tree.Expand(self.root) | 147 | + tree.Expand(self.root) |
147 | 148 | ||
148 | - self.tree.GetMainWindow().Bind(wx.EVT_RIGHT_UP, self.OnRightUp) | ||
149 | - self.tree.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnActivate) | 149 | + tree.GetMainWindow().Bind(wx.EVT_RIGHT_UP, self.OnRightUp) |
150 | + tree.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnActivate) | ||
150 | 151 | ||
151 | 152 | ||
152 | def OnActivate(self, evt): | 153 | def OnActivate(self, evt): |
@@ -177,7 +178,7 @@ class ImagePanel(wx.Panel): | @@ -177,7 +178,7 @@ class ImagePanel(wx.Panel): | ||
177 | self.SetSizer(sizer) | 178 | self.SetSizer(sizer) |
178 | 179 | ||
179 | self.text_panel = SeriesPanel(splitter) | 180 | self.text_panel = SeriesPanel(splitter) |
180 | - splitter.AppendWindow(self.text_panel, 400) | 181 | + splitter.AppendWindow(self.text_panel, 600) |
181 | 182 | ||
182 | self.image_panel = SlicePanel(splitter) | 183 | self.image_panel = SlicePanel(splitter) |
183 | splitter.AppendWindow(self.image_panel, 250) | 184 | splitter.AppendWindow(self.image_panel, 250) |
@@ -185,9 +186,23 @@ class ImagePanel(wx.Panel): | @@ -185,9 +186,23 @@ class ImagePanel(wx.Panel): | ||
185 | class SeriesPanel(wx.Panel): | 186 | class SeriesPanel(wx.Panel): |
186 | def __init__(self, parent): | 187 | def __init__(self, parent): |
187 | wx.Panel.__init__(self, parent, -1) | 188 | wx.Panel.__init__(self, parent, -1) |
188 | - self.SetBackgroundColour((255,255,255)) | 189 | + self.SetBackgroundColour((0,0,0)) |
190 | + self.serie_preview = dpp.DicomPreviewSeries(self) | ||
191 | + | ||
192 | + self.__bind_evt() | ||
193 | + | ||
194 | + def __bind_evt(self): | ||
195 | + ps.Publisher().subscribe(self.ShowDicomSeries, "Load dicom preview") | ||
196 | + | ||
197 | + def ShowDicomSeries(self, pubsub_evt): | ||
198 | + print "---- ShowDicomSeries ----" | ||
199 | + list_dicom = pubsub_evt.data | ||
200 | + print list_dicom | ||
201 | + self.serie_preview.SetDicomSeries(list_dicom) | ||
189 | 202 | ||
203 | + | ||
204 | + | ||
190 | class SlicePanel(wx.Panel): | 205 | class SlicePanel(wx.Panel): |
191 | def __init__(self, parent): | 206 | def __init__(self, parent): |
192 | wx.Panel.__init__(self, parent, -1) | 207 | wx.Panel.__init__(self, parent, -1) |
193 | - self.SetBackgroundColour((0,0,0)) | 208 | + self.SetBackgroundColour((255,255,255)) |