fsleyes.displaycontext
The displaycontext package contains classes which define the display
options for pretty much everything in FSLeyes.
Note
Before perusing this package, you should read the high level
overview in the fsleyes package documentation. Go on -
it won’t take you too long.
Overview
The most important classes defined in this package are:
the
DisplayContextclass, which defines how all of the overlays in anOverlayListshould be displayed.the
Displayclass, which defines how a single overlay should be displayed.the
DisplayOptsbase class, and its sub-classes, which define overlay type specific options.
A DisplayContext instance encapsulates an OverlayList, and
defines how the overlays in the list should be displayed. Each
ViewPanel displayed in FSLeyes (e.g. the OrthoPanel) has
its own DisplayContext instance; a ViewPanel uses its
DisplayContext instance to configure general display properties, and also
to access the Display properties for individual overlays.
All of the classes mentioned on ths page are defined in sub-modules, but are
imported into, and are thus available from, the displaycontext package
namespace. For example:
import fsleyes.displaycontext as fsldc
# The VolumeOpts class is defined in the
# fsleyes.displaycontext.volumeopts
# module, but is available in the
# fsleyes.displaycontext namespace.
volopts = fsldc.VolumeOpts(overlay, display, overlayList, displayCtx)
Overlay display options
The Display class, and the DisplayOpts sub-classes define
how to display a single overlay. Options common to all overlays
(e.g. Display.brightness, Display.alpha) are defined in the
Display class, whereas options which are specific to a particular overlay
type (e.g. VolumeOpts.cmap, LineVectorOpts.lineWidth) are
defined in the corresponding DisplayOpts sub-class.
The Display instance for a particular overlay owns and manages a single
DisplayOpts instance - whenever the overlay display type is changed, the
Display instance deletes the old DisplayOpts instance, and creates a
new one accordingly. The following DisplayOpts sub-classes exist:
The |
|
The |
|
The |
|
The |
|
The |
|
The |
|
The |
|
The |
|
The |
|
The |
|
The |
|
The |
|
The |
|
The |
|
The |
|
Display options for |
Overlay groups
Note
Support for overlay groups is quite basic at this point in time. See
the OverlayListPanel for details.
The group module provides the functionality to
link the display properties of one or more overlays. One or more
OverlayGroup instances may be added to the
DisplayContext.overlayGroups list.
Scene options
Independent of the DisplayContext, Display and DisplayOpts
classes, the displaycontext package is also home to a few classes which
define scene options:
The |
|
The |
|
The |
|
The |
|
The |
|
The |
|
The |
Note
Aside from an increase in code modularity and cleanliness, another reason that all of these scene display settings are separated from the things that use them is so they can be imported, queried, and set without having to import the modules that use them.
For example, the parseargs module needs to be able
to access all of the display settings in order to print out the
corresponding help documentation. This process would take much
longer if parseargs had to import, e.g.
OrthoPanel, which would result in importing both wx
and OpenGL.
Keeping these display settings separate allows us to avoid these time-consuming imports in situations where they are not needed.
- fsleyes.displaycontext.OVERLAY_TYPES = {'Bitmap': ['rgb', 'volume'], 'Image': ['volume', 'mask', 'rgbvector', 'linevector', 'label', 'sh', 'tensor', 'mip', 'rgb', 'complex'], 'Mesh': ['mesh'], 'DTIFitTensor': ['tensor', 'rgbvector', 'linevector'], 'Tractogram': ['tractogram']}
This dictionary provides a mapping between all overlay classes, and the possible values that the
Display.overlayTypeproperty may take for each of them.For each overlay class, the first entry in the corresponding overlay type list is used as the default overlay type.
- fsleyes.displaycontext.ALL_OVERLAY_TYPES = ['linevector', 'tractogram', 'volume', 'mip', 'mask', 'sh', 'complex', 'rgbvector', 'tensor', 'rgb', 'mesh', 'label']
This attribute contains a list of all possible overlay types - see the
Display.overlayTypeproperty and tgedisplay.OVERLAY_TYPESdictionary for more details.
- fsleyes.displaycontext.DISPLAY_OPTS_MAP = {('Nifti', 'volume'): <class 'fsleyes.displaycontext.volumeopts.VolumeOpts'>, ('Nifti', 'rgbvector'): <class 'fsleyes.displaycontext.vectoropts.RGBVectorOpts'>, ('Nifti', 'linevector'): <class 'fsleyes.displaycontext.vectoropts.LineVectorOpts'>, ('Nifti', 'mask'): <class 'fsleyes.displaycontext.maskopts.MaskOpts'>, ('Nifti', 'label'): <class 'fsleyes.displaycontext.labelopts.LabelOpts'>, ('Nifti', 'tensor'): <class 'fsleyes.displaycontext.tensoropts.TensorOpts'>, ('Nifti', 'sh'): <class 'fsleyes.displaycontext.shopts.SHOpts'>, ('Nifti', 'mip'): <class 'fsleyes.displaycontext.mipopts.MIPOpts'>, ('Nifti', 'rgb'): <class 'fsleyes.displaycontext.volumeopts.VolumeRGBOpts'>, ('Nifti', 'complex'): <class 'fsleyes.displaycontext.volumeopts.ComplexOpts'>, ('Mesh', 'mesh'): <class 'fsleyes.displaycontext.meshopts.MeshOpts'>, ('VTKMesh', 'mesh'): <class 'fsleyes.displaycontext.meshopts.MeshOpts'>, ('GiftiMesh', 'mesh'): <class 'fsleyes.displaycontext.giftiopts.GiftiOpts'>, ('FreesurferMesh', 'mesh'): <class 'fsleyes.displaycontext.freesurferopts.FreesurferOpts'>, ('Tractogram', 'tractogram'): <class 'fsleyes.displaycontext.tractogramopts.TractogramOpts'>}
This dictionary provides a mapping between each (overlay type,
Display.overlayType) pair, and theDisplayOptssubclass which contains overlay type-specific display options.
- fsleyes.displaycontext.getOverlayTypes(overlay)[source]
Returns a list of possible overlay types for the given overlay. This is a wrapper around the
OVERLAY_TYPESdictionary, which might adjust the returned list based on properties of the overlay.