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.
Key Features#
Property Management
The Property and PropertyDict classes 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.
Module Structure#
Classes:
Property: Property of a feature.
Defines a single property of a feature, supporting various data types and dynamic evaluations.
PropertyDict: Property dictionary.
A dictionary of properties with utilities for dependency management and sampling.
SequentialProperty: Property for sequential sampling.
Extends Property to support sequential sampling across steps.
Examples#
>>> import deeptrack as dt
Create and use a constant property:
>>> const_prop = dt.Property(42)
>>> const_prop()
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()
10
Create a dictionary of properties:
>>> import numpy as np
>>>
>>> prop_dict = dt.PropertyDict(
... constant=42,
... dependent=lambda constant: constant + 10,
... random=lambda dependent: np.random.rand() + dependent,
... )
>>> prop_dict["constant"]()
42
>>> prop_dict["dependent"]()
52
>>> prop_dict["random"]()
52.35065943710633
Handle sequential properties:
>>> seq_prop = dt.SequentialProperty(
... sampling_rule=lambda: np.random.randint(10, 20),
... sequence_length=5,
... )
>>> for step in range(seq_prop.sequence_length()):
... seq_prop()
... seq_prop.next_step()
... print(f"Sequence at step {step}: {seq_prop.sequence()}")
Sequence at step 0: [19]
Sequence at step 1: [19, 10]
Sequence at step 2: [19, 10, 11]
Sequence at step 3: [19, 10, 11, 14]
Sequence at step 4: [19, 10, 11, 14, 12]
Classes#
|
Property of a feature in the DeepTrack2 framework. |
|
Dictionary with Property elements. |
|
Property that yields different values across sequential steps. |