当前位置: 首页>>代码示例>>Python>>正文


Python Brain.add_foci方法代码示例

本文整理汇总了Python中surfer.Brain.add_foci方法的典型用法代码示例。如果您正苦于以下问题:Python Brain.add_foci方法的具体用法?Python Brain.add_foci怎么用?Python Brain.add_foci使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在surfer.Brain的用法示例。


在下文中一共展示了Brain.add_foci方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: img2disc

# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import add_foci [as 别名]
 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)
开发者ID:soligschlager,项目名称:topography,代码行数:12,代码来源:individual_dist_label.py

示例2: make_pysurfer_images_lh_rh

# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import add_foci [as 别名]
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
开发者ID:jordanmuraskin,项目名称:CCD-scripts,代码行数:53,代码来源:CCD_packages.py

示例3: plot_data_surf_bh

# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import add_foci [as 别名]
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
开发者ID:NeuroanatomyAndConnectivity,项目名称:LeiCA,代码行数:49,代码来源:plot_resting_correlations.py

示例4: plot_rs_surf

# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import add_foci [as 别名]
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
开发者ID:NeuroanatomyAndConnectivity,项目名称:LeiCA,代码行数:48,代码来源:plot_resting_correlations.py

示例5: plot_rs_surf_bh

# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import add_foci [as 别名]
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
开发者ID:NeuroanatomyAndConnectivity,项目名称:LeiCA,代码行数:42,代码来源:plot_resting_correlations.py

示例6: test_foci

# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import add_foci [as 别名]
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()
开发者ID:nipy,项目名称:PySurfer,代码行数:25,代码来源:test_viz.py

示例7:

# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import add_foci [as 别名]
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)
开发者ID:hanke,项目名称:PySurfer,代码行数:32,代码来源:plot_foci.py

示例8:

# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import add_foci [as 别名]
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
开发者ID:Eric89GXL,项目名称:PySurfer,代码行数:33,代码来源:plot_label_foci.py

示例9:

# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import add_foci [as 别名]
          [-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)
开发者ID:FNNDSC,项目名称:PySurfer,代码行数:33,代码来源:plot_foci.py

示例10: Brain

# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import add_foci [as 别名]
"""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")
开发者ID:FNNDSC,项目名称:PySurfer,代码行数:31,代码来源:plot_from_volume.py

示例11:

# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import add_foci [as 别名]
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')
开发者ID:Eric89GXL,项目名称:PySurfer,代码行数:32,代码来源:plot_resting_correlations.py

示例12:

# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import add_foci [as 别名]
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.
开发者ID:akeshavan,项目名称:PySurfer,代码行数:33,代码来源:plot_label_foci.py

示例13: print

# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import add_foci [as 别名]
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")
开发者ID:Eric89GXL,项目名称:PySurfer,代码行数:31,代码来源:plot_transparent_brain.py

示例14: len

# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import add_foci [as 别名]
'''

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)
开发者ID:d-van-de-velden,项目名称:jumeg,代码行数:32,代码来源:plot_vertices_around_seed.py


注:本文中的surfer.Brain.add_foci方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。