fsleyes.gl.textures.colourmaptexture

This module provides the ColourMapTexture class, a 1D Texture which can be used to store a RGBA colour map.

class fsleyes.gl.textures.colourmaptexture.ColourMapTexture(name)[source]

Bases: fsleyes.gl.textures.texture.Texture

The ColourMapTexture class is a Texture which stores a RGB or RGBA colour map.

A ColourMapTexture maps a data range to to a colour map. The data range may be specified by the setDisplayRange() method, and the colour map by the setColourMap() method. Alternately, both can be specified with the set() method.

In OpenGL, textures are indexed with a number between 0.0 and 1.0. So in order to map the data range to texture coordinates, an offset/scale transformation must be applied to data values. The ColourMapTexture calculates this transformation, and makes it available via the getCoordinateTransform() method.

The colour map itself can be specified in a number of ways:

  • A numpy array of size \(N\times 3\) or \(N\times 4\), containing RGB or RGBA colour values, with colour values in the range [0, 1].

  • A function which accepts an array of values in the range [0, 1], and returns an array of size \(N\times 3\) or \(N\times 4\), specifying the RGB/RGBA colours that correspond to the input values.

Some other methods are provided, for configuring the colour map:

setAlpha

Set the transparency of all colours in the colour map.

setInvert

Invert the values in the colour map.

setResolution

Set the resolution (number of colours) of this ColourMapTexture.

setGamma

Gamma correction - uses gamma as an exponent to weight the colour map towards the low or high end.

setLogScale

Log scaling .

setInterp

Set the interpolation used by this ColourMapTexture - either GL_NEAREST or GL_LINEAR.

setBorder

Set the texture border colour.

__init__(name)[source]

Create a ColourMapTexture.

Parameters

name – A unique name for this ColourMapTexture.

setColourMap(cmap)[source]

Set the colour map stored by the ColourMapTexture.

Parameters

cmap – The colour map, either a numpy array of size \(N\times 3\) or \(N\times 4\), specifying RGB/RGBA colours, or a function which accepts values in the range [0, 1], and generates corresponding RGB/RGBA colours.

setResolution(res)[source]

Set the resolution (number of colours) of this ColourMapTexture. This setting is only applicable when the colour map is specified as a function (see setColourMap()).

setAlpha(alpha)[source]

Set the transparency of all colours in the colour map. This setting is only applicable when the colour map is specified as RGB values.

setInvert(invert)[source]

Invert the values in the colour map.

setGamma(gamma)[source]

Gamma correction - uses gamma as an exponent to weight the colour map towards the low or high end. Only applied if the colour map (see setColourMap()) is specified as a function.

setLogScale(logScale)[source]

Log scaling . Only applied if the colour map (see setColourMap()) is specified as a function.

setInterp(interp)[source]

Set the interpolation used by this ColourMapTexture - either GL_NEAREST or GL_LINEAR.

setDisplayRange(drange)[source]

Set the data range which corresponds to the colours stored in this ColourMapTexture. A matrix which transforms values from from this data range into texture coordinates is available via the getCoordinateTransform() method.

setBorder(border)[source]

Set the texture border colour. If None, the edge colours of the colour map are used as the border.

getCoordinateTransform()[source]

Returns a matrix which transforms values from from the colour map data range (see setDisplayRange()) into texture coordinates.

set(**kwargs)[source]

Set any parameters on this ColourMapTexture. Valid keyword arguments are:

cmap

See setColourMap().

invert

See setInvert().

interp

See setInterp().

alpha

See setAlpha().

resolution

See setResolution().

gamma

See setGamma().

logScale

See setLogScale().

displayRange

See setDisplayRange().

border

See setBorder().

__prepareTextureSettings()

Called by __refresh(). Prepares all of the texture settings, and returns a tuple containing:

  • An array containing the colour map data

  • The display range

  • The interpolation setting

  • The border colour

__refresh()

Called when any settings of this ColourMapTexture are changed. Re-configures the texture.

__annotations__ = {}
__module__ = 'fsleyes.gl.textures.colourmaptexture'