Skip to content

Commit ba0d935

Browse files
committed
Improve resting example colormap and commentary
1 parent cf9ccbe commit ba0d935

File tree

1 file changed

+33
-11
lines changed

1 file changed

+33
-11
lines changed

examples/plot_resting_correlations.py

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
"""
2-
Display Volume Data
3-
===================
2+
Display Resting-State Correlations
3+
==================================
44
5-
PySurfer provides a function to sample a volume-encoded file
6-
to the surface for improved visualization. At the moment, this
7-
uses Freesurfer's mri_vol2surf routine.
5+
In this example, we show how to build up a complex visualization of a
6+
volume-based image showing resting-state correlations across the whole brain
7+
from a seed in the angular gyrus. We'll plot several views of both hemispheres
8+
in a single window and manipulate the colormap to best represent the nature of
9+
the data.
810
911
"""
1012
print __doc__
1113

14+
import os
1215
from surfer import Brain, io
1316

1417
"""Bring up the visualization"""
@@ -17,28 +20,47 @@
1720

1821
"""Project the volume file and return as an array"""
1922
mri_file = "example_data/resting_corr.nii.gz"
20-
reg_file = "example_data/register.dat"
23+
reg_file = os.path.join(os.environ["FREESURFER_HOME"],
24+
"average/mni152.register.dat")
2125
surf_data_lh = io.project_volume_data(mri_file, "lh", reg_file)
2226
surf_data_rh = io.project_volume_data(mri_file, "rh", reg_file)
2327

2428
"""
25-
You can pass this array to the add_overlay method for
26-
a typical activation overlay (with thresholding, etc.)
29+
You can pass this array to the add_overlay method for a typical activation
30+
overlay (with thresholding, etc.).
2731
"""
2832
brain.add_overlay(surf_data_lh, min=.3, max=.7, name="ang_corr_lh", hemi='lh')
2933
brain.add_overlay(surf_data_rh, min=.3, max=.7, name="ang_corr_rh", hemi='rh')
3034

3135
"""
3236
You can also pass it to add_data for more control
33-
over the visualzation. Here we'll plot the whole
37+
over the visualization. Here we'll plot the whole
3438
range of correlations
3539
"""
3640
for overlay in brain.overlays_dict["ang_corr_lh"]:
3741
overlay.remove()
3842
for overlay in brain.overlays_dict["ang_corr_rh"]:
3943
overlay.remove()
40-
brain.add_data(surf_data_lh, -.7, .7, colormap="jet", alpha=.7, hemi='lh')
41-
brain.add_data(surf_data_rh, -.7, .7, colormap="jet", alpha=.7, hemi='rh')
44+
45+
"""
46+
We want to use an appropriate color map for these data: a divergent map that
47+
is centered on 0, which is a meaningful transition-point as it marks the change
48+
from negative correlations to positive correlations.
49+
50+
We'll also plot the map with some transparency so that we can see through to the
51+
underlying anatomy.
52+
"""
53+
brain.add_data(surf_data_lh, -.7, .7, colormap="RdBu", alpha=.75, hemi='lh')
54+
brain.add_data(surf_data_rh, -.7, .7, colormap="RdBu", alpha=.75, hemi='rh')
55+
56+
"""
57+
We'll next flip the colormap so negative correlations are blue and positive
58+
correlations are red, which is better aligned with the conventions in fMRI
59+
visualization.
60+
"""
61+
for hemi in ["lh", "rh"]:
62+
for cbar in brain.data_dict[hemi]["colorbars"]:
63+
cbar.reverse_lut = True
4264

4365
"""
4466
This overlay represents resting-state correlations with a

0 commit comments

Comments
 (0)