# The region of interest object (RoiObj) is basically a volume where each voxel # is known to be part of an anatomical region. Hence, you can define the RoiObj # and use it to get the anatomical informations of each source # First, create a basic source object s_obj_ba = SourceObj('S4', xyz) # Then, we define a region of interest object (RoiObj). We use brodmann areas # but you should take a look to the complete tutorial on ROIs because visbrain # povides several templates (Brodmann, AAL, Talairach and MIST) roi_obj = RoiObj('brodmann') # If you want to see labels associated with the brodmann areas, uncomment the # following line # print(roi_obj.get_labels()) # Now, analyse sources using the RoiObj. The argument returned by the # `SourceObj.analyse_sources` method is a Pandas dataframe df_brod = s_obj_ba.analyse_sources(roi_obj=roi_obj) # The dataframe contains a column `brodmann` which is the name of the # associated brodmann area. Hence, we use it to color sources according to the # name of brodmann area s_obj_ba.color_sources(analysis=df_brod, color_by='brodmann') # Finally, add the object to the scene sc.add_to_subplot(s_obj_ba, row=1, col=0, title='Color sources according to\n Brodmann area', **S_KW) ############################################################################### # Color sources, using predefined colors, according to the AAL location ############################################################################### # Similarly to the example above, here, we color sources according to the # Automated Anatomical Labeling (AAL) """Analyse where sources are located using the AAL ROI template and color
############################################################################### # Get anatomical informations of sources ############################################################################### # If you defined sources (like intracranial recording sites, MEG source # reconstruction...) you can use the SourceObj to defined those sources and # then, the RoiObj to identify where are those sources located using the ROI # volume. Here, we use the MIST at the `ROI` resolution to identify where are # located those sources # Define the MIST object at the ROI level roi_mist = RoiObj('mist_ROI') # roi_mist.get_labels(save_to_path=vb_path) # save the labels # Define the source object and analyse those sources using the MIST s_obj = SourceObj('anat', xyz, data=data) analysis = s_obj.analyse_sources(roi_mist) # print(analysis) # anatomical informations are included in a dataframe # Color those sources according to the anatomical informations s_obj.color_sources(analysis=analysis, color_by='name_ROI') # Add the source object to the scene sc.add_to_subplot(s_obj, row=1, col=0, rotate='top', zoom=.6, title='Get anatomical informations of sources') ############################################################################### # .. note:: # In the example above, we analyse sources using only one ROI object. But # you can also combine anatomical informations that come from several # ROI. For example, if you want to analyse your sources using brodmann # areas, AAL and MIST at level 7 : # # brod_roi = RoiObj('brodmann')
############################################################################### # Get anatomical informations of sources ############################################################################### # If you defined sources (like intracranial recording sites, MEG source # reconstruction...) you can use the SourceObj to defined those sources and # then, the RoiObj to identify where are those sources located using the ROI # volume. Here, we use the MIST at the `ROI` resolution to identify where are # located those sources # Define the MIST object at the ROI level roi_mist = RoiObj('mist_ROI') # roi_mist.get_labels(save_to_path=vb_path) # save the labels # Define the source object and analyse those sources using the MIST s_obj = SourceObj('anat', xyz, data=data) analysis = s_obj.analyse_sources(roi_mist) # print(analysis) # anatomical informations are included in a dataframe # Color those sources according to the anatomical informations s_obj.color_sources(analysis=analysis, color_by='name_ROI') # Add the source object to the scene sc.add_to_subplot(s_obj, row=1, col=0, rotate='top', zoom=.6, title='Get anatomical informations of sources') ############################################################################### # .. note:: # In the example above, we analyse sources using only one ROI object. But # you can also combine anatomical informations that come from several
# The region of interest object (RoiObj) is basically a volume where each voxel # is known to be part of an anatomical region. Hence, you can define the RoiObj # and use it to get the anatomical informations of each source # First, create a basic source object s_obj_ba = SourceObj('S4', xyz) # Then, we define a region of interest object (RoiObj). We use brodmann areas # but you should take a look to the complete tutorial on ROIs because visbrain # povides several templates (Brodmann, AAL, Talairach and MIST) roi_obj = RoiObj('brodmann') # If you want to see labels associated with the brodmann areas, uncomment the # following line # print(roi_obj.get_labels()) # Now, analyse sources using the RoiObj. The argument returned by the # `SourceObj.analyse_sources` method is a Pandas dataframe df_brod = s_obj_ba.analyse_sources(roi_obj=roi_obj) # The dataframe contains a column `brodmann` which is the name of the # associated brodmann area. Hence, we use it to color sources according to the # name of brodmann area s_obj_ba.color_sources(analysis=df_brod, color_by='brodmann') # Finally, add the object to the scene sc.add_to_subplot(s_obj_ba, row=1, col=0, title='Color sources according to\n Brodmann area', **S_KW) ############################################################################### # Color sources, using predefined colors, according to the AAL location ############################################################################### # Similarly to the example above, here, we color sources according to the
radius_min=10., radius_max=20., alpha=.4) """Color the sources according to data """ s_obj_l.color_sources(data=data_l, cmap='plasma') """Create a second source object. Then, we analyse where are located the sources using the AAL region of interest and used color according to gyrus """ s_obj_rb = SourceObj('S_right_back', s_xyz_rb, symbol='arrow', radius_min=20., edge_width=0., text_color='white', text_size=1., text_bold=True) """Analyse where the source are located using the Brodmann area (BA) atlas. This method returns a pandas.DataFrame """ df = s_obj_rb.analyse_sources('brodmann') # print(df.keys()) """Then, color the sources according to the BA. Without further arguments, this function use random colors for each BA : """ s_obj_rb.color_sources(df, 'brodmann') """Finally, set the name of the BA for the text : """ s_obj_rb.text = df['brodmann'] """Create a third source object """ s_obj_rf = SourceObj('S_right_front', s_xyz_rf, symbol='ring', radius_min=10., edge_width=0., alpha=.8) """Analyse source's locations using the Talairach atlas """
row=0, col=2, title='Plot dorsal and ventral thalamus with fixed colors') # ============================================================================= # ANATOMICAL LOCATION OF SOURCES # ============================================================================= print('\n-> Anatomical location of sources using an ROI object') # Define the ROI object : roi_tal = RoiObj('talairach') roi_tal.select_roi(select=[681, 682, 808, 809]) roi_tal.translucent = True roi_tal.get_labels(save_to_path=vb_path) # save available Talairach labels # Define a source object : s_obj = SourceObj('FirstSources', xyz, data=data) analysis = s_obj.analyse_sources(roi_tal) s_obj.color_sources(analysis=analysis, color_by='gyrus') sc.add_to_subplot(s_obj, row=1, col=0, title='Anatomical location of sources') sc.add_to_subplot(roi_tal, row=1, col=0, use_this_cam=True) # ============================================================================= # SELECT SOURCES INSIDE ROI'S # ============================================================================= print('\n-> Select only sources inside BA 4, 6 and 8') # Define the ROI object : roi_brod_2 = RoiObj('brodmann') roi_brod_2.select_roi(select=[4, 6, 8]) roi_brod_2.translucent = True # Define a source object : s_obj_2 = SourceObj('SecondSources', xyz, data=data) analysis = s_obj_2.analyse_sources(roi_brod_2,
s_obj_l.color_sources(data=data_l, cmap='plasma') """Create a second source object. Then, we analyse where are located the sources using the AAL region of interest and used color according to gyrus """ s_obj_rb = SourceObj('S_right_back', s_xyz_rb, symbol='arrow', radius_min=20., edge_width=0., text_color='white', text_size=1., text_bold=True) """Analyse where the source are located using the Brodmann area (BA) atlas. This method returns a pandas.DataFrame """ df = s_obj_rb.analyse_sources('brodmann') # print(df.keys()) """Then, color the sources according to the BA. Without further arguments, this function use random colors for each BA : """ s_obj_rb.color_sources(df, 'brodmann') """Finally, set the name of the BA for the text : """ s_obj_rb.text = df['brodmann'] """Create a third source object """ s_obj_rf = SourceObj('S_right_front', s_xyz_rf, symbol='ring', radius_min=10., edge_width=0.,