threshold segmentation utils
Pydantic models and utilities specific to threshold segmentation.
| CLASS | DESCRIPTION |
|---|---|
CreateMaskingRoiTable |
Create Masking ROI Table Configuration. |
InputChannel |
Input channel configuration for threshold segmentation. |
OtsuConfiguration |
Configuration for Otsu threshold-based segmentation. |
SimpleThresholdConfiguration |
Configuration for threshold-based segmentation. |
SkipCreateMaskingRoiTable |
Skip Creating Masking ROI Table Configuration. |
| FUNCTION | DESCRIPTION |
|---|---|
segmentation_function |
Apply threshold-based segmentation to a single image chunk. |
Classes¶
CreateMaskingRoiTable
pydantic-model
¶
Bases: BaseModel
Create Masking ROI Table Configuration.
| ATTRIBUTE | DESCRIPTION |
|---|---|
mode |
Mode to create masking ROI table.
TYPE:
|
table_name |
Name of the masking ROI table to be created. Defaults to "{output_label_name}_masking_ROI_table", where {output_label_name} is the name of the label image used for segmentation.
TYPE:
|
Fields:
-
mode(Literal['Create Masking ROI Table']) -
table_name(str) -
table_backend(AVAILABLE_TABLE_BACKENDS)
Source code in fractal_tasks_core/_threshold_segmentation_utils.py
Attributes¶
table_backend = 'csv'
pydantic-field
¶
Backend to use for storing the masking ROI table. Options are "anndata", "json", "csv", and "parquet". Defaults to "csv".
table_name = '{output_label_name}_masking_ROI_table'
pydantic-field
¶
Name of the masking ROI table to be created. This can include the placeholder "{output_label_name}", which will be replaced by the name of the label image used for segmentation.
Methods:¶
create(ome_zarr, output_label_name, overwrite=True)
¶
Create the masking ROI table based on the provided label image.
| PARAMETER | DESCRIPTION |
|---|---|
|
The OME-Zarr container to add the table to.
TYPE:
|
|
The name of the label image for which to create the masking ROI table.
TYPE:
|
|
Whether to overwrite an existing table. Defaults to True.
TYPE:
|
Source code in fractal_tasks_core/_threshold_segmentation_utils.py
get_table_name(output_label_name)
¶
Get the actual table name by replacing placeholder.
| PARAMETER | DESCRIPTION |
|---|---|
|
Name of the label image used for segmentation.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
Actual name of the masking ROI table.
TYPE:
|
Source code in fractal_tasks_core/_threshold_segmentation_utils.py
InputChannel
pydantic-model
¶
Bases: BaseModel
Input channel configuration for threshold segmentation.
This model is used to select a channel by label, wavelength ID, or index.
| ATTRIBUTE | DESCRIPTION |
|---|---|
mode |
Specifies how to interpret the identifier. Can be "label", "wavelength_id", or "index" (must be an integer string).
TYPE:
|
identifier |
Unique identifier for the channel. This can be a channel label, wavelength ID, or index.
TYPE:
|
skip_if_missing |
If True and the specified channel is not found in the image, the segmentation will be skipped instead of raising an error. Defaults to False.
TYPE:
|
Fields:
-
mode(Literal['label', 'wavelength_id', 'index']) -
identifier(str) -
skip_if_missing(bool)
Source code in fractal_tasks_core/_threshold_segmentation_utils.py
Attributes¶
identifier
pydantic-field
¶
Identifier for the channel to use for segmentation.
mode = 'label'
pydantic-field
¶
Specifies how to interpret the identifier for selecting the channel. Can be "label" to select by channel label, "wavelength_id" to select by wavelength ID, or "index" to select by channel index (the identifier must be an integer string).
skip_if_missing = False
pydantic-field
¶
If True and the specified channel is not found in the image, the segmentation will be skipped instead of raising an error. Defaults to False.
Methods:¶
to_channel_selection_models()
¶
Convert to ChannelSelectionModel.
| RETURNS | DESCRIPTION |
|---|---|
ChannelSelectionModel
|
Channel selection model.
TYPE:
|
Source code in fractal_tasks_core/_threshold_segmentation_utils.py
OtsuConfiguration
pydantic-model
¶
Bases: BaseModel
Configuration for Otsu threshold-based segmentation.
| ATTRIBUTE | DESCRIPTION |
|---|---|
method |
Discriminator for Otsu threshold-based segmentation.
TYPE:
|
Fields:
Source code in fractal_tasks_core/_threshold_segmentation_utils.py
SimpleThresholdConfiguration
pydantic-model
¶
Bases: BaseModel
Configuration for threshold-based segmentation.
| ATTRIBUTE | DESCRIPTION |
|---|---|
method |
Discriminator for simple threshold-based segmentation.
TYPE:
|
threshold |
Threshold value to apply for segmentation.
TYPE:
|
Fields:
Source code in fractal_tasks_core/_threshold_segmentation_utils.py
SkipCreateMaskingRoiTable
pydantic-model
¶
Bases: BaseModel
Skip Creating Masking ROI Table Configuration.
Fields:
Source code in fractal_tasks_core/_threshold_segmentation_utils.py
Functions:¶
segmentation_function(input_image, method)
¶
Apply threshold-based segmentation to a single image chunk.
Pre- and post-processing transforms are handled by the segmentation iterator and should be configured via SegmentationTransformConfig.
| PARAMETER | DESCRIPTION |
|---|---|
|
Input image data (after pre-processing transforms).
TYPE:
|
|
Configuration for the segmentation method.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ndarray
|
np.ndarray: Segmented label image with a leading channel dimension. |