fsleyes.displaycontext.vectoropts

This module provides the VectorOpts, LineVectorOpts, and RGBVectorOpts classes, which contain options for displaying NIFTI vector images.

class fsleyes.displaycontext.vectoropts.VectorOpts[source]

Bases: object

The VectorOpts class is a mixin for use with DisplayOpts sub-classes, providng properties and logic for displaying overlays which can be coloured according to XYZ orientations.

xColour

Colour used to represent the X vector magnitude.

yColour

Colour used to represent the Y vector magnitude.

zColour

Colour used to represent the Z vector magnitude.

suppressX

Do not use the X vector magnitude to colour vectors.

suppressY

Do not use the Y vector magnitude to colour vectors.

suppressZ

Do not use the Z vector magnitude to colour vectors.

suppressMode

How vector direction colours should be suppressed.

normaliseColour

If True, the vector values are normalised to uniform brightness. If False (the default), the vector XYZ values are used directly as RGB values.

getVectorColours()[source]

Prepares the colours that represent each direction.

Returns:
  • a numpy array of size (3, 4) containing the RGBA colours that correspond to the x, y, and z vector directions.

  • A numpy array of shape (4, 4) which encodes a scale and offset to be applied to the vector value before it is combined with the colours, encoding the current brightness and contrast settings.

__annotations__ = {}
__dict__ = mappingproxy({'__module__': 'fsleyes.displaycontext.vectoropts', '__doc__': 'The ``VectorOpts`` class is a mixin for use with :class:`.DisplayOpts`\n    sub-classes, providng properties and logic for displaying overlays which\n    can be coloured according to XYZ orientations.\n    ', 'xColour': <fsleyes_props.properties_types.Colour object>, 'yColour': <fsleyes_props.properties_types.Colour object>, 'zColour': <fsleyes_props.properties_types.Colour object>, 'suppressX': <fsleyes_props.properties_types.Boolean object>, 'suppressY': <fsleyes_props.properties_types.Boolean object>, 'suppressZ': <fsleyes_props.properties_types.Boolean object>, 'suppressMode': <fsleyes_props.properties_types.Choice object>, 'normaliseColour': <fsleyes_props.properties_types.Boolean object>, 'getVectorColours': <function VectorOpts.getVectorColours>, '__dict__': <attribute '__dict__' of 'VectorOpts' objects>, '__weakref__': <attribute '__weakref__' of 'VectorOpts' objects>, '__annotations__': {}})
__module__ = 'fsleyes.displaycontext.vectoropts'
__weakref__

list of weak references to the object

class fsleyes.displaycontext.vectoropts.NiftiVectorOpts(*args, **kwargs)[source]

Bases: NiftiOpts, VectorOpts

The NiftiVectorOpts class is the base class for LineVectorOpts, RGBVectorOpts, TensorOpts, and SHOpts. It contains display settings which are common to each of them.

A note on orientation

The orientFlip property allows you to flip the left-right orientation of line vectors, tensors, and SH functions. This option is necessary, because different tools may output vector data in different ways, depending on the image orientation.

For images which are stored radiologically (with the X axis increasaing from right to left), the FSL tools (e.g. dtifit) will generate vectors which are oriented according to the voxel coordinate system. However, for neurologically stored images (X axis increasing from left to right), FSL tools generate vectors which are radiologically oriented, and thus are inverted with respect to the X axis in the voxel coordinate system. Therefore, in order to correctly display vectors from such an image, we must flip each vector about the X axis.

This issue is also applicable to tensor and sh overlays.

cmap

If an image is selected as the colourImage, this colour map is used to colour the vector voxels.

colourImage

Colour vector voxels by the values contained in this image. Any image which is in the OverlayList, and which has the same voxel dimensions as the vector image can be selected for colouring. If a colourImage is selected, the xColour, yColour, zColour, suppressX, suppressY, and suppressZ properties are all ignored.

modulateImage

Modulate the vector colour brightness/alpha by another image. Any image which is in the OverlayList, and which has the same voxel dimensions as the vector image can be selected for modulation.

modulateMode

Modulate either the brightness or transparency by the modulation image.

clipImage

Clip voxels from the vector image according to another image. Any image which is in the OverlayList, and which has the same voxel dimensions as the vector image can be selected for clipping. The clippingRange dictates the value below which vector voxels are clipped.

clippingRange

Hide voxels for which the clipImage value is outside of this range.

modulateRange

Data range used in brightness/transparency modulation, when a modulateImage is in use.

colourRange

Data range used for colouring, when a colourImage is in use.

__init__(image, *args, **kwargs)[source]

Create a VectorOpts instance for the given image. All arguments are passed through to the NiftiOpts constructor.

orientFlip

If True, individual vectors are flipped along the x-axis. This property is only applicable to the LineVectorOpts, TensorOpts, and SHOpts classes. See the NiftiOpts.getTransform() method for more information.

This value defaults to True for images which have a neurological storage order, and False for radiological images.

__annotations__ = {}
__module__ = 'fsleyes.displaycontext.vectoropts'
destroy()[source]

Removes some property listeners, and calls the NiftiOpts.destroy() method.

__clipImageChanged(*a)

Called when the clipImage property changes. Updates the range of the clippingRange property.

__modulateImageChanged(*a)

Called when the modulateImage property changes. Updates the range of the modulateRange property.

__colourImageChanged(*a)

Called when the colourImage property changes. Updates the range of the coluorRange property.

__updateRange(image, rangeobj, pad=False)

Used whenever clipImage, modulateImage, or colourImage change. Updates the clippingRange, modulateRange, or colourRange respectively.

__overlayListChanged(*a)

Called when the overlay list changes. Updates the modulateImage, colourImage and clipImage properties so that they contain a list of overlays which could be used to modulate the vector image.

__refreshAuxImage(imageName)

Updates the named image property (modulateImage, colourImage or clipImage) so that it contains a list of overlays which could be used to modulate the vector image.

class fsleyes.displaycontext.vectoropts.LineVectorOpts(*args, **kwargs)[source]

Bases: NiftiVectorOpts

The LineVectorOpts class contains settings for displaying vector images, using a line to represent the vector value at each voxel.

__annotations__ = {}
__module__ = 'fsleyes.displaycontext.vectoropts'
lineWidth

Width of the line in pixels.

directed

If True, the vector data is interpreted as directed. Otherwise, the vector data is assumed to be undirected.

modulateMode

Overwrites NiftiVectorOpts.modulateMode.

Modulate the brightness, transparency, or line length by the modulation image. When set to 'lineLength', this is applied after the unitLength and before the lengthScale properties.

unitLength

If True, each vector is scaled so that it has a length of 1 * lengthScale (or 0.5 if directed is True).

lengthScale

Length scaling factor.

__init__(*args, **kwargs)[source]

Create a LineVectorOpts instance. All arguments are passed through to the VectorOpts constructor.

class fsleyes.displaycontext.vectoropts.RGBVectorOpts(*args, **kwargs)[source]

Bases: NiftiVectorOpts

The RGBVectorOpts class contains settings for displaying vector images, using a combination of three colours to represent the vector value at each voxel.

__annotations__ = {}
__module__ = 'fsleyes.displaycontext.vectoropts'
interpolation

Apply interpolation to the image data.

unitLength

Alias for VectorOpts.normaliseColour. Not used internally, kept for compatibility.

__init__(*args, **kwargs)[source]

Create a RGBVectorOpts instance. All arguments are passed through to the VectorOpts constructor.