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_surf¶
- nilearn.plotting.view_surf(surf_mesh=None, surf_map=None, bg_map=None, hemi='left', threshold=None, cmap='RdBu_r', black_bg=False, vmax=None, vmin=None, bg_on_data=False, darkness=0.7, symmetric_cmap=True, colorbar=True, colorbar_height=0.5, colorbar_fontsize=25, title=None, title_fontsize=25)[source]¶
Insert a surface plot of a surface map into an HTML page.
- Parameters:
- surf_mesh
strorlistof twonumpy.ndarrayor aInMemoryMesh, or aPolyMesh, or None, default=None Surface mesh geometry, can be a file (valid formats are .gii or Freesurfer specific files such as .orig, .pial, .sphere, .white, .inflated) or a list of two Numpy arrays, the first containing the x-y-z coordinates of the mesh vertices, the second containing the indices (into coords) of the mesh faces, or a
InMemoryMeshobject with “coordinates” and “faces” attributes, or aPolyMeshobject, or None. If None is passed, thensurf_mapmust be aSurfaceImageinstance and the mesh from thatSurfaceImageinstance will be used.- surf_map
strornumpy.ndarray, orSurfaceImageor None, default=None Data to be displayed on the surface mesh. Can be a file (valid formats are .gii, .mgz, .nii, .nii.gz, or Freesurfer specific files such as .thickness, .area, .curv, .sulc, .annot, .label) or a Numpy array. If None is passed for
surf_meshthensurf_mapmust be aSurfaceImageinstance and its the mesh will be used for plotting.- bg_map
strorpathlib.Pathornumpy.ndarrayorSurfaceImageor None, default=None Background image to be plotted on the mesh underneath the surf_data in grayscale, most likely a sulcal depth map for realistic shading. If the map contains values outside [0, 1], it will be rescaled such that all values are in [0, 1]. Otherwise, it will not be modified. If a
strorpathlib.Pathis passed, it should be loadable to anumpy.ndarraybyload_surf_data. If anumpy.ndarrayis passed, if should have a shape (n_vertices, ), withn_verticesmatching that of the underlying mesh used for plotting.- hemi{“left”, “right”, “both”}, default=”left”
Hemisphere to display. It is only used if
surf_mapisSurfaceImageand / orsurf_meshisPolyMesh. Otherwise a warning will be displayed.Added in version 0.11.0.
- bg_on_data
bool, default=False If True and a bg_map is specified, the surf_data data is multiplied by the background image, so that e.g. sulcal depth is jointly visible with surf_data. Otherwise, the background image will only be visible where there is no surface data (either because surf_data contains nans or because is was thresholded).
Note
This non-uniformly changes the surf_data values according to e.g the sulcal depth.
- darkness
floatbetween 0 and 1, optional Specifying the darkness of the background image:
1 indicates that the original values of the background are used
- 0.5 indicates that the background values
are reduced by half before being applied.
Default=1.
- threshold
str, number or None, default=None If None, no thresholding. If it is a number only values of amplitude greater than threshold will be shown. If it is a string it must finish with a percent sign, e.g. “25.3%”, and only values of amplitude above the given percentile will be shown.
- cmap
matplotlib.colors.Colormap, orstr, optional The colormap to use. Either a string which is a name of a matplotlib colormap, or a matplotlib colormap object. default=”RdBu_r”
- black_bg
bool, default=False If True, image is plotted on a black background. Otherwise on a white background.
- symmetric_cmap
bool, default=True Make colormap symmetric (ranging from -vmax to vmax). Set it to False if you are plotting a surface atlas.
- vmax
floator None, default=None upper bound for the colorbar. if None, use the absolute max of the brain map.
- vmin
floator 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.
- colorbar
bool, default=True Add a colorbar or not.
- colorbar_height
float, default=0.5 Height of the colorbar, relative to the figure height.
- colorbar_fontsize
int, default=25 Fontsize of the colorbar tick labels.
- title
str, default=None Title for the plot.
- title_fontsize
int, default=25 Fontsize of the title.
- surf_mesh
- Returns:
- SurfaceViewplot of the stat map.
It can be saved as an html page or rendered (transparently) by the Jupyter notebook. Useful methods are :
‘resize’ to resize the plot displayed in a Jupyter notebook
‘save_as_html’ to save the plot to a file
‘open_in_browser’ to save the plot and open it in a web browser.
See also
nilearn.plotting.view_img_on_surfSurface plot from a 3D statistical map.