ConditionalSetProperty#

class deeptrack.features.ConditionalSetProperty(feature: Feature, condition=typing.Union[str, typing.Callable[..., str]], **kwargs: Dict[str, Any])#

Bases: StructuralFeature

Conditionally override the properties of child features.

This feature allows selectively modifying the properties of a child feature based on a specified condition. If the condition evaluates to True, the specified properties are applied to the child feature. Otherwise, the child feature is resolved without modification.

Note: It is adviceable to use dt.Arguments instead. Note that this overwrites the properties, and as such may affect future calls.

Parameters#

featureFeature

The child feature whose properties will be conditionally overridden.

conditionbool or str

A boolean value or the name of a boolean property in the feature’s property dictionary. If the condition evaluates to True, the specified properties are applied.

**kwargsDict[str, Any]

The properties to be applied to the child feature if condition is True.

Example#

>>> import deeptrack as dt
>>> gaussian_noise = dt.GaussianNoise()
>>> conditional_feature = dt.ConditionalSetProperty(
...     gaussian_noise, condition="is_noisy", sigma=5
... )
>>> image = conditional_feature.resolve(is_noisy=True)  # Applies sigma=5.
>>> image = conditional_feature.resolve(is_noisy=False)  # Doesn't apply it.

Methods Summary

get(image, condition, **kwargs)

Resolve the child, conditionally applying specified properties.

Methods Documentation

get(image: Any, condition: str | bool, **kwargs: Dict[str, Any])#

Resolve the child, conditionally applying specified properties.

Parameters#

imageAny

The input data or image to process.

conditionUnion[str, bool]

A boolean value or the name of a boolean property in the feature’s property dictionary. If the condition evaluates to True, the specified properties are applied.

**kwargsDict[str, Any]

Additional properties to apply to the child feature if the condition is True.

Returns#

Any

The resolved child feature, with properties conditionally modified.