API Python

Brainsprite python API.

class brainsprite.viewer_substitute(canvas='3Dviewer', sprite='spriteImg', sprite_overlay='overlayImg', img_colorMap='colorMap', 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', opacity=1, value=True, base64=True)

Templating tool to insert a brainsprite viewer in an HTML document

Parameters
  • canvas (str, optional) – The label for the brainsprite html canvas.

  • sprite (str, optional) – The label for the html sprite background image.

  • sprite_overlay (str, optional) – The label for the html sprite overlay image.

  • img_colorMap (str, optional) – The label for the html colormap image.

  • cut_coords (None, or a tuple of floats, optional) – 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.

  • colorbar (boolean, optional) – If True, display a colorbar on top of the plots.

  • title (string or None, optional) – The title displayed on the figure (or None: no title).

  • threshold (string, number or None, optional) – 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.

  • annotate (boolean, optional) – If annotate is True, current cuts are added to the viewer.

  • draw_cross (boolean, optional) – If draw_cross is True, a cross is drawn on the plot to indicate the cuts.

  • black_bg (boolean, optional) – 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.

  • cmap (matplotlib colormap, optional) – The colormap for specified image.

  • symmetric_cmap (bool, optional) – 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.

  • dim (float 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 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.

  • vmax (float, or None, optional) – 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.

  • vmin (float, or None, optional) – 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_interpolation (string, optional) – The interpolation method for resampling. Can be ‘continuous’, ‘linear’, or ‘nearest’. See nilearn.image.resample_img

  • opacity (float in [0,1], optional) – The level of opacity of the overlay (0: transparent, 1: opaque)

  • value (boolean, optional) – dislay the value of the overlay at the current voxel.

  • base64 (boolean (default True)) – turn on/off embedding of sprites in the html using base64 encoding. If the flag is off, the sprites (and the colorbar) will be saved in files named based on parameters sprite, sprite_overlay and img_colorMap.

Return bsprite

a brainsprite viewer template substitution tool.

fit(stat_map_img, bg_img='MNI152')

Generate sprite and meta-data from a brain volume. Also optionally incorporate a background image.

Parameters
transform(template, javascript, html, library, namespace=None, width=None, height=None)

Apply substitution in a template, using tempita.

Parameters
  • template (tempita template) – a template where brainsprite data needs to be substitued.

  • javascript (str or None) – the tempita name to substitute with brainsprite javascript snippet. If None, javascript is not substitued.

  • html (str or None) – the tempita name to substitute with brainsprite html snippet. If None, html is not substitued.

  • library (str or None) – the tempita name to substitue with the brainsprite js library. If None, library is not substitued.

  • namespace (dict) – a list of names to substitute, using tempita’s substitute method.

  • width – the width of the html report. If None, the width of the report will be the width of the viewer.

  • height (int or None) – the height of the html report. If None, the height of the report will be the height of the viewer.