fsl.data.gifti
¶
This class provides classes and functions for working with GIFTI files.
The GIFTI file format specification can be found at http://www.nitrc.org/projects/gifti/
Support is currently very basic - only the following classes/functions are available:
Class which represents a GIFTI surface image.
Extracts surface data from the given
nibabel.gifti.GiftiImage
.Loads vertex data from the given GIFTI file.
Prepares vertex data from the given list of GIFTI data arrays.
Given a GIFTI file, returns a list of other GIFTI files in the same directory which appear to be related with the given one.
-
fsl.data.gifti.
ALLOWED_EXTENSIONS
= ['.surf.gii', '.gii']¶ List of file extensions that a file containing Gifti surface data is expected to have.
-
fsl.data.gifti.
EXTENSION_DESCRIPTIONS
= ['GIFTI surface file', 'GIFTI file']¶ A description for each of the
ALLOWED_EXTENSIONS
.
-
class
fsl.data.gifti.
GiftiMesh
(infile, fixWinding=False, loadAll=False)¶ Bases:
fsl.data.mesh.Mesh
Class which represents a GIFTI surface image. This is essentially just a 3D model made of triangles.
For each GIFTI surface file that is loaded, the
nibabel.gifti.GiftiImage
instance is stored in theMeta
store, with the absolute path to the surface file as the key.-
loadVertices
(infile, key=None, *args, **kwargs)¶ Overrides the
Mesh.loadVertices()
method.Attempts to load vertices for this
GiftiMesh
from the giveninfile
, which may be a GIFTI file or a plain text file containing vertices.
-
loadVertexData
(infile, key=None)¶ Overrides the
Mesh.loadVertexData()
method.Attempts to load data associated with each vertex of this
GiftiMesh
from the giveninfile
, which may be a GIFTI file or a plain text file which contains vertex data.
-
-
fsl.data.gifti.
loadGiftiMesh
(filename)¶ Extracts surface data from the given
nibabel.gifti.GiftiImage
.The image is expected to contain the following``<DataArray>`` elements:
one comprising
NIFTI_INTENT_TRIANGLE
data (vertex indices defining the triangles).one or more comprising
NIFTI_INTENT_POINTSET
data (the surface vertices)
A
ValueError
will be raised if this is not the case.- Parameters
filename – Name of a GIFTI file containing surface data.
- Returns
A tuple containing these values:
The loaded
nibabel.gifti.GiftiImage
instanceA
(M, 3)
array containing the vertex indices forM
triangles.A list of at least one
(N, 3)
arrays containingN
vertices.A
(M, N)
numpy array containingN
data points forM
vertices, orNone
if the file does not contain any vertex data.
-
fsl.data.gifti.
loadGiftiVertexData
(filename)¶ Loads vertex data from the given GIFTI file.
Returns a tuple containing:
The loaded
nibabel.gifti.GiftiImage
objectA
(M, N)
numpy array containingN
data points forM
vertices
-
fsl.data.gifti.
prepareGiftiVertexData
(darrays, filename=None)¶ Prepares vertex data from the given list of GIFTI data arrays.
All of the data arrays are concatenated into one
(M, N)
array, containingN
data points forM
vertices.It is assumed that the given file does not contain any
NIFTI_INTENT_POINTSET
orNIFTI_INTENT_TRIANGLE
data arrays, and which contains either:One
(M, N)
data array containingN
data points forM
verticesOne or more
(M, 1)
data arrays each containing a single data point forM
vertices, and all with the same intent code
Returns a
(M, N)
numpy array containingN
data points forM
vertices.
Given a GIFTI file, returns a list of other GIFTI files in the same directory which appear to be related with the given one. Files which share the same prefix are assumed to be related to the given file.
- Parameters
fname – Name of the file to search for related files for
ftype – If provided, only files with suffixes in this list are searched for. Defaults to files which contain vertex data.