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 for systems neuroscience.
We provide:
- A
GLMfor single neurons and aPopulationGLM, with a choice of observation models (Poisson,Negative Binomial,Gamma,Gaussian,Bernoulli) and aClassifierGLMfor categorical responses. - A composable basis module for constructing and transforming model features.
- Multiple regularization schemes:
Ridge,Lasso,GroupLasso, andElasticNet.
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
import nemos as nmo
# Instantiate the basis
basis_1 = nmo.basis.MSplineEval(n_basis_funcs=5)
basis_2 = nmo.basis.CyclicBSplineEval(n_basis_funcs=6)
basis_3 = nmo.basis.MSplineEval(n_basis_funcs=7)
basis = basis_1 * basis_2 + basis_3
# Generate the design matrix starting from some raw
# input time series, i.e. LFP phase, position, etc.
X = basis.compute_features(input_1, input_2, input_3)
GLM
# 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
import nemos as nmo
# assume that the population spike counts time-series is stored
# in a 2D array spike_counts of shape (n_samples, n_neurons).
# generate 5 basis functions of 100 time-bins,
# and convolve the counts with the basis.
X = nmo.basis.RaisedCosineLogConv(5, window_size=100
).compute_features(spike_counts)
Population GLM
# 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:
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.
Citing us
If you use NeMoS in a published academic article or presentation, please
cite the code by the DOI. You can click on
Cite this repository on the right side of the GitHub page to get a copyable
citation for the code, or use the following:
Support
This package is supported by:
- The Center for Computational Neuroscience, in the Flatiron Institute of the Simons Foundation.
- The NIH BRAIN Initiative (1RF1MH133778).
Metadata
Release files for nemos 0.2.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nemos-0.2.9.tar.gz | 2.1 MB | With provenance | Details for nemos-0.2.9.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nemos-0.2.9-py3-none-any.whl | Python 3 | none | any | Details for nemos-0.2.9-py3-none-any.whl |
Total release size: 2.5 MB
Release files / nemos-0.2.9.tar.gz
| Download URL | nemos-0.2.9.tar.gz |
|---|---|
| Size | 2.1 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e533a16f54885e10014a5edcbabbb0ceaf3410fe9bcdc8acd8f50f118e92fe34
|
|
BLAKE2b-256 checksum How to use checksums |
bb8ad96e2dced590f142784c7ac8f5bda25e293c9df10dfa67c8ce070a323b93
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 4, 2026.
Transparency logRelease files / nemos-0.2.9-py3-none-any.whl
| Download URL | nemos-0.2.9-py3-none-any.whl |
|---|---|
| Size | 335.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5c31ef5edfc9f40b39cae6dc588afa0c581b375b828fc1c2d8fbae9ceef3dd00
|
|
BLAKE2b-256 checksum How to use checksums |
575b1e42c6bcbd2cb9340db25d9c2588b1d586ea9a538bfaf57e4d56c55a8370
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 4, 2026.
Transparency logSecurity for nemos 0.2.9
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for nemos-0.2.9.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 4, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.