fsleyes.gl.textures.data

This module contains functions for working with OpenGL texture data:

numTextureDims

Given a 3D image shape, returns the number of dimensions needd to store the image as a texture - either 2 or 3.

canUseFloatTextures

MagicMock is a subclass of Mock with default implementations of most of the magic methods.

oneChannelFormat

MagicMock is a subclass of Mock with default implementations of most of the magic methods.

getTextureType

MagicMock is a subclass of Mock with default implementations of most of the magic methods.

prepareData

This function prepares and returns the given data, ready to be used as GL texture data.

fsleyes.gl.textures.data._makeInstance(dtype)[source]

Used by oneChannelFormat() and getTextureType(). If a numpy.dtype class is given, converts it into an instance.

fsleyes.gl.textures.data.numTextureDims(shape)[source]

Given a 3D image shape, returns the number of dimensions needd to store the image as a texture - either 2 or 3.

Parameters

shape – 3D image shape

Returns

2 if a 2D texture can be used to store the image data, 3 otherwise.

fsleyes.gl.textures.data.prepareData(data, prefilter=None, prefilterRange=None, resolution=None, scales=None, normalise=None, normaliseRange=None)[source]

This function prepares and returns the given data, ready to be used as GL texture data.

This process potentially involves:

  • Resampling to a different resolution (see the routines.subsample() function).

  • Pre-filtering (see the prefilter parameter to __init__()).

  • Normalising (if the normalise parameter to __init__() was True, or if the data type cannot be used as-is).

  • Casting to a different data type (if the data type cannot be used as-is).

Returns

A tuple containing:

  • A numpy array containing the image data, ready to be

    copied to the GPU.

  • An affine transformation matrix which encodes an offset and a scale, which may be used to transform the texture data from the range [0.0, 1.0] to its raw data range.

  • Inverse of voxValXform.