Skip to main content

Toolkit for processing spiking neural time series

Project description

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

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

spikedata-0.2.1.tar.gz (26.1 kB view details)

Uploaded Source

Built Distribution

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

spikedata-0.2.1-py3-none-any.whl (19.2 kB view details)

Uploaded Python 3

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

Hashes for spikedata-0.2.1.tar.gz
Algorithm Hash digest
SHA256 951456df59517eeaf0b22672604bbe989ec9e37fa5f20e49635eb797fd5339ac
MD5 fa9a71abcf714607456efdf64c4e4c4b
BLAKE2b-256 d74e0c32bfa1ed27f5043e335fe1c6648afaffcc9285739eb45a4b3250094eb0

See more details on using hashes here.

Provenance

The following attestation bundles were made for spikedata-0.2.1.tar.gz:

Publisher: cd.yml on braingeneers/SpikeData

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for spikedata-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d6dd66d3d961ccb34c8a7952b875723be8fc049e27ced1e55755e38bea15194d
MD5 d34c731f91f71381ce2a6b4b097c456e
BLAKE2b-256 966066b7b65879a7174b6bf1f3022ba15fad320f7a04606371acad6ffb43356f

See more details on using hashes here.

Provenance

The following attestation bundles were made for spikedata-0.2.1-py3-none-any.whl:

Publisher: cd.yml on braingeneers/SpikeData

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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