TakeProperties#

class deeptrack.features.TakeProperties(feature: Feature, *names: str, **kwargs: dict[str, Any])#

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.

Parameters#

feature: Feature

The feature from which to extract properties.

names: list[str]

The names of the properties to extract

**kwargs:: dict of str to 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.

Methods#

get(image: Any, names: tuple[str, …], **kwargs: dict[str, Any]) -> np.ndarray | tuple[np.ndarray, …]

Extract the specified properties from the feature pipeline.

Examples#

>>> import deeptrack as dt
>>> 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 = dt.TakeProperties(feature) >>> output = take_properties.get(image=None, names=[“my_property”]) >>> print(output) [42]

Create a Gaussian feature: >>> noise_feature = dt.Gaussian(mu=7, sigma=12)

Use TakeProperties to extract the property: >>> take_properties = dt.TakeProperties(noise_feature) >>> output = take_properties.get(image=None, names=[“mu”]) >>> print(output) [7]

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]) np.ndarray | tuple[np.ndarray, ...]#

Extract the specified properties from the feature pipeline.

This method retrieves the values of the specified properties from the feature’s dependency graph and returns them as NumPy arrays.

Parameters#

image: Any

The input image (unused in this method).

names: tuple[str, …]

The names of the properties to extract.

_ID: tuple[int, …], optional

A unique identifier for the current computation, ensuring that dependencies are correctly matched. Defaults to an empty tuple.

**kwargs: dict[str, Any], optional

Additional keyword arguments (unused in this method).

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.