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 | 31 | 'Save raycasting preset') |
32 | 32 | |
33 | 33 | def StartImportPanel(self, pubsub_evt): |
34 | + # path to directory | |
34 | 35 | path = pubsub_evt.data |
35 | - print path | |
36 | 36 | |
37 | + # retrieve DICOM files splited into groups | |
37 | 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 | 42 | dict = {} |
43 | + series_preview = [] | |
40 | 44 | |
41 | 45 | for key in dicom_series: |
42 | 46 | patient_name = key[0] |
... | ... | @@ -53,29 +57,35 @@ class Controller(): |
53 | 57 | dicom.patient.id, |
54 | 58 | str(dicom.patient.age), |
55 | 59 | dicom.patient.gender, |
56 | - dicom.acquisition.study_description, | |
60 | + dicom.acquisition.study_description, # per patient | |
57 | 61 | dicom.acquisition.modality, |
58 | 62 | date_time, |
59 | 63 | n_images, |
60 | 64 | dicom.acquisition.institution, |
61 | 65 | dicom.patient.birthdate, |
62 | 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 | 78 | try: |
65 | 79 | dict[patient_name].append(exam_data) |
66 | 80 | except KeyError: |
67 | 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 | 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 | 86 | ps.Publisher().sendMessage("Load import panel", dict) |
87 | + ps.Publisher().sendMessage("Load dicom preview", series_preview) | |
88 | + | |
79 | 89 | |
80 | 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 | 3 | import wx.lib.pubsub as ps |
4 | 4 | import wx.lib.splitter as spl |
5 | 5 | |
6 | +import dicom_preview_panel as dpp | |
7 | + | |
6 | 8 | class Panel(wx.Panel): |
7 | 9 | def __init__(self, parent): |
8 | 10 | wx.Panel.__init__(self, parent, pos=wx.Point(5, 5), |
... | ... | @@ -108,7 +110,7 @@ class TextPanel(wx.Panel): |
108 | 110 | tree.SetItemBackgroundColour(parent, (242,246,254)) |
109 | 111 | |
110 | 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 | 114 | value = patient_data[0][item] |
113 | 115 | # Sum slices of all patient's series |
114 | 116 | if (item == 7): |
... | ... | @@ -119,7 +121,6 @@ class TextPanel(wx.Panel): |
119 | 121 | |
120 | 122 | # For each series on patient |
121 | 123 | j = 0 |
122 | - print patient_data | |
123 | 124 | for series in xrange(len(patient_data)): |
124 | 125 | series_title = patient_data[series][0] |
125 | 126 | |
... | ... | @@ -128,7 +129,7 @@ class TextPanel(wx.Panel): |
128 | 129 | tree.SetItemBackgroundColour(child, (242,246,254)) |
129 | 130 | |
130 | 131 | # TODO: change description "protocol_name" |
131 | - description = patient_data[series][4] | |
132 | + description = patient_data[series][-1] | |
132 | 133 | modality = patient_data[series][5] |
133 | 134 | # TODO: add to date the time |
134 | 135 | date = patient_data[series][6] |
... | ... | @@ -143,10 +144,10 @@ class TextPanel(wx.Panel): |
143 | 144 | j += 1 |
144 | 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 | 153 | def OnActivate(self, evt): |
... | ... | @@ -177,7 +178,7 @@ class ImagePanel(wx.Panel): |
177 | 178 | self.SetSizer(sizer) |
178 | 179 | |
179 | 180 | self.text_panel = SeriesPanel(splitter) |
180 | - splitter.AppendWindow(self.text_panel, 400) | |
181 | + splitter.AppendWindow(self.text_panel, 600) | |
181 | 182 | |
182 | 183 | self.image_panel = SlicePanel(splitter) |
183 | 184 | splitter.AppendWindow(self.image_panel, 250) |
... | ... | @@ -185,9 +186,23 @@ class ImagePanel(wx.Panel): |
185 | 186 | class SeriesPanel(wx.Panel): |
186 | 187 | def __init__(self, parent): |
187 | 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 | 205 | class SlicePanel(wx.Panel): |
191 | 206 | def __init__(self, parent): |
192 | 207 | wx.Panel.__init__(self, parent, -1) |
193 | - self.SetBackgroundColour((0,0,0)) | |
208 | + self.SetBackgroundColour((255,255,255)) | ... | ... |