Skip to main content

SpikeData Package

CI

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

For regular use, just install with pip from PyPI.

pip install 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.

Metadata

Release files for spikedata 0.2.2

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

Source distribution (sdist)

Source distribution for spikedata 0.2.2
File Size Uploaded
spikedata-0.2.2.tar.gz 26.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for spikedata 0.2.2
File Interpreter ABI Platform
spikedata-0.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 45.3 kB

Release files / spikedata-0.2.2.tar.gz

Download URL spikedata-0.2.2.tar.gz
Size 26.1 kB
Tags Source
SHA-256 checksum
How to use checksums
775c964cb9f2a7d4cd5f741830cf79e544e47b5b24ec257bf06b9c54418bfe76
BLAKE2b-256 checksum
How to use checksums
2dc1638415879c9744032891a841fcabaae2390b610b31364bf1454f46bea093
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.3

Release files / spikedata-0.2.2-py3-none-any.whl

Download URL spikedata-0.2.2-py3-none-any.whl
Size 19.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
22374920b7e27583a947adace6c8cced0b5da32925759b3b468c68210305dcf0
BLAKE2b-256 checksum
How to use checksums
c5222bf32cb70b76110a7ddfc7a27a105e5134555799a241c3f2743fd4c86b85
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.3

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 release files

0.2.1

2 release files

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