Hi Mark,
As you requested last time we spoke, I’ve put together a small example of how I generate trial-by-trial plots using the Python bridge.
The attached files are an adaption of the MATLAB window demo to Python. The experiment generates random values (10 per trial over 10 trials) and stores them in the variable rand_var
. The Python script draws a histogram of these values, updating the plot whenever new values are received. The script can be run via the client or server bridge. (In the latter case, the conduit resource is assumed to be named server_conduit
.)
The Conduit
class defined in common.py provides a generic framework for online plots. It inherits from mworks.conduit.IPCAccumClientConduit
, which accumulates requested events between “start” and “stop” events, then delivers them as a group to an event handler. (The Conduit class expects variables named start
and stop
for this purpose, but this can be changed to any two variables you prefer.)
The main benefit of the Conduit class is that it handles running of the application main loop (starting and stopping it as needed to handle new events). This keeps the matplotlib window responsive to user input, allowing you to pan, zoom, or whatever.
If you have any questions, please let me know.
Cheers,
Chris