Open/read/close API for WFDB format #100
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Here's a (basic) implementation of the new open/read/close API for the WFDB format classes.
As we've discussed elsewhere, the wfdb-python package doesn't currently have any API for doing this sort of thing (which is certainly on the wishlist!)
So this is a quick re-implementation that just handles the specific (single-segment, format 16/516) formats that we're using for benchmarking.
Since it is a re-implementation, it avoids a lot of the overhead of the wfdb.rdrecord function and consequently the performance numbers are not going to be directly comparable to what you get when using rdrecord - I expect the performance will be better, because there are a number of things in wfdb-python that are not optimally implemented. But let's try it and see. :)
You might also notice that the array returned by
read_opened_waveforms
is slightly different from the array returned byread_waveforms
, due to FP rounding errors. Probably because the former multiplies by 1/gain where the latter divides by gain.This does rely on having a fairly recent version of libsndfile. I think (but I'm not 100% sure) that the soundfile packages on PyPI are sufficiently recent.