2
Automatic plotting of activation maps
3
=====================================
5
.. currentmodule:: fff2.viz.activation_maps
7
The module :mod:`fff2.viz.activation_maps` provides functions to plot
8
visualization of activation maps in a non-interactive way.
10
2D cuts of an activation map can be plotted and superimposed on an
11
anatomical map using matplotlib_. In addition, Mayavi2_ can be used to
12
plot 3D maps, using volumetric rendering. Some emphasis is made on
13
automatic choice of default parameters, such as cut coordinates, to give
14
a sensible view of a map in a purely automatic way, for instance to save
15
a summary of the output of a calculation.
17
.. _matplotlib: http://matplotlib.sourceforge.net
19
.. _Mayavi2: http://code.enthought.com/projects/mayavi
26
from fff2.viz.activation_maps import plot_map, mni_sform, \
29
# First, create a fake activation map: a 3D image in MNI space with
30
# a large rectangle of activation around Brodmann Area 26
32
mni_sform_inv = np.linalg.inv(mni_sform)
33
map = np.zeros((182, 218, 182))
35
x_map, y_map, z_map = coord_transform(x, y, z, mni_sform_inv)
36
map[x_map-30:x_map+30, y_map-3:y_map+3, z_map-10:z_map+10] = 1
38
# And now, visualize it:
39
plot_map(map, mni_sform, cut_coords=(y, x, z), vmin=0.5)
41
This creates the following image:
43
.. image:: activation_map.png
45
The same plot can be obtained fully automaticaly, by using
46
:func:`auto_plot_map` to find the activation threshold `vmin` and the cut
49
from fff2.viz.activation_maps import auto_plot_map
50
auto_plot_map(map, mni_sform)
52
In this simple example, the code will easily detect the bar as activation
53
and position the cut at the center of the bar.
56
fff2.viz.activation_maps functions
57
-----------------------------------
70
The plot_activation script
71
---------------------------
73
In addition to the above functions, callable from Python, there is also
74
script :program:`plot_activation` that can be used to easily render
75
previews from Nifti files. It can also optionally output an html file, to
76
summarize many maps on one screen.
78
In its simplest use, it is called like this::
80
plot_activation file1.nii file2.nii [...]
82
The :program:`plot_activation` script has several many options:
85
show the help message and exit
87
**-o** *DIR*, **--outdir=DIR**
88
write all output to DIR
90
**-f** *FILE*, **--htmlfile=FILE**
91
write report to a html file FILE, useful when visualizing multiple files
93
**-a** *FILE*, **--anat=FILE**
94
use the given Nifti file as an anatomy
96
**-M** *FILE*, **--mask=FILE**
97
use the given Nifti file as a mask
100
don't try to do a 3D view
103
force activation sign to be positive
105
**-c** *CUT_COORDS*, **--cut-coords=CUT_COORDS**
106
Talairach coordinates of the 2D cuts
108
**-m** *VMIN*, **--vmin=VMIN**
109
Minimum value for the activation, used for thresholding