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__.MockClassThe
Displayclass contains display settings which are common to all overlay types.A
Displayinstance is also responsible for managing a singleDisplayOptsinstance, which contains overlay type specific display options. Whenever theoverlayTypeproperty of aDisplayinstance changes, the oldDisplayOptsinstance (if any) is destroyed, and a new one, of the correct type, created.-
overlayType= <MagicMock name='mock.Choice()' id='281473498355456'>¶ 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 thedisplaycontext.OVERLAY_TYPESdictionary. ADisplayOptssub-class exists for every possible value that this property may take.
-
enabled= <MagicMock name='mock.Boolean()' id='281473497326640'>¶ Should this overlay be displayed at all?
-
alpha= <MagicMock name='mock.Percentage()' id='281473488836064'>¶ Opacity - 100% is fully opaque, and 0% is fully transparent.
-
brightness= <MagicMock name='mock.Percentage()' id='281473488836064'>¶ Brightness - 50% is normal brightness.
-
contrast= <MagicMock name='mock.Percentage()' id='281473488836064'>¶ Contrast - 50% is normal contrast.
-
__init__(overlay, overlayList, displayCtx, parent=None, **kwa)[source]¶ Create a
Displayfor the specified overlay.- Parameters
overlay – The overlay object.
overlayList – The
OverlayListinstance which contains all overlays.displayCtx – A
DisplayContextinstance describing how the overlays are to be displayed.parent – A parent
Displayinstance - seeprops.syncable.
All other keyword arguments are assumed to be
name=valuepairs, containing initial property values, for both thisDisplay, and the initially createdDisplayOptsinstance. For the latter, it is assumed that any properties specified are appropriate for the initial overlay type.
-
name= <MagicMock name='mock.String()' id='281473498257632'>¶ The overlay name.
-
destroy()[source]¶ This method must be called when this
Displayinstance is no longer needed.When a
Displayinstance is destroyed, the correspondingDisplayOptsinstance is also destroyed.
-
getOverlay= <MagicMock name='mock.utils.deprecated.deprecated()()' id='281473495817568'>¶
-
property
overlay¶ Returns the overlay associated with this
Displayinstance.
-
property
opts¶ Return the
DisplayOptsinstance associated with thisDisplay, which contains overlay type specific display settings.If a
DisplayOptsinstance has not yet been created, or theoverlayTypeproperty no longer matches the type of the existingDisplayOptsinstance, a newDisplayOptsinstance is created (and the old one destroyed if necessary).See the
__makeDisplayOpts()method.
-
getDisplayOpts= <MagicMock name='mock.utils.deprecated.deprecated()()' id='281473495817568'>¶
-
_Display__findOptBaseType(optType, optName)¶ Finds the class, in the hierarchy of the given
optType(aDisplayOptssub-class) in which the givenoptNameis defined.This method is used by the
__saveOldDisplayOpts()method, and is an annoying necessity caused by the way that theTypeDictclass works. ATypeDictdoes 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
DisplayOptsbase type to be shared across sub types (e.g. copying theNiftiOpts.transformproperty betweenVolumeOptsandLabelOptsinstances), we need to store the name of the common base type in the dictionary.
-
_Display__makeDisplayOpts()¶ Creates a new
DisplayOptsinstance. The specificDisplayOptssub-class that is created is dictated by the current value of theoverlayTypeproperty.The
displaycontext.DISPLAY_OPTS_MAPdictionary defines the mapping between overlay types andoverlayTypevalues, andDisplayOptssub-class types.
-
_Display__overlayTypeChanged(*a)¶ Called when the
overlayTypeproperty changes. Makes sure that theDisplayOptsinstance is of the correct type.
-
_Display__restoreOldDisplayOpts()¶ Restores any cached values for all of the properties on the current
DisplayOptsinstance.
-
_Display__saveOldDisplayOpts()¶ Saves the value of every property on the current
DisplayOptsinstance, 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.ActionProviderThe
DisplayOptsclass contains overlay type specific display settings.DisplayOptsinstances are managed byDisplayinstances.The
DisplayOptsclass is not meant to be created directly - it is a base class for type specific implementations (e.g. theVolumeOptsclass).The following attributes are available on all
DisplayOptsinstances:overlayThe overlay object
displayThe
Displayinstance that created thisDisplayOptsinstance.overlayTypeThe value of the
Display.overlayTypeproperty corresponding to the type of thisDisplayOptsinstance.overlayListThe
OverlayListinstance, which contains all overlays.displayCtxThe
DisplayContextinstance which is responsible for allDisplayandDisplayOptsinstances.nameA unique name for this
DisplayOptsinstance.Warning
DisplayOptssub-classes must not define any properties with the same name as any of theDisplayproperties.-
bounds= <MagicMock name='mock.Bounds()' id='281473494326624'>¶ Specifies a bounding box in the display coordinate system which is big enough to contain the overlay described by this
DisplayOptsinstance.The values in this
boundsproperty must be updated byDisplayOptssubclasses whenever the spatial representation of their overlay changes.
-
__init__(overlay, display, overlayList, displayCtx, **kwargs)[source]¶ Create a
DisplayOptsobject.- Parameters
overlay – The overlay associated with this
DisplayOptsinstance.display – The
Displayinstance which owns thisDisplayOptsinstance.overlayList – The
OverlayListwhich contains all overlays.displayCtx – A
DisplayContextinstance describing how the overlays are to be displayed.
-
destroy()[source]¶ This method must be called when this
DisplayOptsinstance 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
DisplayOptsobject.
-
property
overlayType¶ Return the type of this
DisplayOptsobject (the value ofDisplay.overlayType).
-
property
name¶ Return the name of this
DisplayOptsobject.
-
property
referenceImage¶ Return the reference image associated with this
DisplayOptsinstance.Some non-volumetric overlay types (e.g. the
Mesh- seeMeshOpts) may have a referenceNiftiinstance associated with them, allowing the overlay to be localised in the coordinate space defined by theNifti. TheDisplayOptssub-class which corresponds to such non-volumetric overlays should override this method to return that reference image.DisplayOptssub-classes which are associated with volumetric overlays (i.e.Niftiinstances) 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
Niftiinstance returned by sub-class implementations of this method must be in theOverlayList.
-
getReferenceImage= <MagicMock name='mock.utils.deprecated.deprecated()()' id='281473495817568'>¶
-
getLabels()[source]¶ Generates some orientation labels for the overlay associated with this
DisplayOptsinstance.If the overlay is not a
Niftiinstance, 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)labelsThe
(xorient, yorient, zorient)orientations (seeImage.getOrientation())
-