Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions mne/viz/_brain/_brain.py
Original file line number Diff line number Diff line change
Expand Up @@ -2048,7 +2048,7 @@ def add_label(self, label, color=None, alpha=1, scalar_thresh=None,

def add_foci(self, coords, coords_as_verts=False, map_surface=None,
scale_factor=1, color="white", alpha=1, name=None,
hemi=None):
hemi=None, resolution=50):
"""Add spherical foci, possibly mapping to displayed surf.

The foci spheres can be displayed at the coordinates given, or
Expand Down Expand Up @@ -2078,9 +2078,11 @@ def add_foci(self, coords, coords_as_verts=False, map_surface=None,
If None, it is assumed to belong to the hemipshere being
shown. If two hemispheres are being shown, an error will
be thrown.
resolution : int
The resolution of the spheres.
"""
from matplotlib.colors import colorConverter
hemi = self._check_hemi(hemi)
hemi = self._check_hemi(hemi, extras=['vol'])

# those parameters are not supported yet, only None is allowed
_check_option('map_surface', map_surface, [None])
Expand All @@ -2099,7 +2101,7 @@ def add_foci(self, coords, coords_as_verts=False, map_surface=None,
self._renderer.subplot(ri, ci)
self._renderer.sphere(center=coords, color=color,
scale=(10. * scale_factor),
opacity=alpha)
opacity=alpha, resolution=resolution)
self._renderer.set_camera(**views_dicts[hemi][v])

def add_text(self, x, y, text, name=None, color=None, opacity=1.0,
Expand Down Expand Up @@ -2713,7 +2715,7 @@ def _save_movie(self, filename, time_dilation=4., tmin=None, tmax=None,
kwargs['codec'] = codec
if bitrate is not None:
kwargs['bitrate'] = bitrate
imageio.mimwrite(filename, images)
imageio.mimwrite(filename, images, **kwargs)

@fill_doc
def save_movie(self, filename, time_dilation=4., tmin=None, tmax=None,
Expand Down
10 changes: 9 additions & 1 deletion mne/viz/_brain/tests/test_brain.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,9 +337,14 @@ def test_brain_save_movie(tmpdir, renderer, brain_gc):
brain._renderer.plotter.enable()
else:
brain._renderer.plotter.disable()
brain.save_movie(filename, time_dilation=1,
with pytest.raises(TypeError, match='unexpected keyword argument'):
brain.save_movie(filename, time_dilation=1, tmin=1, tmax=1.1,
bad_name='blah')
assert not path.isfile(filename)
brain.save_movie(filename, time_dilation=0.1,
interpolation='nearest')
assert path.isfile(filename)
os.remove(filename)
brain.close()


Expand Down Expand Up @@ -427,6 +432,9 @@ def test_brain_traces(renderer_interactive, hemi, src, tmpdir,
assert hasattr(brain, "_spheres")
assert brain.plotter.scalar_bar.GetNumberOfLabels() == 3

# add foci should work for volumes
brain.add_foci([[0, 0, 0]], hemi='lh' if src == 'surface' else 'vol')

# test points picked by default
picked_points = brain.get_picked_points()
spheres = brain._spheres
Expand Down