Skip to content

Add a split-Zarr-to-H5 writer with source-H5 parity checks - #1

Merged
wolfgang-ganglberger merged 1 commit into
mainfrom
t3/zarr-to-h5-export
Nov 27, 2026
Merged

wolfgang-ganglberger merged 1 commit into
mainfrom
t3/zarr-to-h5-export

Conversation

@wolfgang-ganglberger

Copy link
Copy Markdown
Collaborator

What

New recordings are published only as split Zarr (primary + derivative + summary JSON). This adds a writer that assembles them back into one local H5 in the layout the converter read, plus a parity check against the archived source H5.

  • bdsp.zarr_to_h5.write_h5 / bdsp-zarr-to-h5 CLI
    • Signals: int16 with a recovered calibration that reproduces every Zarr sample bit-exactly through the converter's formula. If none exists, float32 with an identity calibration. mV/V units are restored.
    • Annotations: original codes and event_map.
    • Feature time series: copied from bdsp.sleep-feature-payload.v1.
    • Recording summary: all rows plus vectors from the JSON.
    • Metadata the split format never stored (e.g. prefilter, rule, producer provenance, features/research) is listed in bdsp_h5_export, not invented.
  • bdsp.h5_compare.compare_h5: compares a rebuilt H5 with its source (names and counts only, never values).
  • validation/h5_parity.py: seeded, resumable live check that also runs the converter's own verifier with the rebuilt H5 standing in as the source.
  • Docs: docs/bids-zarr/H5_EXPORT.md, plus short links from the guides. Version bump to 0.5.0.

Verification

  • pytest: 51 passed, 1 skipped (the existing opt-in AWS test). The new synthetic round-trip tests include mV units, sparse and boolean channels, payload families and tamper detection.
  • Live check on 5 seeded recordings per cohort (S0001, I0002, I0003, I0004, I0006, I0007); see validation/reports/2026-11-27-h5-parity.md:
    • 25/25 pass outside I0007.
    • 1,024/1,024 signals have identical physical samples. 77% also have the archived int16 digital samples and 71% the archived calibration attributes.
    • 221/221 annotation tables, 650/650 published feature families and 126,792 summary rows match.
    • The converter's verifier accepts all 30 rebuilt H5s.
  • bdsp.read_h5, open_h5 and to_dataframe give identical results on a real rebuilt vs source H5.

Finding

I0007 derivative Zarr stores are not published: 0 of 300 sampled subjects have one, and only the summary JSON exists. Rebuilt I0007 H5s therefore lack CAISR annotations and feature time series. Everything I0007 does publish matches.

No cloud data were modified. Participant-level evidence stays in the ignored validation/results/.

New recordings are published only as primary Zarr, derivative Zarr and
summary JSON. bdsp.zarr_to_h5.write_h5 (CLI: bdsp-zarr-to-h5) assembles
them into one local H5 in the layout the converter read:

- signals as int16 with a recovered calibration that reproduces every
  Zarr sample bit-exactly through the converter's formula (float32 with
  an identity calibration when none exists); mV/V units restored;
- annotations with original codes and event maps;
- feature time-series families copied from the payload extension;
- the full recording summary and exported vectors from the JSON.

Metadata the split format never stored is listed in bdsp_h5_export
instead of being invented.

bdsp.h5_compare.compare_h5 checks a rebuilt H5 against its source, and
validation/h5_parity.py runs that check (and the converter's own
verifier) on seeded samples. On 5 recordings per cohort, all 25 from
S0001, I0002, I0003, I0004 and I0006 passed; 1,024/1,024 signals had
identical physical samples and the converter verified all 30 rebuilt
H5s. I0007 cannot be rebuilt completely because its derivative Zarr
stores are not published (0 of 300 sampled subjects); see
validation/reports/2026-11-27-h5-parity.md.

Bumps the version to 0.5.0.
@wolfgang-ganglberger
wolfgang-ganglberger merged commit 23889aa into main Nov 27, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant