Giving credit

Previous topic

7.10.11. nilearn.plotting.show

Next topic

7.11.1. nilearn.signal.clean

Note

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

7.10.12. nilearn.plotting.displays.OrthoSlicer

class nilearn.plotting.displays.OrthoSlicer(cut_coords, axes=None, black_bg=False, **kwargs)

A class to create 3 linked axes for plotting orthogonal cuts of 3D maps.

Notes

The extent of the different axes are adjusted to fit the data best in the viewing area.

Attributes

axes: dictionnary of axes The 3 axes used to plot each view.
frame_axes: axes The axes framing the whole set of views.
__init__(cut_coords, axes=None, black_bg=False, **kwargs)

Create 3 linked axes for plotting orthogonal cuts.

Parameters:

cut_coords: 3 tuple of ints

The cut position, in world space.

axes: matplotlib axes object, optional

The axes that will be subdivided in 3.

black_bg: boolean, optional

If True, the background of the figure will be put to black. If you wish to save figures with a black background, you will need to pass “facecolor=’k’, edgecolor=’k’” to matplotlib.pyplot.savefig.

add_contours(img, filled=False, **kwargs)

Contour a 3D map in all the views.

Parameters:

img: Niimg-like object

filled: boolean, optional

If filled=True, contours are displayed with color fillings.

kwargs:

Extra keyword arguments are passed to contour, see the documentation of pylab.contour Useful, arguments are typical “levels”, which is a list of values to use for plotting a contour, and “colors”, which is one color or a list of colors for these contours.

add_edges(img, color='r')

Plot the edges of a 3D map in all the views.

Parameters:

img: Niimg-like object

See http://nilearn.github.io/manipulating_images/input_output.html. The 3D map to be plotted. If it is a masked array, only the non-masked part will be plotted.

color: matplotlib color: string or (r, g, b) value

The color used to display the edge map

add_markers(marker_coords, marker_color='r', marker_size=30, **kwargs)

Add markers to the plot.

Parameters:

marker_coords: array of size (n_markers, 3)

Coordinates of the markers to plot. For each slice, only markers that are 2 millimeters away from the slice are plotted.

marker_color: pyplot compatible color or list of shape (n_markers,)

List of colors for each marker that can be string or matplotlib colors

marker_size: single float or list of shape (n_markers,)

Size in pixel for each marker

add_overlay(img, threshold=1e-06, colorbar=False, **kwargs)

Plot a 3D map in all the views.

Parameters:

img: Niimg-like object

See http://nilearn.github.io/manipulating_images/input_output.html. If it is a masked array, only the non-masked part will be plotted.

threshold : a number, None

If None is given, the maps are not thresholded. If a number is given, it is used to threshold the maps: values below the threshold (in absolute value) are plotted as transparent.

colorbar: boolean, optional

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

kwargs:

Extra keyword arguments are passed to imshow.

annotate(left_right=True, positions=True, size=12, **kwargs)

Add annotations to the plot.

Parameters:

left_right: boolean, optional

If left_right is True, annotations indicating which side is left and which side is right are drawn.

positions: boolean, optional

If positions is True, annotations indicating the positions of the cuts are drawn.

size: integer, optional

The size of the text used.

kwargs:

Extra keyword arguments are passed to matplotlib’s text function.

close()

Close the figure. This is necessary to avoid leaking memory.

draw_cross(cut_coords=None, **kwargs)

Draw a crossbar on the plot to show where the cut is performed.

Parameters:

cut_coords: 3-tuple of floats, optional

The position of the cross to draw. If none is passed, the ortho_slicer’s cut coordinates are used.

kwargs:

Extra keyword arguments are passed to axhline

classmethod find_cut_coords(img=None, threshold=None, cut_coords=None)

Instanciate the slicer and find cut coordinates

classmethod init_with_figure(img, threshold=None, cut_coords=None, figure=None, axes=None, black_bg=False, leave_space=False, colorbar=False, **kwargs)

Initialize the slicer with an image

savefig(filename, dpi=None)

Save the figure to a file

Parameters:

filename: string

The file name to save to. It’s extension determines the file type, typically ‘.png’, ‘.svg’ or ‘.pdf’.

dpi: None or scalar

The resolution in dots per inch.

title(text, x=0.01, y=0.99, size=15, color=None, bgcolor=None, alpha=1, **kwargs)

Write a title to the view.

Parameters:

text: string

The text of the title

x: float, optional

The horizontal position of the title on the frame in fraction of the frame width.

y: float, optional

The vertical position of the title on the frame in fraction of the frame height.

size: integer, optional

The size of the title text.

color: matplotlib color specifier, optional

The color of the font of the title.

bgcolor: matplotlib color specifier, optional

The color of the background of the title.

alpha: float, optional

The alpha value for the background.

kwargs:

Extra keyword arguments are passed to matplotlib’s text function.