NanoMoSeq
Minimal AR-HMM pipeline for unsupervised behavioral segmentation from pose keypoints.
Installation
pip install nanomoseq
Pipeline
keypoints (T, K, 3)
│
▼
NanoMoseq egocentric alignment → PCA → AR-HMM Gibbs
│
▼
syllable labels (T,)
│
▼
NanoHHMM hierarchical HMM Gibbs
│
▼
behavioral states (T,)
Usage
from nanomoseq import NanoMoseq, NanoHHMM
# Keypoints: dict of recordings, each array of shape (T, K, 3)
# T = number of frames
# K = number of keypoints
# 3 = [x, y, confidence]
keypoints = {
"mouse_01": ..., # (T, K, 3)
"mouse_02": ..., # (T, K, 3)
}
# Stage 1 — segment keypoint sequences into syllables
moseq = NanoMoseq(
n_syllables=10, # number of behavioral syllables
n_dims=10, # PCA dimensions to retain
n_iters=100, # Gibbs iterations
kappa=100.0, # self-transition bias
alpha=1.0, # Dirichlet concentration
)
moseq.fit(keypoints)
syllable_labels = moseq.labels_ # {name: ndarray(T,)}
pca_coords = moseq.pca_coords_ # {name: ndarray(T, n_dims)}
transition_mat = moseq.transition_matrix_ # (n_syllables, n_syllables)
# Stage 2 — group syllable sequences into higher-level behavioral states
hhmm = NanoHHMM(
n_states=5, # number of behavioral states
n_iters=100,
kappa=100.0,
alpha=1.0,
emissions_beta=0.1, # Dirichlet prior on syllable emissions
)
hhmm.fit(moseq.labels_)
behavioral_states = hhmm.states_ # {name: ndarray(T,)}
trans_probs = hhmm.trans_probs_ # (n_states, n_states)
emissions = hhmm.emissions_ # (n_states, n_syllables, n_syllables)
Citation
If you use NanoMoSeq in your research, please cite it as:
@software{cobos2026nanomoseq,
author = {Cobos, Juan},
title = {{NanoMoSeq}: Minimal AR-HMM pipeline for unsupervised behavioral segmentation from pose keypoints},
year = {2026},
url = {https://github.com/juan-cobos/nanomoseq},
version = {0.1.0},
license = {MIT}
}
A machine-readable citation is also available in CITATION.cff.
Acknowledgments
-
Weinreb, C., Pearl, J. E., Lin, S., Osman, M. A. M., Zhang, L., Annapragada, S., Conlin, E., Hoffmann, R., Makowska, S., Gillis, W. F., Jay, M., Ye, S., Mathis, A., Mathis, M. W., Pereira, T., Linderman, S. W., & Datta, S. R. (2024). Keypoint-MoSeq: parsing behavior by linking point tracking to pose dynamics. Nature Methods, 21(7), 1329–1339. https://doi.org/10.1038/s41592-024-02318-2
-
Weinreb, C., Kannan, L. T., Newman-Boulle, A., Sainburg, T., Gillis, W. F., Plotnikoff, A., Makowska, S., Pearl, J. E., Osman, M. A. M., Linderman, S. W., & Datta, S. R. (2026). Spontaneous behavior is a succession of self-directed tasks. Neuron, 114(5), 922–937.e12. https://doi.org/10.1016/j.neuron.2025.11.021
Metadata
Release files for nanomoseq 0.1.0
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 |
|---|---|---|---|---|
| nanomoseq-0.1.0.tar.gz | 7.0 kB | Without provenance | Details for nanomoseq-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nanomoseq-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for nanomoseq-0.1.0-py3-none-any.whl |
Total release size: 14.3 kB
Release files / nanomoseq-0.1.0.tar.gz
| Download URL | nanomoseq-0.1.0.tar.gz |
|---|---|
| Size | 7.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cf9b9aa74026fc84b845901b49b386f289d53e205f6c71aaa9f3846f2346cc3d
|
|
BLAKE2b-256 checksum How to use checksums |
758455e9579b2f65ec1d578d50d34cd54951ba164addaa730d0c346ecf97f3a8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.9
|
Release files / nanomoseq-0.1.0-py3-none-any.whl
| Download URL | nanomoseq-0.1.0-py3-none-any.whl |
|---|---|
| Size | 7.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dfba1e806e38342c37ba92e6fbeb680326ea0518d1afcc2d0fc8b2199203eb3e
|
|
BLAKE2b-256 checksum How to use checksums |
998d37a0815c0c413a25bb289f28ad752b3f8b4f377655379c2ccb3741643484
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.9
|
Security for nanomoseq 0.1.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.