features¶
Base class Feature and structural features
Provides classes and tools for creating and interacting with features.
Classes¶
- Feature
Base abstract class.
- StructuralFeature
Abstract extension of feature for interactions between features.
- Branch
Implementation of StructuralFeature that resolves two features sequentially.
- Probability
Implementation of StructuralFeature that randomly resolves a feature with a certain probability.
- Duplicate
Implementation of StructuralFeature that sequentially resolves an integer number of deep-copies of a feature.
Module classes¶
Branch¶
-
class
deeptrack.features.Branch(feature_1: deeptrack.features.Feature, feature_2: deeptrack.features.Feature, *args, **kwargs)¶ Resolves to features sequentially :param feature_1: :type feature_1: Feature :param feature_2: :type feature_2: Feature
-
get(image, feature_1, feature_2, **kwargs)¶ Resolves feature_1 and feature_2 sequentially
-
ConditionalSetFeature¶
-
class
deeptrack.features.ConditionalSetFeature(on_false: deeptrack.features.Feature = None, on_true: deeptrack.features.Feature = None, condition='is_label', **kwargs)¶ Conditionally resolves one of two features
- Parameters
-
get(image, *, on_false, on_true, condition, **kwargs)¶ Method for altering an image Abstract method that define how the feature transforms the input. The current value of all properties will be passed as keyword arguments.
ConditionalSetProperty¶
-
class
deeptrack.features.ConditionalSetProperty(feature: deeptrack.features.Feature, condition='is_label', **kwargs)¶ Conditionally overrides the properties of child features
- Parameters
feature (Feature) – The child feature
condition (str) – The name of the conditional property
**kwargs – Properties to be used if condition is True
-
get(image, feature, condition, **kwargs)¶ Method for altering an image Abstract method that define how the feature transforms the input. The current value of all properties will be passed as keyword arguments.
Duplicate¶
-
class
deeptrack.features.Duplicate(feature: deeptrack.features.Feature, num_duplicates: int, *args, **kwargs)¶ Resolves copies of a feature sequentially Creates num_duplicates copies of the feature and resolves them sequentially
- Parameters
feature (Feature) – The feature to duplicate
num_duplicates (int) – The number of duplicates to create
-
get(image, features: List[deeptrack.features.Feature], **kwargs)¶ Resolves each feature in features sequentially
-
update(**kwargs)¶ Updates the state of all properties.
- Parameters
**kwargs – Arguments that will be passed to the Property method update().
- Returns
- Return type
self
Feature¶
-
class
deeptrack.features.Feature(*args: dict, **kwargs)¶ Base feature class. Features define the image generation process. All features operate on lists of images. Most features, such as noise, apply some tranformation to all images in the list. This transformation can be additive, such as adding some Gaussian noise or a background illumination, or non-additive, such as introducing Poisson noise or performing a low-pass filter. This transformation is defined by the method get(image, **kwargs), which all implementations of the class Feature need to define.
Whenever a Feature is initiated, all keyword arguments passed to the constructor will be wrapped as a Property, and stored in the properties field as a PropertyDict. When a Feature is resolved, the current value of each property is sent as input to the get method.
- Parameters
*args (dict, optional) – Dicts passed as nonkeyword arguments will be deconstructed to key-value pairs and included in the field properties in the same way as keyword arguments.
**kwargs – All Keyword arguments will be wrapped as instances of
Propertyand included in the field properties.
-
properties¶ A dict that contains all keyword arguments passed to the constructor wrapped as Distributions. A sampled copy of this dict is sent as input to the get function, and is appended to the properties field of the output image.
- Type
dict
-
__list_merge_strategy__¶ Controls how the output of .get(image, **kwargs) is merged with the input list. It can be MERGE_STRATEGY_OVERRIDE (0, default), where the input is replaced by the new list, or MERGE_STRATEGY_APPEND (1), where the new list is appended to the end of the input list.
- Type
int
-
__distributed__¶ Controls whether .get(image, **kwargs) is called on each element in the list separately (__distributed__ = True), or if it is called on the list as a whole (__distributed__ = False).
- Type
bool
-
__property_memorability__¶ Controls whether to store the features properties to the Image. Values 1 or lower will be included by default.
-
abstract
get(image: deeptrack.image.Image, **kwargs) → deeptrack.image.Image¶ Method for altering an image Abstract method that define how the feature transforms the input. The current value of all properties will be passed as keyword arguments.
-
plot(input_image: deeptrack.image.Image = None, resolve_kwargs: dict = None, interval: float = None, **kwargs)¶ Visualizes the output of the feature Resolves the feature and visualizes the result. If the output is an Image, show it using pyplot.imshow. If the output is a list, create an Animation. For notebooks, the animation is played inline using to_jshtml(). For scripts, the animation is played using the matplotlib backend.
Any parameters in kwargs will be passed to pyplot.imshow.
- Parameters
-
resolve(image_list: deeptrack.image.Image = None, **global_kwargs)¶ Creates the image. Transforms the input image by calling the method get() with the correct inputs. The properties of the feature can be overruled by passing a different value as a keyword argument.
- Parameters
- Returns
The resolved image
- Return type
-
sample(**kwargs) → deeptrack.features.Feature¶ Returns the feature
-
update(**kwargs) → deeptrack.features.Feature¶ Updates the state of all properties.
- Parameters
**kwargs – Arguments that will be passed to the Property method update().
- Returns
- Return type
self
Label¶
-
class
deeptrack.features.Label(output_shape=None, **kwargs)¶ Outputs the properties of this features.
Can be used to extract properties in a feature set and combine them into a numpy array.
- Parameters
output_shape (tuple of ints) – Reshapes the output to this shape
-
get(image, output_shape=None, hash_key=None, **kwargs)¶ Method for altering an image Abstract method that define how the feature transforms the input. The current value of all properties will be passed as keyword arguments.
Lambda¶
-
class
deeptrack.features.Lambda(function, **kwargs)¶ Calls a custom functions.
Note that the property function needs to be wrapped in an outer layer function. The outer layer function can depend on other properties, while the inner layer function accepts an image as input.
- Parameters
function (Callable[Image or list of Image]) – Function that takes the current image as first input
-
get(image, function, **kwargs)¶ Method for altering an image Abstract method that define how the feature transforms the input. The current value of all properties will be passed as keyword arguments.
LoadImage¶
-
class
deeptrack.features.LoadImage(path, load_options={}, **kwargs)¶ Loads an image from disk.
Cycles through file-readers numpy, pillow and opencv2 to open the image file.
- Parameters
path (str) – Path to image to load
load_options (dict) – Options passed to the file reader
- Raises
IOError – If no file reader could parse the file or the file doesn’t exist.
-
get(*ign, path, load_options, **kwargs)¶ Method for altering an image Abstract method that define how the feature transforms the input. The current value of all properties will be passed as keyword arguments.
Probability¶
-
class
deeptrack.features.Probability(feature: deeptrack.features.Feature, probability: float, *args, **kwargs)¶ Resolves a feature with a certain probability
- Parameters
feature (Feature) – Feature to resolve
probability (float) – Probability to resolve
-
get(image, feature: deeptrack.features.Feature, probability: float, random_number: float, **kwargs)¶ Resolves feature if random_number is less than probability