Note

This page is a reference documentation. It only explains the function signature, and not how to use it. Please refer to the user guide for the big picture.

7.10.22. nilearn.plotting.view_img

nilearn.plotting.view_img(stat_map_img, bg_img='MNI152', cut_coords=None, colorbar=True, title=None, threshold=1e-06, annotate=True, draw_cross=True, black_bg='auto', cmap=<matplotlib.colors.LinearSegmentedColormap object at 0x7f676c650c90>, symmetric_cmap=True, dim='auto', vmax=None, vmin=None, resampling_interpolation='continuous', opacity=1, **kwargs)

Interactive html viewer of a statistical map, with optional background

Parameters
stat_map_imgNiimg-like object

See http://nilearn.github.io/manipulating_images/input_output.html The statistical map image. Can be either a 3D volume or a 4D volume with exactly one time point.

bg_imgNiimg-like object (default=’MNI152’)

See http://nilearn.github.io/manipulating_images/input_output.html The background image that the stat map will be plotted on top of. If nothing is specified, the MNI152 template will be used. To turn off background image, just pass “bg_img=False”.

cut_coordsNone, or a tuple of floats (default None)

The MNI coordinates of the point where the cut is performed as a 3-tuple: (x, y, z). If None is given, the cuts are calculated automaticaly.

colorbarboolean, optional (default True)

If True, display a colorbar on top of the plots.

titlestring or None (default=None)

The title displayed on the figure (or None: no title).

thresholdstring, number or None (default=1e-6)

If None is given, the image is not thresholded. If a string of the form “90%” is given, use the 90-th percentile of the absolute value in the image. If a number is given, it is used to threshold the image: values below the threshold (in absolute value) are plotted as transparent. If auto is given, the threshold is determined automatically.

annotateboolean (default=True)

If annotate is True, current cuts are added to the viewer.

draw_crossboolean (default=True)

If draw_cross is True, a cross is drawn on the plot to indicate the cuts.

black_bgboolean (default=’auto’)

If True, the background of the image is set to be black. Otherwise, a white background is used. If set to auto, an educated guess is made to find if the background is white or black.

cmapmatplotlib colormap, optional

The colormap for specified image.

symmetric_cmapbool, optional (default=True)

True: make colormap symmetric (ranging from -vmax to vmax). False: the colormap will go from the minimum of the volume to vmax. Set it to False if you are plotting a positive volume, e.g. an atlas or an anatomical image.

dimfloat, ‘auto’ (default=’auto’)

Dimming factor applied to background image. By default, automatic heuristics are applied based upon the background image intensity. Accepted float values, where a typical scan is between -2 and 2 (-2 = increase constrast; 2 = decrease contrast), but larger values can be used for a more pronounced effect. 0 means no dimming.

vmaxfloat, or None (default=None)

max value for mapping colors. If vmax is None and symmetric_cmap is True, vmax is the max absolute value of the volume. If vmax is None and symmetric_cmap is False, vmax is the max value of the volume.

vminfloat, or None (default=None)

min value for mapping colors. If symmetric_cmap is True, vmin is always equal to -vmax and cannot be chosen. If symmetric_cmap is False, vmin defaults to the min of the image, or 0 when a threshold is used.

resampling_interpolationstring, optional (default continuous)

The interpolation method for resampling. Can be ‘continuous’, ‘linear’, or ‘nearest’. See nilearn.image.resample_img

opacityfloat in [0,1] (default 1)

The level of opacity of the overlay (0: transparent, 1: opaque)

Returns
html_viewthe html viewer object.

It can be saved as an html page html_view.save_as_html(‘test.html’), or opened in a browser html_view.open_in_browser(). If the output is not requested and the current environment is a Jupyter notebook, the viewer will be inserted in the notebook.

See also

nilearn.plotting.plot_stat_map

static plot of brain volume, on a single or multiple planes.

nilearn.plotting.view_connectome

interactive 3d view of a connectome.

nilearn.plotting.view_markers

interactive plot of colored markers.

nilearn.plotting.view_surf, nilearn.plotting.view_img_on_surf

interactive view of statistical maps or surface atlases on the cortical surface.

7.10.22.1. Examples using nilearn.plotting.view_img