moberg-h5
Read the HDF5 files that Moberg's connect-client writes from CNS archives, and HDF5 exports from the Moberg Clinical Platform.
The package lists the measurements in a file, finds each one's timestamps, and
reads a time range without loading the whole dataset. It depends on h5py and
numpy. pandas is optional and only needed for read_frame.
Documentation:
- HDF5 format: groups, dataset names, timestamps, attributes, regions and gaps, and the layouts written before format versioning.
- Format changelog: what changed in each
format_version.
Install
pip install moberg-h5
# with pandas support
pip install "moberg-h5[pandas]"
Python 3.10 or newer.
Example
from datetime import datetime, timezone
import moberg_h5
with moberg_h5.open("Patient_2026_Nov_04__10_00_00_000000.h5") as rec:
print(rec.format_version, rec.attrs.get("converter_name"))
for signal in rec.signals(kind="trend"):
print(signal.path, signal.units)
start = datetime(2026, 11, 4, 12, 0, tzinfo=timezone.utc)
end = datetime(2026, 11, 4, 12, 10, tzinfo=timezone.utc)
timestamps_us, icp = rec.read("Trends/ICP_Mean", start, end)
eeg = rec.read_frame(rec.eeg_channels(), start, end) # DataFrame, UTC index
gaps = rec.gaps("EEG/C3", start, end)
Choosing a time window
time_range returns the first sample time and the time 1 µs after the last
sample, so it can go straight into read, which reads start <= t < end:
from datetime import timedelta
with moberg_h5.open(path) as rec:
print(rec.time_range()) # whole file
print(rec.summary(kind="trend")) # one row per signal
span = rec.time_range("Trends/ICP_Mean")
t, icp = rec.read("Trends/ICP_Mean", *span) # every row
t, icp = rec.read("Trends/ICP_Mean", span.start, span.start + timedelta(minutes=10))
A TimeRange unpacks to (start_us, end_us) in integer microseconds. start
and end give the same bounds as UTC datetimes; last_us and duration are
also available. In a file with several archives the whole-file range includes
the time between archives, so use archive=, summary() or regions() to find
where there is data.
The range comes from the first and last timestamps. The start_time and
end_time dataset attributes can be up to 1 µs late, which can drop the first
sample when used as start.
API
| Call | Returns |
|---|---|
moberg_h5.open(path) |
Recording, usable as a context manager |
rec.format_version |
"1.0", or None for files written before format versioning |
rec.attrs |
Root attributes: converter name and version, source archive, creation time |
rec.archives |
Patient_* group names in a file that holds several archives |
rec.signals(kind=None, archive=None) |
Signal list; kinds are eeg, qeeg, waveform, trend, other |
rec.signal(path) |
One Signal by HDF5 path |
rec.eeg_channels(modality="EEG") |
Per-channel EEG datasets; pass "HFEEG" for high-frequency EEG |
rec.read(signal, start=None, end=None) |
(timestamps_us, values) for start <= t < end |
rec.read_frame(signals, start=None, end=None) |
pandas DataFrame indexed by UTC time |
rec.time_range(signal=None, kind=None, archive=None) |
TimeRange from the first sample to 1 µs after the last, for one signal or all matching signals; None without samples |
rec.summary(kind=None, archive=None) |
pandas DataFrame, one row per signal: archive, kind, start, end, duration, rows, sampling rate, gap count |
rec.regions(signal), rec.gaps(signal) |
int64 (n, 2) arrays of microsecond times |
rec.annotations() |
Annotation list with microsecond start and end times |
Times passed to read, read_frame, regions and gaps can be integer
microseconds since the Unix epoch, datetime (naive values are read as UTC),
numpy.datetime64 or pandas.Timestamp. Timestamps come back as int64
microseconds since the Unix epoch, UTC.
A Signal carries the dataset path, its timestamps path, units,
sampling_rate (Hz, format 1.x only), the CNS label, location,
source_device, data_type and representation, and for EEG the modality
and channel.
EEG channels that were not recorded for part of a session (a montage change) hold NaN for those rows, so every channel lines up with the shared timestamps.
Format versions
Files written by newer converters carry a root attribute format_version in
MAJOR.MINOR form. MINOR goes up when something is added; MAJOR goes up when a
group, dataset or attribute is renamed, moved, removed or changes meaning.
| File | Support |
|---|---|
No format_version (legacy) |
Best effort. Timestamps are found by naming convention, including the comma-named datasets written before January 2026; region and gap attributes from older files are read. |
1.x |
Supported |
2.0 and later |
Rejected with UnsupportedFormatVersion. Install a newer moberg-h5. |
The layout is described in docs/hdf5-format.md and the changes in each version in docs/format-changelog.md.
Development
uv run pytest
Package releases are listed in
CHANGELOG.md.
Pushing a vX.Y.Z tag publishes to PyPI after a maintainer approves the
deployment; .agents/skills/release/SKILL.md has the steps.
License
MIT. See LICENSE.
Metadata
Release files for moberg-h5 0.1.0
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 |
|---|---|---|---|---|
| moberg_h5-0.1.0.tar.gz | 166.8 kB | With provenance | Details for moberg_h5-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| moberg_h5-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for moberg_h5-0.1.0-py3-none-any.whl |
Total release size: 181.3 kB
Release files / moberg_h5-0.1.0.tar.gz
| Download URL | moberg_h5-0.1.0.tar.gz |
|---|---|
| Size | 166.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a050dc5094bb86be3cb2deb4333ebf9a4128ffb40c5023a3666db24180fe9ff8
|
|
BLAKE2b-256 checksum How to use checksums |
efc67e3969b53929cc93db8179542a0efaf285234d00b2575158d3f3611c73ee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 18, 2026.
Transparency logRelease files / moberg_h5-0.1.0-py3-none-any.whl
| Download URL | moberg_h5-0.1.0-py3-none-any.whl |
|---|---|
| Size | 14.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a1173a0547e351cb0238c4c4a875838f13feaabf7c3bd7bf4185ae5f23b74a90
|
|
BLAKE2b-256 checksum How to use checksums |
61ec71aa46ac031bbfa5b7e42cc58ee6eb5c2d184407db475a8fefd8d085891f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 18, 2026.
Transparency logSecurity for moberg-h5 0.1.0
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.
Attestation for moberg_h5-0.1.0.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 Nov 18, 2026.
Transparency logA 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.