niwidgets.NiftiWidget

class niwidgets.NiftiWidget(filename)[source]

Turn .nii files into interactive plots using ipywidgets.

Parameters:filename (str) – The path to your .nii file. Can be a string, or a PosixPath from python3’s pathlib.

Methods

These are the methods that are added by niwidgets. All methods, including the inherited ones, are at the end of the page.

nifti_plotter([plotting_func, colormap, figsize]) Plot volumetric data.

Methods Details

class niwidgets.NiftiWidget(filename)[source]

Turn .nii files into interactive plots using ipywidgets.

Parameters:filename (str) – The path to your .nii file. Can be a string, or a PosixPath from python3’s pathlib.
nifti_plotter(plotting_func=None, colormap=None, figsize=(15, 5), **kwargs)[source]

Plot volumetric data.

Parameters:
  • plotting_func (function) – A plotting function for .nii files, most likely
  • mask_background (bool) – Whether the background should be masked (set to NA). This parameter only works in conjunction with the default plotting function (plotting_func=None). It finds clusters of values that round to zero and somewhere touch the edges of the image. These are set to NA. If you think you are missing data in your image, set this False.
  • colormap (str | list) – The matplotlib colormap that should be applied to the data. By default, the widget will allow you to pick from all that are available, but you can pass a string to fix the colormap or a list of strings to offer the user a few options.
  • figsize (tup) – The figure height and width for matplotlib, in inches.
  • you are providing a custom plot function, any kwargs you provide (If) –
  • nifti_plotter will be passed to that function. (to) –