Skip to main content

A fast AEDAT4 decoder with an underlying Rust implementation

Project description

AEDAT

AEDAT is a fast AEDAT 4 python reader, with a Rust underlying implementation.

Run pip install aedat to install it.

Documentation

The aedat library provides a single class: Decoder. A decoder object is created by passing a file name to Decoder. The file name must be a path-like object.

Here's a short example:

import aedat

decoder = aedat.Decoder('/path/to/file.aedat')
print(decoder.id_to_stream())

for packet in decoder:
    print(packet['stream_id'], end=': ')
    if 'events' in packet:
        print('{} polarity events'.format(len(packet['events'])))
    elif 'frame' in packet:
        print('{} x {} frame'.format(packet['frame']['width'], packet['frame']['height']))
    elif 'imus' in packet:
        print('{} IMU samples'.format(len(packet['imus'])))
    elif 'triggers' in packet:
        print('{} trigger events'.format(len(packet['triggers'])))

And the same example with detailed comments:

import aedat

decoder = aedat.Decoder('/path/to/file.aedat')
"""
decoder is a packet iterator with an additional method id_to_stream
id_to_stream returns a dictionary with the following structure:
{
    <int>: {
        'type': <str>,
    }
}
type is one of 'events', 'frame', 'imus', 'triggers'
if type is 'events' or 'frame', its parent dictionary has the following structure:
{
    'type': <str>,
    'width': <int>,
    'height': <int>,
}
"""
print(decoder.id_to_stream())

for packet in decoder:
    """
    packet is a dictionary with the following structure:
    {
        'stream_id': <int>,
    }
    packet also has exactly one of the following fields:
        'events', 'frame', 'imus', 'triggers'
    """
    print(packet['stream_id'], end=': ')
    if 'events' in packet:
        """
        packet['events'] is a structured numpy array with the following dtype:
            [
                ('t', '<u8'),
                ('x', '<u2'),
                ('y', '<u2'),
                ('on', '?'),
            ]
        """
        print('{} polarity events'.format(len(packet['events'])))
    elif 'frame' in packet:
        """
        packet['frame'] is a dictionary with the following structure:
            {
                't': <int>,
                'begin_t': <int>,
                'end_t': <int>,
                'exposure_begin_t': <int>,
                'exposure_end_t': <int>,
                'format': <str>,
                'width': <int>,
                'height': <int>,
                'offset_x': <int>,
                'offset_y': <int>,
                'pixels': <numpy.array(shape=(height, width), dtype=uint8)>,
            }
        format is one of 'Gray', 'BGR', 'BGRA'
        """
        print('{} x {} frame'.format(packet['frame']['width'], packet['frame']['height']))
    elif 'imus' in packet:
        """
        packet['imus'] is a structured numpy array with the following dtype:
            [
                ('t', '<u8'),
                ('temperature', '<f4'),
                ('accelerometer_x', '<f4'),
                ('accelerometer_y', '<f4'),
                ('accelerometer_z', '<f4'),
                ('gyroscope_x', '<f4'),
                ('gyroscope_y', '<f4'),
                ('gyroscope_z', '<f4'),
                ('magnetometer_x', '<f4'),
                ('magnetometer_y', '<f4'),
                ('magnetometer_z', '<f4'),
            ]
        """
        print('{} IMU samples'.format(len(packet['imus'])))
    elif 'triggers' in packet:
        """
        packet['triggers'] is a structured numpy array with the following dtype:
            [
                ('t', '<u8'),
                ('source', 'u1'),
            ]
        the source value has the following meaning:
            0: timestamp reset
            1: external signal rising edge
            2: external signal falling edge
            3: external signal pulse
            4: external generator rising edge
            5: external generator falling edge
            6: frame begin
            7: frame end
            8: exposure begin
            9: exposure end
        """
        print('{} trigger events'.format(len(packet['triggers'])))

Because the lifetime of the file handle is managed by Rust, decoder objects are not compatible with the with statement. To ensure garbage collection, point the decoder variable to something else, for example None, when you are done using it:

import aedat

decoder = aedat.Decoder('/path/to/file.aedat')
# do something with decoder
decoder = None

Install from source

This library requires Python 3.x, x >= 5, and NumPy. This guide assumes that they are installed on your machine.

Note for Windows users: this library requires the x86-64 version of Python. You can download it here: https://www.python.org/downloads/windows/ (the default installer contains the x86 version).

A Rust compiling toolchain is required during the installation (but can be removed afterwards).

Linux

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
git clone https://github.com/neuromorphicsystems/aedat.git
cd aedat
cargo build --release
cp target/release/libaedat.so aedat.so

You can import aedat from python scripts in the same directory as aedat.so, which can be placed in any directory.

macOS

brew install rustup
rustup-init
git clone https://github.com/neuromorphicsystems/aedat.git
cd aedat
cargo build --release
cp target/release/libaedat.dylib aedat.so

You can import aedat from python scripts in the same directory as aedat.so, which can be placed in any directory.

Windows

  1. install rustup (instructions availables at https://www.rust-lang.org/tools/install)
  2. clone or download this repository
  3. run in PowerShell from the aedat directory:
cargo build --release
copy .\target\release\aedat.dll .\aedat.pyd

You can import aedat from python scripts in the same directory as aedat.pyd, which can be placed in any directory.

Contribute

After changing any of the files in framebuffers, one must run:

flatc --rust -o src/ flatbuffers/*.fbs

To format the code, run:

cargo fmt

You may need to install rustfmt first with:

rustup component add rustfmt

Publish

  1. Bump the version number in Cargo.toml.

  2. Install Cubuzoa in a different directory (https://github.com/neuromorphicsystems/cubuzoa) to build pre-compiled versions for all major operating systems. Cubuzoa depends on VirtualBox (with its extension pack) and requires about 75 GB of free disk space.

cd cubuzoa
python3 cubuzoa.py provision
python3 cubuzoa.py build /path/to/aedat
  1. Install twine
pip3 install maturin
pip3 install twine
  1. Upload the compiled wheels and the source code to PyPI:
maturin build --out wheels --interpreter
python3 -m twine upload wheels/*

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aedat-1.2.1.tar.gz (19.8 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

aedat-1.2.1-cp39-none-win_amd64.whl (244.0 kB view details)

Uploaded CPython 3.9Windows x86-64

aedat-1.2.1-cp39-none-win32.whl (233.9 kB view details)

Uploaded CPython 3.9Windows x86

aedat-1.2.1-cp39-cp39-manylinux2014_x86_64.whl (388.8 kB view details)

Uploaded CPython 3.9

aedat-1.2.1-cp39-cp39-macosx_10_7_x86_64.whl (352.9 kB view details)

Uploaded CPython 3.9macOS 10.7+ x86-64

aedat-1.2.1-cp38-none-win_amd64.whl (244.4 kB view details)

Uploaded CPython 3.8Windows x86-64

aedat-1.2.1-cp38-none-win32.whl (234.0 kB view details)

Uploaded CPython 3.8Windows x86

aedat-1.2.1-cp38-cp38-manylinux2014_x86_64.whl (388.5 kB view details)

Uploaded CPython 3.8

aedat-1.2.1-cp38-cp38-macosx_10_7_x86_64.whl (352.8 kB view details)

Uploaded CPython 3.8macOS 10.7+ x86-64

aedat-1.2.1-cp37-none-win_amd64.whl (244.1 kB view details)

Uploaded CPython 3.7Windows x86-64

aedat-1.2.1-cp37-none-win32.whl (232.0 kB view details)

Uploaded CPython 3.7Windows x86

aedat-1.2.1-cp37-cp37m-manylinux2014_x86_64.whl (394.5 kB view details)

Uploaded CPython 3.7m

aedat-1.2.1-cp37-cp37m-macosx_10_7_x86_64.whl (358.5 kB view details)

Uploaded CPython 3.7mmacOS 10.7+ x86-64

File details

Details for the file aedat-1.2.1.tar.gz.

File metadata

  • Download URL: aedat-1.2.1.tar.gz
  • Upload date:
  • Size: 19.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

File hashes

Hashes for aedat-1.2.1.tar.gz
Algorithm Hash digest
SHA256 5256ef9cc5acf8f53b51d7b441aff17a6f9f9fd69c8ae0eba284e95a2b387262
MD5 4f8b801de4cb5c85ecdf09e859ab8489
BLAKE2b-256 316f47d45af4243ed5898c110cf21f467e7f17c37a18afa9fcdacb722a176a31

See more details on using hashes here.

File details

Details for the file aedat-1.2.1-cp39-none-win_amd64.whl.

File metadata

  • Download URL: aedat-1.2.1-cp39-none-win_amd64.whl
  • Upload date:
  • Size: 244.0 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

File hashes

Hashes for aedat-1.2.1-cp39-none-win_amd64.whl
Algorithm Hash digest
SHA256 a799e455f62f16ac02b62e5c21a9ecbbd1498b7f91cbd22126d3f0f6af8c273e
MD5 d7e92dff8272e0536097ba65dc2a9526
BLAKE2b-256 702dc9169e4071d6fafd337f7993a8739dbd0be3e5b8b90916b4e93b60f8e585

See more details on using hashes here.

File details

Details for the file aedat-1.2.1-cp39-none-win32.whl.

File metadata

  • Download URL: aedat-1.2.1-cp39-none-win32.whl
  • Upload date:
  • Size: 233.9 kB
  • Tags: CPython 3.9, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

File hashes

Hashes for aedat-1.2.1-cp39-none-win32.whl
Algorithm Hash digest
SHA256 9273ec522f030fb3ef3c51f39379f13fa135a26595d25f6720cd51cd93dac466
MD5 3bceffcc11a6f854566cc863c5ca79df
BLAKE2b-256 f80e0945e195555267462c48231353ddf2b7bef89d81b67d2755c38a27d5481a

See more details on using hashes here.

File details

Details for the file aedat-1.2.1-cp39-cp39-manylinux2014_x86_64.whl.

File metadata

  • Download URL: aedat-1.2.1-cp39-cp39-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 388.8 kB
  • Tags: CPython 3.9
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

File hashes

Hashes for aedat-1.2.1-cp39-cp39-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 58a5b88dbb20113ea9f50b580bb12e331da73d55c9caec4174d067dcda49f936
MD5 e2fb3dec759108f8e04892db9fdcc680
BLAKE2b-256 a1c4bc33511e48dc38581c4585ea28944613782d2d717fa8a5ff3647efb801d3

See more details on using hashes here.

File details

Details for the file aedat-1.2.1-cp39-cp39-macosx_10_7_x86_64.whl.

File metadata

  • Download URL: aedat-1.2.1-cp39-cp39-macosx_10_7_x86_64.whl
  • Upload date:
  • Size: 352.9 kB
  • Tags: CPython 3.9, macOS 10.7+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

File hashes

Hashes for aedat-1.2.1-cp39-cp39-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 049dab59e07f89e57ea62aba948f83a65b6a559d5ed82a0118f26103157067c1
MD5 64f8a2197fb708ae877e3ad4fa68b764
BLAKE2b-256 3fd80492486f1426dfdb89c45023c93c3afb5e1f1ae5472dd25853a27ec059de

See more details on using hashes here.

File details

Details for the file aedat-1.2.1-cp38-none-win_amd64.whl.

File metadata

  • Download URL: aedat-1.2.1-cp38-none-win_amd64.whl
  • Upload date:
  • Size: 244.4 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

File hashes

Hashes for aedat-1.2.1-cp38-none-win_amd64.whl
Algorithm Hash digest
SHA256 235cc8b802e1c156918cb359538cd18be46e87268b37b563c1d8b3ae50921d99
MD5 e0c22573e7ef16f432a5f3cb666670bf
BLAKE2b-256 58b87dd2c0dee3eb84455b97ca9398ef69e2d7fe09170af8d179275c3a0b9c83

See more details on using hashes here.

File details

Details for the file aedat-1.2.1-cp38-none-win32.whl.

File metadata

  • Download URL: aedat-1.2.1-cp38-none-win32.whl
  • Upload date:
  • Size: 234.0 kB
  • Tags: CPython 3.8, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

File hashes

Hashes for aedat-1.2.1-cp38-none-win32.whl
Algorithm Hash digest
SHA256 5625dc4a3f3adea920bf8b710acd2327bba2b729fe0f390638196e4d49d325b5
MD5 44e1f42bdd2bd0a58e5123dd1684fc33
BLAKE2b-256 4b06a57c55d6b792c7f2fa89cf5c193fd9c63dfc7d30c34a0df14c8858418dd5

See more details on using hashes here.

File details

Details for the file aedat-1.2.1-cp38-cp38-manylinux2014_x86_64.whl.

File metadata

  • Download URL: aedat-1.2.1-cp38-cp38-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 388.5 kB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

File hashes

Hashes for aedat-1.2.1-cp38-cp38-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ab60772304e58948b848e1f81890ff936e88c083f0aae4bd355021e9b0e1b1dd
MD5 d76732a72e79ab8dbdfd75f1cebe6081
BLAKE2b-256 4409bf54edde917edd79976207b16b760977a9883344a4169070a3e150648739

See more details on using hashes here.

File details

Details for the file aedat-1.2.1-cp38-cp38-macosx_10_7_x86_64.whl.

File metadata

  • Download URL: aedat-1.2.1-cp38-cp38-macosx_10_7_x86_64.whl
  • Upload date:
  • Size: 352.8 kB
  • Tags: CPython 3.8, macOS 10.7+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

File hashes

Hashes for aedat-1.2.1-cp38-cp38-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 240fa7837806fb544f144758717591717534deba3a8aa8310bba033d14f485b3
MD5 9569784df323466620a8d52b7f104005
BLAKE2b-256 90832f2c24acf5e39eafe43c3bbc9fe6cccd51661a7db9664451a799f49a0a7e

See more details on using hashes here.

File details

Details for the file aedat-1.2.1-cp37-none-win_amd64.whl.

File metadata

  • Download URL: aedat-1.2.1-cp37-none-win_amd64.whl
  • Upload date:
  • Size: 244.1 kB
  • Tags: CPython 3.7, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

File hashes

Hashes for aedat-1.2.1-cp37-none-win_amd64.whl
Algorithm Hash digest
SHA256 2cf23289b7dbdf3a9427474a5ba18a2faa52d14bdd18e184f63a54cae7d1f5a4
MD5 bd3649b2fc32aaafaa866eae5232d10d
BLAKE2b-256 a13da64b4d0e400d584567b6214c1c2be184fec1d4181a885ba6197cc966890e

See more details on using hashes here.

File details

Details for the file aedat-1.2.1-cp37-none-win32.whl.

File metadata

  • Download URL: aedat-1.2.1-cp37-none-win32.whl
  • Upload date:
  • Size: 232.0 kB
  • Tags: CPython 3.7, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

File hashes

Hashes for aedat-1.2.1-cp37-none-win32.whl
Algorithm Hash digest
SHA256 cf3ae14d89b86313091cd1b1b143e506538ea2e0bf7ddbc97cdf49b6fd5bc2e4
MD5 43e143bd9e9777d1ba789a81b1a0256f
BLAKE2b-256 ab73fd6c70b3241c1e259419811e2674a01ba5820335d7db5aa76d548fb20368

See more details on using hashes here.

File details

Details for the file aedat-1.2.1-cp37-cp37m-manylinux2014_x86_64.whl.

File metadata

  • Download URL: aedat-1.2.1-cp37-cp37m-manylinux2014_x86_64.whl
  • Upload date:
  • Size: 394.5 kB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

File hashes

Hashes for aedat-1.2.1-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 08dba8bc3bca2fe5249c51fd446dddc9da5d5d88591c20fcab64a2b6402b664e
MD5 d929e415f4c943f974837d6699d0ddd7
BLAKE2b-256 44c2334cff71f36be1b7c1a3bd91f73f7ca61b3ead00ea9bb690dfec98ed2ab8

See more details on using hashes here.

File details

Details for the file aedat-1.2.1-cp37-cp37m-macosx_10_7_x86_64.whl.

File metadata

  • Download URL: aedat-1.2.1-cp37-cp37m-macosx_10_7_x86_64.whl
  • Upload date:
  • Size: 358.5 kB
  • Tags: CPython 3.7m, macOS 10.7+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

File hashes

Hashes for aedat-1.2.1-cp37-cp37m-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 0f201b66828d0ac5f4ca0f9a701f48438a9f3a7e038ea167a244739397ff8536
MD5 30711ab624d0d9c74cf05917717dd3c1
BLAKE2b-256 4b1852a587e8912de9e875f158ab59a0353010171f8584998b64a8ba2b6f5c48

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page