Skip to content

Commit 556a9d1

Browse files
committed
Improving aesthetics of the focus label example
1 parent ae183fb commit 556a9d1

File tree

1 file changed

+32
-26
lines changed

1 file changed

+32
-26
lines changed

examples/plot_label_foci.py

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,65 @@
11
"""
2-
============================================
3-
Plot a label generated at an activation foci
4-
============================================
2+
=======================
3+
Generate Surface Labels
4+
=======================
55
6-
Plot a spheroid at a position on the surface manifold
7-
according to an MNI coordinate, generate a label
8-
around it and plot it.
6+
Define a label that is centered on a specific vertex in the surface mesh. Plot
7+
that label and the focus that defines its center.
98
109
"""
1110
print __doc__
1211

13-
import os
1412
from surfer import Brain, utils
1513

1614
subject_id = "fsaverage"
17-
subjects_dir = os.environ["SUBJECTS_DIR"]
1815

1916
"""
2017
Bring up the visualization.
2118
"""
2219
brain = Brain(subject_id, "lh", "inflated")
2320

2421
"""
25-
First we'll get a set of stereotaxic foci in the MNI
26-
coordinate system. These might be peak activations from
27-
a volume based analysis.
22+
First we'll identify a stereotaxic focus in the MNI coordinate system. This
23+
might be a peak activations from a volume based analysis.
2824
"""
2925
coord = [-43, 25, 24]
3026

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

3536
"""
36-
Now we plot the foci on the inflated surface. We will map
37-
the foci onto the surface by finding the vertex on the "white"
38-
mesh that is closest to the coordinate of the point we want
39-
to display.
37+
Now we plot the focus on the inflated surface at the vertex identified in the
38+
previous step.
4039
"""
41-
brain.add_foci([coord], map_surface="white", color="gold")
40+
brain.add_foci([coord], map_surface="white", color="mediumseagreen")
4241

4342
"""
44-
or using a vertex index
43+
We can also do this using a vertex index, perhaps defined as the peak
44+
activation in a surface analysis. This will be more accurate than using a
45+
volume-based focus.
4546
"""
4647
coord = 0
4748

4849
utils.coord_to_label(subject_id, coord, label='example_data/coord',
49-
hemi='lh', n_steps=50, map_surface="white",
50+
hemi='lh', n_steps=40, map_surface="white",
5051
coord_as_vert=True)
51-
brain.add_label('example_data/coord-lh.label', color='blue')
52+
brain.add_label('example_data/coord-lh.label', color='royalblue', alpha=.8)
53+
54+
"""
55+
Now we plot the foci on the inflated surface. We will map the foci onto the
56+
surface by finding the vertex on the "white" mesh that is closest to the
57+
coordinate of the point we want to display.
58+
"""
59+
brain.add_foci([coord], map_surface="white", coords_as_verts=True,
60+
color="mediumblue")
5261

5362
"""
54-
Now we plot the foci on the inflated surface. We will map
55-
the foci onto the surface by finding the vertex on the "white"
56-
mesh that is closest to the coordinate of the point we want
57-
to display.
63+
Set the camera position to show the extent of the labels.
5864
"""
59-
brain.add_foci([coord], map_surface="white", color="red", coords_as_verts=True)
65+
brain.show_view(dict(elevation=40, distance=430))

0 commit comments

Comments
 (0)