Skip to content

Commit ff005a2

Browse files
committed
Merge pull request #93 from dengemann/fix_color_bar
BUG/WIP: positive only overlays + multiple hemis
2 parents 83b0103 + d973b04 commit ff005a2

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

surfer/tests/test_viz.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import numpy as np
22
import os
3+
import os.path as op
34
from os.path import join as pjoin
45
from numpy.testing import assert_raises, assert_array_equal
56
from tempfile import mktemp
@@ -12,10 +13,11 @@
1213
subj_dir = utils._get_subjects_dir()
1314
subject_id = 'fsaverage'
1415
std_args = [subject_id, 'lh', 'inflated']
15-
data_dir = pjoin(os.path.split(__file__)[0], '..', '..',
16-
'examples', 'example_data')
16+
data_dir = pjoin(op.dirname(__file__), '..', '..', 'examples', 'example_data')
1717
small_brain = dict(size=100)
1818

19+
overlay_fname = pjoin(data_dir, 'lh.sig.nii.gz')
20+
1921

2022
def has_freesurfer():
2123
if 'FREESURFER_HOME' not in os.environ:
@@ -42,11 +44,16 @@ def test_offscreen():
4244
def test_image():
4345
"""Test image saving
4446
"""
47+
tmp_name = mktemp() + '.png'
48+
4549
mlab.options.backend = 'auto'
50+
subject_id, _, surf = std_args
51+
brain = Brain(subject_id, 'both', surf=surf, config_opts=small_brain)
52+
brain.add_overlay(overlay_fname, hemi='lh', min=5, max=20, sign="pos")
53+
brain.save_imageset(tmp_name, ['med', 'lat'], 'jpg')
54+
4655
brain = Brain(*std_args, config_opts=small_brain)
47-
tmp_name = mktemp() + '.png'
4856
brain.save_image(tmp_name)
49-
brain.save_imageset(tmp_name, ['med', 'lat'], 'jpg')
5057
brain.save_montage(tmp_name, ['l', 'v', 'm'], orientation='v')
5158
brain.save_montage(tmp_name, ['l', 'v', 'm'], orientation='h')
5259
brain.save_montage(tmp_name, [['l', 'v'], ['m', 'f']])

surfer/viz.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1621,8 +1621,9 @@ def _get_colorbars(self, row, col):
16211621
if len(self.overlays_dict) > 0:
16221622
for name, obj in self.overlays_dict.items():
16231623
for bar in ["pos_bar", "neg_bar"]:
1624-
try:
1625-
colorbars.append(getattr(obj[ind], bar))
1624+
try: # deal with positive overlays
1625+
this_ind = min(len(obj) - 1, ind)
1626+
colorbars.append(getattr(obj[this_ind], bar))
16261627
except AttributeError:
16271628
pass
16281629
return colorbars

0 commit comments

Comments
 (0)