Skip to main content

Calculate spike train distances

Project description

SpikeTrainDist

SpikeTrainDist is a Python package for calculating spike train distances. This tool is designed for neuroscientists and researchers working with temporal coding and spike train analysis.

Features

  • Efficient implementation of the Victor-Purpura distance algorithm
  • Utilizes Numba for performance optimization
  • Supports various cost parameters, including special cases for spike count and infinite cost

Installation

You can install SpikeTrainDist using pip:

pip install spiketraindist

Usage

Here's a quick example of how to use the Victor-Purpura distance function:

import numpy as np
from spiketraindist import victor_purpura_distance

spike_train_a = np.array([0.1, 0.3, 0.5])
spike_train_b = np.array([0.2, 0.4, 0.6])

distance = victor_purpura_distance(spike_train_a, spike_train_b, cost=1.0)
print(f"The Victor-Purpura distance is: {distance}")

API Reference

victor_purpura_distance(spike_train_a, spike_train_b, cost=1.0)

Computes the Victor-Purpura distance between two spike trains.

Parameters:

  • spike_train_a (np.ndarray): The first spike train, represented as a 1D numpy array of spike times.
  • spike_train_b (np.ndarray): The second spike train, represented as a 1D numpy array of spike times.
  • cost (float, optional): The cost of shifting a spike in time. Default is 1.0.

Returns:

  • distance (float): The Victor-Purpura distance between the two spike trains.

Development

To set up the development environment:

  1. Clone the repository
  2. Install Poetry if you haven't already: pip install poetry
  3. Install dependencies: poetry install
  4. Activate the virtual environment: poetry shell

Running Tests

To run the tests, use pytest:

pytest .

Code Style

This project uses Ruff for code linting. To check your code, run:

ruff check .

License

This project is licensed under the Unlicense - see the LICENSE file for details.

References

  1. J. D. Victor and K. P. Purpura, "Nature and precision of temporal coding in visual cortex: a metric-space analysis," Journal of Neurophysiology, vol. 76, no. 2. American Physiological Society, pp. 1310–1326, Aug. 01, 1996. doi: 10.1152/jn.1996.76.2.1310.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request or open an issue.

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

spiketraindist-0.0.1.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

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

spiketraindist-0.0.1-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file spiketraindist-0.0.1.tar.gz.

File metadata

  • Download URL: spiketraindist-0.0.1.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for spiketraindist-0.0.1.tar.gz
Algorithm Hash digest
SHA256 65122edb32bb93a96a2a558c9091a4e500bc7f7860c71d2f4c845cf5162bf3bc
MD5 4b2acd0622eed99318924faf21894c49
BLAKE2b-256 2585c8ecaf8c4f798d0ac84b42e353031ecce51659554b2815a41d446872adc6

See more details on using hashes here.

File details

Details for the file spiketraindist-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: spiketraindist-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for spiketraindist-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3e7be875724827f40bf029ed15e5387c641bffcf4163237b739b1fcdae8a691d
MD5 e44429c3402accf6c763721f9d24e19a
BLAKE2b-256 acf3ec85dc5d39fcaad7604b2006ef1f27f33de4c5773d440475295472e6318f

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