fsl.data.freesurfer
This module provides the FreesurferMesh class, which can be
used for loading Freesurfer geometry and vertex data files.
The following types of files generated by Freesurfer are recognised by this module:
Core geometry files, defining the cortical mesh. Each core geometry file has the same number of vertices and same triangle definitions.
Extra geometry files, defining the cortical mesh. Extra geometry files may have a different number of vertices and/or triangle definitions.
Vertex data files (a.k.a.
'curv'files), containing a scalar value for every vertex in the mesh. This data may also be contained inmgz/mghfiles.Label files, containing indices of a sub-set of vertices in the mesh.
Annotation files, containing a label value, and an RGBA colour for a subset of vertices in the mesh.
The following functions are also available:
Loads the given Freesurfer vertex data, label, or annotation file.
isCoreGeometryFileDecorator which can be used to memoize a function or method. Use like so::.
isGeometryFileDecorator which can be used to memoize a function or method. Use like so::.
isVertexDataFileDecorator which can be used to memoize a function or method. Use like so::.
isVertexLabelFileDecorator which can be used to memoize a function or method. Use like so::.
isVertexAnnotFileDecorator which can be used to memoize a function or method. Use like so::.
Returns a list of all files which (look like they) are freesurfer geometry files which correspond to the given geometry file.
Returns a list of all files which (look like they) are vertex data, label, or annotation files related to the given freesurfer geometry file.
Attempts to locate the volumetric reference image for (what is assumed to be) the given Freesurfer geometry file.
- fsl.data.freesurfer.CORE_GEOMETRY_FILES = ['?h.orig', '?h.pial', '?h.white', '?h.inflated', '?h.sphere', '?h.pial_semi_inflated']
File patterns for identifying the core Freesurfer geometry files.
- fsl.data.freesurfer.CORE_GEOMETRY_DESCRIPTIONS = ['Freesurfer surface (original)', 'Freesurfer surface (pial)', 'Freesurfer surface (white matter)', 'Freesurfer surface (inflated)', 'Freesurfer surface (sphere)', 'Freesurfer surface (pial semi-inflated)']
A description for each extension in
GEOMETRY_EXTENSIONS.
- fsl.data.freesurfer.EXTRA_GEOMETRY_FILES = ['?h.orig.nofix', '?h.smoothwm.nofix', '?h.inflated.nofix', '?h.qsphere.nofix', '?h.sphere.nofix', '?h.white.preaparc']
Other geometry files which may be present in Freesurfer output.
- fsl.data.freesurfer.VERTEX_DATA_FILES = ['?h.thickness', '?h.curv', '?h.area', '?h.sulc']
File patterns which are interpreted as Freesurfer vertex data files, containing a scalar value for every vertex in the mesh.
- fsl.data.freesurfer.VERTEX_MGH_FILES = ['?h.*.mgh', '?h.*.mgz']
File patterns which are interpreted as MGH files containing a scalar value for every vertex in the mesh.
- fsl.data.freesurfer.VERTEX_LABEL_FILES = ['?h.*.label']
File patterns which are interpreted as Freesurfer vertex label files, containing a scalar value for a sub-set of vertices in the mesh.
- fsl.data.freesurfer.VERTEX_ANNOT_FILES = ['?h.*.annot']
File patterns which are interpreted as Freesurfer vertex annotation files, containing a scalar value and an RGBA colour for a sub-set of vertices in the mesh.
- class fsl.data.freesurfer.FreesurferMesh(*args, **kwargs)[source]
Bases:
MeshThe
FreesurferMeshclass represents a triangle mesh loaded from a Freesurfer geometry file.- __init__(filename, fixWinding=False, loadAll=False)[source]
Load the given Freesurfer surface file using
nibabel.- Parameters:
infile – A Freesurfer geometry file (e.g.
*.pial).fixWinding – Passed through to the
addVertices()method for the first vertex set.loadAll – If
True, theinfiledirectory is scanned for other freesurfer surface files which are then loaded as additional vertex sets.
- loadVertices(infile, key=None, **kwargs)[source]
Overrides
Mesh.loadVertices(). If the giveninfilelooks like a Freesurfer file, it is loaded vianibabel.freesurfer.load_geometry. Otherwise, it is passed toMesh.loadVertices().
- loadVertexData(infile, key=None)[source]
Overrides
Mesh.loadVertexData(). If the giveninfilelooks like a Freesurfer file, it is loaded via theloadVertexDataFile()function. Otherwise, it is passed through to the base-class function.If the given
infileis a vertex annotation file, it is assumed that the file contains a value for every vertex in the mesh.
- getVertexDataColourTable(key)[source]
If the given
keyrefers to a Freesurfer.annotfile, the corresponding RGBA lookup table and label names can be retrieved via this method.
- __annotations__ = {}
- __module__ = 'fsl.data.freesurfer'
- fsl.data.freesurfer.loadVertexDataFile(infile)[source]
Loads the given Freesurfer vertex data, label, or annotation file.
This function return different things depending on what
infileis:If
infileis a vertex data file, a(nvertices,)array is returned, containing one value for each vertex in the mesh.If
infileis amgh/mgzfile, the image data is returned as-is, with dimensions of length 1 squeezed out (under the assumption that the image contains scalar vertex data).If
infileis a vertex label file, a tuple containing the following is returned:a
(n,)array, containing the indices of all vertices that are specified in the file.a
(n,)array, containing scalar value for each vertex
If
infileis a vertex annotation file, a tuple containing the following is returned:a
(n,)array containing the indices of allnvertices that are specified in the file.a
(l, 5)array containing the RGBA colour, and the label value, for every label that is specified in the file.A list of length
l, containing the names of every label that is specified in the file.
Returns a list of all files which (look like they) are freesurfer geometry files which correspond to the given geometry file.
Returns a list of all files which (look like they) are vertex data, label, or annotation files related to the given freesurfer geometry file.