Closed satyaog closed 2 years ago
Personally, I also find this API to be confusing. Yes, the length of
aux_note
must be the same as the length of sample
(and symbol
,
chan
, etc.) The nth element of aux_note
is the text note
associated with the nth element of sample
. So it doesn't make sense
to pass lists of different lengths.
If the nth event doesn't require a text note, the corresponding element
of aux_note
should be set to an empty string ('').
Arguably, wrann should be made to accept None as equivalent to an empty string, but that's not currently allowed. (Also, I think wrann should accept any type of iterable, not only lists or numpy arrays.)
If you have a list (or a numpy array) like:
aux_note = [None, '(AFL', None, None, None]
you can replace the None values with empty strings using:
aux_note = [(i or '') for i in aux_note]
Does that help?
Yes thank you this makes things more clear. I was already using an empty string (''
) in my gist but I was wondering if there was a better way. I was a bit surprise that the aux_note
annotations from wfdb.rdann
seemed to be ['None', '(AFL', 'None', 'None', ...]
instead of ['', '(AFL', '', '', ...]
but I'm happy to hear that my usage of the library is ok.
Hi,
I'm currently working on converting an EGC dataset icentia11k to the wfdb format so it can be hosted in the PhysioBank database.
I've received one feedback on the
aux_note
of an annotation file for which I'm not sure how to resolve.They've told me that
aux_note
does not need to include values like'None'
in it but when I try to reduce the size of theaux_note
numpy array that I'm sending to wfdb.io.wrann or replace the string by actualNone
, I'm blocked by two types of errors.Either I get
or
I'm using wfdb-python version 3.4.1.
From the documentation of wfdb.io.wrann, it seams indeed that
aux_note
needs to be the same size ofsample
. So reducing the size ofaux_note
to contain only non-empty values doesn't seem feasible. But it seems to indicate that theNone
value should be acceptable for annotations that doesn't have a note.I have a gist with the code I'm using to do the conversion: https://gist.github.com/satyaog/665dee88cec0c2d0f2ec78f7cb0919af Test data can also be found in this Google Drive: https://drive.google.com/drive/folders/1bW-k7zBF6ZRrd7ZU06YtLmWSXAzG5ZFJ
To test with a filtered
aux_note
, the following snippet can be used to replace the lines in the gist:To test with an aux_note using None in the array, the following snippet can be used to replace the lines in the gist:
Without any change to the gist, the following snippet prints the content of the
aux_note
:Note that the review process is still ongoing and I'm starting to believe that in
"rtype"
3: ('N', '')
should probably be replaced by3: ('', '')
or maybe3: ('+', '(')
. Although this is not related to the issue, an explanation might ease the itchiness some could feel in their eyes by looking at the current version of the code.