Skip to content

fix: handle non-resuscitation recordings in read_zollcsv#277

Merged
behackl merged 3 commits into
mainfrom
fix_276
May 28, 2026
Merged

fix: handle non-resuscitation recordings in read_zollcsv#277
behackl merged 3 commits into
mainfrom
fix_276

Conversation

@sorlob

@sorlob sorlob commented Mar 31, 2026

Copy link
Copy Markdown
Collaborator

When a recording has no CPR activity, CprDepth and CprFrequency columns are all zeros. After filtering out zeros, timestamps1 is empty, causing IndexError on timestamps1[-1] and subsequent KeyError on CompDisp/CompRate accesses that assumed CPR data was always present.
#276

Additionally omits import of vast zero arrays.

Example File for ZOLL R Series containing ECG an PPG:
20260331124955_00147042.zip

When a recording has no CPR activity, CprDepth and CprFrequency columns
are all zeros. After filtering out zeros, timestamps1 is empty, causing
IndexError on timestamps1[-1] and subsequent KeyError on CompDisp/CompRate
accesses that assumed CPR data was always present.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@sorlob sorlob requested a review from behackl March 31, 2026 17:41
Channels that are present in the recording but carry only zero values
(e.g. Ecg2/3/4 leads connected but not recording, CprWaveVal without
CPR activity) are now stored as empty DataFrames instead of being
skipped or loaded with large arrays of meaningless zeros. This preserves
channel presence for downstream detection while avoiding data bloat.
@behackl

behackl commented May 28, 2026

Copy link
Copy Markdown
Contributor

This reviewer fix adds a synthetic regression test for ZOLL CSV imports with
no CPR activity and simplifies read_zollcsv to treat all-zero channels as
absent instead of propagating empty placeholder DataFrames. The loader now
skips zero-only CPR and waveform channels, guards all later optional accesses
to CompDisp and CompRate, and avoids emitting phantom metadata rows for
omitted channels. This makes the behavior more consistent, fixes the
non-resuscitation crash described above, and ensures end-to-end loading
still works when a recording contains ECG/capno/SpO₂ data but no
chest-compression data.

@behackl

behackl commented May 28, 2026

Copy link
Copy Markdown
Contributor

Also adds a regression test. If you really need the empty channels, we can change this fix in a follow-up PR; for now I'd like to get this merged. Other PRs in this chain to follow.

@behackl behackl merged commit 2685636 into main May 28, 2026
10 checks passed
@behackl behackl deleted the fix_276 branch May 28, 2026 08:10
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.

2 participants