sarcasm.structure_modules.domain_clustering
Domain clustering and analysis module.
Attributes
Functions
|
This function clusters sarcomeres into domains based on their spatial and orientational properties |
|
Calculates a binary mask of areas with sarcomeres. |
|
Creates a domain mask, where each domain has a distinct label, and analyzes the individual domains. |
|
Assign sarcomere vectors to domains based on their centroid positions. |
Module Contents
- sarcasm.structure_modules.domain_clustering.logger
- sarcasm.structure_modules.domain_clustering.cluster_sarcomeres(pos_vectors: numpy.ndarray, sarcomere_length_vectors: numpy.ndarray, sarcomere_orientation_vectors: numpy.ndarray, pixelsize: float, size: Tuple[int, int], d_max: float = 3, cosine_min: float = 0.65, leiden_resolution: float = 0.06, random_seed: int = 42, area_min: float = 20, dilation_radius: float = 0.3) Tuple[int, List, numpy.ndarray, numpy.ndarray, numpy.ndarray, numpy.ndarray, numpy.ndarray, numpy.ndarray][source]
This function clusters sarcomeres into domains based on their spatial and orientational properties using the Leiden method for community detection in igraph. It considers sarcomere lengths, orientations, and positions along mbands to form networks of connected sarcomeres. Domains are then identified as communities within these networks, with additional criteria for minimum domain area and connectivity thresholds. Finally, this function quantifies the mean and std of sarcomere lengths, and the orientational order parameter and mean orientation of each domain.
- Parameters:
pos_vectors (np.ndarray) – Array of sarcomere midline point positions in µm.
sarcomere_length_vectors (np.ndarray) – List of midline point sarcomere lengths
sarcomere_orientation_vectors (np.ndarray) – List of midline point sarcomere orientations, in radians
pixelsize (float) – Pixel size in µm
size (tuple(int, int)) – Shape of the image in pixels
d_max (float) – Max. distance threshold for creating a network edge between vector ends
cosine_min (float) – Minimal absolute cosine between vector angles for creating a network edge between vector ends
leiden_resolution (float) – Resolution parameter for the Leiden algorithm
random_seed (int) – Random seed for reproducibility
area_min (float) – Minimal area (in µm²) for a domain to be kept
dilation_radius (float) – Dilation radius for refining domain area masks (in µm)
- Returns:
n_domains (int) – Number of domains
domains (list) – List of domain sets with point indices
area_domains (list) – List with domain areas
sarcomere_length_mean_domains (list) – Mean sarcomere length within each domain
sarcomere_length_std_domains (list) – Standard deviation of sarcomere length within each domain
sarcomere_oop_domains (list) – Orientational order parameter of sarcomeres in each domain
sarcomere_orientation_domains (list) – Main orientation of domains
mask_domains (ndarray) – Masks of domains with value representing domain label
- sarcasm.structure_modules.domain_clustering.sarcomere_mask(points: numpy.ndarray, sarcomere_orientation_vectors: numpy.ndarray, sarcomere_length_vectors: numpy.ndarray, shape: Tuple[int, int], pixelsize: float, dilation_radius: float = 0.3) numpy.ndarray[source]
Calculates a binary mask of areas with sarcomeres.
- Parameters:
points (ndarray) – Positions of sarcomere vectors in µm. (n_vectors, 2)
sarcomere_orientation_vectors (ndarray) – Orientations of sarcomere vectors.
sarcomere_length_vectors (ndarray) – Lengths of sarcomere vectors in µm.
shape (tuple) – Shape of the image, in pixels.
pixelsize (float) – Pixel size in µm.
dilation_radius (float, optional) – Dilation radius to close small holes in mask, in µm (default is 0.3).
- Returns:
mask – Binary mask of sarcomeres.
- Return type:
ndarray
- sarcasm.structure_modules.domain_clustering.analyze_domains(domains: List, pos_vectors: numpy.ndarray, sarcomere_orientation_vectors: numpy.ndarray, sarcomere_length_vectors: numpy.ndarray, size: Tuple[int, int], pixelsize: float, dilation_radius: float, area_min: float)[source]
Creates a domain mask, where each domain has a distinct label, and analyzes the individual domains.
- Parameters:
domains (list) – List with domain labels for each vector. Each domain is labeled with a unique integer.
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.
dilation_radius (float, optional) – Dilation radius for refining domain masks, in µm.
area_min (float, optional) – Minimal area of a domain in µm^2, smaller domains are discarded.
- sarcasm.structure_modules.domain_clustering.assign_vectors_to_domains(pos_vectors: numpy.ndarray, domain_mask: numpy.ndarray, pixelsize: float) numpy.ndarray[source]
Assign sarcomere vectors to domains based on their centroid positions.
Uses the domain mask to look up which domain each vector belongs to based on its position. Vectors that fall outside any domain (background) are assigned domain ID 0.
- Parameters:
pos_vectors (np.ndarray) – Array of sarcomere vector positions in µm. Shape (n_vectors, 2).
domain_mask (np.ndarray) – Integer-labeled domain mask where pixel values indicate domain IDs. Background pixels have value 0, domains are labeled 1, 2, 3, etc.
pixelsize (float) – Pixel size in µm for converting positions to pixel coordinates.
- Returns:
domain_ids – Array of domain IDs for each vector. Shape (n_vectors,). Vectors outside any domain have ID 0.
- Return type:
np.ndarray