fsleyes.gl.textures.imagetexture¶
This module provides the ImageTexture and ImageTexture2D
classes, Texture3D and Texture2D classes for storing an
Image instance.
-
fsleyes.gl.textures.imagetexture.createImageTexture(name, image, *args, **kwargs)[source]¶ Creates and returns an appropriate texture type (either
ImageTextureorImageTexture2D) for the given image.
-
class
fsleyes.gl.textures.imagetexture.ImageTextureBase(image, nvals, ndims)[source]¶ Bases:
objectBase class shared by the
ImageTextureandImageTexture2Dclasses. Contains logic for retrieving a specific volume from a 3D + time or 2D + timeImage, and for retrieving a specific channel from an RGB(A)Image.-
static
validateShape(image, texnvals, texndims)[source]¶ Called by
__init__(). Makes sure that the specified texture settings (number of dimensions, and number of values per texture element) are compatible with the image.- Parameters
image –
Imagetexnvals – Number of values per texture element
texndims – Number of texture dimensions
- Raises
RuntimeErrorif the texture properties are not compatible with the image
-
__init__(image, nvals, ndims)[source]¶ Create an
ImageTextureBase- Parameters
image – The
Imagenvals – Number of values per texture element
ndims – Number of texture dimensions
-
property
image¶ Returns the
Imagemanaged by thisImageTextureBase.
-
property
volume¶ For
Imageinstances with more than three dimensions, specifies the indices for the fourth and above dimensions with which to extract the 3D texture data. If the image has four dimensions, this may be a scalar, otherwise it must be a sequence of (Image.ndim - 3) the correct length.
-
property
channel¶ For
Imageinstances with multiple values per voxel, such asRGB24orRGBA32images, this option allows the channel to be selected.
-
prepareSetArgs(**kwargs)[source]¶ Called by sub-classes in their
Texture2D.set()/Texture3D.set()override.Prepares arguments to be passed through to the underlying
setmethod. This method accepts any parameters that are accepted byTexture3D.set(), plus the following:volumeSee
volume().channelSee
channel().volRefreshIf
True(the default), the texture data will be refreshed even if thevolumeandchannelparameters haven’t changed. Otherwise, ifvolumeandchannelhaven’t changed, the texture will not be refreshed.- Returns
Trueif any settings have changed and theImageTextureis to be refreshed ,Falseotherwise.
-
_ImageTextureBase__getData(volume, channel)¶ Extracts data from the
Imagefor use as texture data.For textures with multiple values per element (either by volume, or by channel), the data is arranged appropriately, i.e. with the value as the first dimension.
- Parameters
volume – Volume index/indices, for images with more than three dimensions.
channel – Channel, for RGB(A) images.
-
_ImageTextureBase__imageDataChanged(image, topic, sliceobj)¶ Called when the
Imagenotifies about a data changes. Triggers an image texture refresh via a call toset().- Parameters
image – The
Imageinstancetopic – The string
'data'sliceobj – Slice object specifying the portion of the image that was changed.
-
__dict__= mappingproxy({'__module__': 'fsleyes.gl.textures.imagetexture', '__doc__': 'Base class shared by the :class:`ImageTexture` and\n :class:`ImageTexture2D` classes. Contains logic for retrieving a\n specific volume from a 3D + time or 2D + time :class:`.Image`, and\n for retrieving a specific channel from an RGB(A) ``Image``.\n ', 'validateShape': <staticmethod object>, '__init__': <function ImageTextureBase.__init__>, 'destroy': <function ImageTextureBase.destroy>, 'image': <property object>, 'volume': <property object>, 'channel': <property object>, 'prepareSetArgs': <function ImageTextureBase.prepareSetArgs>, '_ImageTextureBase__getData': <function ImageTextureBase.__getData>, '_ImageTextureBase__imageDataChanged': <function ImageTextureBase.__imageDataChanged>, '__dict__': <attribute '__dict__' of 'ImageTextureBase' objects>, '__weakref__': <attribute '__weakref__' of 'ImageTextureBase' objects>})¶
-
__module__= 'fsleyes.gl.textures.imagetexture'¶
-
__weakref__¶ list of weak references to the object (if defined)
-
static
-
class
fsleyes.gl.textures.imagetexture.ImageTexture(name, image, **kwargs)[source]¶ Bases:
fsleyes.gl.textures.imagetexture.ImageTextureBase,fsleyes.gl.textures.texture3d.Texture3DThe
ImageTextureclass contains the logic required to create and manage a 3D texture which represents aImageinstance.Once created, the
Imageinstance is available as an attribute of anImageTextureobject, calledimage. See theTexture3Ddocumentation for more details.For multi-valued (e.g. RGB) textures, the
Texture3Dclass requires data to be passed as a(C, X, Y, Z)array (forCvalues). If anImageTextureis created with an image of typeNIFTI_TYPE_RGB24orNIFTI_TYPE_RGBA32, it will take care of re-arranging the image data so that it has the shape required by theTexture3Dclass.-
threadedDefault= None¶ Default value used for the
threadedargument passed to__init__(). When this is set toNone, the default value will be the value offsl.utils.platform.Platform.haveGui.
-
classmethod
enableThreading(enable=True)[source]¶ Context manager which can be used to temporarily set the default value of the
threadedargument passedto__init__().
-
__init__(name, image, **kwargs)[source]¶ Create an
ImageTexture. A listener is added to theImage.dataproperty, so that the texture data can be refreshed whenever the image data changes - see the__imageDataChanged()method.- Parameters
name – A name for this
imageTexure.image – The
Imageinstance.volume – Initial volume index/indices, for >3D images.
All other arguments are passed through to the
Texture3D.__init__()method, and thus used as initial texture settings.Note
The default value of the
threadedparameter is set to the value ofthreadedDefault.
-
set(**kwargs)[source]¶ Overrides
Texture3D.set(). Passes all arguments through theprepareSetArgs()method, then passes them on toTexture3D.set().- Returns
Trueif any settings have changed and theImageTextureis to be refreshed ,Falseotherwise.
-
__module__= 'fsleyes.gl.textures.imagetexture'¶
-
-
class
fsleyes.gl.textures.imagetexture.ImageTexture2D(name, image, **kwargs)[source]¶ Bases:
fsleyes.gl.textures.imagetexture.ImageTextureBase,fsleyes.gl.textures.texture2d.Texture2DThe
ImageTexture2Dclass is the 2D analogue of theImageTextureclass, for managing a 2D texture which represents anImageinstance.-
__module__= 'fsleyes.gl.textures.imagetexture'¶
-