labs.viz_tools.maps_3d

Module: labs.viz_tools.maps_3d

3D visualization of activation maps using Mayavi

Functions

nipy.labs.viz_tools.maps_3d.affine_img_src(data, affine, scale=1, name='AffineImage', reverse_x=False)

Make a Mayavi source defined by a 3D array and an affine, for wich the voxel of the 3D array are mapped by the affine.

Parameters:

data: 3D ndarray

The data arrays

affine: (4 x 4) ndarray

The (4 x 4) affine matrix relating voxels to world coordinates.

scale: float, optional

An optional addition scaling factor.

name: string, optional

The name of the Mayavi source created.

reverse_x: boolean, optional

Reverse the x (lateral) axis. Useful to compared with images in radiologic convention.

Notes

The affine should be diagonal.

nipy.labs.viz_tools.maps_3d.autocrop_img(img, bg_color)
nipy.labs.viz_tools.maps_3d.demo_plot_map_3d()
nipy.labs.viz_tools.maps_3d.m2screenshot(mayavi_fig=None, mpl_axes=None, autocrop=True)

Capture a screeshot of the Mayavi figure and display it in the matplotlib axes.

nipy.labs.viz_tools.maps_3d.plot_anat_3d(anat=None, anat_affine=None, scale=1, sulci_opacity=0.5, gyri_opacity=0.3, opacity=None, skull_percentile=78, wm_percentile=79, outline_color=None)

3D anatomical display

Parameters:

skull_percentile : float, optional

The percentile of the values in the image that delimit the skull from the outside of the brain. The smaller the fraction of you field of view is occupied by the brain, the larger this value should be.

wm_percentile : float, optional

The percentile of the values in the image that delimit the white matter from the grey matter. Typical this is skull_percentile + 1

nipy.labs.viz_tools.maps_3d.plot_map_3d(map, affine, cut_coords=None, anat=None, anat_affine=None, threshold=None, offscreen=False, vmin=None, vmax=None, cmap=None, view=(38.5, 70.5, 300, (-2.7, -12, 9.1)))

Plot a 3D volume rendering view of the activation, with an outline of the brain.

Parameters:

map : 3D ndarray

The activation map, as a 3D image.

affine : 4x4 ndarray

The affine matrix going from image voxel space to MNI space.

cut_coords: 3-tuple of floats, optional

The MNI coordinates of a 3D cursor to indicate a feature or a cut, in MNI coordinates and order.

anat : 3D ndarray, optional

The anatomical image to be used as a background. If None, the MNI152 T1 1mm template is used. If False, no anatomical image is used.

anat_affine : 4x4 ndarray, optional

The affine matrix going from the anatomical image voxel space to MNI space. This parameter is not used when the default anatomical is used, but it is compulsory when using an explicite anatomical image.

threshold : float, optional

The lower threshold of the positive activation. This parameter is used to threshold the activation map.

offscreen: boolean, optional

If True, Mayavi attempts to plot offscreen. Will work only with VTK >= 5.2.

vmin : float, optional

The minimal value, for the colormap

vmax : float, optional

The maximum value, for the colormap

cmap : a callable, or a pylab colormap

A callable returning a (n, 4) array for n values between 0 and 1 for the colors. This can be for instance a pylab colormap.

Notes

If you are using a VTK version below 5.2, there is no way to avoid opening a window during the rendering under Linux. This is necessary to use the graphics card for the rendering. You must maintain this window on top of others and on the screen.