Skip to main content

pisces-lite

ML-backend-agnostic core for wearable sleep data: dataset discovery and loading, accelerometer-to-spectrogram processing, cross-validation splitting, and metrics logging. It carries no model framework, though there is a JAX-accelerated option for the [jax] extra components.

Install

pip install pisces-lite

Python 3.12+. To do the processing yourself rather than read a prebuilt feature cache, install an extra — see Optional extras. The proc and jax extras require a Python version the compiled backend publishes wheels for (currently 3.12–3.14):

pip install "pisces-lite[proc]"

Getting started

from pisces_lite.datasets import DataSetObject, load_subject

# Discover datasets laid out as <dataset>/cleaned_<feature>/<subject>.csv
data_sets = DataSetObject.find_data_sets("data/")
ds = data_sets["mydata"]

# Load one subject: (accelerometer, PSG) frames with standardised columns
subject = load_subject(ds, ds.ids[0])

Datasets are described by an optional data_set.json next to the data; it sets per-feature timestamp units, accelerometer scaling, PSG stage mappings, CSV delimiters, and subject-id patterns. Non-standard layouts can ship a pisces_lite_adapter.py exposing load_data_sets(root, **kwargs).

Configure the processing pipeline and turn raw accelerometer into spectrograms:

from pisces_lite.proc import ProcessingConfig

config = ProcessingConfig.from_dict({"type": "nufft", "fs": 32.0})
X = config.apply(accel_array, origin=psg_start)   # (T, F) or (T, F, C) with spectral_channels

Frames and the window grid

Frame j of X is the FFT of the window [origin + j·hop, origin + j·hop + window), where hop is window_step_seconds: 10 s windows every 2 s give frames for 0–10 s, 2–12 s, 4–14 s, and so on. Every window with data (at least 4 samples) is an FFT. A window without data, usually an accelerometer dropout, holds SPECTROGRAM_PADDING_VALUE in every bin and channel; pisces_lite.proc.frame_validity(X) finds those frames. The last frame is the last window with data, so the windows the recording stops partway through are FFTs too.

origin is where window 0 starts, in the unit and on the clock of the accelerometer timestamp column:

  • Offline, with PSG: pass the PSG start, e.g. the first timestamp of the PSG frame pisces_lite.datasets.align_trim returns. Frame j then starts inside epoch j // frames_per_epoch, whatever the accelerometer's first sample was.
  • Online, no PSG: pass origin="unix", or set "grid_origin": "unix" in the config, to start the grid at a whole number of hops since the Unix epoch, so every session shares one grid.
  • Neither: origin=None anchors the grid at the first sample, as before.

apply_many(arrays, origins=[...]) takes one origin per recording.

Normalization leaves padding frames out of every statistic and returns them still holding SPECTROGRAM_PADDING_VALUE, so frame_validity works on normalized features too.

Gap mode (opt-in)

Setting gap_max_excluded_frame_fraction marks a PSG epoch as the gap label (PAD_CLASS_LABEL, -2) once more than that fraction of its frames are padding. It is off (null) by default, which leaves labels unchanged.

config = ProcessingConfig.from_dict({
    "type": "nufft", "window_seconds": 10, "window_step_seconds": 2,
    "gap_max_excluded_frame_fraction": 0.5,
})
X = config.apply(accel_array, origin=psg_start)
labels = config.mask_gap_epochs(labels, X)      # epoch 0 starts at psg_start

The pieces are also available on their own: pisces_lite.proc.frame_validity and pisces_lite.datasets.mask_labels_by_frame_coverage.

Split subjects and score folds:

from pisces_lite.cv import CVConfig, iter_folds
from pisces_lite.metrics import MetricsConfig, MetricsLogger

cv = CVConfig(mode="loso", train_sets=["mydata"], test_sets=["mydata"])
for fold in iter_folds(cv, data_sets):
    ...  # train on fold.train_subjects, evaluate fold.test_subjects

Optional extras

The base install never pulls a C++ toolchain. Add an extra only when you need the processing pipeline itself.

Extra Install What it adds Use when
proc pip install "pisces-lite[proc]" arcascope-senpy (import name senpy; compiled pybind11 + finufft), the CPU streaming/cpu NUFFT backends You are turning raw accelerometer data into spectrograms
jax pip install "pisces-lite[jax]" arcascope-senpy[jax] and JAX, adding the jax NUFFT backend You want GPU-batched spectrogram extraction
dev pip install "pisces-lite[dev]" pytest You are running the test suite

Working from a prebuilt feature cache — a training or inference host that only reads cv, metrics, model_io, and ProcessingConfig — needs no extra. pisces_lite.proc resolves its pipeline classes lazily, so importing a ProcessingConfig does not import senpy; touching a pipeline class without the extra raises a clear error naming the extra to install.

JAX backend options

The jax backend transforms every channel of every recording passed to apply_many in one call to senpy's jax_backend.compute_nustft_many. nufft_backend_kwargs are passed through to it:

Option Default Meaning
rows_per_call 8192 Windows per device call.
max_in_flight 3 Device calls queued before the host waits on the oldest.
build_threads 4 Host threads building batches ahead of the device.
eps 1e-6 NUFFT tolerance.
enable_x64 false Enable process-wide JAX float64 mode; recommended for closer CPU parity on macOS, but not supported by Metal.

For the standard macOS JAX CPU backend, use "nufft_backend_kwargs": {"enable_x64": true} when numerical agreement with the native double-precision backend matters more than float32 throughput.

Metadata

Release files for pisces-lite 4.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pisces-lite 4.1.1
File Size Uploaded Provenance Actions
pisces_lite-4.1.1.tar.gz 66.4 kB With provenance Details for pisces_lite-4.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pisces-lite 4.1.1
File Interpreter ABI Platform Actions
pisces_lite-4.1.1-py3-none-any.whl Python 3 none any Details for pisces_lite-4.1.1-py3-none-any.whl

Total release size: 126.4 kB

Release files / pisces_lite-4.1.1.tar.gz

Download URL pisces_lite-4.1.1.tar.gz
Size 66.4 kB
Tags Source
SHA-256 checksum
How to use checksums
1996f551248e8c16f2f3822249fa515b0764a2fcaeb765779b4393ef724ca9da
BLAKE2b-256 checksum
How to use checksums
81d2f77aee33355633ab7568fe2adf3301087981d91db092dd8e53791adde2ad
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 Oct 1, 2026.

Transparency log

Release files / pisces_lite-4.1.1-py3-none-any.whl

Download URL pisces_lite-4.1.1-py3-none-any.whl
Size 59.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8227ddad62d9121b1d1a12ecf0bcc09028b7e87e6d05cdb2fbfd997ae5767c80
BLAKE2b-256 checksum
How to use checksums
e0e0d68bb17a47ecebabd63279d4bbc3754722309f0b932f76868b88d5350416
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 Oct 1, 2026.

Transparency log

Security for pisces-lite 4.1.1

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

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pisces_lite-4.1.1.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 Oct 1, 2026.

Transparency log

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page