TakeProperties#

class deeptrack.features.TakeProperties(feature, *names, **kwargs)#

Bases: Feature

Extracts all instances of a set of properties from a pipeline.

Only extracts the properties if the feature contains all given property-names. The order of the properties is not guaranteed to be the same as the evaluation order.

If there is only a single property name, this will return a list of the property values.

If there are multiple property names, this will return a tuple of lists of the property values.

Parameters#

featureFeature

The feature from which to extract properties.

namesList[str]

The names of the properties to extract

**kwargsDict[str, Any]

Additional keyword arguments passed to the parent Feature class.

Attributes#

__distributed__bool

Indicates whether this feature distributes computation across inputs. Always False for TakeProperties, as it processes sequentially.

__list_merge_strategy__int

Specifies how lists of properties are merged. Set to MERGE_STRATEGY_APPEND to append values to the result list.

Example#

>>> from deeptrack.features import Feature, TakeProperties
>>> from deeptrack.properties import Property
>>> class ExampleFeature(Feature):
...     def __init__(self, my_property, **kwargs):
...         super().__init__(my_property=my_property, **kwargs)

Create an example feature with a property:

>>> feature = ExampleFeature(my_property=Property(42))

Use TakeProperties to extract the property:

>>> take_properties = TakeProperties(feature, "my_property")
>>> output = take_properties.get(image=None, names=["my_property"])
>>> print(output)
[42]

Methods Summary

get(image, names[, _ID])

Extract the specified properties from the feature pipeline.

Methods Documentation

get(image: Any, names: Tuple[str, ...], _ID: Tuple[int, ...] = (), **kwargs: Dict[str, Any]) ndarray | Tuple[ndarray, ...]#

Extract the specified properties from the feature pipeline.

Parameters#

imageAny

The input image (unused in this method).

namesTuple[str, …]

The names of the properties to extract.

_IDTuple[int, …], optional

A unique identifier for the current computation, used to match dependencies. Defaults to an empty tuple.

**kwargsAny

Additional keyword arguments (unused here).

Returns#

np.ndarray or Tuple[np.ndarray, …]

If a single property name is provided, a NumPy array containing the property values is returned. If multiple property names are provided, a tuple of NumPy arrays is returned, where each array corresponds to a property.