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 DisplayContext class, which defines how all of the overlays in an OverlayList should be displayed.

  • the Display class, which defines how a single overlay should be displayed.

  • the DisplayOpts base 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:

NiftiOpts

The NiftiOpts class describes how a Nifti overlay should be displayed.

VolumeOpts

The VolumeOpts class defines options for displaying Image instances as regular 3D volumes.

VolumeRGBOpts

The VolumeRGBOpts class is intended for displaying Image instances containing RGB(A) data.

ComplexOpts

The ComplexOpts class is a specialisation of VolumeOpts for images with a complex data type.

Volume3DOpts

The Volume3DOpts class is a mix-in for use with DisplayOpts classes.

MaskOpts

The MaskOpts class defines settings for displaying an Image overlay as a binary mask.

RGBVectorOpts

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

LineVectorOpts

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

MeshOpts

The MeshOpts class defines settings for displaying Mesh overlays.

GiftiOpts

The GiftiOpts class, which contains settings for displaying a GiftiMesh overlay.

FreesurferOpts

The FreesurferOpts class, which contains settings for displaying a FreesurferMesh overlay.

LabelOpts

The LabelOpts class defines settings for displaying Image overlays as label images., such as anatomical atlas images, tissue segmentation images, and so on.

TensorOpts

The TensorOpts class defines options for displaying GLTensor instances.

SHOpts

The SHOpts is used for rendering Image instances which contain fibre orientation distributions (FODs) in the form of spherical harmonic (SH) coefficients.

MIPOpts

The MIPOpts class is used for rendering maximum intensity projections of .Image overlays.

TractogramOpts

Display options for Tractogram overlays.

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:

SliceCanvasOpts

The SliceCanvasOpts class defines all of the display settings for a SliceCanvas.

LightBoxCanvasOpts

The LightBoxCanvasOpts class defines the display settings available on LightBoxCanvas instances.

Scene3DCanvasOpts

The Scene3DCanvasOpts class defines the display settings available on Scene3DCanvas instances.

SceneOpts

The SceneOpts class defines settings which are used by CanvasPanel instances.

OrthoOpts

The OrthoOpts class is used by OrthoPanel instances to manage their display settings.

LightBoxOpts

The LightBoxOpts class contains display settings for the LightBoxPanel class.

Scene3DOpts

The Scene3DOpts class contains display settings for the Scene3DPanel class.

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.overlayType property 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 = ['tractogram', 'volume', 'tensor', 'sh', 'linevector', 'complex', 'mip', 'label', 'rgb', 'mesh', 'mask', 'rgbvector']

This attribute contains a list of all possible overlay types - see the Display.overlayType property and tge display.OVERLAY_TYPES dictionary 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 the DisplayOpts subclass 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_TYPES dictionary, which might adjust the returned list based on properties of the overlay.