Closed MishalJasmine closed 3 years ago
Hey @MishalJasmine, I'm kind of confused by your question because resampling shouldn't truncate any annotations, just move them to a new sample number so the lengths should all be the same as before the resampling. The only difference is with ann.sample
:
>>> import wfdb
>>> from wfdb import processing
>>>
>>> sig, fields = wfdb.rdsamp('sample-data/100')
>>> ann = wfdb.rdann('100', 'atr', pn_dir='mitdb')
>>> new_sig, new_ann = processing.resample_singlechan(sig[:, 0], ann, fields['fs'], 125)
>>>
>>> ann.sample[:10]
array([ 18, 77, 370, 662, 946, 1231, 1515, 1809, 2044, 2402])
>>> new_ann.sample[:10]
array([ 6, 27, 128, 230, 328, 427, 526, 628, 710, 834])
>>> # Note 18 = 6 * (360 / 125)
>>>
>>> ann.symbol[:10]
['+', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'A', 'N']
>>> new_ann.symbol[:10]
['+', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'A', 'N']
>>>
>>> ann.aux_note[:10]
['(N\x00', '', '', '', '', '', '', '', '', '']
>>> new_ann.aux_note[:10]
['(N\x00', '', '', '', '', '', '', '', '', '']
>>>
>>> len(ann.sample)
2274
>>> len(new_ann.sample)
2274
>>> len(ann.symbol)
2274
>>> len(new_ann.symbol)
2274
>>> len(ann.aux_note)
2274
>>> len(new_ann.aux_note)
2274
@Lucas-Mc, Thanks for the code snippet. Looks like I had done a mistake in the script. My bad. Please close this issue.
I extracted the ECG signal and the annotations including the auxiliary note from the MIT BIH database. I resampled the database record to 125Hz using the function
resample_singlechan
. After resampling I observed that the length of the qrs peaks and the labels match but the length of the auxiliary notes is different. The number of auxiliary notes is the same as prior resampling.