**S_KW) ############################################################################### # Force sources to fit to the surface of the brain ############################################################################### # First, we force sources to fit to the white matter of the brain. Then, we use # the talaich ROI to identify which sources belong to the left or right # hemisphere and color them accordingly # Define the Brain and Source objects s_obj_fit = SourceObj('Fit', xyz, symbol='diamond') b_obj_fit = BrainObj('white', translucent=True) # Get the vertices of the brain object and force sources to fit to those # vertices b_obj_vert = b_obj_fit.vertices s_obj_fit.fit_to_vertices(b_obj_vert) # Analyse source's anatomical location using the Talairach atlas df_tal = s_obj_fit.analyse_sources(roi_obj='talairach') # Color sources accordingly to the hemisphere (left='purple', right='yellow') s_obj_fit.color_sources(analysis=df_tal, color_by='hemisphere', roi_to_color={ 'Left': 'purple', 'Right': 'yellow' }) # Finally, add those objects to the scene sc.add_to_subplot(s_obj_fit, row=3, col=1, title="Force sources to fit to the\nsurface of the brain") sc.add_to_subplot(b_obj_fit, row=3, col=1, use_this_cam=True)
title='Display sources in left hemisphere', **S_KW) ############################################################################### # Force sources to fit to the surface of the brain ############################################################################### # First, we force sources to fit to the white matter of the brain. Then, we use # the talaich ROI to identify which sources belong to the left or right # hemisphere and color them accordingly # Define the Brain and Source objects s_obj_fit = SourceObj('Fit', xyz, symbol='diamond') b_obj_fit = BrainObj('white', translucent=True) # Get the vertices of the brain object and force sources to fit to those # vertices b_obj_vert = b_obj_fit.vertices s_obj_fit.fit_to_vertices(b_obj_vert) # Analyse source's anatomical location using the Talairach atlas df_tal = s_obj_fit.analyse_sources(roi_obj='talairach') # Color sources accordingly to the hemisphere (left='purple', right='yellow') s_obj_fit.color_sources(analysis=df_tal, color_by='hemisphere', roi_to_color={'Left': 'purple', 'Right': 'yellow'}) # Finally, add those objects to the scene sc.add_to_subplot(s_obj_fit, row=3, col=1, title="Force sources to fit to the\nsurface of the brain") sc.add_to_subplot(b_obj_fit, row=3, col=1, use_this_cam=True) ############################################################################### # Display only sources inside the brain ############################################################################### # In this little example, we illustrate how to only display sources inside the # brain
""" s_obj_left = SourceObj('S_left', xyz, color='#ab4642') s_obj_left.set_visible_sources('left') sc.add_to_subplot(s_obj_left, row=2, col=0, title='Display sources in left hemisphere') """Create a sphere using VisPy """ sphere = create_sphere(rows=100, cols=100, radius=50) sphere_vertices = sphere.get_vertices() """Force sources to fit on the vertices of the sphere. Then, we color sources according to the hemisphere (left=purple, right=yellow) """ s_obj_fit = SourceObj('Fit', xyz, symbol='diamond') s_obj_fit.fit_to_vertices(sphere_vertices) df_tal = s_obj_fit.analyse_sources(roi_obj='talairach') s_obj_fit.color_sources(analysis=df_tal, color_by='hemisphere', roi_to_color={'Left': 'purple', 'Right': 'yellow'}) sc.add_to_subplot(s_obj_fit, row=2, col=1, title="Force sources to fit on a sphere") """Use the same sphere to display only sources that are inside """ s_obj_inside = SourceObj('In', xyz, symbol='cross', color='firebrick') s_obj_inside.set_visible_sources('inside', sphere_vertices) sc.add_to_subplot(s_obj_inside, row=2, col=2, title='Display only sources inside a sphere') """If you need, you can link the rotation off all cameras but this can considerably slow down visualization updates