recon_surf.smooth_aparc

recon_surf.smooth_aparc.bincount2D_vectorized(a)[source]

Count number of occurrences of each value in array of non-negative ints.

Parameters:
anp.ndarray

Input 2D array of non-negative ints.

Returns:
np.ndarray

Array of counted values.

recon_surf.smooth_aparc.get_adjM(trias, n)[source]

Create symmetric sparse adjacency matrix of triangle mesh.

Parameters:
triasnpt.NDArray[int](m, 3)

Triangle mesh matrix.

nint

Shape of output (n,n) adjaceny matrix, where n>=m.

Returns:
adjMnp.ndarray (bool) shape (n,n)

Symmetric sparse CSR adjacency matrix, true corresponds to an edge.

recon_surf.smooth_aparc.main(insurfname, inaparcname, incortexname, outaparcname)[source]

Read files, smooth the aparc labels on the surface and save the smoothed labels.

Parameters:
insurfnamestr

Suface filepath and name of source.

inaparcnamestr

Annotation filepath and name of source.

incortexnamestr

Label filepath and name of source.

outaparcnamestr

Surface filepath and name of destination.

recon_surf.smooth_aparc.mode_filter(adjM, labels, fillonlylabel=None, novote=[])[source]

Apply mode filter (smoothing) to integer labels on mesh vertices.

Parameters:
adjMsparse.csr_matrix[bool]

Symmetric adjacency matrix defining edges between vertices, this determines what edges can vote so usually one adds the identity to the adjacency matrix so that each vertex is included in its own vote.

labelsnpt.NDArray[int]

List of integer labels at each vertex of the mesh.

fillonlylabelint

Label to fill exclusively. Defaults to None to smooth all labels.

novotenpt.ArrayLike

Label ids that should not vote. Defaults to [].

Returns:
labels_newnpt.NDArray[int]

New smoothed labels.

recon_surf.smooth_aparc.options_parse()[source]

Create a command line interface and return command line options.

Returns:
options

Namespace object holding options.

recon_surf.smooth_aparc.smooth_aparc(surf, labels, cortex=None)[source]

Smooth aparc label regions on the surface and fill holes.

First all labels with 0 and -1 unside cortex are filled via repeated mode filtering, then all labels are smoothed first with a wider and then with smaller filters to produce smooth label boundaries. Labels outside cortex are set to -1 at the end.

Parameters:
surfnibabel surface

Suface filepath and name of source.

labelsnp.array[int]

Labels at each vertex (int).

cortexnp.array[int]

Vertex ids inside cortex mask.

Returns:
smoothed_labelsnp.array[int]

Smoothed labels.