undr.formats
#
File formats supported by UNDR.
File types that are not listed here can still be included, downloaded, decompressed, and checked with UNDR. However, they are listed as “other files” and UNDR does not attempt to parse or load them.
To add a new file format, create and implement a derived class of undr.path.File
(see for instance ApsFile
) and add it to file_from_dict()
and Switch
.
Overview#
Classes#
Functions#
Creates a file object from a dictionary, typically loaded from an index file. |
Attributes#
Callback channel for messages generated by a file handler during data iteration. |
Module Contents#
- class undr.formats.ApsFile#
Bases:
undr.path.File
A file that contains luminance (grey levels) frames.
Active-pixel sensors (APS) describe, strictly speaking, any sensor with pixels that use MOSFET amplifiers. However, the term is commonly used to refer to the integrating pixels found in non-CCD conventional cameras. In the context of Neuromorphic Engineering, APS is used to describe DAVIS frames.
- packets() Iterable[numpy.ndarray] #
Iterates over the file data.
This function streams the file from the remote server if it is not available locally, and decompresses the file in memory if it is locally available but compressed.
- Returns:
Iterator over the file’s data converted into numpy arrays with dtype
undr.raw.aps_dtype()
.- Return type:
- class undr.formats.DvsFile#
Bases:
undr.path.File
A file that contains DVS (polarity) events.
Dynamic Vision Sensor events, often called polarity events, contain a timestamp, pixel coordinates, and a polarity (ON or OFF) that indicates whether luminance increased or decreased.
- packets() Iterable[numpy.ndarray] #
Iterates over the file data.
This function streams the file from the remote server if it is not available locally, and decompresses the file in memory if it is locally available but compressed.
- Returns:
Iterator over the file’s data converted into numpy arrays with dtype
undr.raw.DVS_DTYPE
.- Return type:
- class undr.formats.ImuFile#
Bases:
undr.path.File
A file that contains IMU events.
Inertial Measurement Unit (IMU) events are produced by an accelerometer / gyroscope / magnetometer.
- packets() Iterable[numpy.ndarray] #
Iterates over the file data.
This function streams the file from the remote server if it is not available locally, and decompresses the file in memory if it is locally available but compressed.
- Returns:
Iterator over the file’s data converted into numpy arrays with dtype
undr.raw.IMU_DTYPE
.- Return type:
- undr.formats.SendMessage#
Callback channel for messages generated by a file handler during data iteration.
- class undr.formats.Switch#
Calls specialized file handlers while iterating a dataset.
If a handler is None, the corresponding files are ignored by the iterator.
- Parameters:
handle_aps (Optional[Callable[[ApsFile, SendMessage], None]]) – Handler for APS files.
handle_dvs (Optional[Callable[[DvsFile, SendMessage], None]]) – Handler for DVS files.
handle_imu (Optional[Callable[[ImuFile, SendMessage], None]]) – Handler for IMU files.
handle_other (Optional[Callable[[path.File, SendMessage], None]]) – Handler for other files.
- handle_other: Callable[[undr.path.File, SendMessage], None] | None#
- handle_file(file: undr.path.File, send_message: SendMessage)#
Calls the specialized file handler for the file, if the handler is non-None.
- Parameters:
file (path.File) – The file to process.
send_message (SendMessage) – Callback channel for messages.
- Raises:
RuntimeError – if the file type is not supported by this function.
- undr.formats.file_from_dict(data: dict[str, Any], parent: undr.path_directory.Directory) undr.path.File #
Creates a file object from a dictionary, typically loaded from an index file.
- Parameters:
data (dict[str, Any]) – Dictionary describing the file and its properties.
parent (path_directory.Directory) – Parent directory of the file, used to generate the file system path.
- Raises:
RuntimeError – if the file type is not supported by this function.
- Returns:
A specialized file object.
- Return type: