MiSleep
MiSleep is an open-source Python toolbox for mice sleep EEG/EMG visualization, scoring, and analysis.
The name MiSleep comes from "Mice Sleep" and sounds like "my sleep".
| License | BSD 3-Clause |
| Python | 3.9 – 3.14 |
| GUI toolkit | PySide6 (Qt6) — Windows, macOS, Linux |
| Documentation | https://bryanwang.cn/MiSleep/ |
Features
- Cross-platform desktop GUI built on PySide6 (Qt6). Works on Windows, macOS and Linux without any platform-specific code.
- Flexible data input — load MATLAB, EDF/EDF+, BDF, NumPy NPY/NPZ, CSV and TSV recordings; JSON/CSV/TSV annotation imports are also built in.
- Full scoring workflow — per-second sleep state scoring (NREM / REM / Wake / Init), single time-point markers, start-end events, hypnogram, spectrogram and per-state spectral analysis.
- Event detection — slow-wave activity (SWA) and sleep spindle detection with state-specific thresholds.
- Automatic sleep staging — a LightGBM classifier (trained on time- and frequency-domain features) and an optional PyTorch causal-transformer model.
- Analysis export — per-hour and 12 h light/dark phase sleep statistics exported to Excel.
- Clean, modular architecture — data, I/O, preprocessing, analysis, visualization and GUI are separate modules with a stable public API and plugin-friendly extension points (see the developer guide).
Installation
# Base install - includes everything (data, I/O, preprocessing, analysis,
# visualization AND the PySide6 GUI)
pip install misleep
# With the LightGBM auto-staging model as well
pip install "misleep[full]"
# For development / contributing
git clone https://github.com/BryanWang0702/MiSleep.git
cd misleepv3
pip install -e ".[analysis,dev]"
Note on PyTorch: the causal-transformer auto-staging model requires
torch, which is not available on every platform. Install it separately withpip install "misleep[transformer]".
Quick start
Launch the GUI
python -m misleep
# or, after installation:
misleep
Open files directly (command line)
misleep data.mat # open a recording
misleep data.mat anno.txt # open a recording + its annotation
misleep --data data.edf --anno anno.txt
python -m misleep data.mat # same via the module
Open files by double-clicking (Windows)
Register MiSleep as the handler for your recording files:
python tools/install_file_associations.py
After that, double-clicking a .mat or .edf file opens it in MiSleep
(no console window). Annotation .txt files get an "Open with MiSleep"
right-click menu item without changing their default handler. The previous
.mat/.edf handlers are backed up automatically and restored with:
python tools/install_file_associations.py --uninstall
On macOS/Linux, run the same script for instructions (or open files from the command line as shown above).
Use the library
import misleep as ms
# Load a recording
midata = ms.load_signal("data.npz") # MAT, EDF/BDF, NPY/NPZ, CSV or TSV
# Inspect it
print(midata.channels, midata.sf, midata.duration)
# Preprocess
midata.filter(chans=["EEG"], btype="bandpass", low=0.5, high=30)
nrem, rem, wake, init = ms.crop_state_data(midata, mianno)
# Analyze
freq, psd = ms.spectrum(midata.signals[0], midata.sf[0])
swa = ms.SWA_detection(midata.signals[0], midata.sf[0], df=True)
# Plot
fig, ax = ms.plot_hypno(mianno.sleep_state)
See docs/getting_started.md and the examples folder for more.
Project layout
misleepv3/
├── pyproject.toml # modern packaging (PEP 621)
├── src/misleep/
│ ├── data/ # data model: MiData, MiAnnotation
│ ├── io/ # input/output: MAT, EDF, annotations (+ plugin registry)
│ ├── preprocessing/ # filtering, artifact rejection, spectral analysis
│ ├── analysis/ # detection, feature extraction, auto staging
│ ├── viz/ # matplotlib plotting (signals, spectra, hypnograms)
│ ├── gui/ # PySide6 desktop application
│ ├── utils/ # shared helpers
│ ├── config.py # INI configuration handling
│ └── logger.py # logging setup
├── tests/ # pytest suite
├── docs/ # user + developer documentation
├── examples/ # runnable examples
└── tools/ # UI/resource compilation scripts
Documentation
- Getting started — installation and first steps
- User guide — the GUI in detail
- Data formats — how data and annotations are stored
- Configuration — the
config.inireference - API reference — full API documentation
- Developer guide — architecture and how to extend MiSleep
- Changelog
Citing MiSleep
If you use this software in your research, please cite it as:
Xueqiang Wang. (2024). BryanWang0702/MiSleep. Zenodo. https://doi.org/10.5281/zenodo.14511905
License
BSD 3-Clause. See LICENSE.
Metadata
Release files for misleep 0.3.4
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 |
|---|---|---|---|---|
| misleep-0.3.4.tar.gz | 26.6 MB | Without provenance | Details for misleep-0.3.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| misleep-0.3.4-py3-none-any.whl | Python 3 | none | any | Details for misleep-0.3.4-py3-none-any.whl |
Total release size: 53.0 MB
Release files / misleep-0.3.4.tar.gz
| Download URL | misleep-0.3.4.tar.gz |
|---|---|
| Size | 26.6 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
571d5a56fbf339bbcea7c5d6521b5b0a5fec21fe63acecfc6a63a15e9fa5bf9d
|
|
BLAKE2b-256 checksum How to use checksums |
6dc9cb8009d903fa9dfa7aac2c185f1e706993f352159a535c01d5ddbbdf2d5c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.8.18
|
Release files / misleep-0.3.4-py3-none-any.whl
| Download URL | misleep-0.3.4-py3-none-any.whl |
|---|---|
| Size | 26.3 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a4b006dac60476ad52e5bd7b77e46451d4cd8d855bd141bbf6a0ef7605725738
|
|
BLAKE2b-256 checksum How to use checksums |
2103f2b91507b5a220735e97fe0be32d772148269e4e9b3f5af9627305f74c19
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.8.18
|
Security for misleep 0.3.4
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.