fsleyes.displaycontext.display

This module provides the Display and DisplayOpts classes, which encapsulate overlay display settings.

class fsleyes.displaycontext.display.Display(overlay, overlayList, displayCtx, parent=None, **kwa)[source]

Bases: __main__.MockClass

The Display class contains display settings which are common to all overlay types.

A Display instance is also responsible for managing a single DisplayOpts instance, which contains overlay type specific display options. Whenever the overlayType property of a Display instance changes, the old DisplayOpts instance (if any) is destroyed, and a new one, of the correct type, created.

overlayType = <MagicMock name='mock.Choice()' id='3029825168'>

This property defines the overlay type - how the data is to be displayed.

The options for this property are populated in the __init__() method, from the displaycontext.OVERLAY_TYPES dictionary. A DisplayOpts sub-class exists for every possible value that this property may take.

enabled = <MagicMock name='mock.Boolean()' id='3030379152'>

Should this overlay be displayed at all?

alpha = <MagicMock name='mock.Percentage()' id='3029005168'>

Opacity - 100% is fully opaque, and 0% is fully transparent.

brightness = <MagicMock name='mock.Percentage()' id='3029005168'>

Brightness - 50% is normal brightness.

contrast = <MagicMock name='mock.Percentage()' id='3029005168'>

Contrast - 50% is normal contrast.

__init__(overlay, overlayList, displayCtx, parent=None, **kwa)[source]

Create a Display for the specified overlay.

Parameters
  • overlay – The overlay object.

  • overlayList – The OverlayList instance which contains all overlays.

  • displayCtx – A DisplayContext instance describing how the overlays are to be displayed.

  • parent – A parent Display instance - see props.syncable.

All other keyword arguments are assumed to be name=value pairs, containing initial property values, for both this Display, and the initially created DisplayOpts instance. For the latter, it is assumed that any properties specified are appropriate for the initial overlay type.

name = <MagicMock name='mock.String()' id='3029803952'>

The overlay name.

__del__()[source]

Prints a log message.

destroy()[source]

This method must be called when this Display instance is no longer needed.

When a Display instance is destroyed, the corresponding DisplayOpts instance is also destroyed.

getOverlay = <MagicMock name='mock.utils.deprecated.deprecated()()' id='3029266832'>
property overlay

Returns the overlay associated with this Display instance.

property opts

Return the DisplayOpts instance associated with this Display, which contains overlay type specific display settings.

If a DisplayOpts instance has not yet been created, or the overlayType property no longer matches the type of the existing DisplayOpts instance, a new DisplayOpts instance is created (and the old one destroyed if necessary).

See the __makeDisplayOpts() method.

getDisplayOpts = <MagicMock name='mock.utils.deprecated.deprecated()()' id='3029266832'>
_Display__findOptBaseType(optType, optName)

Finds the class, in the hierarchy of the given optType (a DisplayOpts sub-class) in which the given optName is defined.

This method is used by the __saveOldDisplayOpts() method, and is an annoying necessity caused by the way that the TypeDict class works. A TypeDict does not allow types to be used as keys - they must be strings containing the type names.

Furthermore, in order for the property values of a common DisplayOpts base type to be shared across sub types (e.g. copying the NiftiOpts.transform property between VolumeOpts and LabelOpts instances), we need to store the name of the common base type in the dictionary.

_Display__makeDisplayOpts()

Creates a new DisplayOpts instance. The specific DisplayOpts sub-class that is created is dictated by the current value of the overlayType property.

The displaycontext.DISPLAY_OPTS_MAP dictionary defines the mapping between overlay types and overlayType values, and DisplayOpts sub-class types.

_Display__overlayTypeChanged(*a)

Called when the overlayType property changes. Makes sure that the DisplayOpts instance is of the correct type.

_Display__restoreOldDisplayOpts()

Restores any cached values for all of the properties on the current DisplayOpts instance.

_Display__saveOldDisplayOpts()

Saves the value of every property on the current DisplayOpts instance, so they can be restored later if needed.

__module__ = 'fsleyes.displaycontext.display'
class fsleyes.displaycontext.display.DisplayOpts(overlay, display, overlayList, displayCtx, **kwargs)[source]

Bases: __main__.MockClass, fsleyes.actions.ActionProvider

The DisplayOpts class contains overlay type specific display settings. DisplayOpts instances are managed by Display instances.

The DisplayOpts class is not meant to be created directly - it is a base class for type specific implementations (e.g. the VolumeOpts class).

The following attributes are available on all DisplayOpts instances:

overlay

The overlay object

display

The Display instance that created this DisplayOpts instance.

overlayType

The value of the Display.overlayType property corresponding to the type of this DisplayOpts instance.

overlayList

The OverlayList instance, which contains all overlays.

displayCtx

The DisplayContext instance which is responsible for all Display and DisplayOpts instances.

name

A unique name for this DisplayOpts instance.

Warning

DisplayOpts sub-classes must not define any properties with the same name as any of the Display properties.

bounds = <MagicMock name='mock.Bounds()' id='3029366064'>

Specifies a bounding box in the display coordinate system which is big enough to contain the overlay described by this DisplayOpts instance.

The values in this bounds property must be updated by DisplayOpts subclasses whenever the spatial representation of their overlay changes.

__init__(overlay, display, overlayList, displayCtx, **kwargs)[source]

Create a DisplayOpts object.

Parameters
  • overlay – The overlay associated with this DisplayOpts instance.

  • display – The Display instance which owns this DisplayOpts instance.

  • overlayList – The OverlayList which contains all overlays.

  • displayCtx – A DisplayContext instance describing how the overlays are to be displayed.

__del__()[source]

Prints a log message.

destroy()[source]

This method must be called when this DisplayOpts instance is no longer needed.

If a subclass overrides this method, the subclass implementation must call this method, after performing its own clean up.

__module__ = 'fsleyes.displaycontext.display'
classmethod getVolumeProps()[source]

Intended to be overridden by sub-classes as needed. Returns a list of property names which control the currently displayed volume/timepoint for 4D overlays. The default implementation returns an empty list.

property overlay

Return the overlay associated with this DisplayOpts object.

property display

Return the Display that is managing this DisplayOpts object.

property overlayType

Return the type of this DisplayOpts object (the value of Display.overlayType).

property name

Return the name of this DisplayOpts object.

property referenceImage

Return the reference image associated with this DisplayOpts instance.

Some non-volumetric overlay types (e.g. the Mesh - see MeshOpts) may have a reference Nifti instance associated with them, allowing the overlay to be localised in the coordinate space defined by the Nifti. The DisplayOpts sub-class which corresponds to such non-volumetric overlays should override this method to return that reference image.

DisplayOpts sub-classes which are associated with volumetric overlays (i.e. Nifti instances) do not need to override this method - in this case, the overlay itself is considered to be its own reference image, and is returned by the base-class implementation of this method.

Note

The reference Nifti instance returned by sub-class implementations of this method must be in the OverlayList.

getReferenceImage = <MagicMock name='mock.utils.deprecated.deprecated()()' id='3029266832'>
getLabels()[source]

Generates some orientation labels for the overlay associated with this DisplayOpts instance.

If the overlay is not a Nifti instance, or does not have a reference image set, the labels will represent an unknown orientation.

Returns a tuple containing:

  • The (xlo, ylo, zlo, xhi, yhi, zhi) labels

  • The (xorient, yorient, zorient) orientations (see Image.getOrientation())