Plot source space

Plot from a .fif file using the visbrain.mne.mne_plot_source_space function


Load .fif file in the MNE-python dataset

import os
import numpy as np

from mne.datasets import sample

from visbrain import Brain
from visbrain.mne import mne_plot_source_space

# Define path :
main_path = sample.data_path()
sbj_dir = os.path.join(*(main_path, 'subjects', 'fsaverage', 'bem'))

# fif file to load :
fif_file = os.path.join(sbj_dir, 'fsaverage-ico-5-src.fif')

Active data

Active data defined for illustration.
active_data = np.arange(20484)

Additional inputs

Additional inputs for BrainObj :
kw_b_obj = dict(translucent=False, hemisphere='both')
# Additional inputs for SourceObj :
kw_s_obj = dict(color='blue', symbol='square')
# Additional inputs for activations (colormap, clim...) :
kw_activation = dict(cmap='viridis', hide_under=10000,
                     clim=(active_data.min(), active_data.max()), vmax=20000,

Get the brain and source objects

Note that here, we use show=False. In that case, a visbrain.objects.BrainObj and a visbrain.objects.SourceObj are returned.
b_obj, s_obj = mne_plot_source_space(fif_file, active_data=active_data,

Pass the brain and source objects to the visbrain.Brain module

Note that here, we pass the source object to Brain but by default we set it as not visible. But if you don’t need to see it, simply remove the source_obj=s_obj
s_obj.visible_obj = False
brain = Brain(brain_obj=b_obj, source_obj=s_obj)

Total running time of the script: ( 0 minutes 0.000 seconds)

Gallery generated by Sphinx-Gallery