fsleyes.displaycontext.meshopts
¶
This module provides the MeshOpts
class, which defines settings
for displaying Mesh
overlays.
-
fsleyes.displaycontext.meshopts.
genMeshColour
(overlay)[source]¶ Called by
MeshOpts.__init__()
. Generates an initial colour for the givenMesh
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)[source]¶ Bases:
fsleyes.displaycontext.colourmapopts.ColourMapOpts
,fsleyes.displaycontext.display.DisplayOpts
The
MeshOpts
class defines settings for displayingMesh
overlays. See also theGiftiOpts
andFreesurferOpts
sub-classes.-
outline
= <MagicMock name='mock.Boolean()' id='3031712864'>¶ If
True
, an outline of the mesh is shown. Otherwise a cross- section of the mesh is filled.
-
outlineWidth
= <MagicMock name='mock.Real()' id='3030854648'>¶ If
outline
isTrue
, this property defines the width of the outline in pixels.
-
showName
= <MagicMock name='mock.Boolean()' id='3031712864'>¶ If
True
, the mesh name is shown alongside it.Note
Not implemented yet, and maybe never will be.
-
discardClipped
= <MagicMock name='mock.Boolean()' id='3031712864'>¶ 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 flatcolour
.
-
vertexSet
= <MagicMock name='mock.Choice()' id='3030895104'>¶ May be populated with the names of files which contain different vertex sets for the
Mesh
object.
-
vertexData
= <MagicMock name='mock.Choice()' id='3030895104'>¶ 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='3030091688'>¶ 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='3031712864'>¶ If
True
, and if somevertexData
is loaded, thelut
is used to colour vertex values instead of thecmap
andnegativeCmap
.
-
lut
= <MagicMock name='mock.Choice()' id='3030895104'>¶ If
useLut
isTrue
, aLookupTable
is used to colour vertex data instead of thecmap
/negativeCmap
.
-
coordSpace
= <MagicMock name='mock.Choice()' id='3030895104'>¶ If
refImage
is notNone
, 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.
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.
torig
The mesh coordinates are defined in the Freesurfer “Torig” / “vox2ras-tkr” coordnie system.
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 theNiftiOpts.getTransform()
method.
-
wireframe
= <MagicMock name='mock.Boolean()' id='3031712864'>¶ 3D only. If
True
, the mesh is rendered as a wireframe.
-
__init__
(overlay, *args, **kwargs)[source]¶ Create a
MeshOpts
instance.- Parameters
useTorig – If
False
(the default), the'torig'
option from thecoordSpace
property is removed.
All other arguments are passed through to the
DisplayOpts
constructor.
-
colour
= <MagicMock name='mock.Colour()' id='3032902768'>¶ The mesh colour.
-
refImage
= <MagicMock name='mock.Choice()' id='3030895104'>¶ 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 therefImage
to that T1 image.Any
Image
instance in theOverlayList
may be chosen as the reference image.
-
destroy
()[source]¶ Removes some property listeners, and calls the
DisplayOpts.destroy()
method.
-
classmethod
getVolumeProps
()[source]¶ Overrides
DisplayOpts.getVolumeProps()
. Returns a list of property names which control the displayed volume/timepoint.
-
getDataRange
()[source]¶ Overrides the
ColourMapOpts.getDisplayRange()
method. Returns the display range of the currently selectedvertexData
, or(0, 1)
if none is selected.
-
getVertexData
()[source]¶ Returns the
MeshOpts.vertexData
, if some is loaded. ReturnsNone
otherwise.
-
vertexDataLen
()[source]¶ Returns the length (number of data points per vertex) of the currently selected
vertexData
, or0
if no vertex data is selected.
-
addVertexDataOptions
(paths)[source]¶ 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 thisMeshOpts
instance.
-
addVertexSetOptions
(paths)[source]¶ 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 thisMeshOpts
instance.
-
getConstantColour
()[source]¶ Returns the current :attr::colour, adjusted according to the current
Display.brightness
,Display.contrast
, andDisplay.alpha
.
-
property
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 ofcolour
.
-
_MeshOpts__colourChanged
(*a)¶ Called when
colour
changes. UpdatesDisplay.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 thevertexSet
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 currentrefImage
changes. Calls__updateBounds()
.
-
_MeshOpts__updateBounds
()¶ Called whenever any of the
refImage
,coordSpace
, ortransform
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 thegetVertexData()
method.
-
_MeshOpts__vertexSetChanged
(*a)¶ Called when the
MeshOpts.vertexSet
property changes. Updates the current vertex set on theMesh
overlay, and the overlay bounds.
-
__module__
= 'fsleyes.displaycontext.meshopts'¶
-
getCoordSpaceTransform
= <MagicMock name='mock.utils.deprecated.deprecated()()' id='3031103328'>¶
-
getVertex
(xyz=None, tol=1)[source]¶ Returns an integer identifying the index of the mesh vertex that coresponds to the given
xyz
location, assumed to be specified in the display coordinate system.- Parameters
xyz – Location to convert to a vertex index. If not provided, the current
DisplayContext.location
is used.tol – Tolerance in mesh coordinate system units - if
xyz
is farther thantol
to any vertex,None
is returned. Pass inNone
to always return the nearest vertex.
-
normaliseSpace
(space)[source]¶ Used by
transformCoords()
andgetTransform()
to normalise theirfrom_
andto
parameters.
-
transformCoords
(coords, from_, to, *args, **kwargs)[source]¶ Transforms the given
coords
fromfrom_
toto
.- 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 imageDisplayOpts
.The following values are accepted for the
from_
andto
parameters:'world'
: World coordinate system'display'
Display coordinate system'mesh'
The coordinate system of this mesh.
-