deeptrack.properties Module#
Tools to manage feature properties in DeepTrack2.
This module provides classes for managing, sampling, and evaluating properties of features within the DeepTrack2 framework. It offers flexibility in defining and handling properties with various data types, dependencies, and sampling rules.
Main Features#
Property Management
Classes like Property and PropertyDict provide tools for defining, sampling, and evaluating properties. These properties can be constants, functions, lists, dictionaries, iterators, or slices, allowing for dynamic and context-dependent evaluations.
Sequential Sampling
The SequentialProperty class enables the creation of properties that evolve over a sequence, useful for applications like creating dynamic features in videos or time-series data.
Model Structure#
Property Classes:
Property: Property of a feature.
Defines a single property of a feature, supporting various data types and dynamic evaluations.
SequentialProperty: Property for sequential sampling.
Extends Property to support sequential sampling across steps.
PropertyDict: Property dictionary.
A dictionary of properties with utilities for dependency management and sampling.
Example#
Create and use a constant property:
>>> import deeptrack as dt
>>> const_prop = dt.Property(42)
>>> const_prop() # Returns 42
Define a dynamic property dependent on another:
>>> const_prop = dt.Property(5)
>>> dynamic_prop = dt.Property(lambda x: x * 2, x=const_prop)
>>> dynamic_prop() # Returns 10
Create a dictionary of properties:
>>> prop_dict = dt.PropertyDict(
... constant=42,
... dependent=lambda constant: constant + 10,
... random=lambda dependent: np.random.rand() + dependent,
... )
>>> print(prop_dict["constant"]()) # Returns 42
>>> print(prop_dict["dependent"]()) # Returns 52
>>> print(prop_dict["random"]())
Handle sequential properties:
>>> seq_prop = dt.SequentialProperty()
>>> seq_prop.sequence_length.store(5)
>>> seq_prop.current = lambda _ID=(): seq_prop.sequence_step() + 1
>>> for step in range(seq_prop.sequence_length()):
... seq_prop.sequence_step.store(step)
... seq_prop.store(seq_prop.current())
... print(seq_prop.data[()].current_value())
Classes#
|
Object corresponding to a node in a computation graph. |
|
Property of a feature in the DeepTrack2 framework. |
|
Dictionary with Property elements. |
|
Property that yields different values for sequential steps. |