niworkflows.viz.utils module

Helper tools for visualization purposes.

niworkflows.viz.utils.compose_view(bg_svgs, fg_svgs, ref=0, out_file='report.svg')[source]

Compose the input svgs into one standalone svg with CSS flickering animation.

niworkflows.viz.utils.cuts_from_bbox(mask_nii, cuts=3)[source]

Find equi-spaced cuts for presenting images.

niworkflows.viz.utils.extract_svg(display_object, dpi=300, compress='auto')[source]

Remove the preamble of the svg files generated with nilearn.

niworkflows.viz.utils.plot_melodic_components(melodic_dir, in_file, tr=None, out_file='melodic_reportlet.svg', compress='auto', report_mask=None, noise_components_file=None)[source]

Plots the spatiotemporal components extracted by FSL MELODIC from functional MRI data.

Parameters:
  • melodic_dir (str) – Path pointing to the outputs of MELODIC

  • in_file (str) – Path pointing to the reference fMRI dataset. This file will be used to extract the TR value, if the tr argument is not set. This file will be used to calculate a mask if report_mask is not provided.

  • tr (float) – Repetition time in seconds

  • out_file (str) – Path where the resulting SVG file will be stored

  • compress ('auto' or bool) – Whether SVG should be compressed. If 'auto', compression will be executed if dependencies are installed (SVGO)

  • report_mask (str) – Path to a brain mask corresponding to in_file

  • noise_components_file (str) – A CSV file listing the indexes of components classified as noise by some manual or automated (e.g. ICA-AROMA) procedure. If a noise_components_file is provided, then components will be plotted with red/green colors (correspondingly to whether they are in the file -noise components, red-, or not -signal, green-). When all or none of the components are in the file, a warning is printed at the top.

niworkflows.viz.utils.plot_registration(anat_nii, div_id, plot_params=None, order=('z', 'x', 'y'), cuts=None, estimate_brightness=False, label=None, contour=None, compress='auto', dismiss_affine=False)[source]

Plots the foreground and background views Default order is: axial, coronal, sagittal

niworkflows.viz.utils.plot_segs(image_nii, seg_niis, out_file, bbox_nii=None, masked=False, colors=None, compress='auto', **plot_params)[source]

Generate a static mosaic with ROIs represented by their delimiting contour.

Plot segmentation as contours over the image (e.g. anatomical). seg_niis should be a list of files. mask_nii helps determine the cut coordinates. plot_params will be passed on to nilearn plot_* functions. If seg_niis is a list of size one, it behaves as if it was plotting the mask.

niworkflows.viz.utils.robust_set_limits(data, plot_params, percentiles=(15, 99.8))[source]

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

niworkflows.viz.utils.svg2str(display_object, dpi=300)[source]

Serialize a nilearn display object to string.

niworkflows.viz.utils.svg_compress(image, compress='auto')[source]

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

niworkflows.viz.utils.transform_to_2d(data, max_axis)[source]

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