CorpusCallosum.shape.thickness

CorpusCallosum.shape.thickness.cc_thickness(contour_2d, endpoint_idx, n_points=100)[source]

Calculate corpus callosum thickness using Laplace equation.

Parameters:
contour_2dnp.ndarray

Array of shape (N, 2) containing contour points.

endpoint_idxpair of ints

Indices of anterior and posterior endpoints in contour.

n_pointsint, default=100

Number of points for thickness measurement.

Returns:
midline_lengthfloat

Total length of the midline.

thicknessfloat

Mean thickness across all level paths.

curvaturefloat

Mean absolute curvature in degrees.

midline_equidistantnp.ndarray

Equidistant points along the midline in same space as contour2d of shape (N, 2).

levelpathslist[np.ndarray]

Level paths for thickness measurement in same space as contour2d, each of shape (N, 2).

contour_with_thicknessnp.ndarray

Contour coordinates with thickness information in same space as contour2d of shape (N+2, 3).

endpoint_indicespair of ints

Pair of updated indices of anterior and posterior endpoint.

Notes

Uses the Laplace equation to compute thickness by: 1. Creating a triangular mesh from the contour 2. Setting boundary conditions (0 at endpoints, ±1 on sides) 3. Solving Laplace equation to get level sets 4. Computing thickness along level sets

CorpusCallosum.shape.thickness.find_closest_edge(point, contour)[source]

Find the index of the edge closest to the given point.

Parameters:
pointnp.ndarray

2D point coordinates.

contournp.ndarray

Array of shape (N, 2) containing contour points.

Returns:
int

Index of the closest edge.

CorpusCallosum.shape.thickness.insert_point_with_thickness(contour_in_as_space, contour_thickness, point, thickness_value, return_index=False)[source]

Inserts a point and its thickness value into the contour.

Parameters:
contour_in_as_spacenp.ndarray

Array of coordinates of the contour in AS space, shape (N, 2).

contour_thicknessnp.ndarray

Array of thickness values of the contour, shape (N,).

pointnp.ndarray

2D point to insert, shape (2,).

thickness_valuefloat

Thickness value corresponding to the point.

return_indexbool, default=False

If True, return the index where point was inserted, by default False.

Returns:
contour_in_as_spacenp.ndarray

Updated contour of shape (N+1, 2).

contour_thicknessnp.ndarray

Updated thickness values of shape (N+1,).

insertion_indexint

The index, where the point was inserted (only if return_index is True).

CorpusCallosum.shape.thickness.make_mesh_from_contour(contour_2d, max_volume=0.5, min_angle=25, verbose=False)[source]

Create a triangular mesh from a 2D contour.

Parameters:
contour_2dnp.ndarray

Array of shape (N, 2) containing contour points.

max_volumefloat, optional

Maximum triangle area, by default 0.5.

min_anglefloat, optional

Minimum angle in triangles (degrees), by default 25.

verbosebool, optional

Whether to print mesh generation info, by default False.

Returns:
mesh_pointsnp.ndarray

Array of shape (M, 2) containing mesh vertices.

mesh_triasnp.ndarray

Array of shape (K, 3) containing triangle indices.

Notes

Uses meshpy.triangle to create a constrained Delaunay triangulation of the contour. The contour must not have duplicate points.

CorpusCallosum.shape.thickness.set_contour_zero_idx(contour, idx, anterior_endpoint_idx, posterior_endpoint_idx)[source]

Roll contour points to set a new zero index, while keeping track of CC endpoints.

Parameters:
contournp.ndarray

Array of contour points.

idxint

New zero index.

anterior_endpoint_idxint

Index of anterior endpoint.

posterior_endpoint_idxint

Index of posterior endpoint.

Returns:
contournp.ndarray

Rolled contour points.

anterior_endpoint_idxint

Updated anterior endpoint index.

posterior_endpoint_idxint

Updated posterior endpoint index.