fsleyes.displaycontext.meshopts

This module provides the MeshOpts class, which defines settings for displaying Mesh overlays.

fsleyes.displaycontext.meshopts.genMeshColour(overlay)

Called by MeshOpts.__init__(). Generates an initial colour for the given Mesh overlay.

If the overlay file name looks like it was generated by the FSL FIRST segmentation tool, returns a colour from the freesurfercolorlut colour map. Otherwise returns a random colour.

class fsleyes.displaycontext.meshopts.MeshOpts(overlay, *args, **kwargs)

Bases: fsleyes.displaycontext.colourmapopts.ColourMapOpts, fsleyes.displaycontext.display.DisplayOpts

The MeshOpts class defines settings for displaying Mesh overlays. See also the GiftiOpts and FreesurferOpts sub-classes.

outline = <MagicMock name='mock.Boolean()' id='139845844115072'>

If True, an outline of the mesh is shown. Otherwise a cross- section of the mesh is filled.

outlineWidth = <MagicMock name='mock.Real()' id='139845842337520'>

If outline is True, this property defines the width of the outline in pixels.

showName = <MagicMock name='mock.Boolean()' id='139845844115072'>

If True, the mesh name is shown alongside it.

Note

Not implemented yet, and maybe never will be.

discardClipped = <MagicMock name='mock.Boolean()' id='139845844115072'>

Flag which controls clipping. When the mesh is coloured according to some data (the vertexData property), vertices with a data value outside of the clipping range are either discarded (not drawn), or they are still drawn, but not according to the data, rather with the flat colour.

vertexSet = <MagicMock name='mock.Choice()' id='139845843612560'>

May be populated with the names of files which contain different vertex sets for the Mesh object.

vertexData = <MagicMock name='mock.Choice()' id='139845843612560'>

May be populated with the names of files which contain data associated with each vertex in the mesh, that can be used to colour the mesh. When some vertex data has been succsessfully loaded, it can be accessed via the getVertexData() method.

vertexDataIndex = <MagicMock name='mock.Int()' id='139845843069248'>

If vertexData is loaded, and has multiple data points per vertex (e.g. time series), this property controls the index into the data.

useLut = <MagicMock name='mock.Boolean()' id='139845844115072'>

If True, and if some vertexData is loaded, the lut is used to colour vertex values instead of the cmap and negativeCmap.

lut = <MagicMock name='mock.Choice()' id='139845843612560'>

If useLut is True, a LookupTable is used to colour vertex data instead of the cmap/negativeCmap.

coordSpace = <MagicMock name='mock.Choice()' id='139845843612560'>

If refImage is not None, this property defines the reference image coordinate space in which the mesh coordinates are defined (i.e. voxels, scaled voxels, or world coordinates).

affine The mesh coordinates are defined in the reference image world coordinate system.
torig Equivalent to 'affine', except for FreesurferOpts sub-classes.
id The mesh coordinates are defined in the reference image voxel coordinate system.
pixdim The mesh coordinates are defined in the reference image voxel coordinate system, scaled by the voxel pixdims.
pixdim-flip The mesh coordinates are defined in the reference image voxel coordinate system, scaled by the voxel pixdims. If the reference image transformation matrix has a positive determinant, the X axis is flipped.

The default value is pixdim-flip, as this is the coordinate system used in the VTK sub-cortical segmentation model files output by FIRST. See also the note on coordinate systems, and the NiftiOpts.getTransform() method.

wireframe = <MagicMock name='mock.Boolean()' id='139845844115072'>

3D only. If True, the mesh is rendered as a wireframe.

__init__(overlay, *args, **kwargs)

Create a MeshOpts instance. All arguments are passed through to the DisplayOpts constructor.

colour = <MagicMock name='mock.Colour()' id='139845842273280'>

The mesh colour.

refImage = <MagicMock name='mock.Choice()' id='139845843612560'>

A reference Image instance which the mesh coordinates are in terms of.

For example, if this Mesh represents the segmentation of a sub-cortical region from a T1 image, you would set the refImage to that T1 image.

Any Image instance in the OverlayList may be chosen as the reference image.

destroy()

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

classmethod getVolumeProps()

Overrides DisplayOpts.getVolumeProps(). Returns a list of property names which control the displayed volume/timepoint.

getDataRange()

Overrides the ColourMapOpts.getDisplayRange() method. Returns the display range of the currently selected vertexData, or (0, 1) if none is selected.

getVertexData()

Returns the MeshOpts.vertexData, if some is loaded. Returns None otherwise.

vertexDataLen()

Returns the length (number of data points per vertex) of the currently selected vertexData, or 0 if no vertex data is selected.

addVertexDataOptions(paths)

Adds the given sequence of paths as options to the vertexData property. It is assumed that the paths refer to valid vertex data files for the overlay associated with this MeshOpts instance.

addVertexSetOptions(paths)

Adds the given sequence of paths as options to the vertexSet property. It is assumed that the paths refer to valid vertex files for the overlay associated with this MeshOpts instance.

getConstantColour()

Returns the current :attr::colour, adjusted according to the current Display.brightness, Display.contrast, and Display.alpha.

referenceImage

Overrides DisplayOpts.referenceImage().

If a refImage is selected, it is returned. Otherwise,``None`` is returned.

_MeshOpts__alphaChanged(*a)

Called when Display.alpha changes. Updates the alpha component of colour.

_MeshOpts__colourChanged(*a)

Called when colour changes. Updates Display.alpha from the alpha component.

_MeshOpts__coordSpaceChanged(*a)

Called when the coordSpace property changes. Calls __updateBounds().

_MeshOpts__overlayListChanged(*a)

Called when the overlay list changes. Updates the refImage property so that it contains a list of overlays which can be associated with the mesh.

_MeshOpts__overlayVerticesChanged(*a)

Called when the Mesh.vertices change. Makes sure that the vertexSet attribute is synchronised.

_MeshOpts__refImageChanged(*a)

Called when the refImage property changes.

If a new reference image has been specified, removes listeners from the old one (if necessary), and adds listeners to the NiftiOpts.transform property associated with the new image. Calls __updateBounds().

_MeshOpts__transformChanged(value, valid, ctx, name)

Called when the NiftiOpts.transform property of the current refImage changes. Calls __updateBounds().

_MeshOpts__updateBounds()

Called whenever any of the refImage, coordSpace, or transform properties change.

Updates the DisplayOpts.bounds property accordingly.

_MeshOpts__vertexDataChanged(*a)

Called when the vertexData property changes. Attempts to load the data if possible. The data may subsequently be retrieved via the getVertexData() method.

_MeshOpts__vertexSetChanged(*a)

Called when the MeshOpts.vertexSet property changes. Updates the current vertex set on the Mesh overlay, and the overlay bounds.

__module__ = 'fsleyes.displaycontext.meshopts'
getCoordSpaceTransform = <MagicMock name='mock.deprecated()()' id='139845843667040'>
getVertex(xyz=None)

Returns an integer identifying the index of the mesh vertex that coresponds to the given xyz location,

Parameters:xyz – Location to convert to a vertex index. If not provided, the current DisplayContext.location is used.
normaliseSpace(space)

Used by transformCoords() and getTransform() to normalise their from_ and to parameters.

transformCoords(coords, from_, to, *args, **kwargs)

Transforms the given coords from from_ to to.

Parameters:
  • coords – Coordinates to transform.
  • from – Space that the coordinates are in
  • to – Space to transform the coordinates to

All other parameters are passed through to the NiftiOpts.transformCoords() method of the reference image DisplayOpts.

The following values are accepted for the from_ and to parameters:

  • 'world': World coordinate system
  • 'display' Display coordinate system
  • 'mesh' The coordinate system of this mesh.
getTransform(from_, to)

Return a matrix which may be used to transform coordinates from from_ to to.

The following values are accepted for the from_ and to parameters:

  • 'world': World coordinate system
  • 'display' Display coordinate system
  • 'mesh' The coordinate system of this mesh.