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 givenMeshoverlay.If the overlay file name looks like it was generated by the FSL FIRST segmentation tool, returns a colour from the
freesurfercolorlutcolour map. Otherwise returns a random colour.
-
class
fsleyes.displaycontext.meshopts.MeshOpts(overlay, *args, **kwargs)[source]¶ Bases:
fsleyes.displaycontext.colourmapopts.ColourMapOpts,fsleyes.displaycontext.display.DisplayOptsThe
MeshOptsclass defines settings for displayingMeshoverlays. See also theGiftiOptsandFreesurferOptssub-classes.-
outline= <MagicMock name='mock.Boolean()' id='4117273880'>¶ If
True, an outline of the mesh is shown. Otherwise a cross- section of the mesh is filled.
-
outlineWidth= <MagicMock name='mock.Real()' id='4116054224'>¶ If
outlineisTrue, this property defines the width of the outline in pixels.
-
showName= <MagicMock name='mock.Boolean()' id='4117273880'>¶ If
True, the mesh name is shown alongside it.Note
Not implemented yet, and maybe never will be.
-
discardClipped= <MagicMock name='mock.Boolean()' id='4117273880'>¶ Flag which controls clipping. When the mesh is coloured according to some data (the
vertexDataproperty), 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='4117029600'>¶ May be populated with the names of files which contain different vertex sets for the
Meshobject.
-
vertexData= <MagicMock name='mock.Choice()' id='4117029600'>¶ 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='4116300320'>¶ If
vertexDatais loaded, and has multiple data points per vertex (e.g. time series), this property controls the index into the data.
-
modulateData= <MagicMock name='mock.Choice()' id='4117029600'>¶ Populated with the same files available for the
vertexDataattribute. Used to apply theColourMapOpts.modulateAlphasetting.Note
There is currently no support for indexing into multi- dimensional modulate data (e.g. time points). A separate
modulateDataIndexproperty may be added in the future.
-
useLut= <MagicMock name='mock.Boolean()' id='4117273880'>¶ If
True, and if somevertexDatais loaded, thelutis used to colour vertex values instead of thecmapandnegativeCmap.
-
lut= <MagicMock name='mock.Choice()' id='4117029600'>¶ If
useLutisTrue, aLookupTableis used to colour vertex data instead of thecmap/negativeCmap.
-
coordSpace= <MagicMock name='mock.Choice()' id='4117029600'>¶ If
refImageis notNone, this property defines the reference image coordinate space in which the mesh coordinates are defined (i.e. voxels, scaled voxels, or world coordinates).affineThe mesh coordinates are defined in the reference image world coordinate system.
idThe mesh coordinates are defined in the reference image voxel coordinate system.
pixdimThe mesh coordinates are defined in the reference image voxel coordinate system, scaled by the voxel pixdims.
pixdim-flipThe 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.
torigThe 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.
-
interpolation= <MagicMock name='mock.Choice()' id='4117029600'>¶ Interpolate across vertices when colouring a mesh with vertex data. When using nearest neighbour interpolation, each face is coloured according to the data value from the first vertex in the face. Otherwise the colour is linearly interpolated across the face according to the data values at all three vertices.
-
wireframe= <MagicMock name='mock.Boolean()' id='4117273880'>¶ 3D only. If
True, the mesh is rendered as a wireframe.
-
__init__(overlay, *args, **kwargs)[source]¶ Create a
MeshOptsinstance.All other arguments are passed through to the
DisplayOptsconstructor.
-
colour= <MagicMock name='mock.Colour()' id='4116519520'>¶ The mesh colour.
-
refImage= <MagicMock name='mock.Choice()' id='4117029600'>¶ A reference
Imageinstance which the mesh coordinates are in terms of.For example, if this
Meshrepresents the segmentation of a sub-cortical region from a T1 image, you would set therefImageto that T1 image.Any
Imageinstance in theOverlayListmay 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.
-
getModulateRange()[source]¶ Overrides the
ColourMapOpts.getModulateRange()method. Returns the display range of the currently selectedvertexData, orNoneif none is selected.
-
getVertexData(vdtype='vertex')[source]¶ Returns the
MeshOpts.vertexDataormodulateData, if some is loaded. ReturnsNoneotherwise.
-
vertexDataLen()[source]¶ Returns the length (number of data points per vertex) of the currently selected
vertexData, or0if no vertex data is selected.
-
__module__= 'fsleyes.displaycontext.meshopts'¶
-
addVertexData(key, data)[source]¶ Adds the given data as a vertex data set to the
Meshoverlay associated with thisMeshOpts.- Parameters
key – A unique key to identify the data. If a vertex data set with the key already exists, a unique one is generated and returned.
data –
numpyarray containing per-vertex data.
- Returns
The key used to identify the data (typically equal to
key)
-
addVertexDataOptions(paths)[source]¶ Adds the given sequence of paths as options to the
vertexDataproperty. It is assumed that the paths refer to valid vertex data files for the overlay associated with thisMeshOptsinstance.
-
addVertexSetOptions(paths)[source]¶ Adds the given sequence of paths as options to the
vertexSetproperty. It is assumed that the paths refer to valid vertex files for the overlay associated with thisMeshOptsinstance.
-
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
refImageis selected, it is returned. Otherwise,``None`` is returned.
-
getVertex(xyz=None, tol=1)[source]¶ Returns an integer identifying the index of the mesh vertex that coresponds to the given
xyzlocation, assumed to be specified in the display coordinate system.- Parameters
xyz – Location to convert to a vertex index. If not provided, the current
DisplayContext.locationis used.tol – Tolerance in mesh coordinate system units - if
xyzis farther thantolto any vertex,Noneis returned. Pass inNoneto always return the nearest vertex.
-
normaliseSpace(space)[source]¶ Used by
transformCoords()andgetTransform()to normalise theirfrom_andtoparameters.
-
transformCoords(coords, from_, to, *args, **kwargs)[source]¶ Transforms the given
coordsfromfrom_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_andtoparameters:'world': World coordinate system'display'Display coordinate system'mesh'The coordinate system of this mesh.'voxel': The voxel coordinate system of the referenceimage
'id': Equivalent to'voxel'.
-
getTransform(from_, to)[source]¶ Return a matrix which may be used to transform coordinates from
from_toto.If the
refImageproperty is not set, an identity matrix is returned.The following values are accepted for the
from_andtoparameters:'world': World coordinate system'display': Display coordinate system'mesh': The coordinate system of this mesh.'voxel': The voxel coordinate system of the referenceimage
'id': Equivalent to'voxel'.
-
__transformChanged(value, valid, ctx, name)¶ Called when the
NiftiOpts.transformproperty of the currentrefImagechanges. Calls__updateBounds().
-
__coordSpaceChanged(*a)¶ Called when the
coordSpaceproperty changes. Calls__updateBounds().
-
__refImageChanged(*a)¶ Called when the
refImageproperty changes.If a new reference image has been specified, removes listeners from the old one (if necessary), and adds listeners to the
NiftiOpts.transformproperty associated with the new image. Calls__updateBounds().
-
__updateBounds()¶ Called whenever any of the
refImage,coordSpace, ortransformproperties change.Updates the
DisplayOpts.boundsproperty accordingly.
-
__overlayListChanged(*a)¶ Called when the overlay list changes. Updates the
refImageproperty so that it contains a list of overlays which can be associated with the mesh.
-
__overlayVerticesChanged(*a)¶ Called when the
Mesh.verticeschange. Makes sure that thevertexSetattribute is synchronised.
-
__vertexSetChanged(*a)¶ Called when the
MeshOpts.vertexSetproperty changes. Updates the current vertex set on theMeshoverlay, and the overlay bounds.
-
__vdataChanged(value, valid, ctx, name)¶ Called when the
vertexDataormodulateDataproperties changes. Attempts to load the data if possible. The data may subsequently be retrieved via thegetVertexData()method.
-