Skip to content

Commit 6482f49

Browse files
committed
Test visualization example
1 parent 9f13f5e commit 6482f49

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

nipy/labs/tests/test_viz.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
""" Tests for visualization
2+
"""
3+
4+
import numpy as np
5+
6+
from nipy.labs.viz import plot_map, mni_sform, coord_transform
7+
8+
9+
def test_example():
10+
# Example from tutorial.
11+
# First, create a fake activation map: a 3D image in MNI space with
12+
# a large rectangle of activation around Broca Area
13+
mni_sform_inv = np.linalg.inv(mni_sform)
14+
# Color an asymmetric rectangle around Broca area:
15+
x, y, z = -52, 10, 22
16+
x_map, y_map, z_map = [int(coord) for coord in coord_transform(x, y, z,
17+
mni_sform_inv)]
18+
map = np.zeros((182, 218, 182))
19+
map[x_map-30:x_map+30, y_map-3:y_map+3, z_map-10:z_map+10] = 1
20+
21+
# We use a masked array to add transparency to the parts that we are
22+
# not interested in:
23+
thresholded_map = np.ma.masked_less(map, 0.5)
24+
25+
# And now, visualize it:
26+
plot_map(thresholded_map, mni_sform, cut_coords=(x, y, z), vmin=0.5)

0 commit comments

Comments
 (0)