megafish.segment module
- watershed_label(zarr_path, group, min_distance, footer='_wts')[source]
Applies watershed segmentation to the image data.
- Parameters:
zarr_path (str) – Path to the Zarr file containing the image data.
group (str) – Group name in the Zarr file where the data is stored.
footer (str, optional) – Footer string to append to the output Zarr group name; defaults to “_wts”.
min_distance (int) – Minimum distance between peaks in the distance map.
- Returns:
The function saves the segmented result to a new Zarr group.
- Return type:
None
- dilation(zarr_path, group, mask_radius, footer='_dil')[source]
Applies a binary dilation operation to the image data.
- Parameters:
zarr_path (str) – Path to the Zarr file containing the image data.
group (str) – Group name in the Zarr file where the data is stored.
mask_radius (int) – Radius of the structuring element used for dilation.
footer (str, optional) – Footer string to append to the output Zarr group name; defaults to “_dil”.
- Returns:
The function saves the dilated result to a new Zarr group.
- Return type:
None
- merge_split_label(zarr_path, group, footer='_msl')[source]
Merges split labels in an image dataset by applying offsets and resolving conflicts.
- Parameters:
- Returns:
The function saves the merged label dataset to a new Zarr group.
- Return type:
None
- grow_voronoi(zarr_path, group, depth, max_distance, footer='_vor')[source]
Expands labeled regions in an image using a Voronoi-like approach, filling the image based on the nearest labeled pixel within a specified maximum distance.
- Parameters:
zarr_path (str) – Path to the Zarr file containing the image data.
group (str) – Group name in the Zarr file where the image data is stored.
depth (int) – The depth of overlap used when applying the Voronoi expansion across chunks.
max_distance (float) – The maximum allowable distance for a pixel to be filled based on the nearest label.
footer (str, optional) – Footer string to append to the output Zarr group name; defaults to “_vor”.
- Returns:
This function saves the expanded Voronoi regions as a new Zarr group.
- Return type:
None
- masking(zarr_path, group_target, group_mask, reverse=False, footer='_msk')[source]
Applies a mask to the target image data, setting values outside the mask to zero.
- Parameters:
zarr_path (str) – Path to the Zarr file containing the image data.
group_target (str) – Group name in the Zarr file for the target data to be masked.
group_mask (str) – Group name in the Zarr file for the mask data.
reverse (bool, optional) – If True, inverts the mask, setting values within the mask to zero; defaults to False.
footer (str, optional) – Footer string to append to the output Zarr group name; defaults to “_msk”.
- Returns:
This function saves the masked result as a new Zarr group.
- Return type:
None
- fill_holes(zarr_path, group, footer='_fil')[source]
Fills holes in labeled regions of an image dataset.
- Parameters:
- Returns:
This function saves the image with filled holes as a new Zarr group.
- Return type:
None
- remove_edge_mask(zarr_path, group, footer='_egr')[source]
Removes labeled regions touching the edges of the image.
- Parameters:
- Returns:
This function saves the image with edge labels removed as a new Zarr group.
- Return type:
None
- label_edge(zarr_path, group, thickness, footer='_edg')[source]
Identifies and labels the edges of labeled regions in an image dataset, with adjustable thickness.
- Parameters:
- Returns:
This function saves the image with labeled edges as a new Zarr group.
- Return type:
None
- repeat_cycle(zarr_path, group, n_cycle, footer='_rep')[source]
Repeats an image dataset over multiple cycles.
- Parameters:
zarr_path (str) – Path to the Zarr file containing the image data.
group (str) – Group name in the Zarr file where the image data is stored.
n_cycle (int) – Number of times to repeat the dataset over cycles.
footer (str, optional) – Footer string to append to the output Zarr group name; defaults to “_rep”.
- Returns:
This function saves the repeated dataset as a new Zarr group.
- Return type:
None
- info_csv(zarr_path, group, pitch, footer='_seg')[source]
Generates segment information CSV files from image data stored in a Zarr file, summarizing properties such as area and centroid for each segment. Merges the CSV files into a single summary.
- Parameters:
zarr_path (str) – Path to the Zarr file containing the image data.
group (str) – Group name in the Zarr file where the image data is stored.
pitch (tuple of float) – Pixel size in (y, x) directions, used to convert pixel measurements to micrometers.
footer (str, optional) – Footer string to append to the output CSV directory name; defaults to “_seg”.
- Returns:
This function saves the segment information as CSV files.
- Return type:
None
- merge_groups(zarr_path, groups, output_group)[source]
Merges multiple groups of image data from a Zarr file into a single output group.
- Parameters:
- Returns:
This function saves the merged dataset as a new group in the Zarr file.
- Return type:
None
- normalize_groups(zarr_path, group, footer='_nrm')[source]
Normalizes intensity values across groups within an image dataset and computes the maximum intensity projection (MIP).
- Parameters:
- Returns:
This function saves the normalized and MIP result as a new Zarr group.
- Return type:
None
- select_slice(zarr_path, group, dim, position, chunk_dict, footer='sel')[source]
Selects a slice from an image dataset along a specified dimension.
- Parameters:
zarr_path (str) – Path to the Zarr file containing the image data.
group (str) – Group name in the Zarr file where the image data is stored.
dim (str) – The dimension along which to select the slice (e.g., “z”, “cycle”).
position (int) – The index position of the slice to select along the specified dimension.
chunk_dict (dict or None) – A dictionary specifying chunk sizes for each dimension. If None, the original chunk sizes (excluding the selected dimension) are used.
footer (str, optional) – Footer string to append to the output Zarr group name; defaults to “sel”.
- Returns:
This function saves the selected slice as a new Zarr group.
- Return type:
None
- merge_to_one_group(zarr_path, groups, output_group)[source]
Merges multiple groups of image data from a Zarr file into a single output group.
- Parameters:
- Returns:
This function saves the merged dataset as a new group in the Zarr file.
- Return type:
None
- scaled_mip(zarr_path, group, dim='cycle', footer='_nrm')[source]
Normalizes intensity values across a specified dimension and computes the maximum intensity projection (MIP).
- Parameters:
zarr_path (str) – Path to the Zarr file containing the image data.
group (str) – Group name in the Zarr file where the image data is stored.
dim (str, optional) – The dimension along which to compute the MIP; defaults to “cycle”.
footer (str, optional) – Footer string to append to the output Zarr group name; defaults to “_nrm”.
- Returns:
This function saves the normalized and MIP result as a new Zarr group.
- Return type:
None