recon_surf.sample_parc¶
- recon_surf.sample_parc.construct_adj_cluster(tria, annot)[source]¶
Compute adjacency matrix of edges from same annotation label only.
Operates only on triangles and removes edges that cross annotation label boundaries.
- Returns:
csc_matrix
The non-directed adjacency matrix will be symmetric. Each inner edge (i,j) will have the number of triangles that contain this edge. Inner edges usually 2, boundary edges 1. Higher numbers can occur when there are non-manifold triangles. The sparse matrix can be binarized via: adj.data = np.ones(adj.data.shape).
- recon_surf.sample_parc.find_all_islands(surf, annot)[source]¶
Find vertices in disconnected islands for all labels in surface annotation.
- Parameters:
- surf
tuple
Surface as returned by nibabel fs.read_geometry, where: surf[0] is the np.array of (n, 3) vertex coordinates and surf[1] is the np.array of (m, 3) triangle indices.
- annot
np.ndarray
Annotation as an int array of (n,) with label ids for each vertex. This is for example the first element of the tuple returned by nibabel fs.read_annot.
- surf
- Returns:
- vidx
np.ndarray
(i,) Array listing vertex indices of island vertices, empty if no islands (components disconnetcted from largest label region) are found.
- vidx
- recon_surf.sample_parc.options_parse()[source]¶
Create a command line interface and return command line options.
- Returns:
- options
argparse.Namespace
Namespace object holding options.
- options
- recon_surf.sample_parc.replace_labels(img_labels, img_lut, surf_lut)[source]¶
Replace image labels with corresponding surface labels or unknown.
- Parameters:
- img_labels
np.ndarray
(n,) Array with image label ids.
- img_lut
str
Filename for image label look up table.
- surf_lut
str
Filename for surface label look up table.
- img_labels
- Returns:
- surf_labels
np.ndarray
(n,) Array with surface label ids.
- surf_ctab
np.ndarray
shape
(m,4) Surface color table (RGBA).
- surf_names
np.ndarray
[str
]shape
(m,) Names of label regions.
- surf_labels
- recon_surf.sample_parc.sample_img(surf, img, cortex=None, projmm=0.0, radius=None)[source]¶
Sample volume at a distance from the surface.
- Parameters:
- surf
tuple
|str
Surface as returned by nibabel fs.read_geometry, where: surf[0] is the np.array of (n, 3) vertex coordinates and surf[1] is the np.array of (m, 3) triangle indices. If type is str, read surface from file.
- img
nibabel.image
|str
Image to sample. If type is str, read image from file.
- cortex
np.ndarray
|str
Filename of cortex label or np.array with cortex indices.
- projmm
float
Sample projmm mm along the surface vertex normals (default=0).
- radius
float
,optional
If given and if the sample is equal to zero, then consider all voxels inside this radius to find a non-zero value.
- surf
- Returns:
- samples
np.ndarray
(n,) Sampled values.
- samples
- recon_surf.sample_parc.sample_nearest_nonzero(img, vox_coords, radius=3.0)[source]¶
Sample closest non-zero value in a ball of radius around vox_coords.
- Parameters:
- Returns:
- samples
np.ndarray
(n,) Sampled values, returns zero for vertices where values are zero in ball.
- samples
- recon_surf.sample_parc.sample_parc(surf, seg, imglut, surflut, outaparc, cortex=None, projmm=0.0, radius=None)[source]¶
Sample cortical GM labels from image to surface and smooth.
- Parameters:
- surf
tuple
|str
Surface as returned by nibabel fs.read_geometry, where: surf[0] is the np.array of (n, 3) vertex coordinates and surf[1] is the np.array of (m, 3) triangle indices. If type is str, read surface from file.
- seg
nibabel.image
|str
Image to sample. If type is str, read image from file.
- imglut
str
Filename for image label look up table.
- surflut
str
Filename for surface label look up table.
- outaparc
str
Filename for output surface parcellation.
- cortex
np.ndarray
|str
Filename of cortex label or np.ndarray with cortex indices.
- projmm
float
Sample projmm mm along the surface vertex normals (default=0).
- radius
float
,optional
If given and if the sample is equal to zero, then consider all voxels inside this radius to find a non-zero value.
- surf