Transformations#
Transforms are common event transformations. They can be chained together using Compose
.
Additionally, there is the tonic.functional
module.
Functional transforms give fine-grained control over the transformations.
This is useful if you have to build a more complex transformation pipeline.
- class tonic.transforms.Compose(transforms: Callable)[source]#
Composes several transforms together. This a literal copy of torchvision.transforms.Compose function for convenience.
- Parameters:
transforms (list of
Transform
objects) – list of transform(s) to compose. Can combine Tonic, PyTorch Vision/Audio transforms.
Example
>>> transforms.Compose([ >>> transforms.Denoise(filter_time=10000), >>> transforms.ToFrame(n_time_bins=3), >>> ])
Transforms on events#
|
Crops events at the center to a specific output size. |
|
Drops events with timestamps below min and above max. |
|
Drops events that are spatio-temporally not sufficiently close enough to other events in the sample. |
|
Deterministically drops every nth event for every spatial location x (and potentially y). |
|
Randomly drops events with probability p. |
|
Drops events in a certain time interval with a length proportional to a specified ratio of the original length. |
|
Drops events located in a randomly chosen box area. |
|
Applies EventDrop transformation from the paper "EventDrop: Data Augmentation for Event-based Learning". |
|
Drops events for individual pixels. |
|
Multiplies timestamps and spatial pixel coordinates with separate factors. |
Sets all polarities to zero. |
|
|
Crops the sensor size to a smaller size in a random location. |
|
Flips events in x with probability p. |
|
Flips events in y with probability p. |
|
Flips polarity of individual events with p. |
|
Reverses temporal order of events with probability p. |
|
Changes x/y coordinate for each event by adding samples from a multivariate Gaussian distribution. |
|
Changes timestamp for each event by adding samples from a Gaussian distribution. |
|
Sets a refractory period for each pixel, during which events will be ignored/discarded. |
Removes offset for timestamps, so that first event starts at time zero. |
|
|
Skew all event timestamps according to a linear transform. |
|
Adds a fixed number of n noise events that are uniformly distributed across sensor size dimensions such as x, y, t and p. |
Event Representations#
|
Change dtype of numpy ndarray to custom dtype. |
|
Create averaged timesurfaces for each event. |
|
Accumulate events to frames by slicing along constant time (time_window), constant number of events (event_count) or constant number of frames (n_time_bins / n_event_bins). |
|
PyTorch sparse tensor drop-in replacement for ToFrame. |
|
Counts up all events to a single image of size sensor_size. |
|
Create global time surfaces at a specific time interval dt. |
|
Build a voxel grid with bilinear interpolation in the time domain from a set of events. |
|
Takes T*B binary event frames to produce a sequence of T frames of N-bit numbers. |
Target transforms#
|
Transforms one or more targets into a one hot encoding scheme. |
|
Copies target n times. |
Functional transforms in numpy#
|
Crops the sensor size to a smaller sensor. |
|
Returns 1/n events for each pixel location. |
|
Drops events that are 'not sufficiently connected to other events in the recording.' In practise that means that an event is dropped if no other event occured within a spatial neighbourhood of 1 pixel and a temporal neighbourhood of filter_time time units. |
|
Randomly drops events with drop_probability. |
|
Drops events in a certain time interval with a length proportional to a specified ratio of the original length. |
|
Drops events located in a randomly chosen box area. |
|
Drops events for pixel locations that fire. |
|
Drops events for pixel locations. |
|
Identifies pixels that fire above above a certain frequency, averaged across whole event recording. |
|
Identifies pixels that fire above a certain predefined spike amount, supports both. |
|
Sets a refractory period for each pixel, during which events will be ignored/discarded. |
|
Changes x/y coordinate for each event by adding samples from a multivariate Gaussian distribution. |
|
Changes timestamp for each event by drawing samples from a Gaussian distribution and adding them to each timestamp. |
|
Skew all event timestamps according to a linear transform, potentially sampled from a distribution of acceptable functions. |
|
Accumulate events to frames by slicing along constant time (time_window), constant number of events (event_count) or constant number of frames (n_time_bins / n_event_bins). |
|
Representation that creates timesurfaces for each event in the recording. |
|
Build a voxel grid with bilinear interpolation in the time domain from a set of events. |
|
Representation that takes T*B binary event frames to produce a sequence of T frames of N-bit numbers. |