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:
- Clone the repository
- Install Poetry if you haven't already:
pip install poetry - Install dependencies:
poetry install - 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
- 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
65122edb32bb93a96a2a558c9091a4e500bc7f7860c71d2f4c845cf5162bf3bc
|
|
| MD5 |
4b2acd0622eed99318924faf21894c49
|
|
| BLAKE2b-256 |
2585c8ecaf8c4f798d0ac84b42e353031ecce51659554b2815a41d446872adc6
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3e7be875724827f40bf029ed15e5387c641bffcf4163237b739b1fcdae8a691d
|
|
| MD5 |
e44429c3402accf6c763721f9d24e19a
|
|
| BLAKE2b-256 |
acf3ec85dc5d39fcaad7604b2006ef1f27f33de4c5773d440475295472e6318f
|