nanslice.layer module

layer.py

Contains the Layer class and the blend_layers() function.

class nanslice.layer.Layer(image, scale=1.0, volume=0, interp_order=1, cmap=None, clim=None, label='', mask=None, mask_threshold=0, alpha=None, alpha_lim=None, alpha_scale=1.0, alpha_label='')[source]

Bases: object

The Layer class

Each layer consists of a base MR image, with optional mask and alpha (transparency) images and their associated parameters (colormap, limits, scales etc.)

Constructor parameters:

  • image – The image contained in this layer. Can be either a string/path to an image file or an nibabel image
  • scale – A scaling factor to multiply all voxels in the image by
  • volume – If reading a 4D file, specify which volume to use
  • interp_order – Interpolation order. 1 is linear interpolation
  • cmap – The colormap to apply to the Layer. Any valid matplotlib colormap
  • clim – The limits (min, max) values to use for the colormap
  • label – The label for this layer (used for colorbars)
  • mask – A mask image to use with this layer
  • mask_threshold – Apply a threshold (lower) to the mask
  • alpha – An alpha (transparency) image to use with this layer
  • alpha_lim – Specify the limits/window for the alpha image
  • alpha_scale – Scaling factor for the alpha image
  • alpha_label – Label for the alpha axis on alphabars
get_alpha(slicer)[source]

Returns the alpha (transparency) slice for this Layer

Parameters:

  • slicer – The Slicer object to slice this layer with
get_color(slicer)[source]

Returns a colorized slice through the base image contained in the Layer

Parameters:

  • slicer – The Slicer object to slice this layer with
get_mask(slicer)[source]
get_slice(slicer)[source]

Returns a slice through the base image

Parameters:

  • slicer – The Slicer object to slice this layer with
plot(slicer, axes)[source]

Plot a Layer into a Matplotlib axes using the provided Slicer

Parameters:

  • slicer – The Slicer object to slice this layer with
  • axes – A matplotlib axes object
nanslice.layer.blend_layers(layers, slicer)[source]

Blends together a set of overlays using their alpha information

Parameters:

  • layers – An iterable (e.g. list/tuple) of Layer objects
  • slicer – The Slicer object to slice the layers with