Minimal AR-HMM pipeline for unsupervised behavioral segmentation from pose keypoints
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nanomoseq-0.1.0.tar.gz.
File metadata
- Download URL: nanomoseq-0.1.0.tar.gz
- Upload date:
- Size: 7.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cf9b9aa74026fc84b845901b49b386f289d53e205f6c71aaa9f3846f2346cc3d
|
|
| MD5 |
98bf442cfade3994e169e4970f522d01
|
|
| BLAKE2b-256 |
758455e9579b2f65ec1d578d50d34cd54951ba164addaa730d0c346ecf97f3a8
|
File details
Details for the file nanomoseq-0.1.0-py3-none-any.whl.
File metadata
- Download URL: nanomoseq-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dfba1e806e38342c37ba92e6fbeb680326ea0518d1afcc2d0fc8b2199203eb3e
|
|
| MD5 |
cba2dfccc3074faa657fc95a063f895c
|
|
| BLAKE2b-256 |
998d37a0815c0c413a25bb289f28ad752b3f8b4f377655379c2ccb3741643484
|