nireports.reportlets.utils module

Helper tools for visualization purposes.

class nireports.reportlets.utils.DisplayObject(*args, **kwargs)[source]

Bases: Protocol

frame_axes: Axes
nireports.reportlets.utils.combine_svg(svg_list: list[str], axis='vertical') SVGFigure[source]

Composes the input svgs into one standalone svg

nireports.reportlets.utils.compose_view(bg_svgs: list[SVGFigure], fg_svgs: list[SVGFigure], ref: int = 0, out_file: str | PathLike[str] = 'report.svg') str[source]

Compose svgs into one standalone svg with CSS flickering animation.

Parameters:
  • bg_svgs (list) – Full paths to input svgs for background.

  • fg_svgs (list) – Full paths to input svgs for foreground.

  • ref (int, optional) – Which panel to use as reference for sizing all panels. Default: 0

  • out_file (str, optional) – Full path to the output file. Default: “report.svg”.

Returns:

out_file

Return type:

same as input

nireports.reportlets.utils.cuts_from_bbox(mask_nii: SpatialImage, cuts: int = 3) dict[str, list[float]][source]

Find equi-spaced cuts for presenting images.

nireports.reportlets.utils.extract_svg(display_object: DisplayObject, dpi: int = 300, compress: bool | Literal['auto'] = 'auto') str[source]

Remove the preamble of the svg files generated with nilearn.

nireports.reportlets.utils.get_parula() LinearSegmentedColormap[source]

Generate a ‘parula’ colormap.

nireports.reportlets.utils.robust_set_limits(data: ndarray[tuple[Any, ...], dtype[_ScalarT]], plot_params: dict[str, Any], percentiles: tuple[float, float] = (15, 99.8)) dict[str, Any][source]

Set (vmax, vmin) based on percentiles of the data.

nireports.reportlets.utils.svg2str(display_object: DisplayObject, dpi: int = 300) str[source]

Serialize a nilearn display object to string.

nireports.reportlets.utils.svg_compress(image: str, compress: bool | Literal['auto'] = 'auto') str[source]

Generate a blob SVG from a matplotlib figure, may perform compression.

nireports.reportlets.utils.transform_to_2d(data: ndarray[tuple[Any, ...], dtype[_ScalarT]], max_axis: int) ndarray[tuple[Any, ...], dtype[_ScalarT]][source]

Projects 3d data cube along one axis using maximum intensity with preservation of the signs. Adapted from nilearn.