SleepKit PSG
SleepKit PSG turns PSG recordings and scored hypnograms into checked NumPy arrays for sleep-staging research.
python -m pip install sleep-kit-psg
sleepkit-psg demo --output sleepkit-demo
The demo is generated locally, uses no network, and finishes with this JSON:
{
"output": "sleepkit-demo",
"processed_records": 1,
"total_epochs": 20,
"total_sequences": 1,
"valid": true
}
The demo validates software installation and output structure, not clinical correctness. Real-data evidence is limited to one-record smoke tests for 18 profiles; dcsm, dod, mass13, and wsc remain migrated-unverified. SleepKit PSG is not a medical device.
Prepare a dataset
Inspect pairing before reading signal samples:
sleepkit-psg scan \
--profile shhs1 \
--input-root /path/to/shhs1/edfs \
--annotation-root /path/to/shhs1/annotations \
--details
Then preprocess selected channels and validate every written artifact:
sleepkit-psg preprocess \
--profile shhs1 \
--input-root /path/to/shhs1/edfs \
--annotation-root /path/to/shhs1/annotations \
--output-root outputs/shhs1 \
--channels C4 E1 \
--target-sfreq 100 \
--workers 4
sleepkit-psg validate --output-root outputs/shhs1
Input paths accept str and pathlib.Path in Python. The CLI reports progress on standard error, returns JSON on standard output, and uses exit codes 0 for success, 1 for completed work with failures, and 2 for invalid invocation or setup.
What the package does
- Pairs recordings and annotations with profile-defined regular expressions and keeps unmatched files visible.
- Resolves EEG, EOG, EMG, and reference channels in the requested order.
- Reads EDF/BDF/REC through MNE, plus documented NPZ, MATLAB, HDF5, XML, text, table, and EDF-annotation contracts.
- Applies explicit filters, resampling, epoch alignment, normalization, stage mapping, and sequence generation.
- Writes record and sequence NPZ files atomically with QC, provenance, completion markers, and structured failures.
- Rejects input/output overlap, unrelated non-empty output directories, and incompatible resume contracts.
HDF5 readers are optional:
python -m pip install 'sleep-kit-psg[hdf5]'
Find the task you need
| Task | Guide |
|---|---|
| Install and run the first dataset | Getting started |
| Use every CLI command and exit code | CLI reference |
| Call the typed Python interface | Python API |
| Choose or write a dataset profile | Dataset profiles |
| Process one public Sleep-EDF record | Public-data tutorial |
| Load sequences for a downstream model | Downstream loading |
| Read array shapes and provenance fields | Output format |
| Interpret tests and real-data evidence | Validation |
| Migrate an older integration | Migration |
| Diagnose common failures | FAQ |
The distribution name is sleep-kit-psg, the Python import is sleep_kit, and the command is sleepkit-psg. These are the only names to use in new integrations.
Development
git clone https://github.com/lijinyang439-arch/PSGPrep.git sleepkit-psg
cd sleepkit-psg
python -m pip install -e '.[dev]'
python scripts/release_check.py
Scientific behavior changes need a synthetic regression test and a precise evidence boundary. Do not submit recordings, annotations, clinical data, participant identifiers, credentials, salts, or private paths. See CONTRIBUTING.md for the full gate.
Use CITATION.cff when citing the software and cite each source dataset separately. SleepKit PSG is licensed under Apache-2.0; that license does not cover input datasets.
Release files for sleep-kit-psg 2.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| sleep_kit_psg-2.1.1.tar.gz | 204.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sleep_kit_psg-2.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 268.6 kB
Release files / sleep_kit_psg-2.1.1.tar.gz
| Download URL | sleep_kit_psg-2.1.1.tar.gz |
|---|---|
| Size | 204.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cf4776610e2788d07bdb97237a12db22d1f3779daf73d3dc32fd160bfa0f0920
|
|
BLAKE2b-256 checksum How to use checksums |
59df8ea26f29d01b3a704a4ea0cc493a97b64fab1b636641f2f28b1d38b4e9c5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Aug 23, 2026.
Transparency logRelease files / sleep_kit_psg-2.1.1-py3-none-any.whl
| Download URL | sleep_kit_psg-2.1.1-py3-none-any.whl |
|---|---|
| Size | 64.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
04f9f9c1e0af29224c7dddf62a65773ead0e663d106405818d57db382d64e481
|
|
BLAKE2b-256 checksum How to use checksums |
54f5b555566487b4a275a9e4fce3e0b0c608cf557cffe84f05e5d5627e7d28a2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Aug 23, 2026.
Transparency log