sarcasm.structure_modules.myofibril_analysis
Myofibril line detection and analysis module.
Attributes
Functions
|
Grow a single line from a seed point. |
|
Line growth algorithm to determine myofibril lines perpendicular to sarcomere z-bands |
|
The create_myofibril_length_map function generates a 2D spatial map of myofibril lengths represented |
Module Contents
- sarcasm.structure_modules.myofibril_analysis.logger
- sarcasm.structure_modules.myofibril_analysis.grow_line(seed, points_t, sarcomere_length_vectors_t, sarcomere_orientation_vectors_t, tree, threshold_distance, pixelsize, persistence)[source]
Grow a single line from a seed point.
- Parameters:
seed (int) – Index of the seed point.
points_t (np.ndarray) – Array of point coordinates.
sarcomere_length_vectors_t (np.ndarray) – Sarcomere lengths at each point.
sarcomere_orientation_vectors_t (np.ndarray) – Sarcomere orientations at each point.
tree (scipy.spatial.cKDTree) – Fitted cKDTree for nearest-neighbor queries.
threshold_distance (float) – Maximum distance for neighbor search in pixels.
pixelsize (float) – Pixel size in µm.
persistence (int) – Number of points to consider for averaging.
- Returns:
Array of indices forming the line.
- Return type:
np.ndarray
- sarcasm.structure_modules.myofibril_analysis.line_growth(points_t: numpy.ndarray, sarcomere_length_vectors_t: numpy.ndarray, sarcomere_orientation_vectors_t: numpy.ndarray, midline_length_vectors_t: numpy.ndarray, pixelsize: float, ratio_seeds: float = 0.1, persistence: int = 4, threshold_distance: float = 0.3, n_min: int = 5, random_seed: None | int = None)[source]
Line growth algorithm to determine myofibril lines perpendicular to sarcomere z-bands
- Parameters:
points_t (np.ndarray) – List of midline point positions
sarcomere_length_vectors_t (list) – Sarcomere length at midline points
sarcomere_orientation_vectors_t (list) – Sarcomere orientation angle at midline points, in radians
midline_length_vectors_t (list) – Length of sarcomere mbands of midline points
pixelsize (float) – Pixel size in µm
ratio_seeds (float) – Ratio of sarcomere vectors to be takes as seeds for line growth
persistence (int) – Number of points to consider for averaging length and orientation.
random_seed (int, optional) – Random seed for reproducibility. Defaults to None.
- Returns:
line_data – Dictionary with LOI data keys = (lines, line_features)
- Return type:
dict
- sarcasm.structure_modules.myofibril_analysis.create_myofibril_length_map(myof_lines: numpy.ndarray, myof_length: numpy.ndarray, pos_vectors: numpy.ndarray, sarcomere_orientation_vectors: numpy.ndarray, sarcomere_length_vectors: numpy.ndarray, size: tuple, pixelsize: float, median_filter_radius: float = 0.6) numpy.ndarray[source]
The create_myofibril_length_map function generates a 2D spatial map of myofibril lengths represented as pixel values. It achieves this by rasterizing myofibril line segments, assigning their corresponding lengths to the pixels they occupy, and averaging these values at overlapping pixels. The resulting map is optionally smoothed using a median filter to reduce noise and provide a more coherent spatial representation.
- Parameters:
myof_lines (ndarray) – Line indices for myofibril structures.
myof_length (ndarray) – Length values for each myofibril line.
pos_vectors (ndarray) – Position vectors in micrometers.
sarcomere_orientation_vectors (ndarray) – Orientation angles in radians.
sarcomere_length_vectors (ndarray) – Sarcomere lengths in micrometers.
size (tuple of int) – Output map dimensions (height, width) in pixels.
pixelsize (float) – Physical size of one pixel in micrometers.
median_filter_radius (float, optional) – Filter radius in micrometers, by default 0.6.
- Returns:
2D array of calculated myofibril lengths with NaN for empty regions.
- Return type:
ndarray