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

Requirements

  1. Build the Docker image for Linux builds
docker build manylinux -t manylinux
  1. Install all the Pythons for macOS
brew install pyenv
pyenv install 3.7.10
pyenv install 3.8.8
pyenv install 3.9.2
LDFLAGS="-L/usr/local/opt/bzip2/lib -L/usr/local/opt/zlib/lib -L/usr/local/opt/openssl@1.1/lib" CFLAGS="-I/usr/local/opt/bzip2/include -I/usr/local/opt/zlib/include -I/usr/local/opt/openssl@1.1/include -I$(xcrun --show-sdk-path)/usr/include -Wno-implicit-function-declaration" pyenv install 3.6.13
pyenv global 3.6.13 3.7.10 3.8.8 3.9.2
pip install maturin
pip install twine
  1. Download the base Vagrant box for Windows builds
vagrant box add gusztavvargadr/windows-10

Build and publish

rm -rf target
eval "$(pyenv init -)"
maturin publish
docker run --rm -v $(pwd):/io manylinux maturin build --release --strip
cd windows
vagrant up
vagrant destroy -f
cd ..
twine upload --skip-existing target/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.0.tar.gz (22.2 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.0-cp39-none-win_amd64.whl (454.6 kB view details)

Uploaded CPython 3.9Windows x86-64

aedat-1.2.0-cp39-none-win32.whl (378.5 kB view details)

Uploaded CPython 3.9Windows x86

aedat-1.2.0-cp39-cp39-manylinux2010_x86_64.whl (385.4 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.12+ x86-64

aedat-1.2.0-cp39-cp39-macosx_10_7_x86_64.whl (338.2 kB view details)

Uploaded CPython 3.9macOS 10.7+ x86-64

aedat-1.2.0-cp38-none-win_amd64.whl (454.3 kB view details)

Uploaded CPython 3.8Windows x86-64

aedat-1.2.0-cp38-none-win32.whl (378.6 kB view details)

Uploaded CPython 3.8Windows x86

aedat-1.2.0-cp38-cp38-manylinux2010_x86_64.whl (385.5 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.12+ x86-64

aedat-1.2.0-cp38-cp38-macosx_10_7_x86_64.whl (338.4 kB view details)

Uploaded CPython 3.8macOS 10.7+ x86-64

aedat-1.2.0-cp37-none-win_amd64.whl (454.4 kB view details)

Uploaded CPython 3.7Windows x86-64

aedat-1.2.0-cp37-none-win32.whl (378.5 kB view details)

Uploaded CPython 3.7Windows x86

aedat-1.2.0-cp37-cp37m-manylinux2010_x86_64.whl (384.5 kB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.12+ x86-64

aedat-1.2.0-cp37-cp37m-macosx_10_7_x86_64.whl (338.7 kB view details)

Uploaded CPython 3.7mmacOS 10.7+ x86-64

aedat-1.2.0-cp36-none-win_amd64.whl (454.2 kB view details)

Uploaded CPython 3.6Windows x86-64

aedat-1.2.0-cp36-none-win32.whl (378.4 kB view details)

Uploaded CPython 3.6Windows x86

aedat-1.2.0-cp36-cp36m-manylinux2010_x86_64.whl (384.5 kB view details)

Uploaded CPython 3.6mmanylinux: glibc 2.12+ x86-64

aedat-1.2.0-cp36-cp36m-macosx_10_7_x86_64.whl (338.8 kB view details)

Uploaded CPython 3.6mmacOS 10.7+ x86-64

File details

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

File metadata

  • Download URL: aedat-1.2.0.tar.gz
  • Upload date:
  • Size: 22.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/0.9.4

File hashes

Hashes for aedat-1.2.0.tar.gz
Algorithm Hash digest
SHA256 6b0e2433a926e6fef24dd1a82e3358a911dd2bd58959e630a3ef3f50f7c7d08f
MD5 37936e0165dae2cddfb8de9c0a7424d4
BLAKE2b-256 6783553575742bb3a3591909522ffaaa9130d77cdbf8ed8c52a1516267d33023

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for aedat-1.2.0-cp39-none-win_amd64.whl
Algorithm Hash digest
SHA256 06fe44dcd94d92512b8e130250e593aebb5ed96243b0405db9d756375b2cee9a
MD5 23ddeedc0e8d0419b59b2cb8dd376102
BLAKE2b-256 af571174cab3b18d25b317001119b5bbd6ba26b00fb44183a54d59548060685f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: aedat-1.2.0-cp39-none-win32.whl
  • Upload date:
  • Size: 378.5 kB
  • Tags: CPython 3.9, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for aedat-1.2.0-cp39-none-win32.whl
Algorithm Hash digest
SHA256 d1305336e049a7cea3d9af6751eabcdf59557f770ab466c147400390b4cc4470
MD5 2f8379bf045e833e7e35a6c47a90b3c0
BLAKE2b-256 770574778f322eb94b076dc1cb8cc2c618226733879d9b9fd681b4450b3ffdda

See more details on using hashes here.

File details

Details for the file aedat-1.2.0-cp39-cp39-manylinux2010_x86_64.whl.

File metadata

  • Download URL: aedat-1.2.0-cp39-cp39-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 385.4 kB
  • Tags: CPython 3.9, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for aedat-1.2.0-cp39-cp39-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 96856a1f34872a4668df08186095c8c2befb27456ec8e405e5a33c489e68318e
MD5 64ccb5de417ec0499c9ff2bd933c5723
BLAKE2b-256 48e8b22fd5dca3aa184aa818f0cb659793b07ce07578853b940c671b0d9291eb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aedat-1.2.0-cp39-cp39-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 5570e7bc2440af13e28916f4e3fde90658f50a54be0c26789f7032d599c9a852
MD5 d15ff5ff41d3df5599a435591e8ccfe7
BLAKE2b-256 668b15334db5544fb9bf5f3bed22be05acfb28244e92b3cb7e09314aff7ebaa7

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for aedat-1.2.0-cp38-none-win_amd64.whl
Algorithm Hash digest
SHA256 c668ea6b68d1e20a365750007add937b98497ae6b34e7729906afdec68184e41
MD5 742de39be370de4ca27e8aba137c35f0
BLAKE2b-256 e0328c4653f254a1ecd053d3ccfd0f562242824cb5358753861cbbf766b763bd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: aedat-1.2.0-cp38-none-win32.whl
  • Upload date:
  • Size: 378.6 kB
  • Tags: CPython 3.8, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for aedat-1.2.0-cp38-none-win32.whl
Algorithm Hash digest
SHA256 09d0665d71357a38e1ebe01a4fab257e9b1dde966b2282738e3f3de76f1efdde
MD5 10e0b5c8b77fee56e7885c509c0c54af
BLAKE2b-256 f1eabd75987560f45d007fc2e8b47b2a47ce93d4a1e5a8801fca2c5312801c2c

See more details on using hashes here.

File details

Details for the file aedat-1.2.0-cp38-cp38-manylinux2010_x86_64.whl.

File metadata

  • Download URL: aedat-1.2.0-cp38-cp38-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 385.5 kB
  • Tags: CPython 3.8, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for aedat-1.2.0-cp38-cp38-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 47692f6b32876dc4eea997e1441e6cb3f5e6f8b41c5a2096631582f7035789e0
MD5 7b0c7e205a6969377e8becb3087f8b8f
BLAKE2b-256 ebb54410bd3fa3c557e53829acaef1f89c1c9235e871ebe38e8c7d1d9f50e9b1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aedat-1.2.0-cp38-cp38-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 3cc83e745a264eb4d0f95d7626b37e05f5f44f178c55346adf8c960ccc4c351e
MD5 b992d3d75701002f9931b7a6b13c3cd9
BLAKE2b-256 212362a3a21f458e22d792c1131633a0852f2963da2ab6890d337bc9981fbe01

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for aedat-1.2.0-cp37-none-win_amd64.whl
Algorithm Hash digest
SHA256 7ecc23bea6cdb4bfab205f04285747d90e9ce8440963ebae74e715775c2d0b14
MD5 bb05b96b11aa2a831c6835a5fd67f13a
BLAKE2b-256 576125828c45fc2c2e1f348c1f20deb2c8baccd2f7a9ef538a0cba6af16b7240

See more details on using hashes here.

File details

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

File metadata

  • Download URL: aedat-1.2.0-cp37-none-win32.whl
  • Upload date:
  • Size: 378.5 kB
  • Tags: CPython 3.7, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for aedat-1.2.0-cp37-none-win32.whl
Algorithm Hash digest
SHA256 3605c0d6f4d0f2413edc75e1e0f66a2863e42fb901ece5ffc6fe828d365f88f7
MD5 d241bd7cfc9e4bad32a693192f29c15d
BLAKE2b-256 7fd16a86aae0d1f2721445711ab0661fc56bbea8c49e33f41d36f562d42360c7

See more details on using hashes here.

File details

Details for the file aedat-1.2.0-cp37-cp37m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: aedat-1.2.0-cp37-cp37m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 384.5 kB
  • Tags: CPython 3.7m, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for aedat-1.2.0-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 76a7bb679e2ab4f1b0372e08f7df82cfefe58fce5dabdea8ae315dad84d9d4e4
MD5 93270659ccce6b0064b2cebe7fd686ae
BLAKE2b-256 e2a70d3c8c328e782ab65e635b2f6ea8557ccd82eecac209b5548a941087a82e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aedat-1.2.0-cp37-cp37m-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 565c076309166a0b84afe237c2a5a98baf2a37402f90879ed817ac3cfe7fd9ef
MD5 4861ebe6664102323d1235cb05c0a631
BLAKE2b-256 d8e47d0ba49d87b5167dbfabf543a806b8d3ee4c6d33942eb5928f8478da3459

See more details on using hashes here.

File details

Details for the file aedat-1.2.0-cp36-none-win_amd64.whl.

File metadata

  • Download URL: aedat-1.2.0-cp36-none-win_amd64.whl
  • Upload date:
  • Size: 454.2 kB
  • Tags: CPython 3.6, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for aedat-1.2.0-cp36-none-win_amd64.whl
Algorithm Hash digest
SHA256 6f129364453ecc3d9c7e51c6738bd3319128d6a8e7c0e58ef3b75f0c07daa1c9
MD5 fbbad61d82ac17e02a850216fec86658
BLAKE2b-256 d1f546d76f3face509ff655b95424e68585e7c6585961d4c5f6a31dba457e8e2

See more details on using hashes here.

File details

Details for the file aedat-1.2.0-cp36-none-win32.whl.

File metadata

  • Download URL: aedat-1.2.0-cp36-none-win32.whl
  • Upload date:
  • Size: 378.4 kB
  • Tags: CPython 3.6, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for aedat-1.2.0-cp36-none-win32.whl
Algorithm Hash digest
SHA256 0b42990055fa27484eb4bc4bbcdb4c450936b3ea9ecdc67248aa19ea3cdbc5a1
MD5 7352dcee2c82c92863efaef9f6233d79
BLAKE2b-256 ca78bbb12cec403a61b68b3882b9df56ce89832bc19cf43b47ccb039f7ef362c

See more details on using hashes here.

File details

Details for the file aedat-1.2.0-cp36-cp36m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: aedat-1.2.0-cp36-cp36m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 384.5 kB
  • Tags: CPython 3.6m, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for aedat-1.2.0-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 3796cbf3e7690a21a095f762b9ffd0f0618a8c60aa19108220a96f3a2bbb8c88
MD5 c858a5d0739c74dbe1325d8119d6ee09
BLAKE2b-256 6b3356a4a394ae47dd6558a4002077f0dd9706f983d9b071491ae2c9f41c4447

See more details on using hashes here.

File details

Details for the file aedat-1.2.0-cp36-cp36m-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for aedat-1.2.0-cp36-cp36m-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 897e43b97383691115435c9701d271e4575edab15954e27c047a1408429708b2
MD5 23f3b033ba80632a9583d06e38f4d63f
BLAKE2b-256 a97730541ce77f509f01886af6c493a4670c90a940a5dea391a02e92f5ebf14f

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