measure features utils
Utility models and functions for the measure_features task.
| CLASS | DESCRIPTION |
|---|---|
AdvancedOptions |
Advanced options for feature measurement. |
InputChannel |
Input channel configuration for measurement tasks. |
IntensityFeatures |
Intensity features extracted from regionprops. |
ShapeFeatures |
Shape features extracted from regionprops. |
| FUNCTION | DESCRIPTION |
|---|---|
region_props_features_func |
Extract region properties features from a label image within a ROI. |
Classes¶
AdvancedOptions
pydantic-model
¶
Bases: BaseModel
Advanced options for feature measurement.
Fields:
-
level_path(str | None) -
use_scaling(bool) -
use_cache(bool) -
table_backend(AVAILABLE_TABLE_BACKENDS)
Source code in fractal_tasks_core/_measure_features_utils.py
Attributes¶
level_path = None
pydantic-field
¶
Optional path to the pyramid level to use for the measurement. If None, the highest resolution level will be used.
table_backend = 'parquet'
pydantic-field
¶
Table backend to use for the output table. Defaults to "parquet".
use_cache = True
pydantic-field
¶
Whether to cache in the regionprops function. This can speed up the measurement for but can also increase memory usage. Defaults to True.
use_scaling = True
pydantic-field
¶
Whether to use pixel scaling from the OME-Zarr metadata. This will scale the features according to the physical pixel size, e.g. area will be in square microns instead of square pixels. Defaults to True.
InputChannel
pydantic-model
¶
Bases: BaseModel
Input channel configuration for measurement tasks.
This model is used to select a channel by label, wavelength ID, or index.
Fields:
-
mode(Literal['label', 'wavelength_id', 'index']) -
identifier(str)
Source code in fractal_tasks_core/_measure_features_utils.py
Attributes¶
identifier
pydantic-field
¶
Unique identifier for the channel. This can be a channel label, wavelength ID, or index.
mode = 'label'
pydantic-field
¶
Specifies how to interpret the identifier. Can be "label", "wavelength_id", or "index" (must be an integer string).
Methods:¶
to_channel_selection_models()
¶
Convert to ChannelSelectionModel.
| RETURNS | DESCRIPTION |
|---|---|
ChannelSelectionModel
|
Channel selection model.
TYPE:
|
Source code in fractal_tasks_core/_measure_features_utils.py
IntensityFeatures
pydantic-model
¶
Bases: BaseModel
Intensity features extracted from regionprops.
Fields:
-
type(Literal['IntensityFeatures']) -
channels(list[InputChannel] | None)
Source code in fractal_tasks_core/_measure_features_utils.py
Attributes¶
channels = None
pydantic-field
¶
List of channels to extract intensity features from. If None all channels will be used.
type = 'IntensityFeatures'
pydantic-field
¶
Features included in this model are: intensity_mean, intensity_median, intensity_max, intensity_min, intensity_std.
Methods:¶
to_channel_selection_models()
¶
Convert to list of ChannelSelectionModel.
| RETURNS | DESCRIPTION |
|---|---|
list[ChannelSelectionModel] | None
|
list[ChannelSelectionModel] | None: List of channel selection models, or None if no channels are specified. |
Source code in fractal_tasks_core/_measure_features_utils.py
ShapeFeatures
pydantic-model
¶
Bases: BaseModel
Shape features extracted from regionprops.
Fields:
-
type(Literal['ShapeFeatures']) -
include_convex_hull_properties(bool)
Source code in fractal_tasks_core/_measure_features_utils.py
Attributes¶
include_convex_hull_properties = False
pydantic-field
¶
Whether to include convex hull related properties like area_convex, area_filled, extent, solidity. These are not included since they can sometimes return unexpected Warnings.
type = 'ShapeFeatures'
pydantic-field
¶
Features included in this model are: area, area_bbox, num_pixels, equivalent_diameter_area, axis_major_length, axis_minor_length, euler_number, and if 2D also feret_diameter_max, perimeter, perimeter_crofton, eccentricity, orientation.
Functions:¶
_prepare_regionprops_kwargs(image, list_features, use_scaling=True, use_cache=True)
¶
Prepare keyword arguments for regionprops based on the requested features.
This includes determining which channels to load for intensity features.
| PARAMETER | DESCRIPTION |
|---|---|
|
The image to check against.
TYPE:
|
|
List of requested features.
TYPE:
|
|
Whether to use pixel scaling from the image metadata. Defaults to True.
TYPE:
|
|
Whether to cache the loaded images. Defaults to True.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[dict, list[ChannelSelectionModel] | None]
|
tuple[dict, list[ChannelSelectionModel] | None]: Keyword arguments to pass to regionprops, e.g. {"intensity_image": ...}, and the list of channel selection models. |
Source code in fractal_tasks_core/_measure_features_utils.py
region_props_features_func(image, label, roi, properties, channel_identifiers=None, spacings=None, use_cache=True)
¶
Extract region properties features from a label image within a ROI.