Skip to main content

A Python package to convert signal data to spike trains

Project description

Spikify Overview

Spikify is a Python package designed to transform raw signals into spike trains that can be fed into Spiking Neural Networks (SNNs). This package implements a variety of spike encoding techniques based on recent research to facilitate the integration of time-varying signals into neuromorphic computing frameworks.

Introduction

Spiking Neural Networks (SNNs) are a novel type of artificial neural network that operates using discrete events (spikes) in time, inspired by the behavior of biological neurons. They are characterized by their potential for low energy consumption and computational cost, making them suitable for edge computing and IoT applications. However, traditional digital signals must be encoded into spike trains before they can be processed by SNNs.

This package provides a suite of spike encoding techniques that convert time-varying signals into spikes, enabling seamless integration with neuromorphic computing technologies. The encoding techniques implemented in this package are based on the research article: "Spike Encoding Techniques for IoT Time-Varying Signals Benchmarked on a Neuromorphic Classification Task" (Forno et al., 2022).

Features

  • Multiple Spike Encoding Techniques: Includes both rate-based and temporal encoding schemes
  • Signal Preprocessing: Tools for filtering and preparing signals, including:
    • Gammatone Filter: Mimics human auditory filtering, useful for audio and speech signals.
    • Butterworth Filter: Smooths and removes noise from signals, ideal for general sensor data.
    • Easily chain filters before encoding to improve spike train quality.

Installation

To install the Spikify package, use pip:

pip install innuce-spikify

Usage

Here is a simple example to get started:

import numpy as np
from spikify.filtering import FilterBank
from spikify.encoding.rate import poisson_rate

# Generate a sinusoidal signal
time = np.linspace(0, 2 * np.pi, 100)  # Time from 0 to 2*pi
amplitude = np.sin(time)  # Sinusoidal signal

filter = FilterBank(fs=50, channels=5, f_min=0.5, f_max=5, order=4, filter_type='butterworth')

filtered_signal = filter.decompose(signal) # (timesteps, channels, features)

filtered_signal = np.reshape(filtered_signal, (-1, filtered_signal.shape[1] * filtered_signal.shape[2]))

# Encode the filtered signal
encoded_signal = poisson_rate(filtered_signal, interval_length=2)

For more detailed examples and usage, please refer to the documentation.

Encoding Techniques

This package implements several spike encoding families techniques, including:

Encoding Family Algorithm Description
Rate Encoding Poisson Rate Encodes intensity as firing rate
Temporal Encoding Moving Window Spikes on local changes
Step Forward Spikes on signal steps
Threshold-Based Spikes when crossing thresholds
Zero-Cross Step Forward Spikes on zero-crossings
Deconvolution-Based Ben Spiker Deconvolves spikes from signal
Hough Spiker Uses Hough transform for spikes
Modified Hough Spiker Robust Hough-based encoding
Global Referenced Phase Encoding Encodes phase information
Time-to-Spike Spikes at specific time delays
Latency Encoding Burst Encoding Encodes bursts of spikes

Tip:

  • Use Poisson Rate for general-purpose encoding.
  • Use Temporal or Deconvolution methods for signals where timing or event structure is important.

Filters

Spikify provides preprocessing filters that can be applied to signals before encoding to improve spike train quality and remove noise. These filters help condition the raw signal data for better encoding performance.

Available Filters

Filter Type Description
Gammatone Mimics human auditory filtering
Butterworth Low-pass filter for noise reduction and smoothing

Encoded Datasets

The following datasets have been selected to serve as examples for benchmarking spike train encoding techniques:

  • WISDM Dataset: 20 Hz recordings of human activity through mobile and wearable inertial sensors

These datasets are preprocessed and converted into spike trains to evaluate the performance of different encoding techniques.

Citation

If you use this framework in your research, please cite the following article:

@ARTICLE{
    10.3389/fnins.2022.999029,
    AUTHOR={Forno, Evelina  and Fra, Vittorio  and Pignari, Riccardo  and Macii, Enrico  and Urgese, Gianvito },
    TITLE={Spike encoding techniques for IoT time-varying signals benchmarked on a neuromorphic classification task},
    JOURNAL={Frontiers in Neuroscience},
    VOLUME={16},
    YEAR={2022},
    URL={https://www.frontiersin.org/journals/neuroscience/articles/10.3389/fnins.2022.999029},
    DOI={10.3389/fnins.2022.999029},
    ISSN={1662-453X},
}

Contributing

We welcome contributions from the community. Please see our CONTRIBUTING.rst file for more details on how to get involved.

License

This project is licensed under the Apache 2.0 License - see the LICENSE file for details.

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

innuce_spikify-0.3.0.tar.gz (19.3 kB view details)

Uploaded Source

Built Distribution

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

innuce_spikify-0.3.0-py3-none-any.whl (29.8 kB view details)

Uploaded Python 3

File details

Details for the file innuce_spikify-0.3.0.tar.gz.

File metadata

  • Download URL: innuce_spikify-0.3.0.tar.gz
  • Upload date:
  • Size: 19.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.11.14 Linux/6.11.0-1018-azure

File hashes

Hashes for innuce_spikify-0.3.0.tar.gz
Algorithm Hash digest
SHA256 20528540ce6404225efddbb14aab41f0dd29ad83702aaf3f9ed0acbd8c073067
MD5 59e4e59f395e01f77300e548f2832989
BLAKE2b-256 93a5aa5111e97bb81470b53037ef5dc370350af2715836b791af9f1d40a4accd

See more details on using hashes here.

File details

Details for the file innuce_spikify-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: innuce_spikify-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 29.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.11.14 Linux/6.11.0-1018-azure

File hashes

Hashes for innuce_spikify-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6f25a02adfb21cba8ab27553d0f5f2fab60efb498389af0c5db606e5b2c1611b
MD5 de840da1bdab8492b16c21061a503562
BLAKE2b-256 53edc62cc36a4172ca1e94ed2829691aff6682239a6fa0d7d7655e35e7a29929

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