Metadata-Version: 2.5
Name: bdsp
Version: 0.2.0
Summary: Python readers for BDSP/Sleep YODA HDF5 and split BIDS/TS-Zarr data.
Project-URL: Homepage, https://bdsp.io/
Project-URL: Documentation, https://github.com/bdsp-core/bdsp-python/blob/main/docs/README.md
Project-URL: Repository, https://github.com/bdsp-core/bdsp-python
Project-URL: Issues, https://github.com/bdsp-core/bdsp-python/issues
Author: BDSP Core
License-Expression: Apache-2.0
License-File: LICENSE
Keywords: bdsp,eeg,hdf5,neurophysiology,psg,sleep
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Medical Science Apps.
Requires-Python: >=3.10
Requires-Dist: h5py>=3.8
Requires-Dist: numpy>=1.24
Requires-Dist: pandas>=2.0
Requires-Dist: scipy>=1.10
Provides-Extra: test
Requires-Dist: pytest>=7; extra == 'test'
Provides-Extra: zarr
Requires-Dist: zarr<4,>=3.1; (python_version >= '3.11') and extra == 'zarr'
Description-Content-Type: text/markdown

# BDSP Data Guide and Python Reader

Understand and load standardized sleep/PSG recordings from
[BDSP](https://bdsp.io/) with the `bdsp` Python package.
This repository contains the reader, data-format documentation, and examples.
Start with your dataset's page on bdsp.io to request access and download its files.

## Install

Use Python 3.11+ in a project environment:

```bash
python -m pip install --upgrade "bdsp[zarr]"
```

Zarr support is included in `bdsp` version 0.2.0 and later.

## Open a Zarr recording

One recording has three matching artifacts: **primary Zarr** (signals and expert
annotations), **derivative Zarr** (model annotations and time-varying features),
and **summary JSON** (feature summaries).
Pass those three paths to the reader:

```python
from bdsp.bids_zarr import open_recording

with open_recording(
    primary="/data/primary.zarr",
    derivatives="/data/derivative.zarr",
    summary_json="/data/summary.json",
) as record:
    print(list(record.signals))
    signal = next(iter(record.signals.values()))
    window = signal.read(start=0, duration=30)
    summaries = record.features.summary.to_dataframe()
```

Replace the example paths with your files; `.zarr` paths refer to directories.
`window` contains sample values, times, sampling rate, and physical units.
Signals keep their native sampling rates, and only the requested window is loaded.
Keep lazy reads inside the `with` block.
Available channels, scorers, and features depend on the recording.

## H5 and further help

For H5 recordings, use `bdsp.read_h5("recording.h5")` after `import bdsp`.
The [getting started guide](https://github.com/bdsp-core/bdsp-python/blob/main/docs/README.md) covers H5, annotations, features,
installation, and development.
The [data-format guide](https://github.com/bdsp-core/bdsp-python/blob/main/docs/bids-zarr/README.md) explains the directory layout,
units, and primary/derivative split; the
[reader reference](https://github.com/bdsp-core/bdsp-python/blob/main/docs/bids-zarr/READER_DESIGN.md) covers the full Zarr API.

This reader loads existing results; it does not download datasets, convert EDF
files, or run models.
For H5-to-Zarr conversion, see
[bdsp-psg-conversion](https://github.com/bdsp-core/bdsp-psg-conversion);
for feature computation, see
[bdsp-sleep-features](https://github.com/bdsp-core/bdsp-sleep-features).

Licensed under [Apache 2.0](https://github.com/bdsp-core/bdsp-python/blob/main/LICENSE).
