223.1.6
by Gael Varoquaux
Document the activation map visualization scripts |
1 |
Automatic plotting of activation maps
|
2 |
=====================================
|
|
3 |
||
4 |
.. currentmodule:: fff2.viz.activation_maps |
|
5 |
||
6 |
The module :mod:`fff2.viz.activation_maps` provides functions to plot |
|
7 |
visualization of activation maps in a non-interactive way. |
|
8 |
||
9 |
2D cuts of an activation map can be plotted and superimposed on an |
|
10 |
anatomical map using matplotlib_. In addition, Mayavi2_ can be used to |
|
11 |
plot 3D maps, using volumetric rendering. Some emphasis is made on |
|
12 |
automatic choice of default parameters, such as cut coordinates, to give |
|
13 |
a sensible view of a map in a purely automatic way, for instance to save |
|
14 |
a summary of the output of a calculation. |
|
15 |
||
16 |
.. _matplotlib: http://matplotlib.sourceforge.net |
|
17 |
||
18 |
.. _Mayavi2: http://code.enthought.com/projects/mayavi |
|
19 |
||
20 |
An example
|
|
21 |
-----------
|
|
22 |
||
23 |
::
|
|
24 |
||
25 |
from fff2.viz.activation_maps import plot_map, mni_sform, \
|
|
26 |
coord_transform
|
|
27 |
||
28 |
# First, create a fake activation map: a 3D image in MNI space with
|
|
29 |
# a large rectangle of activation around Brodmann Area 26
|
|
30 |
import numpy as np
|
|
31 |
mni_sform_inv = np.linalg.inv(mni_sform)
|
|
32 |
map = np.zeros((182, 218, 182))
|
|
33 |
x, y, z = -6, -53, 9
|
|
34 |
x_map, y_map, z_map = coord_transform(x, y, z, mni_sform_inv)
|
|
35 |
map[x_map-30:x_map+30, y_map-3:y_map+3, z_map-10:z_map+10] = 1
|
|
36 |
|
|
37 |
# And now, visualize it:
|
|
38 |
plot_map(map, mni_sform, cut_coords=(x, y, z), vmin=0.5)
|
|
223.1.7
by Gael Varoquaux
Correct typo |
39 |
|
223.1.6
by Gael Varoquaux
Document the activation map visualization scripts |
40 |
This creates the following image: |
41 |
||
42 |
.. image:: activation_map.png |
|
43 |
||
44 |
The same plot can be obtained fully automaticaly, by using |
|
45 |
:func:`auto_plot_map` to find the activation threshold `vmin` and the cut |
|
46 |
coordinnates::
|
|
47 |
||
48 |
from fff2.viz.activation_maps import auto_plot_map
|
|
49 |
auto_plot_map(map, mni_sform)
|
|
50 |
||
51 |
In this simple example, the code will easily detect the bar as activation |
|
52 |
and position the cut at the center of the bar. |
|
53 |
||
54 |
||
55 |
fff2.viz.activation_maps functions
|
|
56 |
-----------------------------------
|
|
57 |
||
58 |
.. autosummary:: |
|
59 |
:toctree: generated
|
|
60 |
||
61 |
coord_transform |
|
62 |
find_activation |
|
63 |
find_cut_coords |
|
64 |
plot_map_2d |
|
65 |
plot_map_3d |
|
66 |
auto_plot_map |
|
67 |
plot_niftifile |
|
68 |
||
69 |
The plot_activation script
|
|
70 |
---------------------------
|
|
71 |
||
72 |
In addition to the above functions, callable from Python, there is also |
|
73 |
script :program:`plot_activation` that can be used to easily render |
|
74 |
previews from Nifti files. It can also optionally output an html file, to |
|
75 |
summarize many maps on one screen. |
|
76 |
||
77 |
In its simplest use, it is called like this::
|
|
78 |
||
79 |
plot_activation file1.nii file2.nii [...]
|
|
80 |
||
81 |
The :program:`plot_activation` script has several many options: |
|
82 |
||
83 |
**-h**, **--help** |
|
84 |
show the help message and exit |
|
85 |
||
86 |
**-o** *DIR*, **--outdir=DIR** |
|
87 |
write all output to DIR |
|
88 |
||
89 |
**-f** *FILE*, **--htmlfile=FILE** |
|
90 |
write report to a html file FILE, useful when visualizing multiple files |
|
91 |
||
92 |
**-a** *FILE*, **--anat=FILE** |
|
93 |
use the given Nifti file as an anatomy |
|
94 |
||
95 |
**-M** *FILE*, **--mask=FILE** |
|
96 |
use the given Nifti file as a mask |
|
97 |
||
98 |
**-d**, **--no3d** |
|
99 |
don't try to do a 3D view |
|
100 |
||
101 |
**-s**, **--sign** |
|
102 |
force activation sign to be positive |
|
103 |
||
104 |
**-c** *CUT_COORDS*, **--cut-coords=CUT_COORDS** |
|
105 |
Talairach coordinates of the 2D cuts |
|
106 |
||
107 |
**-m** *VMIN*, **--vmin=VMIN** |
|
108 |
Minimum value for the activation, used for thresholding |
|
109 |
||
110 |
||
111 |