You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
wfdb_to_wav writes invalid samples as 0 for resolutions below 12 bits #637
wfdb_to_wav computes each output sample as (d - adc_zero) << (16 - adc_res) and then casts it to int16. For signals with a resolution below 12 bits, the invalid sample value overflows int16 and becomes 0, so a gap in the signal looks like a valid zero in the .wav file.
For example, a format 212 record with samples 100, -2048, 200, where -2048 is the invalid value for format 212, gives:
adc_res
valid samples
invalid sample in the .wav
12
1600, 3200
-32768
11
3200, 6400
0
With 11 bits, -2048 << 5 is -65536, which wraps to 0 as an int16. Record 100 in sample-data is format 212 with 11-bit resolution, so this affects MIT-BIH records that contain gaps.
One fix is to map invalid samples to -32768 (the format 16 invalid value) after the shift, instead of shifting them.
Activity