CorpusCallosum.shape.endpoint_heuristic¶
- CorpusCallosum.shape.endpoint_heuristic.connect_diagonally_connected_components(cc_mask)[source]¶
Connect diagonally connected components in the CC mask.
- Parameters:
- cc_mask
np.ndarray Binary mask of the corpus callosum.
- cc_mask
Notes
Modifies the input mask in-place to connect diagonally connected components.
- CorpusCallosum.shape.endpoint_heuristic.extract_cc_contour(cc_mask, contour_smoothing=5)[source]¶
Extract the contour of the CC from the mask using a marching squares approach.
- Parameters:
- cc_mask
np.ndarray Binary mask of the corpus callosum.
- contour_smoothing
int, default=5 Window size for contour smoothing.
- cc_mask
- Returns:
lapy.PolygonA lapy Polygon object with a closed polygon contour.
- CorpusCallosum.shape.endpoint_heuristic.find_cc_endpoints(contour, ac_2d, pc_2d, plot=False)[source]¶
Extracts the contour of the CC, rotates to AC-PC alignment, and determines closest points of CC to AC and PC.
- Parameters:
- contour
np.ndarrayofshape(2,N) Points of the CC contour in AS (millimeter).
- ac_2d
np.ndarrayofshape(2,)andtypefloat 2D AS coordinates of the anterior commissure in millimeter.
- pc_2d
np.ndarrayofshape(2,)andtypefloat 2D AS coordinates of the posterior commissure in millimeter.
- contour
- Returns:
- anterior_posterior_point_indices
pairofints Indices of anterior and posterior points in the contour.
- anterior_posterior_point_indices
Notes
Expects AS orientation of contour, ac_2d, and pc_2d.
- CorpusCallosum.shape.endpoint_heuristic.smooth_contour(x, y, window_size)[source]¶
Smooth a contour using a moving average filter.
- Parameters:
- x
np.ndarray X-coordinates of the contour points.
- y
np.ndarray Y-coordinates of the contour points.
- window_size
int Size of the smoothing window. Must be odd and > 2.
- x
- Returns:
tuple[np.ndarray,np.ndarray]Smoothed x and y coordinates of the contour.