Implement GLM-based firing rate estimation#709
Conversation
Implements issue katzlabbrandeis#708: GLM-based firing rate inference using nemos library. Features: - Spike history modeling with raised cosine basis functions - Optional stimulus timing features - Optional coupling between simultaneously recorded neurons - Bits per spike metric for model comparison vs binned rates - Separate processing by taste and/or region Co-authored-by: Ona <no-reply@ona.com>
Implementation DetailsGLM Model StructureThe script fits a Poisson GLM for each neuron with the following components:
Bits Per Spike MetricThe bits per spike metric quantifies model performance as information gain over a baseline: Where:
Positive values indicate the GLM captures structure beyond the mean rate. Typical values for well-fit models range from 0.1-1.0 bits/spike. Comparison to RNN ApproachThis GLM approach complements the existing
Future ExtensionsPer issue #708, potential additions:
|
Move GLM scripts to utils/glm/ subdirectory with two-environment architecture: - infer_glm_rates.py: Main orchestrator that detects environments - _glm_extract_data.py: Runs in blech_clust conda env for data extraction - _glm_fit_models.py: Runs in nemos venv for GLM fitting Data is passed between environments via temporary numpy files. Remove nemos from requirements-optional.txt since it runs in separate venv. Co-authored-by: Ona <no-reply@ona.com>
Co-authored-by: Ona <no-reply@ona.com>
…perations - Omitted regularizer strength parameter to default to `Ridge`. - Temporarily commented out model saving and bits per spike distribution plotting to streamline current execution. These tweaks are intended to improve performance for now.
…ting - Introduced a `test_mode` parameter to enable running tests without actual command-line arguments, facilitating easier code testing. - Enhanced `find_conda_env` to efficiently parse the conda environment list, providing the Python path for better environment management. - Improved the script's feedback with inline comments and print statements when operating in test mode. - Adjusted the default behavior of `sys.exit` to allow for graceful test termination and better debugging.
Closes #708
Summary
Adds
utils/glm/module for GLM-based firing rate estimation using the nemos library.Architecture
Due to dependency conflicts between nemos and blech_clust, this module uses a two-environment architecture:
Data is passed between environments via temporary numpy files in
utils/glm/_temp/.Features
Setup
Usage
The script auto-detects environments or prompts if not found.
Output
/glm_output/regions/