Friday, March 15, 2013

Re-evaluating Library Options for Python Graphing

So we figured out that matplotlib by itself may not be optimal for real time graphing. We looked around and found the following alternatives:
wxPython + matplotlib (came with a piece of code, testing this now) Stack Overflow Post
- wxPython is a GUI wrapper for Python, which will supposedly make matplotlib faster

chaco: recommended by official Python page for real-time plotting
Some other possible options (last post on page):
http://pyqwt.sourceforge.net/
http://code.google.com/p/guiqwt/
http://luke.campagnola.me/code/pyqtgraph/

Another option is to store a fixed amount of data in a buffer and plot the contents at once, reducing the frequency of graph updates. To make the updates appear as smooth real-time plotting, we can animate the plotting. From our (Daniel & Anand) discussion, we concluded that the quality of the data updates will determine the quality of our ECG GUI, which we will measure by the following metrics:
- Smoothness: does the graph appear to be constantly updating, without any abrupt pauses
- sequential cycle: collect data --> plot --> collect --> plot ...
- this will work under the assumption that collecting data takes a negligible amount of time (ie. no pauses)
- if not, then we will have to look into multithreading (painful!) so that the updates will be smooth

- Delay: what is the delay between when the data is collected off the patient's skin to when it's displayed on the computer screen? ideally this number should be small, but more importantly it should remain constant (increasing means that data is accumulating in the serial buffer, very bad!)

- Data accumulation in buffer - 0, else we risk a buffer overflow as t --> infinity

Some possible algorithm designs considerations:
- Create a rotating buffer of two arrays. At any time, one is being plotted and covering up the other. During the first iteration, the array being replaced is empty, so there are no ugly effects from replacing a zero'd array.

-

No comments:

Post a Comment