nemos
NEural MOdelS, a statistical modeling framework for neuroscience.
Science Score: 52.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
Organization flatironinstitute has institutional domain (flatironinstitute.org) -
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (18.1%) to scientific vocabulary
Repository
NEural MOdelS, a statistical modeling framework for neuroscience.
Basic Info
- Host: GitHub
- Owner: flatironinstitute
- License: mit
- Language: Python
- Default Branch: main
- Homepage: https://nemos.readthedocs.io/
- Size: 9 MB
Statistics
- Stars: 101
- Watchers: 4
- Forks: 11
- Open Issues: 124
- Releases: 12
Metadata Files
README.md
NeMoS (Neural ModelS) is a statistical modeling framework optimized for systems neuroscience and powered by JAX. It streamlines the process of creating and selecting models, through a collection of easy-to-use methods for feature design.
The core of NeMoS includes GPU-accelerated, well-tested implementations of standard statistical models, currently focusing on the Generalized Linear Model (GLM).
We provide a Poisson GLM for analyzing spike counts, and a Gamma GLM for calcium or voltage imaging traces.
The package is under active development and more methods will be added in the future.
For those looking to get a better grasp of the Generalized Linear Model, we recommend checking out the Neuromatch Academy's lesson here and Jonathan Pillow's tutorial from Cosyne 2018 here.
Overview
At his core, NeMoS consists of two primary modules: the basis and the glm module.
The basis module focuses on designing model features (inputs) for the GLM. It includes a suite of composable feature
constructors that accept time-series data as inputs. These inputs can be any observed variables, such as presented
stimuli, head direction, position, or spike counts.
The basis objects can perform two types of transformations on the inputs:
Non-linear Mapping: This process transforms the input data through a non-linear function, allowing it to capture complex, non-linear relationships between inputs and neuronal firing rates. Importantly, this transformation preserves the properties that makes GLM easy to fit and guarantee a single optimal solution (e.g. convexity).
Convolution: This applies a convolution of the input data with a bank of filters, designed to capture linear temporal effects. This transformation is particularly useful when analyzing data with inherent time dependencies or when the temporal dynamics of the input are significant.
Both transformations produce a vector of features X that changes over time, with a shape
of (n_time_points, n_features).
On the other hand, the glm module maps the feature to spike counts. It is used to learn the GLM weights,
evaluating the model performance, and explore its behavior on new input.
Examples
Here's a brief demonstration of how the basis and glm modules work together within NeMoS.
Poisson GLM for features analysis
In this example, we'll construct a time-series of features using the basis objects, applying a non-linear mapping (default behavior):
Feature Representation
```python import nemos as nmo
Instantiate the basis
basis1 = nmo.basis.MSplineEval(nbasisfuncs=5) basis2 = nmo.basis.CyclicBSplineEval(nbasisfuncs=6) basis3 = nmo.basis.MSplineEval(nbasis_funcs=7)
basis = basis1 * basis2 + basis_3
Generate the design matrix starting from some raw
input time series, i.e. LFP phase, position, etc.
X = basis.computefeatures(input1, input2, input3) ```
GLM
```python
Fit the model mapping X to the spike count
time-series y
glm = nmo.glm.GLM().fit(X, y)
Inspect the learned coefficients
print(glm.coef, glm.intercept)
compute the rate
firing_rate = glm.predict(X)
compute log-likelihood
ll = glm.score(X, y) ```
Poisson GLM for neural population
This second example demonstrates feature construction by convolving the simultaneously recorded population spike counts with a bank of filters, utilizing the basis in conv mode.
The figure above show the GLM scheme for a single neuron, however in NeMoS you can fit jointly the whole population with the PopulationGLM object.
Feature Representation
```python import nemos as nmo
assume that the population spike counts time-series is stored
in a 2D array spikecounts of shape (nsamples, n_neurons).
generate 5 basis functions of 100 time-bins,
and convolve the counts with the basis.
X = nmo.basis.RaisedCosineLogConv(5, windowsize=100 ).computefeatures(spike_counts) ```
Population GLM
```python
fit a GLM to the first neuron counts time-series
glm = nmo.glm.PopulationGLM().fit(X, spike_counts)
compute the rate
firing_rate = glm.predict(X)
compute log-likelihood
ll = glm.score(X, spike_counts) ```
For a deeper dive, see our Quickstart guide and consider using pynapple for data exploration and preprocessing. When initializing the GLM object, you may optionally specify an observation model and a regularizer.
Note: Multi-epoch Convolution
If your data is formatted as a
pynappletime-series, the convolution performed by the basis objects will be executed epoch-by-epoch, avoiding the risk of introducing artifacts from gaps in your time-series.
Installation
Run the following pip command in your virtual environment.
For macOS/Linux users:
bash
pip install nemos
For Windows users:
python -m pip install nemos
For more details, including specifics for GPU users and developers, refer to NeMoS docs.
Disclaimer
Please note that this package is currently under development. While you can download and test the functionalities that are already present, please be aware that syntax and functionality may change before our preliminary release.
Getting help and getting in touch
We communicate via several channels on Github:
- To report a bug, open an issue.
- To ask usage questions, discuss broad issues, or show off what you’ve made with NeMoS, go to Discussions.
- To send suggestions for extensions or enhancements, please post in the ideas section of discussions first. We’ll discuss it there and, if we decide to pursue it, open an issue to track progress.
- To contribute to the project, see the contributing guide.
In all cases, we request that you respect our code of conduct.
Support
This package is supported by:
- The Center for Computational Neuroscience, in the Flatiron Institute of the Simons Foundation.
- The NIH BRAIN Initiative (1RF1MH133778).

Owner
- Name: Flatiron Institute
- Login: flatironinstitute
- Kind: organization
- Location: New York City
- Website: https://flatironinstitute.org/
- Repositories: 177
- Profile: https://github.com/flatironinstitute
@SimonsFoundation
Citation (CITATION.cff)
cff-version: 1.2.0
message: "If you use this software, please cite it using the preferred-citation metadata."
title: ""NEural MOdelS, a statistical modeling framework for neuroscience."
authors:
- family-names: Balzani
given-names: Edoardo
orcid: "https://orcid.org/0000-0002-3702-5856"
- family-names: Broderick
given-names: William
orcid: "https://orcid.org/0000-0002-8999-9003"
- family-names: Viejo
given-names: Guillaume
orcid: "https://orcid.org/0000-0002-2450-7397"
- family-names: Williams
given-names: Alex
orcid: "https://orcid.org/0000-0001-5853-103X"
repository-code: "https://github.com/flatironinstitute/nemos"
url: "https://nemos.readthedocs.io/"
license: MIT
keywords:
- neuroscience
- Poisson GLM
- spike counts modeling
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 145
- Total pull requests: 195
- Average time to close issues: 4 months
- Average time to close pull requests: 17 days
- Total issue authors: 15
- Total pull request authors: 11
- Average comments per issue: 0.99
- Average comments per pull request: 1.33
- Merged pull requests: 149
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 43
- Pull requests: 115
- Average time to close issues: 3 months
- Average time to close pull requests: 7 days
- Issue authors: 9
- Pull request authors: 8
- Average comments per issue: 0.63
- Average comments per pull request: 1.49
- Merged pull requests: 91
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- BalzaniEdoardo (89)
- billbrod (49)
- sjvenditto (9)
- bagibence (5)
- EricThomson (5)
- clewis7 (3)
- ahwillia (2)
- samdeoxys1 (2)
- FlyingFordAnglia (2)
- macari216 (1)
- ZhexinXu (1)
- wulfdewolf (1)
- arturoptophys (1)
- gviejo (1)
- RobertoDF (1)
Pull Request Authors
- BalzaniEdoardo (162)
- billbrod (28)
- bagibence (10)
- gviejo (6)
- clewis7 (5)
- sjvenditto (5)
- pcrespo2017 (5)
- camila-maura (3)
- pranmod01 (3)
- EricThomson (3)
- arnabiswas (2)
- ahwillia (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- pypi 181 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 11
- Total maintainers: 1
pypi.org: nemos
NEural MOdelS, a statistical modeling framework for neuroscience.
- Documentation: https://nemos.readthedocs.io/
- License: MIT License Copyright (c) 2023 nemos authors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
Latest release: 0.2.3
published 10 months ago
Rankings
Maintainers (1)
Dependencies
- actions/checkout v3 composite
- actions/setup-python v4 composite
- re-actors/alls-green v1.2.2 composite
- actions/checkout v3 composite
- actions/setup-python v4 composite
- mxschmitt/action-tmate v3 composite
- jax >=0.4
- jaxopt >=0.6
- matplotlib >=3.7
- numpy >1.20
- scikit-learn >=1.2
- scipy >=1.10
- typing_extensions >=4.6