plot_probabilistic_label.py 1.58 KB
Newer Older
1
"""
2
============================
3 4 5 6 7 8 9 10 11 12 13
Display Probabilistic Labels
============================

Freesurfer ships with some probabilistic labels of cytoarchitectonic
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
14 15
from surfer import Brain
from nibabel.freesurfer import read_label
16

Eric89GXL's avatar
Eric89GXL committed
17 18
print(__doc__)

19 20 21 22 23 24 25
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)
26 27

"""
28 29
The easiest way to label any vertex that could be in the region is with
add_label.
30
"""
31
brain.add_label("BA1", color="#A6BDDB")
32 33

"""
34 35
You can also threshold based on the probability of that region being at each
vertex.
36
"""
37
brain.add_label("BA1", color="#2B8CBE", scalar_thresh=.5)
38 39

"""
40 41 42
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.
43
"""
44
brain.add_label("BA45", color="#F0F8FF", borders=3, scalar_thresh=.5)
45
brain.add_label("BA45", color="#F0F8FF", alpha=.3, scalar_thresh=.5)
46 47 48 49

"""
Finally, with a few tricks, you can display the whole probabilistic map.
"""
50 51 52
subjects_dir = environ["SUBJECTS_DIR"]
label_file = join(subjects_dir, "fsaverage", "label", "lh.BA6.label")

53
prob_field = np.zeros_like(brain._geo.x)
54
ids, probs = read_label(label_file, read_scalars=True)
55
prob_field[ids] = probs
56
brain.add_data(prob_field, thresh=1e-5, colormap="RdPu")