Skip to main content

Calculate STTC for large datasets of spiking time-series.

Project description

STTCPy Documentation

Overview

STTCPy is a Python package designed to efficiently compute the Spike Time Tiling Coefficient (STTC), a metric introduced by Cutts and Eglen et al. to assess synchrony between neuronal spike trains (Cutts and Eglen, 2014). While existing STTC implementations in both Python and MATLAB are limited to one-to-one calculations (i.e., STTC between a single pair of signals), STTCPy vectorizes these computations, enabling much faster processing of large datasets.

This approach significantly accelerates STTC calculations, making it suitable for high-volume data analysis. The package also includes functionality for calculating null distributions for significance testing and offers GPU acceleration using PyTorch backend for even greater performance on large-scale analyses.

Key features:

  • Efficient, vectorized STTC computation for large datasets.
  • Scalable GPU-based functionality with PyTorch and CUDA support.
  • Helper functions for pre-processing, analysis, and significance testing via null calculations.

Installation

Requirements:

  • Python 3.8 or newer.
  • Dependencies: numpy, scipy

Note: To enable GPU functionality, PyTorch must be installed with the appropriate CUDA version for your system. For installation instructions, visit the PyTorch installation guide.

Installation:

Install the package via pip:

pip install STTCPy

Alternatively, clone the repository and install manually:

git clone https://github.com/aditiaravind/STTCPy.git
cd STTCPy
pip install .

Usage

Import the Package:

from STTCPy import STTC, null

Using CPU-only version:

Compute STTC:

from STTCPy import STTC, null, generate_spike_train

N = 3 # Number of spike trains
L = 1000 # Length of each spike train
sparsity = 0.2 # Density of spikes within the train

spikes = generate_spike_train(N, L, sparsity)

dt = 2  # Number of frames to pad when calculating STTC

spikes_STTC = STTC(spikes, dt)

You can then plot the STTC values as follows

plt.imshow(spikes_STTC, vmax=1, vmin=-1, cmap='bwr')
plt.colorbar()
plt.xlabel('STTC Value')
plt.ylabel('STTC Value')
plt.title(f'STTC across {N} spike trains')
plt.show()

Null Model for Statistical Testing:

Calculate STTC when the signals are shuffled or shifted 'n' times. Average this to compare against the actualy STTC values to check for significance.

n_shifts = 5

spikes_null = null(spikes, n_shifts, dt)
print(f"Null STTC Shape: {spikes_null.shape}")

# Output : (5, 10, 10)

Using GPU:

Here, you have to have torch installed.

import torch
from STTCPy import STTC_gpu as STTC, null_gpu as null

N = 3 # Number of spike trains
L = 1000 $ Length of each spike train
sparsity = 0.2 # Density of spikes within the train

spikes_numpy = generate_spike_train(N, L, sparsity)
spikes = torch.tensor(spikes_numpy, device='cuda', dtype=torch.float32) #Specify dtype as float for best results.

dt = 2  # Number of frames to pad when calculating STTC
n_shifts = 5

spikes_STTC = STTC(spikes, dt)
null_STTC = null(spikes, n_shifts, dt)

For full documentation visit the Github repository


Acknowledgments

I would like to acknowledge the following paper for introducing the Spike Time Tiling Coefficient (STTC) metric:

Cutts CS, Eglen SJ. Detecting pairwise correlations in spike trains: an objective comparison of methods and application to the study of retinal waves. J Neurosci. 2014 Oct 22;34(43):14288-303. https://doi.org/10.1523/jneurosci.2767-14.2014. PMID: 25339742; PMCID: PMC4205553.


License

STTCPy is distributed under the GNU General Public License v3 (GPLv3). For more details, refer to the GNU GPLv3 License.


Contributing

I welcome contributions! Here’s how you can help:

  1. Fork the repository.
  2. Create a new branch for your feature or bug fix:
    git checkout -b feature-name
    
  3. Commit your changes and push to your branch:
    git commit -m "Description of changes"
    git push origin feature-name
    
  4. Submit a pull request with a detailed description of your changes.

For issues or feature requests, please use the GitHub issues page.


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

sttcpy-1.0.0.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

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

STTCPy-1.0.0-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file sttcpy-1.0.0.tar.gz.

File metadata

  • Download URL: sttcpy-1.0.0.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.7

File hashes

Hashes for sttcpy-1.0.0.tar.gz
Algorithm Hash digest
SHA256 9fac02dbdd8eab3903502eef0920997c980f64a93e406ab993112c742bfae0dd
MD5 f144b8c30343b57840820815cb1b0271
BLAKE2b-256 3fb59b32170e2fed068e4c3464242e44da7cbe78e8b19d74fc03a4a573cc0cd2

See more details on using hashes here.

File details

Details for the file STTCPy-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: STTCPy-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.7

File hashes

Hashes for STTCPy-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b88b309864149f791b5ea83979a4d7bae91e29fe010db4947248dd7507e51fe9
MD5 830b8d232b31b3449f8e7050ebd9f360
BLAKE2b-256 d77b0e659a5805ca70cda9b36907080591edb288d7c9bc9bfc51e28b9afaf0c2

See more details on using hashes here.

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