def _plt_src(name, kw_brain_obj, active_data, active_vert, sources, kw_source_obj, kw_activation, show): # Define a brain object and a source object : logger.info(' Define a Brain and Source objects') from visbrain.objects import BrainObj, SourceObj, SceneObj brain_obj, source_obj = name + '_brain', name + '_sources' b_obj = BrainObj(brain_obj, **kw_brain_obj) s_obj = SourceObj(source_obj, sources, **kw_source_obj) s_obj.visible_obj = False # Add data to the BrainObj if needed : if isinstance(active_data, np.ndarray): logger.info(" Add active data between " "[%2f, %2f]" % (active_data.min(), active_data.max())) b_obj.add_activation(data=active_data, vertices=active_vert, **kw_activation) # Return either a scene or a BrainObj and SourceObj : if show is True: # Display inside the Brain GUI # Define a Brain instance : from visbrain.gui import Brain brain = Brain(brain_obj=b_obj, source_obj=s_obj) brain._brain_template.setEnabled(False) # By default, display colorbar if activation : if isinstance(active_data, np.ndarray): brain.menuDispCbar.setChecked(True) brain._fcn_menu_disp_cbar() brain.show() elif show is 'scene': # return a SceneObj logger.info(" Define a unique scene for the Brain and Source " "objects") sc = SceneObj() sc.add_to_subplot(s_obj) sc.add_to_subplot(b_obj, use_this_cam=True) return sc else: # return the BrainObj and SourceObj s_obj.visible_obj = True return b_obj, s_obj
""" Display conjunction map ======================= Display a conjunction map from a nii.gz file (NiBabel required). See the original PySurfer example : https://pysurfer.github.io/auto_examples/plot_fmri_conjunction.html#sphx-glr-auto-examples-plot-fmri-conjunction-py .. image:: ../../_static/examples/ex_eegmeg_conjunction_map.png """ from visbrain.gui import Brain from visbrain.objects import BrainObj from visbrain.io import download_file """Download files if needed """ file_1 = download_file('lh.sig.nii.gz', astype='example_data') file_2 = download_file('lh.alt_sig.nii.gz', astype='example_data') b_obj = BrainObj('inflated', translucent=False, sulcus=True) b_obj.add_activation(file=file_1, clim=(4., 30.), hide_under=4, cmap='Reds_r', hemisphere='left') b_obj.add_activation(file=file_2, clim=(4., 30.), hide_under=4, cmap='Blues_r', hemisphere='left') vb = Brain(brain_obj=b_obj) vb.rotate('left') vb.show()
"""Create the source object. If you want to previsualize the result without opening Brain, use s_obj.preview() """ s_obj = SourceObj('SourceExample', xyz, **kwargs) # s_obj.preview() """Color sources according to the data """ # s_obj.color_sources(data=kwargs['data'], cmap='viridis') """Colorbar properties """ cb_kw = dict( cblabel="Project source activity", cbtxtsz=3., border=False, ) """Define a brain object with the B3 template and project source's activity onto the surface """ b_obj = BrainObj('B3', **cb_kw) b_obj.project_sources(s_obj, cmap='viridis', vmin=50., under='orange', vmax=550., over='darkred') """Create a Brain instance and pass both of the brain and source object defined After the interface is opened, press C to display the colorbar. """ vb = Brain(source_obj=s_obj, brain_obj=b_obj) vb.show()
# 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, over='red') ############################################################################### # Get the brain and source objects ############################################################################### # Note that here, we use `show=False`. In that case, a # :class:`visbrain.objects.BrainObj` and a :class:`visbrain.objects.SourceObj` # are returned. b_obj, s_obj = mne_plot_source_space(fif_file, active_data=active_data, kw_brain_obj=kw_b_obj, kw_source_obj=kw_s_obj, kw_activation=kw_activation, show=False) ############################################################################### # Pass the brain and source objects to the :class:`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) brain.show()
def visualise_brain(b_obj): """Opens Visbrain GUI with colored ROI """ vb = Brain(brain_obj=b_obj, bgcolor='black') vb.show()