Skip to main content
https://badge.fury.io/py/pyspike.png https://travis-ci.org/mariomulansky/PySpike.svg?branch=master

PySpike is a Python library for the numerical analysis of spike train similarity. Its core functionality is the implementation of the ISI-distance [1] and SPIKE-distance [2], SPIKE-Synchronization [3], as well as their adaptive generalizations [4]. It provides functions to compute multivariate profiles, distance matrices, as well as averaging and general spike train processing. All computation intensive parts are implemented in C via cython to reach a competitive performance (factor 100-200 over plain Python).

PySpike provides the same fundamental functionality as the SPIKY framework for Matlab, which additionally contains spike-train generators, more spike train distance measures and many visualization routines.

All source codes are available on Github and are published under the BSD_License.

Citing PySpike

If you use PySpike in your research, please cite our SoftwareX publication on PySpike:

Mario Mulansky, Thomas Kreuz, PySpike - A Python library for analyzing spike train synchrony, Software X 5, 183 (2016) [pdf]

Additionally, depending on the used methods: ISI-distance [1], SPIKE-distance [2], SPIKE-Synchronization [3], or their adaptive generalizations [4], please cite one or more of the following publications:

Important Changelog

With version 0.8.0, Adaptive and Rate Independent algorithms are supported.

With version 0.7.0, support for Python 2 was dropped, PySpike now officially supports Python 3.7, 3.8, 3.9, 3.10.

With version 0.6.0, the spike directionality and spike train order function have been added.

With version 0.5.0, the interfaces have been unified and the specific functions for multivariate computations have become deprecated.

With version 0.2.0, the SpikeTrain class has been introduced to represent spike trains. This is a breaking change in the function interfaces. Hence, programs written for older versions of PySpike (0.1.x) will not run with newer versions.

Requirements and Installation

PySpike is available at Python Package Index and this is the easiest way to obtain the PySpike package. If you have pip installed, just run

sudo pip install pyspike

to install pyspike. PySpike requires numpy as minimal requirement, as well as a C compiler to generate the binaries.

Install from Github sources

You can also obtain the latest PySpike developer version from the github repository. For that, make sure you have the following Python libraries installed:

  • numpy

  • cython

  • matplotlib (for the examples)

  • pytest (for running the tests)

  • scipy (also for the tests)

In particular, make sure that cython is configured properly and able to locate a C compiler, otherwise PySpike will use the much slower Python implementations.

To install PySpike, simply download the source, e.g. from Github, and run the setup.py script:

git clone https://github.com/mariomulansky/PySpike.git
cd PySpike
python setup.py build_ext --inplace

Then you can run the tests using the pytest test framework:

pytest

Finally, you should make PySpike’s installation folder known to Python to be able to import pyspike in your own projects. Therefore, add your /path/to/PySpike to the $PYTHONPATH environment variable.

Examples

The following code loads some exemplary spike trains, computes the dissimilarity profile of the ISI-distance of the first two SpikeTrain objects, and plots it with matplotlib:

import matplotlib.pyplot as plt
import pyspike as spk

spike_trains = spk.load_spike_trains_from_txt("PySpike_testdata.txt",
                                              edges=(0, 4000))
isi_profile = spk.isi_profile(spike_trains[0], spike_trains[1])
x, y = isi_profile.get_plottable_data()
plt.plot(x, y, '--k')
print("ISI distance: %.8f" % isi_profile.avrg())
plt.show()

The following example computes the multivariate ISI-, SPIKE- and SPIKE-Sync-profile for a list of spike trains loaded from a text file:

spike_trains = spk.load_spike_trains_from_txt("PySpike_testdata.txt",
                                              edges=(0, 4000))
avrg_isi_profile = spk.isi_profile(spike_trains)
avrg_spike_profile = spk.spike_profile(spike_trains)
avrg_spike_sync_profile = spk.spike_sync_profile(spike_trains)

More examples with detailed descriptions can be found in the tutorial section.


The work on PySpike was supported by the European Comission through the Marie Curie Initial Training Network Neural Engineering Transformative Technologies (NETT) under the project number 289146.

Python/C Programming:
  • Mario Mulansky

  • Edmund J Butler

Scientific Methods:
  • Thomas Kreuz

  • Daniel Chicharro

  • Conor Houghton

  • Nebojsa Bozanic

  • Mario Mulansky

Release files for pyspike 0.9.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyspike 0.9.0
File Size Uploaded
pyspike-0.9.0.tar.gz 78.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyspike 0.9.0
File Interpreter ABI Platform
pyspike-0.9.0-cp39-cp39-macosx_10_9_universal2.whl CPython 3.9 CPython 3.9 macOS 10.9+ universal2 (ARM64, x86-64) Details

Total release size: 1.1 MB

Release files / pyspike-0.9.0.tar.gz

Download URL pyspike-0.9.0.tar.gz
Size 78.1 kB
Tags Source
SHA-256 checksum
How to use checksums
b74008d88723a7781a6b7265621fe4555197d724156a6905ee5328c3e31e1fad
BLAKE2b-256 checksum
How to use checksums
d216aa9d9b3604a8c4906ec14fb38c46f1fe6d364f2dfcc28cc303f61215269f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Release files / pyspike-0.9.0-cp39-cp39-macosx_10_9_universal2.whl

Download URL pyspike-0.9.0-cp39-cp39-macosx_10_9_universal2.whl
Size 1.0 MB
Tags CPython 3.9 macOS 10.9+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
6fcf2c16bb61b212887acef4d5f1657ce44bd02dfd489b000ee99dcce3429c67
BLAKE2b-256 checksum
How to use checksums
20f6a9b6ee66df3706247e70e6f7e25b2529a132cbde431aae1757bf3ccf940f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Release history Release notifications | RSS feed

This release

0.9.0 This release

2 release files

0.8.0

1 release file

0.7.0

2 release files

0.6.0

1 release file

0.5.3

1 release file

0.5.2

1 release file

0.5.1

1 release file

0.5.0

1 release file

0.4.0

1 release file

0.3.0

1 release file

0.2.0

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page