fsleyes.overlay
This module defines the OverlayList
class, which is a simple but
fundamental class in FSLeyes - it is a container for all loaded overlays.
Only one OverlayList
ever exists, and it is shared throughout the entire
application.
What is an overlay?
The definition of an overlay is fairly broad; any object can be added to
the OverlayList
- there is no Overlay
base class, nor any interface
which must be provided by an overlay object. The only requirements imposed on
an overlay type are:
Must be able to be created with a single
__init__
parameter, which is a string specifying the data source location (e.g. a file name) (but see the note below aboutImage
overlays).Must have an attribute called
name
, which is used as the initial display name for the overlay.Must have an attribute called
dataSource
, which is used to identify the source of the overlay data.Must be hashable (i.e. usable as a dictionary key).
Must be supported by the
gl
package .. ok, this is a pretty big requirement .. See theglobject
and thedisplaycontext.OVERLAY_TYPES
documentation for details on how to get started with this one.
One further requirement is imposed on overlay types which derive from the
Image
class:
The
__init__
method for sub-classes of theImage
class must accept theloadData
,calcRange
,indexed
, andthreaded
parameters, and pass them through to the base class__init__
method.
Currently (fsleyes
version 1.3.3) the only overlay types in existence
(and able to be rendered) are:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
This module also provides a few convenience classes and functions:
|
MagicMock is a subclass of Mock with default implementations of most of the magic methods. |
Searches the given |
- class fsleyes.overlay.OverlayList(overlays=None)[source]
Bases:
__main__.docbuilder.run.<locals>.MockClass
Class representing a collection of overlays to be displayed together.
Contains a
props.properties_types.List
property calledoverlays
, containing overlay objects (e.g.Image
orMesh
objects). Listeners can be registered on theoverlays
property, so they are notified when the overlay list changes.An
OverlayList
object has a few wrapper methods around theoverlays
property, allowing theOverlayList
to be used as if it were a list itself.The
loadoverlay
module contains some convenience functions for loading and adding overlays.The
getData()
andsetData()
methods allow arbitrary bits of data associated with an overlay to be stored and retrieved.- __validateOverlay(atts, overlay)
Makes sure that the given overlay object is valid.
- overlays = <MagicMock name='mock.List()' id='140735757651536'>
A list of overlay objects to be displayed.
- initProps(overlay)[source]
Returns a dict containing initial
Display
andDisplayOpts
property values to be used for the givenoverlay
, if they were specified via theappend()
orinsert()
methods.This method requires that there is no overlap between the property names used in
Display
andDisplayOpts
classes.
- getData(overlay, key, *args)[source]
Returns any stored value associated with the specified
overlay
andkey
.- Parameters
default – Default value if there is no value associated with the given
key
. If not specified, and an unknown key is given, aKeyError
is raised.
- find(name)[source]
Returns the first overlay with the given
name
ordataSource
, orNone
if there is no overlay with saidname
/dataSource
.
- insert(index, item, **initProps)[source]
Insert a new overlay into the overlay list.
Any initial
Display
/DisplayOpts
property values may be passed in as keyword arguments.
- append(item, **initProps)[source]
Add a new overlay to the end of the overlay list.
Any initial
Display
/DisplayOpts
property values may be passed in as keyword arguments.
- extend(iterable, **initProps)[source]
Add new overlays to the overlay list.
Any initial
Display
/DisplayOpts
property values may be passed in as keyword arguments, where the argument name is the property name, and the argument value is a dict of{overlay : value}
mappings.
- __annotations__ = {}
- __module__ = 'fsleyes.overlay'
- fsleyes.overlay.findFEATImage(overlayList, overlay)[source]
Searches the given
OverlayList
to see if there is aFEATImage
associated with the givenoverlay
. Returns theFEATImage
if found, otherwise returnsNone
.
- fsleyes.overlay.findMeshReferenceImage(overlayList, overlay)[source]
Searches the
OverlayList
and tries to identify a reference image for the givenMesh
overlay. Returns the identified overlay, orNone
if one can’t be found.