Skip to content

Commit e783de2

Browse files
committed
brain regions aggregation mappings
1 parent 9cd6981 commit e783de2

File tree

2 files changed

+41
-12
lines changed

2 files changed

+41
-12
lines changed

atlasview/atlasview.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,13 @@ def __init__(self, **kwargs):
5959
self.line_sagittal.sigDragged.connect(self._refresh_sagittal)
6060
self.plotItem_topview.addItem(self.line_coronal)
6161
self.plotItem_topview.addItem(self.line_sagittal)
62-
# connect signals and slots
62+
# connect signals and slots: mouse moved
6363
s = self.plotItem_topview.getViewBox().scene()
6464
self.proxy = pg.SignalProxy(s.sigMouseMoved, rateLimit=60, slot=self.mouseMoveEvent)
65+
# combobox for the atlas remapping choices
66+
self.comboBox_mappings.addItems(self.ctrl.atlas.regions.mappings.keys())
67+
self.comboBox_mappings.currentIndexChanged.connect(self._refresh)
68+
# slider for transparency between image and labels
6569
self.slider_alpha.sliderMoved.connect(self.slider_alpha_move)
6670
self.ctrl.set_top()
6771

@@ -119,10 +123,12 @@ def _refresh(self):
119123
self._refresh_coronal()
120124

121125
def _refresh_coronal(self):
122-
self.ctrl.set_slice(self.ctrl.fig_coronal, self.line_coronal.value())
126+
self.ctrl.set_slice(self.ctrl.fig_coronal, self.line_coronal.value(),
127+
mapping=self.comboBox_mappings.currentText())
123128

124129
def _refresh_sagittal(self):
125-
self.ctrl.set_slice(self.ctrl.fig_sagittal, self.line_sagittal.value())
130+
self.ctrl.set_slice(self.ctrl.fig_sagittal, self.line_sagittal.value(),
131+
mapping=self.comboBox_mappings.currentText())
126132

127133

128134
class SliceView(QtWidgets.QWidget):
@@ -255,10 +261,10 @@ class ControllerTopView(PgImageController):
255261
"""
256262
TopView ControllerTopView
257263
"""
258-
def __init__(self, qmain: TopView, res: int = 25, volume='image'):
264+
def __init__(self, qmain: TopView, res: int = 25, volume='image', brainmap='Allen'):
259265
super(ControllerTopView, self).__init__(qmain)
260266
self.volume = volume
261-
self.atlas = AllenAtlas(res)
267+
self.atlas = AllenAtlas(res, brainmap=brainmap)
262268
self.fig_top = self.qwidget = qmain
263269
# Setup Coronal slice: width: ml, height: dv, depth: ap
264270
self.fig_coronal = SliceView(qmain, waxis=0, haxis=2, daxis=1)
@@ -271,7 +277,7 @@ def __init__(self, qmain: TopView, res: int = 25, volume='image'):
271277
self.set_slice(self.fig_sagittal)
272278
self.fig_sagittal.show()
273279

274-
def set_slice(self, fig, coord=0):
280+
def set_slice(self, fig, coord=0, mapping="Allen"):
275281
waxis, haxis, daxis = (fig.ctrl.waxis, fig.ctrl.haxis, fig.ctrl.daxis)
276282
# construct the transform matrix image 2 ibl coordinates
277283
dw = self.atlas.bc.dxyz[waxis]
@@ -281,7 +287,7 @@ def set_slice(self, fig, coord=0):
281287
# the ImageLayer object carries slice kwargs and pyqtgraph ImageSet kwargs
282288
# reversed order so the self.im is set with the base layer
283289
for layer in reversed(fig.ctrl.image_layers):
284-
_slice = self.atlas.slice(coord, axis=daxis, **layer.slice_kwargs)
290+
_slice = self.atlas.slice(coord, axis=daxis, mapping=mapping, **layer.slice_kwargs)
285291
fig.ctrl.set_image(layer.image_item, _slice, dw, dh, wl[0], hl[0], **layer.pg_kwargs)
286292
fig.ctrl.slice_coord = coord
287293

@@ -354,10 +360,10 @@ class ImageLayer:
354360
slice_kwargs: dict = field(default_factory=lambda: {'volume': 'image', 'mode': 'clip'})
355361

356362

357-
def view(res=25, title=None, volume='image', levels=None):
363+
def view(res=25, title=None, brainmap='Allen'):
358364
"""
359365
"""
360366
qt.create_app()
361-
av = TopView._get_or_create(title=title, res=res)
367+
av = TopView._get_or_create(title=title, res=res, brainmap=brainmap)
362368
av.show()
363369
return av

atlasview/topview.ui

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
<property name="frameShadow">
3333
<enum>QFrame::Raised</enum>
3434
</property>
35-
<widget class="QLabel" name="label">
35+
<widget class="QLabel" name="label_slider_annotation">
3636
<property name="geometry">
3737
<rect>
3838
<x>20</x>
@@ -61,7 +61,7 @@
6161
<enum>Qt::Vertical</enum>
6262
</property>
6363
</widget>
64-
<widget class="QLabel" name="label_2">
64+
<widget class="QLabel" name="label_slider_image">
6565
<property name="geometry">
6666
<rect>
6767
<x>10</x>
@@ -74,6 +74,29 @@
7474
<string>Image</string>
7575
</property>
7676
</widget>
77+
<widget class="QComboBox" name="comboBox_mappings">
78+
<property name="geometry">
79+
<rect>
80+
<x>0</x>
81+
<y>350</y>
82+
<width>93</width>
83+
<height>27</height>
84+
</rect>
85+
</property>
86+
</widget>
87+
<widget class="QLabel" name="label_cb_mappings">
88+
<property name="geometry">
89+
<rect>
90+
<x>10</x>
91+
<y>330</y>
92+
<width>67</width>
93+
<height>17</height>
94+
</rect>
95+
</property>
96+
<property name="text">
97+
<string>Mapping</string>
98+
</property>
99+
</widget>
77100
</widget>
78101
</item>
79102
</layout>
@@ -84,7 +107,7 @@
84107
<x>0</x>
85108
<y>0</y>
86109
<width>435</width>
87-
<height>22</height>
110+
<height>24</height>
88111
</rect>
89112
</property>
90113
</widget>

0 commit comments

Comments
 (0)