blechrnn

Estimating neural firing rates using LSTM

https://github.com/abuzarmahmood/blechrnn

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (14.0%) to scientific vocabulary
Last synced: 10 months ago · JSON representation ·

Repository

Estimating neural firing rates using LSTM

Basic Info
  • Host: GitHub
  • Owner: abuzarmahmood
  • Language: Python
  • Default Branch: master
  • Size: 30.3 KB
Statistics
  • Stars: 2
  • Watchers: 1
  • Forks: 1
  • Open Issues: 10
  • Releases: 0
Created about 2 years ago · Last pushed 11 months ago
Metadata Files
Readme Citation

README.md

BlechRNN

Neural network pipeline to estimate neural firing rates from spike train data using continuous-time RNNs.

Architecture

The model uses an autoencoder architecture with three main components:

  • Encoder: Projects input spike data to latent space

    • Reduces dimensionality of spike train data
    • Learns efficient compressed representations
    • Implemented as a feedforward neural network
  • RNN: Learns temporal dynamics in latent space

    • Continuous-time RNN (CTRNN) architecture
    • Captures temporal dependencies in neural activity
    • Supports variable time steps via dt parameter
    • Optional bidirectional processing
  • Decoder: Projects latent representations back to firing rate space

    • Reconstructs firing rate estimates from latent space
    • Matches input dimensionality
    • Includes rectification to ensure non-negative rates

Key Features

  • Continuous-time RNN implementation
  • Optional dropout for regularization
  • PCA preprocessing of spike data
  • MSE and Poisson loss functions
  • Cross-validation during training
  • GPU acceleration support

Modules

  • get_data.py: Loads and preprocesses spike train data from .h5 files
  • model.py: Implements CTRNN and autoencoder network architectures
  • train.py: Handles model training with cross-validation
  • run_model.py: End-to-end pipeline for data loading, training and evaluation

Usage

Quick Start

The main pipeline follows these steps: 1. Loads spike train data and bins it 2. Preprocesses using PCA and scaling 3. Splits data into train/test sets 4. Trains the model with cross-validation 5. Saves trained model and generates performance plots

Detailed Example

```python from getdata import loadspikedata from model import CTRNNplusoutput from train import trainmodel import torch

Load and preprocess data

spikedata = loadspikedata('path/to/data.h5') inputsize = spike_data.shape[-1]

Create model

model = CTRNNplusoutput( inputsize=inputsize, hiddensize=64, outputsize=input_size, dt=0.1 )

Train model

trainedmodel = trainmodel( net=model, inputs=spikedata, labels=spikedata, # For autoencoder outputsize=inputsize, train_steps=1000, lr=0.01 )

Save model

torch.save(trainedmodel.statedict(), 'trained_model.pth') ```

Configuration Options

Key parameters that can be tuned: - hidden_size: Number of hidden neurons in CTRNN - dt: Time step for continuous-time dynamics - train_steps: Number of training iterations - lr: Learning rate for optimization

Installation

  1. Clone the repository: bash git clone https://github.com/yourusername/blechRNN.git cd blechRNN

  2. Create and activate a virtual environment (recommended): bash python -m venv venv source venv/bin/activate # On Windows use: venv\Scripts\activate

  3. Install dependencies: bash pip install -r requirements.txt

Requirements

All dependencies are listed in requirements.txt: - PyTorch (2.3.1) - Deep learning framework - NumPy (2.0.0) - Numerical computing - Scikit-learn (1.4.0) - Data preprocessing - Matplotlib (3.8.2) - Visualization - SciPy (1.14.0) - Scientific computing - tqdm (4.66.1) - Progress bars

Contributing

We welcome contributions to BlechRNN! Here's how you can help:

Reporting Issues

  • Use the GitHub issue tracker
  • Include detailed description and steps to reproduce
  • Attach relevant data samples if possible

Development Process

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Add tests for new functionality
  5. Commit changes (git commit -m 'Add amazing feature')
  6. Push to branch (git push origin feature/amazing-feature)
  7. Open a Pull Request

Code Style

  • Follow PEP 8 guidelines
  • Add docstrings for new functions/classes
  • Comment complex algorithms
  • Keep functions focused and modular

Running Tests

bash python -m pytest tests/

Owner

  • Name: Abuzar Mahmood
  • Login: abuzarmahmood
  • Kind: user
  • Location: Waltham, MA
  • Company: Graduate Program in Neuroscience, Brandeis University

I am a Systems Neuroscience graduate student at Brandeis University working on methods to describe firing in neuronal populations

Citation (CITATION.cff)

# This CITATION.cff file was generated with cffinit.
# Visit https://bit.ly/cffinit to generate yours today!

cff-version: 1.2.0
title: blechRNN
message: Estimating neural firing rates using LSTM
type: software
authors:
  - given-names: Abuzar
    family-names: Mahmood
    email: abuzarmahmood@gmail.com
    affiliation: Brandeis University
    orcid: 'https://orcid.org/0000-0002-2448-4818'
repository-code: 'https://github.com/abuzarmahmood/blechRNN'
keywords:
  - time-series modelling
  - latent neural population modelling
  - recurrent neural networks
  - pytorch
license: GPL-3.0
commit: '9e5632d '

GitHub Events

Total
  • Issues event: 17
  • Watch event: 1
  • Delete event: 3
  • Issue comment event: 33
  • Push event: 16
  • Pull request event: 11
  • Fork event: 1
  • Create event: 7
Last Year
  • Issues event: 17
  • Watch event: 1
  • Delete event: 3
  • Issue comment event: 33
  • Push event: 16
  • Pull request event: 11
  • Fork event: 1
  • Create event: 7

Issues and Pull Requests

Last synced: 10 months ago

All Time
  • Total issues: 12
  • Total pull requests: 8
  • Average time to close issues: 2 months
  • Average time to close pull requests: 5 days
  • Total issue authors: 1
  • Total pull request authors: 1
  • Average comments per issue: 0.75
  • Average comments per pull request: 0.88
  • Merged pull requests: 4
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 12
  • Pull requests: 8
  • Average time to close issues: 2 months
  • Average time to close pull requests: 5 days
  • Issue authors: 1
  • Pull request authors: 1
  • Average comments per issue: 0.75
  • Average comments per pull request: 0.88
  • Merged pull requests: 4
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • abuzarmahmood (13)
Pull Request Authors
  • abuzarmahmood (8)
Top Labels
Issue Labels
blech_bot (3) under_development (1)
Pull Request Labels