本文整理汇总了Python中surfer.Brain.add_label方法的典型用法代码示例。如果您正苦于以下问题:Python Brain.add_label方法的具体用法?Python Brain.add_label怎么用?Python Brain.add_label使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类surfer.Brain
的用法示例。
在下文中一共展示了Brain.add_label方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: drawROI
# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import add_label [as 别名]
def drawROI():
for hemi in ["lh"]:
# load data
roivol = io.project_volume_data(roifile,
hemi,
subject_id=surfsubj,
smooth_fwhm=4.0,
projmeth="dist",
projsum="avg",
projarg=[0,6,0.1],
surf="white")
# create label
roivol = abs(roivol)
roivol[roivol < 0.33] = 0
#if max(roivol) < 1:
# brain.close()
# continue
#else:
write_label(np.asarray(np.nonzero(roivol)),"/gablab/p/bps/zqi_ytang/scripts/roi/surf-IFG.label")
# load brain
my_fig = mlab.figure(figure="new_fig1", size=(800,800))
brain = Brain("fsaverage",hemi,"inflated",curv=True,size=[800,800],background="white",cortex=(("gist_yarg",-1.5,3.5,False)),figure=my_fig)
set_mylights(my_fig,lights[hemi])
#add label
brain.add_label("/gablab/p/bps/zqi_ytang/scripts/roi/surf-IFG.label",borders=False,color="#ffff00",alpha=1)
brain.add_label("/gablab/p/bps/zqi_ytang/scripts/roi/surf-IFG.label",borders=1,color="black",alpha=0.5)
brain.show_view('lat')
brain.save_image("/gablab/p/bps/zqi_ytang/scripts/roi/surf-IFG.tiff")
brain.close()
示例2: img2disc
# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import add_label [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)
示例3: inflated_surfaces
# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import add_label [as 别名]
def inflated_surfaces(out_dir, subj, close=True):
"""Native inflated surfaces with cortical label."""
for hemi in ["lh", "rh"]:
b = Brain(subj, hemi, "inflated", curv=False,
config_opts=dict(background="white",
width=800, height=500))
b.add_label("cortex", color="#6B6B6B")
for view in ["lat", "med"]:
b.show_view(view)
mlab.view(distance=400)
png = op.join(out_dir, "%s.surface_%s.png" % (hemi, view))
b.save_image(png)
if close:
b.close()
示例4: save_groups_labels_figures
# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import add_label [as 别名]
def save_groups_labels_figures():
labels, groups = get_groups()
for group in groups:
print(group)
if len(get_group_labels(group)) < 4:
group_label = [l for l in labels if group in l]
colors = get_spaced_colors(len(group_label))
brain = Brain(subject, hemi, surf, offscreen=False)
for label_id, label in enumerate(group_label):
print(label)
brain.add_label(label, color=colors[label_id])
fol = os.path.join(subjects_dir, subject, 'label', '{}_figures'.format(aparc_name))
if not os.path.isdir(fol):
os.mkdir(fol)
brain.save_imageset(os.path.join(fol, group), get_views(), 'jpg')
brain.remove_labels()
brain.close()
示例5: test_probabilistic_labels
# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import add_label [as 别名]
def test_probabilistic_labels():
"""Test plotting of probabilistic labels."""
_set_backend()
brain = Brain("fsaverage", "lh", "inflated",
cortex="low_contrast")
brain.add_label("BA1", color="darkblue")
brain.add_label("BA1", color="dodgerblue", scalar_thresh=.5)
brain.add_label("BA45", color="firebrick", borders=True)
brain.add_label("BA45", color="salmon", borders=True, scalar_thresh=.5)
subj_dir = utils._get_subjects_dir()
label_file = pjoin(subj_dir, "fsaverage", "label", "lh.BA6.label")
prob_field = np.zeros_like(brain.geo['lh'].x)
ids, probs = nib.freesurfer.read_label(label_file, read_scalars=True)
prob_field[ids] = probs
brain.add_data(prob_field, thresh=1e-5)
with warnings.catch_warnings(record=True):
brain.data["colorbar"].number_of_colors = 10
brain.data["colorbar"].number_of_labels = 11
brain.close()
示例6: any
# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import add_label [as 别名]
b.add_morphometry(args.morphometry)
# Maybe load an overlay
if args.overlay is not None:
if args.range is not None:
args.min, args.max = args.range
b.add_overlay(args.overlay, args.min, args.max, args.sign)
# Maybe load an annot
if args.annotation is not None:
if not args.borders:
args.borders = any([args.overlay, args.morphometry])
b.add_annotation(args.annotation, args.borders)
# Maybe load a label
if args.label is not None:
if not args.borders:
args.borders = any([args.overlay, args.morphometry])
b.add_label(args.label, args.borders)
# Also point brain at the Brain() object
brain = b
# It's nice to have mlab in the namespace, but we'll import it
# after the other stuff so getting usage is not interminable
from enthought.mayavi import mlab
# Now clean up the namespace a bit
del parser, args
示例7: Brain
# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import add_label [as 别名]
to help characterize the location of your data.
"""
from os import environ
from os.path import join
import numpy as np
from surfer import Brain, io
brain = Brain("fsaverage", "lh", "inflated",
config_opts=dict(cortex="low_contrast"))
"""
The easiest way to label any vertex that could be in the region is with
add_label.
"""
brain.add_label("BA1", color="#A6BDDB")
"""
You can also threshold based on the probability of that region being at each
vertex.
"""
brain.add_label("BA1", color="#2B8CBE", scalar_thresh=.5)
"""
It's also possible to plot just the label boundary, in case you wanted to
overlay the label on an activation plot to asses whether it falls within that
region.
"""
brain.add_label("BA45", color="#F0F8FF", borders=True, scalar_thresh=.5)
brain.add_label("BA45", color="#F0F8FF", alpha=.3, scalar_thresh=.5)
示例8:
# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import add_label [as 别名]
units='m')
"""
First we'll identify a stereotaxic focus in the MNI coordinate system. This
might be a peak activations from a volume based analysis.
"""
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',
示例9: perception
# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import add_label [as 别名]
# Author: Jean-Remi King <[email protected]>
#
# Licence: BSD 3-clause
"""Make a plot of the selected region of interest typically associated with
visual perception (i.e. ventral and dorsal stream + PFC)
Used to generate Figure 2.a
"""
import numpy as np
import matplotlib.pyplot as plt
import mne
from surfer import Brain
rois = ['lingual', 'inferiortemporal', 'superiorparietal',
'supramarginal', 'rostralmiddlefrontal', 'precentral']
brain = Brain('fsaverage', 'split', 'inflated', background='w')
labels = mne.read_labels_from_annot('fsaverage', parc='aparc')
cmap = plt.get_cmap('rainbow')
colors = cmap(np.linspace(0., 1., len(rois)))
for roi, color in zip(rois, colors):
for hemi in ['lh', 'rh']:
label = [lbl for lbl in labels if lbl.name == (roi + '-' + hemi)][0]
brain.add_label(label, color=color, alpha=.9, hemi=hemi)
示例10: drawContrast
# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import add_label [as 别名]
def drawContrast(infile,outname):
for hemi in ["rh"]:
# load data
volpos = io.project_volume_data(infile,
hemi,
subject_id=surfsubj,
smooth_fwhm=4.0,
projmeth="dist",
projsum="max",
projarg=[-6,6,0.1],
surf="pial")
"""
volneg = io.project_volume_data(rsfcfile_neg,
hemi,
subject_id=surfsubj,
smooth_fwhm=4.0,
projmeth="dist",
projsum="max",
projarg=[-6,6,0.1],
surf="white")
volneg=volneg*-1
ccvol=volpos+volneg
"""
# load brain
my_fig = mlab.figure(figure="new_fig1", size=(800,800))
brain = Brain("fsaverage",hemi,"inflated",curv=True,size=[800,800],background="white",cortex=(("gist_yarg",-1.5,3.5,False)),figure=my_fig)
set_mylights(my_fig,lights[hemi])
if outname == "fig6b":
# create label
labIFG = volpos
labIFG[labIFG < 2.0739] = 0
write_label(np.asarray(np.nonzero(labIFG)),"fig6prep/roi_IFG.label")
#brain.add_label("fig6prep/roi_IFG.label",borders=False,color="red",alpha=0.125)
brain.add_label("fig6prep/roi_IFG.label",borders=2,color="#e7298a",alpha=1)
if outname == "fig6d":
# create label
labAG = io.project_volume_data("/gablab/p/CASL/Results/Imaging/resting/zqi/conn_CASL_pre_post_training13o/results/secondlevel/ANALYSIS_01/3mohsk_all(0).3mohsk(1)/pre-training(-1).post-training(1)/anat_func_lifg_1_1/roi_AG.nii.gz",
hemi,
subject_id=surfsubj,
smooth_fwhm=4.0,
projmeth="dist",
projsum="max",
projarg=[-6,6,0.1],
surf="pial")
labAG[labAG < 0.33] = 0
write_label(np.asarray(np.nonzero(labAG)),"fig6prep/roi_AG.label")
labSTGMTG = io.project_volume_data("/gablab/p/CASL/Results/Imaging/resting/zqi/conn_CASL_pre_post_training13o/results/secondlevel/ANALYSIS_01/3mohsk_all(0).3mohsk(1)/pre-training(-1).post-training(1)/anat_func_lifg_1_1/roi_STGMTG.nii.gz",
hemi,
subject_id=surfsubj,
smooth_fwhm=4.0,
projmeth="dist",
projsum="max",
projarg=[-6,6,0.1],
surf="pial")
labSTGMTG[labSTGMTG < 0.66] = 0
write_label(np.asarray(np.nonzero(labSTGMTG)),"fig6prep/roi_STGMTG.label")
#brain.add_label("fig6prep/roi_AG.label",borders=False,color="black",alpha=0.125)
brain.add_label("fig6prep/roi_AG.label",borders=2,color="#1b9e77",alpha=1)
#brain.add_label("fig6prep/roi_STGMTG.label",borders=False,color="blue",alpha=0.125)
brain.add_label("fig6prep/roi_STGMTG.label",borders=2,color="#7570b3",alpha=1)
brain.add_overlay(volpos,
min=2.0739, #p = 0.025 2-tailed
max=5.0216, #p = 0.000025, 2-tailed
sign="abs",
name=outname,
hemi=hemi)
brain.show_view('lat')
brain.save_image("fig6prep/%s.tiff"%(outname))
brain.close()
示例11: test_label
# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import add_label [as 别名]
def test_label():
"""Test plotting of label."""
_set_backend()
subject_id = "fsaverage"
hemi = "lh"
surf = "inflated"
brain = Brain(subject_id, hemi, surf)
view = get_view(brain)
extra, subj_dir = _get_extra()
brain.add_label("BA1" + extra)
check_view(brain, view)
brain.add_label("BA1" + extra, color="blue", scalar_thresh=.5)
label_file = pjoin(subj_dir, subject_id,
"label", "%s.MT%s.label" % (hemi, extra))
brain.add_label(label_file)
brain.add_label("BA44" + extra, borders=True)
brain.add_label("BA6" + extra, alpha=.7)
brain.show_view("medial")
brain.add_label("V1" + extra, color="steelblue", alpha=.6)
brain.add_label("V2" + extra, color="#FF6347", alpha=.6)
brain.add_label("entorhinal" + extra, color=(.2, 1, .5), alpha=.6)
brain.set_surf('white')
brain.show_view(dict(elevation=40, distance=430), distance=430)
with pytest.raises(ValueError, match='!='):
brain.show_view(dict(elevation=40, distance=430), distance=431)
# remove labels
brain.remove_labels('V1' + extra)
assert 'V2' + extra in brain.labels_dict
assert 'V1' + extra not in brain.labels_dict
brain.remove_labels()
assert 'V2' + extra not in brain.labels_dict
brain.close()
示例12: test_label
# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import add_label [as 别名]
def test_label():
"""Test plotting of label
"""
mlab.options.backend = 'test'
subject_id = "fsaverage"
hemi = "lh"
surf = "inflated"
brain = Brain(subject_id, hemi, surf)
brain.add_label("BA1")
brain.add_label("BA1", color="blue", scalar_thresh=.5)
label_file = pjoin(subj_dir, subject_id,
"label", "%s.MT.label" % hemi)
brain.add_label(label_file)
brain.add_label("BA44", borders=True)
brain.add_label("BA6", alpha=.7)
brain.show_view("medial")
brain.add_label("V1", color="steelblue", alpha=.6)
brain.add_label("V2", color="#FF6347", alpha=.6)
brain.add_label("entorhinal", color=(.2, 1, .5), alpha=.6)
brain.close()
示例13: print
# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import add_label [as 别名]
print(__doc__)
brain = Brain("fsaverage", "lh", "inflated")
"""
Show the morphometry with a continuous grayscale colormap.
"""
brain.add_morphometry("curv", colormap="binary",
min=-.8, max=.8, colorbar=False)
"""
The easiest way to label any vertex that could be in the region is with
add_label.
"""
brain.add_label("BA1_exvivo", color="#A6BDDB")
"""
You can also threshold based on the probability of that region being at each
vertex.
"""
brain.add_label("BA1_exvivo", color="#2B8CBE", scalar_thresh=.5)
"""
It's also possible to plot just the label boundary, in case you wanted to
overlay the label on an activation plot to asses whether it falls within that
region.
"""
brain.add_label("BA45_exvivo", color="#F0F8FF", borders=3, scalar_thresh=.5)
brain.add_label("BA45_exvivo", color="#F0F8FF", alpha=.3, scalar_thresh=.5)
示例14: Brain
# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import add_label [as 别名]
subject_id = "fsaverage"
hemi = "both"
#surf = "smoothwm"
surf = 'inflated'
brain = Brain(subject_id, hemi, surf)
list_dirs = os.walk(subject_path + '/func_labels/')
color = ['#990033', '#9900CC', '#FF6600', '#FF3333', '#00CC33']
for root, dirs, files in list_dirs:
for f in files:
label_fname = os.path.join(root, f)
label = mne.read_label(label_fname)
#label.values.fill(1.0)
#label_morph = label.morph(subject_from='fsaverage', subject_to=subject, smooth=5,
# n_jobs=1, copy=True)
if label.hemi == 'lh':
brain.add_label(label, color=random.choice(color))
elif label.hemi == 'rh':
brain.add_label(label, color=random.choice(color))
#brain.add_foci(vertno_max, coords_as_verts=True, hemi='lh', color='blue', scale_factor=0.6)
# If the label lives in the normal place in the subjects directory,
# you can plot it by just using the name
#ref_ROI_fname = '/home/qdong/freesurfer/subjects/fsaverage/label/lh.Auditory_82.label'
#ref_label = mne.read_label(ref_ROI_fname)
#brain.add_label(ref_label, color="blue")
#brain.add_label("ROI1", color="blue")
#brain.add_label("ROI2", color="red")
#brain.add_label("ROI3", color="green")
#brain.add_label("ROI4", color="blue")
#brain.add_label("ROI5", color="blue")
#brain.add_label("ROI6", color="blue")
#brain.add_label("ROI7", color="blue")
示例15: Brain
# 需要导入模块: from surfer import Brain [as 别名]
# 或者: from surfer.Brain import add_label [as 别名]
and visual areas. Here we show several ways to visualize these labels
to help characterize the location of your data.
"""
from os import environ
from os.path import join
import numpy as np
from surfer import Brain, io
brain = Brain("fsaverage", "lh", "inflated",
config_opts=dict(cortex="low_contrast"))
"""
The simplest way is to use add_label.
"""
brain.add_label("BA1", color="darkblue")
"""
You can also threshold based on the probability of that
region being at each vertex.
"""
brain.add_label("BA1", color="dodgerblue", scalar_thresh=.5)
"""
It's also possible to plot just the label boundary, in case
you wanted to overlay the label on an activation plot to
asses whether it falls within that region.
"""
brain.add_label("BA45", color="firebrick", borders=True)
brain.add_label("BA45", color="salmon", borders=True, scalar_thresh=.5)