MIT-LCP / wfdb-python

Native Python WFDB package
MIT License
738 stars 300 forks source link

Option to display aux strings in plot #412

Open bemoody opened 2 years ago

bemoody commented 2 years ago

plot_wfdb has an option plot_sym to display the annotation type (mnemonic) next to each annotation.

It'd be nice to have an option to display the aux strings, too.

sul24mib commented 1 year ago

Hello @bemoody , I think this would be a good starter issue. Could you expand on what you are looking for in terms of the aux strings?

bemoody commented 1 year ago

Here's one example. If you run the following:

import wfdb

rec = wfdb.rdrecord('485', pn_dir='mimicdb/485/', sampfrom=753500, sampto=754750)
ann = wfdb.rdann('485', 'al', pn_dir='mimicdb/485/',
                 sampfrom=753500, sampto=754750, shift_samps=True)

wfdb.plot_wfdb(rec, ann)

you'll see that there are a bunch of signals (II, aVF, V, etc.), and two annotations (shown as red stars.) However, the stars don't tell you anything about what the annotations mean.

Each of these annotations has a text description that was provided by the bedside monitor (the first one is "ALARM: ** RUN VPBs 3 - 9" and the second is "ALARM: ***VENT TACHY"). These descriptions are called "aux" strings in WFDB terminology.

So it would be good for the plot to display those strings where we can see them. Here's what that same plot looks like when viewed using metaann or WAVE:

metaann screenshot

Of course the plot doesn't need to look exactly like this - this is just an example to give you an idea.

If you want to try to solve this issue you'll need to familiarize yourself with matplotlib and how the functions in wfdb/plot/plot.py use it, as well as familiarizing yourself with wfdb-python data structures such as Record and Annotation.

There's a lot of room to improve the plotting interface - what information is presented, how it's presented, and what knobs and switches are available to programmer/user. If you see other ways to make it more intuitive and easier to use, go for it!