Toolkit for processing spiking neural time series
Project description
SpikeData Package
Overview
SpikeData is a Python package designed for handling and analyzing neuronal spike data. It provides a suite of tools for loading, processing, and analyzing spike data from various in-memory sources such as NEST simulation outputs, lists of indices and times, spike raster matrices, and more.
Features
- Flexible Data Loading: Load spike data from various formats including NEST Simulator, raster matrices, raw data via filtering & thresholding, and custom event lists.
- Data Processing: Process spike trains with functions for binning, resampling, thresholding, and filtering.
- Analysis Tools: Perform detailed analyses such as burst detection, cumulative moving averages, Fano factors, and population firing rates.
- Customization: Add metadata and neuron attributes for comprehensive data management.
- Utilities: Generate matched pairs of unit indices and times, iterate through spike events, and create subwindows of spike data.
Installation
You can install the SpikeData package via pip. 🚧 So far only from GitHub, not PyPI.
pip install git+https://github.com/braingeneers/SpikeData
Working with SpikeData Objects
This section describes the usage of a few key methods via simple examples. There are a lot of usage examples in the unit test code as well.
Constructors
The main constructor for SpikeData takes a list of arrays of spike times, but there are various other constructors that take other in-memory formats implemented as static methods for convenience.
All of the constructors also take a variety of metadata parameters.
-
From indices and times:
idces = [0, 1, 0, 1] times = [10, 20, 30, 40] spike_data = SpikeData.from_idces_times(idces, times)
-
From raster:
raster = np.array([[1, 0, 2], [0, 1, 1]]) spike_data = SpikeData.from_raster(raster, bin_size_ms=10)
-
From NEST spike recorder:
nodes = nest.Create(...) other_nodes = nest.Create(...) spike_recorder = nest.Create('spike_recorder') nest.Connect(spike_recorder, nodes) nest.Simulate(...) spike_data = SpikeData.from_nest(spike_recorder, nodes, other_nodes)
You can also get a SpikeData object from a list of spike trains represented using Neo (neo.SpikeTrain via SpikeData.from_neo_spiketrains) or MuscleBeachTools (mbt.Neuron via SpikeData.from_mbt_neurons).
Accessing Spike Data
-
Spike times of a particular unit:
for time in spike_data.train[i]: print(f"Unit {i} fired at {time} ms")
-
Spike times of all units:
for time in spike_data.times: print(f"Some neuron fired at {time} ms")
-
Events from all units:
for index, time in spike_data.events: print(f"Neuron {index} fired at {time} ms")
-
Binned population activity:
binned_data = spike_data.binned(bin_size=40) print(f"There were {binned_data[1]} firings between 40 and 80 ms")
Firing Rates
-
Mean firing rate in each time bin:
rate = spike_data.binned_meanrate(bin_size=40, unit='Hz') print(rate)
-
Firing rate of each neuron:
rates = spike_data.rates(unit='Hz') print(rates)
-
Instantaneous firing rates of every neuron via ISI resampling:
times = np.linspace(0, 1000, 100) # Example times resampled_isi = spike_data.resampled_isi(times) print(resampled_isi)
-
Spike raster, in N×T format:
raster = spike_data.raster(bin_size=20.0)
Slicing and Combining Spike Data Objects
-
Appending in time:
spike_data2 = SpikeData.from_idces_times([2, 3], [50, 60]) combined_data = spike_data.append(spike_data2, offset=10)
-
Subsetting neurons:
subset_data = spike_data.subset({0, 1}) subset_data = spike_data[{0, 1}]
-
Slicing time windows:
window_data = spike_data.subtime(0, 100) subset_data = spike_data[0:100]
Analysis Methods
🚧 Various other analysis methods are provided, but there aren't usage examples written up yet.
Contributing
Contributions to SpikeData are welcome. Please fork the repository and submit pull requests. Ensure that your code adheres to the PEP 8 style guide and includes appropriate tests.
License
SpikeData is licensed under the MIT License. See the LICENSE file for more details.
Acknowledgements
This package utilizes numpy for numerical operations and scipy for signal processing. There is also an optional dependency on powerlaw, which is used for calculating the deviation from criticality coefficient (DCC).
For any questions or issues, please open an issue on the GitHub repository.
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 spikedata-0.2.1.tar.gz.
File metadata
- Download URL: spikedata-0.2.1.tar.gz
- Upload date:
- Size: 26.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
951456df59517eeaf0b22672604bbe989ec9e37fa5f20e49635eb797fd5339ac
|
|
| MD5 |
fa9a71abcf714607456efdf64c4e4c4b
|
|
| BLAKE2b-256 |
d74e0c32bfa1ed27f5043e335fe1c6648afaffcc9285739eb45a4b3250094eb0
|
Provenance
The following attestation bundles were made for spikedata-0.2.1.tar.gz:
Publisher:
cd.yml on braingeneers/SpikeData
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spikedata-0.2.1.tar.gz -
Subject digest:
951456df59517eeaf0b22672604bbe989ec9e37fa5f20e49635eb797fd5339ac - Sigstore transparency entry: 218609195
- Sigstore integration time:
-
Permalink:
braingeneers/SpikeData@3d3533a00b141ad06e1ec984c49204bdf82e1f9f -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/braingeneers
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@3d3533a00b141ad06e1ec984c49204bdf82e1f9f -
Trigger Event:
release
-
Statement type:
File details
Details for the file spikedata-0.2.1-py3-none-any.whl.
File metadata
- Download URL: spikedata-0.2.1-py3-none-any.whl
- Upload date:
- Size: 19.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d6dd66d3d961ccb34c8a7952b875723be8fc049e27ced1e55755e38bea15194d
|
|
| MD5 |
d34c731f91f71381ce2a6b4b097c456e
|
|
| BLAKE2b-256 |
966066b7b65879a7174b6bf1f3022ba15fad320f7a04606371acad6ffb43356f
|
Provenance
The following attestation bundles were made for spikedata-0.2.1-py3-none-any.whl:
Publisher:
cd.yml on braingeneers/SpikeData
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spikedata-0.2.1-py3-none-any.whl -
Subject digest:
d6dd66d3d961ccb34c8a7952b875723be8fc049e27ced1e55755e38bea15194d - Sigstore transparency entry: 218609213
- Sigstore integration time:
-
Permalink:
braingeneers/SpikeData@3d3533a00b141ad06e1ec984c49204bdf82e1f9f -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/braingeneers
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@3d3533a00b141ad06e1ec984c49204bdf82e1f9f -
Trigger Event:
release
-
Statement type: