Cortex¶
from mcot.surface.cortex import Cortex
-
class
mcot.surface.cortex.
Cortex
(surfaces)[source]¶ A cortex defined by 2 or more cortical meshes (sorted from inner to outer).
The first one will generally be the white/gray matter boundary and the last one the pial surface with arbitrarily many cortical meshes defined in between.
A ValueError will be raised if the cortical meshes describe different structures
-
__init__
(surfaces)[source]¶ Creates a new cortex from the provided cortical meshes.
- Parameters
surfaces (Iterable[CorticalMesh]) – 2 or more cortical meshes describing the same brain structure (in the same hemisphere if appropriate)
- Raises
ValueError
Inheritance diagram
Methods
distance
(mask[, affine])Computes for each non-zero voxel in mask the closest vertex.
gyral_bias
(curvature[, use_cortex, …])Computes the theoretical gyral bias based on a script originally derived by David van Essen.
segment
(shape[, affine])Segments a volume based on the cortical meshes.
volume
([use_wb])Computes the total volume of the cortex.
wedge_volume
([use_wb, atpoint])Computes the total wedge volume associated with every mesh triangle.
Attributes
hemisphere
Hemisphere containing the structure described by the cortical meshes.
nfaces
Number of faces in the cortical meshes.
nvertices
Number of vertices in the cortical meshes.
primary
Name of the structure described by the cortical meshes.
-
distance¶
-
Cortex.
distance
(mask, affine=None)[source]¶ Computes for each non-zero voxel in mask the closest vertex.
Each vertex is represented by the line elements connecting that surface between the different cortical layers. The distance to each voxel center is calculated based on the distance to these line element.
- Parameters
mask – (Nx, Ny, Nz) array, which is non-zero for all the voxels that will be processed
affine – transformation from the voxel space of mask to the mm-space in which the cortex has been defined
- Returns
labeled array with ‘distance’, ‘closest’, ‘valid’:
valid: boolean, which is True wherever the input mask is non-zero
distance: contains the distance from the closest vertex (np.inf wherever the input mask is zero)
closest: contains the index of the closest vertex (-1 wherever the input mask is zero)
gyral_bias¶
-
Cortex.
gyral_bias
(curvature, use_cortex=None, zero_curv_threshold=0.05)[source]¶ Computes the theoretical gyral bias based on a script originally derived by David van Essen.
Converted from a matlab script from Stamatios Sotiropoulos.
- Parameters
curvature – (N, ) array describing the curvature of the surface at every point
use_cortex – which part of the cortex to consider (e.g. remove the medial wall), default: not masked
zero_curv_threshold – threshold below which the surface is considered to be flat
- Returns
(Nfaces, )-array with the relative fiber density expected to cross each surface element
segment¶
-
Cortex.
segment
(shape, affine=None)[source]¶ Segments a volume based on the cortical meshes.
- Parameters
shape – (Nx, Ny, Nz) tuple giving the shape of the resulting array
affine – (4 x 4) array giving the transformation from voxel to mm coordinates
- Returns
(Nx x Ny x Nz) array, that is 0 outside the brain, and increases by 1 for every surface crossed into the brain (so WM will be len(self.surfaces)).
volume¶
wedge_volume¶
-
Cortex.
wedge_volume
(use_wb=False, atpoint=False)[source]¶ Computes the total wedge volume associated with every mesh triangle.
Uses the algorithm from http://dx.doi.org/10.1101/074666 (Winkler et al, 2016)
- Parameters
use_wb – use workbench to compute the wedge volume if True (about 1.5 times larger than my implementation)
atpoint – if True assigns the wedge volume to the vertices rather than the faces
- Returns
(Nfaces, )-array with the wedge volume for every surface element