|
1 | 1 | """
|
2 |
| -Display Volume Data |
3 |
| -=================== |
| 2 | +Display Resting-State Correlations |
| 3 | +================================== |
4 | 4 |
|
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. |
8 | 10 |
|
9 | 11 | """
|
10 | 12 | print __doc__
|
11 | 13 |
|
| 14 | +import os |
12 | 15 | from surfer import Brain, io
|
13 | 16 |
|
14 | 17 | """Bring up the visualization"""
|
|
17 | 20 |
|
18 | 21 | """Project the volume file and return as an array"""
|
19 | 22 | 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") |
21 | 25 | surf_data_lh = io.project_volume_data(mri_file, "lh", reg_file)
|
22 | 26 | surf_data_rh = io.project_volume_data(mri_file, "rh", reg_file)
|
23 | 27 |
|
24 | 28 | """
|
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.). |
27 | 31 | """
|
28 | 32 | brain.add_overlay(surf_data_lh, min=.3, max=.7, name="ang_corr_lh", hemi='lh')
|
29 | 33 | brain.add_overlay(surf_data_rh, min=.3, max=.7, name="ang_corr_rh", hemi='rh')
|
30 | 34 |
|
31 | 35 | """
|
32 | 36 | 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 |
34 | 38 | range of correlations
|
35 | 39 | """
|
36 | 40 | for overlay in brain.overlays_dict["ang_corr_lh"]:
|
37 | 41 | overlay.remove()
|
38 | 42 | for overlay in brain.overlays_dict["ang_corr_rh"]:
|
39 | 43 | 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 |
42 | 64 |
|
43 | 65 | """
|
44 | 66 | This overlay represents resting-state correlations with a
|
|
0 commit comments