fsleyes.gl.gllabel

This module provides the GLLabel class, which implements functionality to render an Image overlay as a label/atlas image.

class fsleyes.gl.gllabel.GLLabel(image, overlayList, displayCtx, canvas, threedee)

Bases: fsleyes.gl.glimageobject.GLImageObject

The GLLabel class is a GLImageObject which encapsulates the logic required to render an Image overlay as a label image. Within the image, each contiguous region with the same label value is rendered in the same colour. Regions may be shown either with a filled colour, or with a border around them.

When created, a GLLabel instance assumes that the provided Image instance has a Display.overlayType of label, and that its associated Display instance contains a LabelOpts instance, containing label-specific display properties.

An ImageTexture is used to store the Image data, and a LookupTableTexture used to store the LookupTable (defined by the LabelOpts.lut property). OpenGL version-specific modules (gl14.gllabel_funcs and gl21.gllabel_funcs) are used to configure the vertex/fragment shader programs used for rendering.

The GLLabel class is modelled upon the GLVolume class, and the version specific modules for the GLLabel class must provide the same set of functions that are required by the GLVolume class.

__init__(image, overlayList, displayCtx, canvas, threedee)

Create a GLLabel.

Parameters
  • image – The Image instance.

  • overlayList – The OverlayList

  • displayCtx – The DisplayContext managing the scene.

  • canvas – The canvas doing the drawing.

  • threedee – 2D or 3D rendering

destroy()

Must be called when this GLLabel is no longer needed. Destroys the ImageTexture and LookupTableTexture.

ready()

Returns True if this GLLabel is ready to be drawn, False otherwise.

textureReady()

Returns True if the imageTexture is ready to be used, False otherwise.

updateShaderState(*args, **kwargs)

Calls gl14.gllabel_funcs.updateShaderState() or gl21.gllabel_funcs.updateShaderState(), and Notifier.notify(). Uses idle.idleWhen() to ensure that they don’t get called until ready() returns True.

addListeners()

Called by __init__(). Adds listeners to several properties of the Display and LabelOpts instances, so the OpenGL representation can be updated when they change.

removeListeners()

Called by destroy(). Removes all of the listeners that were added by addListeners().

refreshImageTexture()

Makes sure that the ImageTexture, used to store the Image data, is up to date.

refreshLutTexture(*a)

Refreshes the LookupTableTexture which stores the LookupTable used to colour the overlay.

registerLut()

Registers a listener on the current LookupTable instance.

preDraw(xform=None, bbox=None)

Binds the ImageTexture and LookupTableTexture, and calls the version-dependent preDraw function.

draw2D(zpos, axes, xform=None, bbox=None)

Calls the version-dependent draw2D function.

draw3D(*args, **kwargs)

Calls the version-dependent draw3D function.

drawAll(axes, zposes, xforms)

Calls the version-dependent drawAll function.

postDraw(xform=None, bbox=None)

Unbinds the ImageTexture and LookupTableTexture, and calls the version-dependent postDraw function.

_GLLabel__colourPropChanged(*a)

Called when a Display property changes (e.g. alpha). Refreshes the LUT texture.

_GLLabel__imagePropChanged(*a)

Called when the NiftiOpts.volume property changes. Updates the imageTexture and calls updateShaderState().

_GLLabel__imageSyncChanged(*a)

Called when the NiftiOpts.volume property is synchronised or un-synchronised. Calls refreshImageTexture() and updateShaderState().

_GLLabel__imageTextureChanged(*a)

Called when the ImageTexture containing the image data changes. Calls updateShaderState().

_GLLabel__lutChanged(*a)

Called when the LabelOpts.lut property changes. Re-creates the LookupTableTexture.

__module__ = 'fsleyes.gl.gllabel'