# 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](https://numba.pydata.org/) for performance optimization
- Supports various cost parameters, including special cases for spike count and infinite cost
## Installation
You can install SpikeTrainDist using pip:
```bash
pip install spiketraindist
```
## Usage
Here's a quick example of how to use the Victor-Purpura distance function:
```python
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:
```bash
pytest .
```
### Code Style
This project uses Ruff for code linting. To check your code, run:
```bash
ruff check .
```
## License
This project is licensed under the Unlicense - see the [LICENSE](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.
Raw data
{
"_id": null,
"home_page": null,
"name": "spiketraindist",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.9",
"maintainer_email": null,
"keywords": "temporal coding, metric space, dynamic programming, neuroscience, Spike train",
"author": "matrix-reloaded-zen",
"author_email": "zen@example.com",
"download_url": "https://files.pythonhosted.org/packages/25/85/c8ecaf8c4f798d0ac84b42e353031ecce51659554b2815a41d446872adc6/spiketraindist-0.0.1.tar.gz",
"platform": null,
"description": "# SpikeTrainDist\n\nSpikeTrainDist is a Python package for calculating spike train distances.\nThis tool is designed for neuroscientists and researchers working with temporal coding and spike train analysis.\n\n## Features\n\n- Efficient implementation of the Victor-Purpura distance algorithm\n- Utilizes [Numba](https://numba.pydata.org/) for performance optimization\n- Supports various cost parameters, including special cases for spike count and infinite cost\n\n## Installation\n\nYou can install SpikeTrainDist using pip:\n\n```bash\npip install spiketraindist\n```\n\n## Usage\n\nHere's a quick example of how to use the Victor-Purpura distance function:\n\n```python\nimport numpy as np\nfrom spiketraindist import victor_purpura_distance\n\nspike_train_a = np.array([0.1, 0.3, 0.5])\nspike_train_b = np.array([0.2, 0.4, 0.6])\n\ndistance = victor_purpura_distance(spike_train_a, spike_train_b, cost=1.0)\nprint(f\"The Victor-Purpura distance is: {distance}\")\n```\n\n## API Reference\n\n### `victor_purpura_distance(spike_train_a, spike_train_b, cost=1.0)`\n\nComputes the Victor-Purpura distance between two spike trains.\n\nParameters:\n\n- `spike_train_a` (np.ndarray): The first spike train, represented as a 1D numpy array of spike times.\n- `spike_train_b` (np.ndarray): The second spike train, represented as a 1D numpy array of spike times.\n- `cost` (float, optional): The cost of shifting a spike in time. Default is 1.0.\n\nReturns:\n\n- `distance` (float): The Victor-Purpura distance between the two spike trains.\n\n## Development\n\nTo set up the development environment:\n\n1. Clone the repository\n2. Install Poetry if you haven't already: `pip install poetry`\n3. Install dependencies: `poetry install`\n4. Activate the virtual environment: `poetry shell`\n\n### Running Tests\n\nTo run the tests, use pytest:\n\n```bash\npytest .\n```\n\n### Code Style\n\nThis project uses Ruff for code linting. To check your code, run:\n\n```bash\nruff check .\n```\n\n## License\n\nThis project is licensed under the Unlicense - see the [LICENSE](LICENSE) file for details.\n\n## References\n\n1. 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\u20131326, Aug. 01, 1996. doi: 10.1152/jn.1996.76.2.1310.\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request or open an issue.\n\n",
"bugtrack_url": null,
"license": "Unlicense",
"summary": "Calculate spike train distances",
"version": "0.0.1",
"project_urls": null,
"split_keywords": [
"temporal coding",
" metric space",
" dynamic programming",
" neuroscience",
" spike train"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "acf3ec85dc5d39fcaad7604b2006ef1f27f33de4c5773d440475295472e6318f",
"md5": "e44429c3402accf6c763721f9d24e19a",
"sha256": "3e7be875724827f40bf029ed15e5387c641bffcf4163237b739b1fcdae8a691d"
},
"downloads": -1,
"filename": "spiketraindist-0.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e44429c3402accf6c763721f9d24e19a",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.9",
"size": 5212,
"upload_time": "2024-09-27T12:44:21",
"upload_time_iso_8601": "2024-09-27T12:44:21.626581Z",
"url": "https://files.pythonhosted.org/packages/ac/f3/ec85dc5d39fcaad7604b2006ef1f27f33de4c5773d440475295472e6318f/spiketraindist-0.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "2585c8ecaf8c4f798d0ac84b42e353031ecce51659554b2815a41d446872adc6",
"md5": "4b2acd0622eed99318924faf21894c49",
"sha256": "65122edb32bb93a96a2a558c9091a4e500bc7f7860c71d2f4c845cf5162bf3bc"
},
"downloads": -1,
"filename": "spiketraindist-0.0.1.tar.gz",
"has_sig": false,
"md5_digest": "4b2acd0622eed99318924faf21894c49",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.9",
"size": 4216,
"upload_time": "2024-09-27T12:44:23",
"upload_time_iso_8601": "2024-09-27T12:44:23.322648Z",
"url": "https://files.pythonhosted.org/packages/25/85/c8ecaf8c4f798d0ac84b42e353031ecce51659554b2815a41d446872adc6/spiketraindist-0.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-27 12:44:23",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "spiketraindist"
}