def img2disc(data, foci_all=False, foci_dmn=False, labelfile=False, hemi='lh', filename='temp.png'):
     brain = Brain('fsaverage5', hemi, 'inflated', curv=False)
     brain.add_data(data, data.min(), data.max(), colormap="spectral", alpha=0.6)
     if labelfile:
         brain.add_label(labelfile, borders=True, color='grey')
     if foci_all:
         brain.add_foci(foci_all, coords_as_verts=True, scale_factor=.5, color='black')
     if foci_dmn:
         brain.add_foci(foci_dmn, coords_as_verts=True, scale_factor=.7, color='blue')
     brain.save_montage(filename, order=['lat', 'med'], orientation='h', border_size=10)
def make_pysurfer_images_lh_rh(folder,suffix='cope1',hemi='lh',threshold=0.9499,coords=(),surface='inflated',fwhm=0,filename='',saveFolder=[],vmax=5.0,bsize=5):
    from surfer import Brain, io
    TFCEposImg,posImg,TFCEnegImg,negImg=getFileNamesfromFolder(folder,suffix)

    pos=image.math_img("np.multiply(img1,img2)",
                         img1=image.threshold_img(TFCEposImg,threshold=threshold),img2=posImg)
    neg=image.math_img("np.multiply(img1,img2)",
                         img1=image.threshold_img(TFCEnegImg,threshold=threshold),img2=negImg)
    fw=image.math_img("img1-img2",img1=pos,img2=neg)

    if fwhm==0:
        smin=np.min(np.abs(fw.get_data()[fw.get_data()!=0]))
    else:
        smin=2

    mri_file = "%s/thresholded_posneg.nii.gz" % folder
    fw.to_filename(mri_file)

    """Bring up the visualization"""
    brain = Brain("fsaverage",hemi,surface, offscreen=True , background="white")

    """Project the volume file and return as an array"""

    reg_file = os.path.join("/opt/freesurfer","average/mni152.register.dat")
    surf_data = io.project_volume_data(mri_file, hemi, reg_file,smooth_fwhm=fwhm)
    #  surf_data_rh = io.project_volume_data(mri_file, "rh", reg_file,smooth_fwhm=fwhm)


    """
    You can pass this array to the add_overlay method for a typical activation
    overlay (with thresholding, etc.).
    """
    brain.add_overlay(surf_data, min=smin, max=vmax, name="activation", hemi=hemi)
    # brain.overlays["activation"]
    # brain.add_overlay(surf_data_rh, min=smin, max=5, name="ang_corr_rh", hemi='rh')

    if len(coords)>0:
        if coords[0]>0:
            hemi2='rh'
        else:
            hemi2='lh'
        brain.add_foci(coords, map_surface="pial", color="gold",hemi=hemi2)

    if len(saveFolder)>0:
        folder=saveFolder
        image_out=brain.save_montage('%s/%s-%s.png' % (folder,hemi,filename),order=['l','m'],orientation='h',border_size=bsize,colorbar=None)

    else:
        image_out=brain.save_image('%s/surfaceplot.jpg' % folder)
    brain.close()
    return image_out
def plot_data_surf_bh(in_file, colormap='jet', thr_list=[(None, None, None)],roi_coords=(), fwhm=0):
    '''
    allows more flexible visualization than plot_rs_surf_bh
    thr_list = [(min, max, thresh)]
    colormap: matplotlib colormap (http://matplotlib.org/examples/color/colormaps_reference.html)
    '''

    # in_file .nii to be projected on surface


    import os
    from surfer import Brain, io

    out_file_list = []
    in_file_name = os.path.basename(in_file)

    reg_file = os.path.join(os.environ["FREESURFER_HOME"],"average/mni152.register.dat")
    for thr in thr_list:
        min_thr = thr[0]
        max_thr = thr[1]
        thr_thr = thr[2]


        brain = Brain("fsaverage", "split", "inflated", views=['lat', 'med'], config_opts=dict(background="white"))

        surf_data_lh = io.project_volume_data(in_file, "lh", reg_file, smooth_fwhm=fwhm)
        surf_data_rh = io.project_volume_data(in_file, "rh", reg_file, smooth_fwhm=fwhm)

        brain.add_data(surf_data_lh, min=min_thr, max=max_thr, thresh=thr_thr, colormap=colormap, hemi='lh')
        brain.add_data(surf_data_rh, min=min_thr, max=max_thr, thresh=thr_thr, colormap=colormap, hemi='rh')

        roi_str = ''
        if not(roi_coords == ()):
            if roi_coords[0] <0: #lh
                hemi_str = 'lh'
            else:
                hemi_str = 'rh'
            roi_str = '_roi_%s.%s.%s' % roi_coords

            brain.add_foci(roi_coords, map_surface="white", hemi=hemi_str, color='red', scale_factor=2)


        out_filename = os.path.join(os.getcwd(), in_file_name + roi_str + '_thr_%s' % min_thr + '.png')
        out_file_list += [out_filename]
        brain.save_image(out_filename)
        brain.close()
    return out_file_list
Beispiel #4
0
def test_foci():
    """Test plotting of foci."""
    mlab.options.backend = 'test'
    brain = Brain(*std_args)
    coords = [[-36, 18, -3],
              [-43, 25, 24],
              [-48, 26, -2]]
    brain.add_foci(coords, map_surface="white", color="gold")

    annot_path = pjoin(subj_dir, subject_id, 'label', 'lh.aparc.a2009s.annot')
    ids, ctab, names = nib.freesurfer.read_annot(annot_path)
    verts = np.arange(0, len(ids))
    coords = np.random.permutation(verts[ids == 74])[:10]
    scale_factor = 0.7
    brain.add_foci(coords, coords_as_verts=True,
                   scale_factor=scale_factor, color="#A52A2A")
    brain.close()
def plot_rs_surf(in_file, thr_list=[(.2,1)],roi_coords=(), fwhm=0):
    # in_file .nii to be projected on surface
    # list of tuples defining min and max thr_list=[(.2,1)]
    import os
    import subprocess
    from surfer import Brain, io

    arch = subprocess.check_output('arch')
    if arch.startswith('x86_'): # set offscrene rendering to avoid intereference on linux
        from mayavi import mlab
        mlab.options.offscreen = True

    out_file_list = []
    in_file_name = os.path.basename(in_file)

    reg_file = os.path.join(os.environ["FREESURFER_HOME"],"average/mni152.register.dat")
    for thr in thr_list:
        min_thr = thr[0]
        max_thr = thr[1]
        print(min_thr)
        print(max_thr)

        for hemi in ['lh', 'rh']:
            brain = Brain("fsaverage", hemi, "inflated", views=['lat', 'med'], config_opts=dict(background="white"))

            surf_data = io.project_volume_data(in_file, hemi, reg_file, smooth_fwhm=fwhm)

            brain.add_overlay(surf_data, min=min_thr, max=max_thr, name="ang_corr", hemi=hemi)

            roi_str = ''
            if not(roi_coords == ()):
                if roi_coords[0] <0: #lh
                    hemi_str = 'lh'
                else:
                    hemi_str = 'rh'
                roi_str = '_roi_%s.%s.%s' % roi_coords

                if hemi_str == hemi:
                    brain.add_foci(roi_coords, map_surface="white", hemi=hemi_str, color='red', scale_factor=2)


            out_filename = os.path.join(os.getcwd(), in_file_name + roi_str + '_thr_%s' % min_thr + '_' + hemi + '.png')
            out_file_list += [out_filename]
            brain.save_image(out_filename)
            brain.close()
    return out_file_list
def plot_rs_surf_bh(in_file, thr_list=[(.2,1)],roi_coords=(), fwhm=0):
    # in_file .nii to be projected on surface
    # list of tuples defining min and max thr_list=[(.2,1)]
    import os
    from surfer import Brain, io

    out_file_list = []
    in_file_name = os.path.basename(in_file)

    reg_file = os.path.join(os.environ["FREESURFER_HOME"],"average/mni152.register.dat")
    for thr in thr_list:
        min_thr = thr[0]
        max_thr = thr[1]
        print(min_thr)
        print(max_thr)

        brain = Brain("fsaverage", "split", "inflated", views=['lat', 'med'], config_opts=dict(background="white"))

        surf_data_lh = io.project_volume_data(in_file, "lh", reg_file, smooth_fwhm=fwhm)
        surf_data_rh = io.project_volume_data(in_file, "rh", reg_file, smooth_fwhm=fwhm)

        brain.add_overlay(surf_data_lh, min=min_thr, max=max_thr, name="ang_corr_lh", hemi='lh')
        brain.add_overlay(surf_data_rh, min=min_thr, max=max_thr, name="ang_corr_rh", hemi='rh')

        roi_str = ''
        if not(roi_coords == ()):
            if roi_coords[0] <0: #lh
                hemi_str = 'lh'
            else:
                hemi_str = 'rh'
            roi_str = '_roi_%s.%s.%s' % roi_coords

            brain.add_foci(roi_coords, map_surface="white", hemi=hemi_str, color='red', scale_factor=2)


        out_filename = os.path.join(os.getcwd(), in_file_name + roi_str + '_thr_%s' % min_thr + '.png')
        out_file_list += [out_filename]
        brain.save_image(out_filename)
        brain.close()
    return out_file_list
Beispiel #7
0
def test_foci():
    """Test plotting of foci."""
    _set_backend('test')
    brain = Brain(*std_args)
    coords = [[-36, 18, -3],
              [-43, 25, 24],
              [-48, 26, -2]]
    brain.add_foci(coords, map_surface="white", color="gold", name='test1')

    subj_dir = utils._get_subjects_dir()
    annot_path = pjoin(subj_dir, subject_id, 'label', 'lh.aparc.a2009s.annot')
    ids, ctab, names = nib.freesurfer.read_annot(annot_path)
    verts = np.arange(0, len(ids))
    coords = np.random.permutation(verts[ids == 74])[:10]
    scale_factor = 0.7
    brain.add_foci(coords, coords_as_verts=True, scale_factor=scale_factor,
                   color="#A52A2A", name='test2')
    with pytest.raises(ValueError):
        brain.remove_foci(['test4'])
    brain.remove_foci('test1')
    brain.remove_foci()
    assert len(brain.foci_dict) == 0
    brain.close()
Beispiel #8
0
coordinate system. These might be peak activations from
a volume based analysis.
"""
coord = [-43, 25, 24]

utils.coord_to_label(subject_id, coord, label='coord', hemi='lh', n_steps=50,
                     map_surface="white")
brain.add_label('coord-lh.label')

"""
Now we plot the foci on the inflated surface. We will map
the foci onto the surface by finding the vertex on the "white"
mesh that is closest to the coordinate of the point we want
to display.
"""
brain.add_foci([coord], map_surface="white", color="gold")

"""
or using a vertex index
"""
coord = 0

utils.coord_to_label(subject_id, coord, label='coord', hemi='lh', n_steps=50,
                     map_surface="white", coord_as_vert=True)
brain.add_label('coord-lh.label', color='blue')

"""
Now we plot the foci on the inflated surface. We will map
the foci onto the surface by finding the vertex on the "white"
mesh that is closest to the coordinate of the point we want
to display.
print(__doc__)

subject_id = "fsaverage"
subjects_dir = os.environ["SUBJECTS_DIR"]

"""To render a transparent brain, we are specifying an alpha <
1.0. This allows us to visualize foci that are not on the cortical
surface. When the brain see-through, rendering of binary curvature is
distracting, so we specify a color, rather than a color map as the
argument for cortex:

"""
brain = Brain(subject_id, "lh", "pial", cortex='ivory', alpha=0.5)

"""Here's a set of stereotaxic foci in the MNI coordinate system that
are not on the cortical surface which we want to display.

"""

coords = [[-20, 10, 10],
          [-25, 22, 15],
          [-18, 8, 20]]

"""Now we plot the foci in the brain. Because the foci are not on the
cortical surface, they are only visible when alpha is set to < 1.0 in
the call to Brain.

"""
brain.add_foci(coords, color="red")
Beispiel #10
0
              views=['lat', 'med'],
              config_opts=dict(background="white"))
"""Project the volume file and return as an array"""
mri_file = "example_data/resting_corr.nii.gz"
reg_file = "example_data/register.dat"
surf_data_lh = io.project_volume_data(mri_file, "lh", reg_file)
surf_data_rh = io.project_volume_data(mri_file, "rh", reg_file)
"""
You can pass this array to the add_overlay method for
a typical activation overlay (with thresholding, etc.)
"""
brain.add_overlay(surf_data_lh, min=.3, max=.7, name="ang_corr_lh", hemi='lh')
brain.add_overlay(surf_data_rh, min=.3, max=.7, name="ang_corr_rh", hemi='rh')
"""
You can also pass it to add_data for more control
over the visualzation. Here we'll plot the whole
range of correlations
"""
for overlay in brain.overlays_dict["ang_corr_lh"]:
    overlay.remove()
for overlay in brain.overlays_dict["ang_corr_rh"]:
    overlay.remove()
brain.add_data(surf_data_lh, -.7, .7, colormap="jet", alpha=.7, hemi='lh')
brain.add_data(surf_data_rh, -.7, .7, colormap="jet", alpha=.7, hemi='rh')
"""
This overlay represents resting-state correlations with a
seed in left angular gyrus. Let's plot that seed.
"""
seed_coords = (-45, -67, 36)
brain.add_foci(seed_coords, map_surface="white", hemi='lh')
Beispiel #11
0
BidsIeegRootDir = '/Users/davidgroppe/Desktop/HandMotor/'
hemi = 'lh'

# Pysurfer/Freesurfer parameters
subject_id = 'sub-' + sub
subjects_dir = os.path.join(BidsIeegRootDir, 'derivatives', 'iELVis')
surf = 'pial'

# Import electrode info
inFname = os.path.join(BidsIeegRootDir, subject_id, 'ieeg',
                       subject_id + '_ses-01_space-pial_electrodes.tsv')
xyzDf = pd.read_csv(inFname, sep='\t')
nElec = xyzDf.shape[0]
xyz = np.zeros((nElec, 3))
# You need to subtract 1 from each coordinate to account for differences in Python and Matlab coordinates
# (since electrode coordinates were derived in Matlab)
for c in range(nElec):
    xyz[c, 0] = xyzDf['x'][c] - 1
    xyz[c, 1] = xyzDf['y'][c] - 1
    xyz[c, 2] = xyzDf['z'][c] - 1
"""
Call the Brain object constructor with these
parameters to initialize the visualization session.
"""
brain = Brain(subject_id, hemi, surf, subjects_dir=subjects_dir)

# Add electrodes
brain.add_foci(xyz, map_surface="white", color="gold", scale_factor=0.5)

input("Press Enter to continue...")
Beispiel #12
0
def plot_mixn(sub, mne_evoked_time, parcellation):
    trans = sub.load_transformation()
    dipole_dict = sub.load_mixn_dipoles()
    for trial in dipole_dict:
        dipoles = dipole_dict[trial]
        # Plot Dipole Amplitues (derived from Source Code with added legend)
        colors = plt.cm.get_cmap(name='hsv', lut=len(dipoles) + 1)
        fig1, ax = plt.subplots(1, 1)
        xlim = [np.inf, -np.inf]
        for i, dip in enumerate(dipoles):
            ax.plot(dip.times,
                    dip.amplitude * 1e9,
                    color=colors(i),
                    linewidth=1.5,
                    label=f'dipole {i + 1}')
            xlim[0] = min(xlim[0], dip.times[0])
            xlim[1] = max(xlim[1], dip.times[-1])
        ax.set(xlim=xlim, xlabel='Time (s)', ylabel='Amplitude (nAm)')
        ax.legend()
        fig1.suptitle(f'Dipoles Amplitudes', fontsize=16)
        fig1.show(warn=False)

        plot_save(sub,
                  'mixed-norm-estimate',
                  subfolder='dipoles',
                  trial=trial,
                  matplotlib_figure=fig1)

        for idx, dipole in enumerate(dipoles):
            # Assumption right in Head Coordinates?
            if dipole.pos[0, 0] < 0:
                side = 'left'
                hemi = 'lh'
            else:
                side = 'right'
                hemi = 'rh'
            fig2 = mne.viz.plot_dipole_locations(dipole,
                                                 trans=trans,
                                                 subject=sub.subtomri,
                                                 subjects_dir=sub.subjects_dir,
                                                 coord_frame='mri')
            fig2.suptitle(f'Dipole {idx + 1} {side}', fontsize=16)

            plot_save(sub,
                      'mixed-norm-estimate',
                      subfolder='dipoles',
                      trial=trial,
                      idx=idx,
                      matplotlib_figure=fig2)

            brain = Brain(sub.subtomri, hemi=hemi, surf='pial', views='lat')
            dip_loc = mne.head_to_mri(dipole.pos,
                                      sub.subtomri,
                                      trans,
                                      subjects_dir=sub.subjects_dir)
            brain.add_foci(dip_loc[0])
            brain.add_annotation(parcellation)
            # Todo: Comparision with label
            plot_save(sub,
                      'mixed-norm-estimate',
                      subfolder='dipoles',
                      trial=trial,
                      idx=idx,
                      brain=brain)

    stcs = sub.load_mixn_source_estimates()
    brain_plot(sub, stcs, 'mixed-norm-estimate/stc', sub.subtomri,
               mne_evoked_time)
Beispiel #13
0
    #                                 norm=norm, orientation='horizontal')
    # cb1.set_label('CS+ - CS- reinstatement')
    # fig.show()


"""
This overlay represents resting-state correlations with a
seed in left angular gyrus. Let's plot that seed.
"""
seed_coords = (-45, -67, 36)
brain.add_foci(seed_coords, map_surface="white", hemi='lh')


'''
a priori rois for paper
'''
mri_file = f'{HOME}/Desktop/standard/vmPFC_mask.nii.gz'
surf_data_lh = project_volume_data(mri_file, "lh", reg_file, projarg=[0, 1, .5], smooth_fwhm=1)
surf_data_rh = project_volume_data(mri_file, "rh", reg_file, projarg=[0, 1, .5], smooth_fwhm=1)
minval = np.min([np.min(surf_data_lh[np.nonzero(surf_data_lh)]),np.min(surf_data_rh[np.nonzero(surf_data_rh)])])
    
for view in ['med','lat']:
    brain = Brain('fsaverage', 'split', surf, cortex='low_contrast',size=(400,400),
                    views=view, background='white', foreground=None)
    
    brain.add_data(surf_data_lh, 0, .5, center=None, hemi='lh', thresh=minval, colorbar=False, colormap=cmap)
    brain.add_data(surf_data_rh, 0, .5, center=None, hemi='rh',thresh=minval, colorbar=False, colormap=cmap)
        
    dACC_coords = (1, 21, 27)
    brain.add_foci(dACC_coords, map_surface='pial', hemi='rh',color='orange')
Beispiel #14
0
coord = [-43, 25, 24]

"""
Next we grow a label along the surface around the neareset vertex to this
coordinate in the white surface mesh. The `n_steps` argument controls the size
of the resulting label.
"""
utils.coord_to_label(subject_id, coord, label='example_data/coord',
                     hemi='lh', n_steps=25, map_surface="white")
brain.add_label('example_data/coord-lh.label', color="darkseagreen", alpha=.8)

"""
Now we plot the focus on the inflated surface at the vertex identified in the
previous step.
"""
brain.add_foci([coord], map_surface="white", color="mediumseagreen")

"""
We can also do this using a vertex index, perhaps defined as the peak
activation in a surface analysis. This will be more accurate than using a
volume-based focus.
"""
coord = 0

utils.coord_to_label(subject_id, coord, label='example_data/coord',
                     hemi='lh', n_steps=40, map_surface="white",
                     coord_as_vert=True)
brain.add_label('example_data/coord-lh.label', color='royalblue', alpha=.8)

"""
Now we plot the foci on the inflated surface. We will map the foci onto the
Beispiel #15
0
          [-48, 26, -2]]

"""
Now we plot the foci on the inflated surface. We will map
the foci onto the surface by finding the vertex on the "white"
mesh that is closest to the coordinate of each point we want
to display.

While this is not a perfect transformation, it can give you
some idea of where peaks from a volume-based analysis would
be located on the surface.

You can use any valid matplotlib color for the foci; the
default is white.
"""
brain.add_foci(coords, map_surface="white", color="gold")

"""
You can also plot foci with a set of surface vertex ids.
For instance, you might want to plot the peak activation
within an ROI for each of your indivdiual subjects over
the group activation map.

Here, we will just demonstrate with a set of randomly
choosen vertices from within the superior temporal sulcus.

First, we load in the Destrieux parcellation annotation file
and find 10 random vertices within the STS.
"""
annot_path = op.join(subjects_dir, subject_id, "label/lh.aparc.a2009s.annot")
ids, ctab, names = nib.freesurfer.read_annot(annot_path)
We want to use an appropriate color map for these data: a divergent map that
is centered on 0, which is a meaningful transition-point as it marks the change
from negative correlations to positive correlations. By providing the 'center'
argument the add_data function automatically chooses a divergent colormap.
"""
brain.add_data(surf_data_lh, 0, .7, center=0, hemi='lh')
brain.add_data(surf_data_rh, 0, .7, center=0, hemi='rh')

"""
You can tune the data display by shifting the colormap around interesting
regions. For example, you can ignore small correlation up to a magnitude of 0.2
and let colors become gradually less transparent from 0.2 to 0.5 by re-scaling
the colormap as follows. For more information see the help string of this
function.
"""
brain.scale_data_colormap(.2, .5, .7, transparent=True, center=0)

"""
You can also set the overall opacity of the displayed data while maintaining
the transparency of the small values.
"""
brain.scale_data_colormap(0, .35, .7, transparent=True, center=0,
                          alpha=0.75)

"""
This overlay represents resting-state correlations with a
seed in left angular gyrus. Let's plot that seed.
"""
seed_coords = (-45, -67, 36)
brain.add_foci(seed_coords, map_surface="white", hemi='lh')
Beispiel #17
0
brain = Brain(subject_id, "rh", "inflated", cortex='high_contrast')
"""
Now we plot the foci on the inflated surface. We will map
the foci onto the surface by finding the vertex on the "white"
mesh that is closest to the coordinate of each point we want
to display.

While this is not a perfect transformation, it can give you
some idea of where peaks from a volume-based analysis would
be located on the surface.

You can use any valid matplotlib color for the foci; the
default is white.
"""
# plot A1
brain.add_foci(vis_mni[0], map_surface="white", color="gold")

# plot A2
brain.add_foci(vis_mni[1], map_surface="white", color="green")

# plot IT
brain.add_foci(vis_mni[2], map_surface="white", color="blue")

# plot FS
brain.add_foci(vis_mni[3], map_surface="white", color="orange")

# plot D1
brain.add_foci(vis_mni[4], map_surface="white", color="red")

# plot D2
brain.add_foci(vis_mni[5], map_surface="white", color="pink")
Beispiel #18
0
"""Bring up the visualization"""
brain = Brain("fsaverage", "lh", "inflated",
              config_opts=dict(background="white"))

"""Project the volume file and return as an array"""
mri_file = "auto_examples/data/resting_corr.nii.gz"
reg_file = "auto_examples/data/register.dat"
surf_data = io.project_volume_data(mri_file, "lh", reg_file)

"""
You can pass this array to the add_overlay method for
a typical activation overlay (with thresholding, etc.)
"""
brain.add_overlay(surf_data, min=.3, max=.7, name="ang_corr")

"""
You can also pass it to add_data for more control
over the visualzation. Here we'll plot the whole
range of correlations
"""
brain.overlays["ang_corr"].remove()
brain.add_data(surf_data, -.7, .7, colormap="jet", alpha=.7)

"""
This overlay represents resting-state correlations with a
seed in left angular gyrus. Let's plot that seed.
"""
seed_coords = (-45, -67, 36)
brain.add_foci(seed_coords, map_surface="white")
'''

import mne
from mne.datasets import sample

data_path = sample.data_path()
subjects_dir = data_path + '/subjects'

tris, vert, dist = {}, {}, {}
hemi = 0  # lh

# read the surface
vert[hemi], tris[hemi] = mne.read_surface(subjects_dir + '/fsaverage/surf/lh.inflated')

# obtain distance matrix
dist[hemi] = mne.label.mesh_dist(tris[hemi], vert[hemi])

# choose seed vertex as 20 and plot vertices within 5mm radius around it
# obtain neighbouring vertices within 5mm distance
my_verts, my_dist = mne.label._verts_within_dist(dist[hemi], [20], 5)

# number of vertices in a given radius
print len(my_verts)

from surfer import Brain
brain = Brain('fsaverage', hemi='lh', surf='inflated',
              subjects_dir='/Users/psripad/sciebo/resting_state_analysis/')

for myv in my_verts:
    brain.add_foci(myv, coords_as_verts=True, color='b', scale_factor=0.1)
Beispiel #20
0
          [-48, 26, -2]]

"""
Now we plot the foci on the inflated surface. We will map
the foci onto the surface by finding the vertex on the "white"
mesh that is closest to the coordinate of each point we want
to display.

While this is not a perfect transformation, it can give you
some idea of where peaks from a volume-based analysis would
be located on the surface.

You can use any valid matplotlib color for the foci; the
default is white.
"""
brain.add_foci(coords, map_surface="white", color="gold")

"""
You can also plot foci with a set of surface vertex ids.
For instance, you might want to plot the peak activation
within an ROI for each of your indivdiual subjects over
the group activation map.

Here, we will just demonstrate with a set of randomly
choosen vertices from within the superior temporal sulcus.

First, we load in the Destrieux parcellation annotation file
and find 10 random vertices within the STS.
"""
annot_path = op.join(subjects_dir, subject_id, "label/lh.aparc.a2009s.annot")
ids, ctab, names = io.read_annot(annot_path)
Beispiel #21
0
coord = [-43, 25, 24]

utils.coord_to_label(subject_id,
                     coord,
                     label='coord',
                     hemi='lh',
                     n_steps=50,
                     map_surface="white")
brain.add_label('coord-lh.label')
"""
Now we plot the foci on the inflated surface. We will map
the foci onto the surface by finding the vertex on the "white"
mesh that is closest to the coordinate of the point we want
to display.
"""
brain.add_foci([coord], map_surface="white", color="gold")
"""
or using a vertex index
"""
coord = 0

utils.coord_to_label(subject_id,
                     coord,
                     label='coord',
                     hemi='lh',
                     n_steps=50,
                     map_surface="white",
                     coord_as_vert=True)
brain.add_label('coord-lh.label', color='blue')
"""
Now we plot the foci on the inflated surface. We will map
Beispiel #22
0
an rgb triplet where values range from 0 to 1.
(They are white by default.)
"""
rgb = (1, 0.63, 0.49)

"""
Now we plot the foci on the inflated surface. We will map
the foci onto the surface by finding the vertex on the "white"
mesh that is closest to the coordinate of each point we want 
to display.

While this is not a perfect transformation, it can give you
some idea of where peaks from a volume-based analysis would
be located on the surface.
"""
brain.add_foci(coords, map_surface="white", color=rgb)

"""
You can also plot foci with a set of surface vertex ids.
For instance, you might want to plot the peak activation
within an ROI for each of your indivdiual subjects over
the group activation map.

Here, we will just demonstrate with a set of randomly
choosen vertices from within the superior temporal sulcus.

First, we load in the Destrieux parcellation annotation file.
"""
annot_path = op.join(subjects_dir, subject_id, "label/lh.aparc.a2009s.annot")
ids, ctab, names = io.read_annot(annot_path)
Beispiel #23
0
"""
coords = [[-36, 18, -3], [-43, 25, 24], [-48, 26, -2]]
"""
Now we plot the foci on the inflated surface. We will map
the foci onto the surface by finding the vertex on the "white"
mesh that is closest to the coordinate of each point we want
to display.

While this is not a perfect transformation, it can give you
some idea of where peaks from a volume-based analysis would
be located on the surface.

You can use any valid matplotlib color for the foci; the
default is white.
"""
brain.add_foci(coords, map_surface="white", color="gold")
"""
You can also plot foci with a set of surface vertex ids.
For instance, you might want to plot the peak activation
within an ROI for each of your indivdiual subjects over
the group activation map.

Here, we will just demonstrate with a set of randomly
choosen vertices from within the superior temporal sulcus.

First, we load in the Destrieux parcellation annotation file
and find 10 random vertices within the STS.
"""
annot_path = op.join(subjects_dir, subject_id, "label/lh.aparc.a2009s.annot")
ids, ctab, names = nib.freesurfer.read_annot(annot_path)
verts = arange(0, len(ids))