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.

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>, symmetric_cmap=True, dim='auto', vmax=None, vmin=None, resampling_interpolation='continuous', width_view=600, opacity=1)[source]

Interactive html viewer of a statistical map, with optional background.

Parameters:
stat_map_imgNiimg-like object

See Input and output: neuroimaging data representation. The statistical map image. Can be either a 3D volume or a 4D volume with exactly one time point.

bg_imgNiimg-like object, optional

See Input and output: neuroimaging data representation. The background image to plot on top of. If nothing is specified, the MNI152 template will be used. To turn off background image, just pass “bg_img=False”. Default=’MNI152’.

cut_coordsNone, or a tuple of float, 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 automatically.

colorbarbool, default=True

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

titlestr, or None, default=None

The title displayed on the figure.

thresholdstr, number or None, default=1e-06

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.

annotatebool, default=True

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

draw_crossbool, default=True

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

black_bgbool or ‘auto’, 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.colors.Colormap, or str, optional

The colormap to use. Either a string which is a name of a matplotlib colormap, or a matplotlib colormap object. Default=`plt.cm.cold_hot`.

symmetric_cmapbool, 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, or “auto”, optional

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

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 is equal to the min of the image, or 0 when a threshold is used.

resampling_interpolationstr, optional

Interpolation to use when resampling the image to the destination space. Can be:

  • "continuous": use 3rd-order spline interpolation

  • "nearest": use nearest-neighbor mapping.

Note

"nearest" is faster but can be noisier in some cases.

Default=’continuous’.

width_viewint, default=600

Default=600. Width of the viewer in pixels.

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.

Examples using nilearn.plotting.view_img

A introduction tutorial to fMRI decoding

A introduction tutorial to fMRI decoding

Plotting tools in nilearn

Plotting tools in nilearn

Decoding with ANOVA + SVM: face vs house in the Haxby dataset

Decoding with ANOVA + SVM: face vs house in the Haxby dataset