예제 #1
0
# 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
only the precentral left (green), right (orange), insula right (blue). Others
ROI are turn into white.
예제 #2
0
    # xyz15 = b15.locs.values

    template_brain = 'B3'

    sc = SceneObj(bgcolor='white', size=(1000, 1000))

    CBAR_STATE = dict(cbtxtsz=12,
                      clim=[0, 15],
                      txtsz=10.,
                      width=.1,
                      cbtxtsh=3.,
                      rect=(-.3, -2., 1., 4.))
    KW = dict(title_size=14., zoom=1)

    s_obj_1 = SourceObj('iEEG', xyz1, data=data1, cmap=cmap)
    s_obj_1.color_sources(data=data1)
    s_obj_2 = SourceObj('iEEG', xyz2, data=data2, cmap=cmap)
    s_obj_2.color_sources(data=data2)
    s_obj_3 = SourceObj('iEEG', xyz3, data=data3, cmap=cmap)
    s_obj_3.color_sources(data=data3)
    s_obj_4 = SourceObj('iEEG', xyz4, data=data4, cmap=cmap)
    s_obj_4.color_sources(data=data4)
    s_obj_5 = SourceObj('iEEG', xyz5, data=data5, cmap=cmap)
    s_obj_5.color_sources(data=data5)
    s_obj_6 = SourceObj('iEEG', xyz6, data=data6, cmap=cmap)
    s_obj_6.color_sources(data=data6)
    s_obj_7 = SourceObj('iEEG', xyz7, data=data7, cmap=cmap)
    s_obj_7.color_sources(data=data7)
    s_obj_8 = SourceObj('iEEG', xyz8, data=data8, cmap=cmap)
    s_obj_8.color_sources(data=data8)
    s_obj_9 = SourceObj('iEEG', xyz9, data=data9, cmap=cmap)
예제 #3
0
    clim = (psds.min(), psds.max())

    # Find indices of frequencies :
    idx_fplt = np.abs(
        (freqs.reshape(1, 1, -1) - freq_bands[..., np.newaxis])).argmin(2)
    psdf = np.array([psds[:, k[0]:k[1]].mean(1) for k in idx_fplt])
    radius = normalize(np.c_[psdf.min(1), psdf.max(1)], 5, 25).astype(float)

    for num, (fb, fbn, psd,
              rx) in enumerate(zip(freq_bands, freq_band_names, psdf, radius)):
        s_obj = SourceObj('s',
                          xyz,
                          data=psd,
                          radius_min=rx[0],
                          radius_max=rx[1])  # noqa
        s_obj.color_sources(data=psd, cmap='cool', clim=clim)
        sc.add_to_subplot(s_obj,
                          col=num,
                          title=str(fb) + ' - ' + fbn,
                          title_color='white',
                          rotate='top',
                          zoom=.6)
    cbar = ColorbarObj(s_obj,
                       txtcolor='white',
                       cblabel='PSD',
                       txtsz=15,
                       cbtxtsz=20)
    sc.add_to_subplot(cbar, col=len(freq_bands), width_max=200)

sc.preview()
예제 #4
0
fig_dir = '../../../paper/figs/source/best_locs'

# Colorbar default arguments
CBAR_STATE = dict(cbtxtsz=20, txtsz=20., txtcolor='white', width=.1, cbtxtsh=3.,
                  rect=(-.3, -2., 1., 4.))
KW = dict(title_size=14., zoom=2)

template_brain = 'B3'

bo = se.load(os.path.join(nii_bo_dir, 'best_90th.bo'))

data1 = bo.get_data().values.ravel()
xyz1 = bo.locs.values

s_obj_1 = SourceObj('iEEG', xyz1, data=data1, cmap=cmap)
s_obj_1.color_sources(data=data1)

sc = SceneObj(bgcolor='white', size=(1000, 500))

b_obj_proj_left = BrainObj(template_brain, hemisphere='left', translucent=False)
b_obj_proj_left.project_sources(s_obj_1, clim=(0, 2), cmap='binary')
sc.add_to_subplot(b_obj_proj_left, row=0, col=0, rotate='left', use_this_cam=True)


b_obj_proj_left = BrainObj(template_brain, hemisphere='left', translucent=False)
b_obj_proj_left.project_sources(s_obj_1, clim=(0, 2), cmap='binary')
sc.add_to_subplot(b_obj_proj_left, row=0, col=1, rotate='right', use_this_cam=True)

b_obj_proj_right = BrainObj(template_brain, hemisphere='right', translucent=False)
b_obj_proj_right.project_sources(s_obj_1, clim=(0, 2), cmap='binary')
sc.add_to_subplot(b_obj_proj_right, row=0, col=2, rotate='left', use_this_cam=True)
예제 #5
0
xyz6 = b6.locs.values

template_brain = 'B3'

sc = SceneObj(bgcolor='white', size=(1000, 1000))

CBAR_STATE = dict(cbtxtsz=12,
                  clim=[0, 7],
                  txtsz=10.,
                  width=.1,
                  cbtxtsh=3.,
                  rect=(-.3, -2., 1., 4.))
KW = dict(title_size=14., zoom=1)

s_obj_1 = SourceObj('iEEG', xyz1, data=data1, cmap=cmap)
s_obj_1.color_sources(data=data1)
s_obj_2 = SourceObj('iEEG', xyz2, data=data2, cmap=cmap)
s_obj_2.color_sources(data=data2)
s_obj_3 = SourceObj('iEEG', xyz3, data=data3, cmap=cmap)
s_obj_3.color_sources(data=data3)
s_obj_4 = SourceObj('iEEG', xyz4, data=data4, cmap=cmap)
s_obj_4.color_sources(data=data4)
s_obj_5 = SourceObj('iEEG', xyz5, data=data5, cmap=cmap)
s_obj_5.color_sources(data=data5)
s_obj_6 = SourceObj('iEEG', xyz6, data=data6, cmap=cmap)
s_obj_6.color_sources(data=data6)

#s_obj_all = s_obj_1 + s_obj_2 + s_obj_3 + s_obj_4+ s_obj_5 + s_obj_6 + s_obj_7

s_obj_all = s_obj_6 + s_obj_5 + s_obj_4 + s_obj_3 + s_obj_2 + s_obj_1
예제 #6
0
###############################################################################
"""Create a first source object with uniform red square markers
"""
s_obj_l = SourceObj('S_left',
                    s_xyz_l,
                    data=data_l,
                    color='red',
                    edge_color='white',
                    symbol='disc',
                    edge_width=2.,
                    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')
data_l = np.random.uniform(-10, 10, s_xyz_l.shape[0])


###############################################################################
#                                 SOURCES
###############################################################################
"""Create a first source object with uniform red square markers
"""
s_obj_l = SourceObj('S_left', s_xyz_l, data=data_l, color='red',
                    edge_color='white', symbol='disc', edge_width=2.,
                    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 :
"""
예제 #8
0
# 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
only the precentral left (green), right (orange), insula right (blue). Others
ROI are turn into white.
"""
# Create a basic source object
예제 #9
0
b_obj_lw = BrainObj('white', hemisphere='left', translucent=False)
sc.add_to_subplot(b_obj_lw, row=0, col=1, rotate='right',
                  title='Left hemisphere', **KW)

###############################################################################
# Projection iEEG data on the surface of the brain
###############################################################################
# As explain above, we define a source object and project the source's activity
# on the surface of the brain

# First, define a brain object used for the projection
b_obj_proj = BrainObj('B3', hemisphere='both', translucent=False)
# Define the source object
s_obj = SourceObj('iEEG', xyz, data=data, cmap='inferno')
# Just for fun, color sources according to the data :)
s_obj.color_sources(data=data)
# Project source's activity
s_obj.project_sources(b_obj_proj, cmap='plasma')
# Finally, add the source and brain objects to the subplot
sc.add_to_subplot(s_obj, row=0, col=2, title='Project iEEG data', **KW)
sc.add_to_subplot(b_obj_proj, row=0, col=2, rotate='left', use_this_cam=True)
# Finally, add the colorbar :
cb_proj = ColorbarObj(s_obj, cblabel='Projection of niEEG data', **CBAR_STATE)
sc.add_to_subplot(cb_proj, row=0, col=3, width_max=200)

###############################################################################
# .. note::
#     Here, we used s_obj.project_sources(b_obj) to project source's activity
#     on the surface. We could also have used to b_obj.project_sources(s_obj)

###############################################################################
예제 #10
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,
                                   distance=20.,
예제 #11
0
NSources = 200
index = np.random.choice(verts.shape[0], n_channels, replace=False)
xyz = verts[index]

brain_obj = BrainObj('Custom',
                     vertices=verts,
                     faces=faces,
                     normals=normals,
                     translucent=False)

source_object = SourceObj('iEEG', xyz, data=data[:, 0], cmap=colormap)

# Project source's activity
source_object.project_sources(brain_obj)
source_object.color_sources(data=data[:, 0])

# Finally, add the source and brain objects to the subplot
scene.add_to_subplot(source_object,
                     row=0,
                     col=0,
                     title='Project iEEG data',
                     **KW)
scene.add_to_subplot(brain_obj, row=0, col=0, rotate='left', use_this_cam=True)

# Finally, add the colorbar :
colorbar = ColorbarObj(source_object,
                       cblabel='Projection of niEEG data',
                       **CBAR_STATE)
scene.add_to_subplot(colorbar, row=0, col=1, width_max=200, rotate='up')
예제 #12
0
sc.add_to_subplot(s_obj_1, row=1, title='Animate multiple objects')
sc.add_to_subplot(b_obj_2, row=1, rotate='right', use_this_cam=True)


###############################################################################
# Animate sources
###############################################################################
# Previous subplots are using the brain object. But every 3D objects in
# Visbrain can also be animated. We illustrate this with a source object

# Define connectivity links and sources
c_obj_1 = ConnectObj('c1', xyz, conn, select=conn_select, dynamic=(0., 1.),
                     dynamic_orientation='center', dynamic_order=3, cmap='bwr',
                     antialias=True)
s_obj_2 = SourceObj('s2', xyz, data=data, radius_min=5., radius_max=20)
s_obj_2.color_sources(data=data, cmap='inferno')

# Animate sources
s_obj_2.animate()

# Add objects to the scene
sc.add_to_subplot(c_obj_1, col=1, title='Animate a source object')
sc.add_to_subplot(s_obj_2, col=1, rotate='front', use_this_cam=True, zoom=.7)

###############################################################################
# Configure the animation rate
###############################################################################
# Here, we configure animations so that there's a 60° rotation update every
# second

# Define a connectivity object and a brain object :
예제 #13
0
def vis_sources_by_pval(padj, all_coord, short_label):
    ''' 
    1. visualize the sources (brain regions) based on the FDR-adjusted p values
    display both the source objects and the brain object
    
    '''

    # Define the default camera state used for each subplot
    CAM_STATE = dict(
        azimuth=0,  # azimuth angle
        elevation=90,  # elevation angle
        scale_factor=180  # distance to the camera
    )
    S_KW = dict(camera_state=CAM_STATE)

    # Create the scene
    CBAR_STATE = dict(cbtxtsz=12,
                      txtsz=13.,
                      width=.5,
                      cbtxtsh=2.,
                      rect=(1., -2., 1., 4.))
    sc = SceneObj(bgcolor='black', size=(1600, 1000))

    # mask = padj<=0.05  # significant regions with true label

    data0, max_p, min_p = get_log_pval(padj)

    b_obj = BrainObj('white', hemisphere='both', translucent=True)
    b_obj.animate(iterations=10, step=30, interval=1)
    s_obj = SourceObj(
        's1',
        all_coord,  #all_coord, 
        # mask = mask,
        # mask_color='white',
        # mask_radius = 15,
        color=padj * 100,
        data=data0,
        text=short_label,
        text_size=10,
        text_bold=True,
        text_color='yellow',
        symbol='disc',
        visible=True,
        radius_min=10,
        radius_max=40,
        alpha=0.65)

    s_obj_1.set_visible_sources('left')

    s_obj.color_sources(data=data0, cmap='jet', clim=(min_p, max_p))
    cb_data = ColorbarObj(s_obj,
                          cblabel='Log FDR-adjusted p value',
                          border=False,
                          **CBAR_STATE)

    sc.add_to_subplot(b_obj, row=0, col=0, rotate='front')
    sc.add_to_subplot(s_obj, row=0, col=0)
    sc.add_to_subplot(cb_data, row=0, col=1, width_max=90)

    # recording animation and save it
    sc.record_animation('output/animate_pvalue_projection.gif', n_pic=10)
    sc.preview()
예제 #14
0
                  rotate='right',
                  title='Left hemisphere',
                  **KW)

###############################################################################
# Projection iEEG data on the surface of the brain
###############################################################################
# As explain above, we define a source object and project the source's activity
# on the surface of the brain

# First, define a brain object used for the projection
b_obj_proj = BrainObj('B3', hemisphere='both', translucent=False)
# Define the source object
s_obj = SourceObj('iEEG', xyz, data=data, cmap='inferno')
# Just for fun, color sources according to the data :)
s_obj.color_sources(data=data)
# Project source's activity
s_obj.project_sources(b_obj_proj, cmap='plasma')
# Finally, add the source and brain objects to the subplot
sc.add_to_subplot(s_obj, row=0, col=2, title='Project iEEG data', **KW)
sc.add_to_subplot(b_obj_proj, row=0, col=2, rotate='left', use_this_cam=True)
# Finally, add the colorbar :
cb_proj = ColorbarObj(s_obj, cblabel='Projection of niEEG data', **CBAR_STATE)
sc.add_to_subplot(cb_proj, row=0, col=3, width_max=200)

###############################################################################
# .. note::
#     Here, we used s_obj.project_sources(b_obj) to project source's activity
#     on the surface. We could also have used to b_obj.project_sources(s_obj)

###############################################################################
예제 #15
0
###############################################################################
# Previous subplots are using the brain object. But every 3D objects in
# Visbrain can also be animated. We illustrate this with a source object

# Define connectivity links and sources
c_obj_1 = ConnectObj('c1',
                     xyz,
                     conn,
                     select=conn_select,
                     dynamic=(0., 1.),
                     dynamic_orientation='center',
                     dynamic_order=3,
                     cmap='bwr',
                     antialias=True)
s_obj_2 = SourceObj('s2', xyz, data=data, radius_min=5., radius_max=20)
s_obj_2.color_sources(data=data, cmap='inferno')

# Animate sources
s_obj_2.animate()

# Add objects to the scene
sc.add_to_subplot(c_obj_1, col=1, title='Animate a source object')
sc.add_to_subplot(s_obj_2, col=1, rotate='front', use_this_cam=True, zoom=.7)

###############################################################################
# Configure the animation rate
###############################################################################
# Here, we configure animations so that there's a 60° rotation update every
# second

# Define a connectivity object and a brain object :
예제 #16
0
###############################################################################
# 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 :
#
예제 #17
0
                    clim=clim,
                    dynamic=(0., 1.),
                    dynamic_order=3,
                    antialias=True,
                    cmap='bwr',
                    line_width=4.)
 s_obj = SourceObj('s',
                   xyz,
                   data=radius,
                   radius_min=5,
                   radius_max=15,
                   text=names,
                   text_size=10,
                   text_color='white',
                   text_translate=(0., 0., 0.))
 s_obj.color_sources(data=radius, cmap='inferno')
 cbar = ColorbarObj(c_obj,
                    txtcolor='white',
                    txtsz=15,
                    cblabel='Connectivity',
                    cbtxtsz=20)
 band = _parse_string(connect_file, freq_band_names)
 title = 'Connectivity on {} band'.format(band)
 sc.add_to_subplot(c_obj,
                   title=title,
                   title_size=14,
                   title_bold=True,
                   title_color='white',
                   row=nf)
 sc.add_to_subplot(s_obj, rotate='top', zoom=.5, use_this_cam=True, row=nf)
 sc.add_to_subplot(cbar, col=1, width_max=200, row=nf)
예제 #18
0
###############################################################################
# Region Of Interest (ROI)
###############################################################################

roi_aal = RoiObj('aal')
roi_aal.select_roi(select=[29, 30], unique_color=True, smooth=11)
sc.add_to_subplot(roi_aal, row=0, col=1, title='Region Of Interest (ROI)')
sc.add_to_subplot(BrainObj('B1'), use_this_cam=True, row=0, col=1)

###############################################################################
# Sources
###############################################################################

s_obj = SourceObj('FirstSources', xyz, data=data)
s_obj.color_sources(data=data, cmap='Spectral_r')
sc.add_to_subplot(s_obj, row=1, col=1, title='Sources')
sc.add_to_subplot(BrainObj('B3'), use_this_cam=True, row=1, col=1)

###############################################################################
# 3D Time-series
###############################################################################

ts, _ = generate_eeg(n_pts=100, n_channels=xyz.shape[0])
select = np.zeros((xyz.shape[0],), dtype=bool)
select[slice(0, 100, 10)] = True
ts_obj = TimeSeries3DObj('TS3D', ts, xyz, select=select, color='pink',
                         ts_amp=24.)
sc.add_to_subplot(ts_obj, row=0, col=2, title='3D time series')
sc.add_to_subplot(BrainObj('B2'), use_this_cam=True, row=0, col=2)
예제 #19
0
===============================================================================
                           Region Of Interest (ROI)
===============================================================================
""")
roi_aal = RoiObj('aal')
roi_aal.select_roi(select=[29, 30], unique_color=True, smooth=11)
sc.add_to_subplot(roi_aal, row=0, col=1, title='Region Of Interest (ROI)')
sc.add_to_subplot(BrainObj('B1'), use_this_cam=True, row=0, col=1)

print("""
=============================================================================
                                    Sources
=============================================================================
""")
s_obj = SourceObj('FirstSources', xyz, data=data)
s_obj.color_sources(data=data, cmap='Spectral_r')
sc.add_to_subplot(s_obj, row=1, col=1, title='Sources')
sc.add_to_subplot(BrainObj('B3'), use_this_cam=True, row=1, col=1)


print("""
# =============================================================================
#                               3D Time-series
# =============================================================================
""")
ts, _ = generate_eeg(n_pts=100, n_channels=xyz.shape[0])
select = np.zeros((xyz.shape[0],), dtype=bool)
select[slice(0, 100, 10)] = True
ts_obj = TimeSeries3DObj('TS3D', ts, xyz, select=select, color='pink',
                         ts_amp=24.)
sc.add_to_subplot(ts_obj, row=0, col=2, title='3D time series')
예제 #20
0
###############################################################################
# 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')
#
#         brod_aal = RoiObj('aal')
#
예제 #21
0
orange
"""
mask = np.logical_and(xyz[:, 0] >= -20., xyz[:, 0] <= 20.)
data = np.random.rand(n_sources)
s_obj_mask = SourceObj('S3', xyz, mask=mask, mask_color='orange',
                       color='slateblue', data=data, radius_min=2.,
                       radius_max=20.)
sc.add_to_subplot(s_obj_mask, row=0, col=2,
                  title='Mask sources between [-20., 20.]')

"""Analyse where sources are located using the Brodmann ROI template and color
sources according to the Brodmann area
"""
s_obj_ba = SourceObj('S4', xyz)
df_brod = s_obj_ba.analyse_sources(roi_obj='brodmann')
s_obj_ba.color_sources(analysis=df_brod, color_by='brodmann')
sc.add_to_subplot(s_obj_ba, row=1, col=0,
                  title='Color sources according to Brodmann area')

"""Analyse where sources are located using the AAL ROI template and color
only the precentral left (green), right (orange), insula right (blue). Others
ROI are turn into white.
"""
s_obj_aal = SourceObj('S5', xyz)
df_aal = s_obj_aal.analyse_sources(roi_obj='aal')
aal_col = {'Precentral (R)': 'green',
           'Precentral (L)': 'orange',
           'Insula (R)': 'blue'}
s_obj_aal.color_sources(analysis=df_aal, color_by='aal', roi_to_color=aal_col,
                        color_others='white')
sc.add_to_subplot(s_obj_aal, row=1, col=1,