sarcasm.structure_modules.detection
Neural network-based detection module for sarcomeres and Z-bands.
Attributes
Functions
|
Predict sarcomeres (Z-bands, mbands, distance, orientation) with U-Net. |
|
Predict sarcomere z-bands with 3D U-Net for high-speed movies for improved temporal consistency. |
|
Analyzes the area occupied by cells in the given image(s) and calculates the average cell intensity and |
Module Contents
- sarcasm.structure_modules.detection.logger
- sarcasm.structure_modules.detection.detect_sarcomeres_unet(images: numpy.ndarray, model_path: str, base_dir: str, model_dir: str, pixelsize: float, max_patch_size: Tuple[int, int] = (1024, 1024), normalization_mode: str = 'all', clip_thres: Tuple[float, float] = (0.0, 99.98), rescale_factor: float = 1.0, device: torch.device | str = 'auto', progress_notifier: bio_image_unet.progress.ProgressNotifier = ProgressNotifier.progress_notifier_tqdm())[source]
Predict sarcomeres (Z-bands, mbands, distance, orientation) with U-Net.
- Parameters:
images (np.ndarray) – Images to process.
model_path (str, optional) – Path of trained network weights for U-Net. Default is None.
base_dir (str) – Base directory for output files.
model_dir (str) – Directory containing model files.
pixelsize (float) – Pixel size in micrometers.
max_patch_size (tuple of int, optional) – Maximal patch dimensions for convolutional neural network (n_x, n_y). Default is (1024, 1024).
normalization_mode (str, optional) – Mode for intensity normalization for 3D stacks prior to prediction (‘single’: each image individually, ‘all’: based on histogram of full stack, ‘first’: based on histogram of first image in stack). Default is ‘all’.
clip_thres (tuple of float, optional) – Clip threshold (lower / upper) for intensity normalization. Default is (0., 99.8).
rescale_factor (float, optional) – Factor by which to rescale the input images in the XY dimensions before prediction. For example, 0.5 reduces the XY resolution by half. The images and all subsequent outputs will be rescaled back to their original resolution after prediction. Default is 1.0 (no rescaling).
device (torch.device or str) – Device on which PyTorch kernels are executed.
progress_notifier (ProgressNotifier, optional) – Progress notifier for inclusion in GUI. Default is ProgressNotifier.progress_notifier_tqdm().
- Return type:
None
- sarcasm.structure_modules.detection.detect_z_bands_fast_movie_unet(images: numpy.ndarray, model_path: str, base_dir: str, model_dir: str, max_patch_size: Tuple[int, int, int] = (32, 256, 256), normalization_mode: str = 'all', clip_thres: Tuple[float, float] = (0.0, 99.8), device: torch.device | str = 'auto', progress_notifier: bio_image_unet.progress.ProgressNotifier = ProgressNotifier.progress_notifier_tqdm()) None[source]
Predict sarcomere z-bands with 3D U-Net for high-speed movies for improved temporal consistency.
- Parameters:
images (np.ndarray) – Images to process.
model_path (str, optional) – Path of trained network weights for 3D U-Net. Default is None.
base_dir (str) – Base directory for output.
model_dir (str) – Directory containing model files.
max_patch_size (tuple of int, optional) – Maximal patch dimensions for convolutional neural network (n_frames, n_x, n_y). Dimensions need to be divisible by 16. Default is (32, 256, 256).
normalization_mode (str, optional) – Mode for intensity normalization for 3D stacks prior to prediction (‘single’: each image individually, ‘all’: based on histogram of full stack, ‘first’: based on histogram of first image in stack). Default is ‘all’.
clip_thres (tuple of float, optional) – Clip threshold (lower / upper) for intensity normalization. Default is (0., 99.8).
device (torch.device or str) – Device for PyTorch.
progress_notifier (ProgressNotifier, optional) – Progress notifier for inclusion in GUI. Default is ProgressNotifier.progress_notifier_tqdm().
- Return type:
None
- sarcasm.structure_modules.detection.analyze_cell_mask_from_file(file_cell_mask: str, images: numpy.ndarray, pixelsize: float, frames: str | int | List[int] | numpy.ndarray = 'all', threshold: float = 0.1) Tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray][source]
Analyzes the area occupied by cells in the given image(s) and calculates the average cell intensity and cell area ratio.
- Parameters:
file_cell_mask (str) – Path to the cell mask file.
images (np.ndarray) – Raw images.
pixelsize (float) – Pixel size in micrometers.
frames ({'all', int, list, np.ndarray}, optional) – Frames for z-band analysis (‘all’ for all frames, int for a single frame, list or ndarray for selected frames). Defaults to ‘all’.
threshold (float, optional) – Threshold value for binarizing the cell mask image. Pixels with intensity above threshold are considered cell. Defaults to 0.1.
- Returns:
cell_area (np.ndarray) – Cell area in square micrometers.
cell_area_ratio (np.ndarray) – Ratio of cell area to total image area.
cell_mask_intensity (np.ndarray) – Average intensity in the cell mask.