I have been looking for a tutorial or guide on how to set up an online analysis of my experiment via python.
Sorry, MWorks' documentation is still lacking in this area.
I found these threads and pages:
FYI, Python file resources and Python actions are used for running Python code within your experiment (i.e. inside MWServer), so they're not relevant when using the Python Script Bridge.
I keep failing at the very first step: loading the mworks.conduit
As I think you discovered, MWorks 0.8 supports only Python 2.7 and 3.6. MWorks 0.9 supports Python 2.7 and 3.7. The current nightly build, which will eventually become MWorks 0.10, supports Python 3.5 and later. (Python 2.7 is no longer supported.)
However, in MWorks 0.8 and 0.9, the Python bridge window always launches the system Python 2.7 (/usr/bin/python). The option to choose the Python version to launch was added to the nightly build fairly recently. If, instead of the Python bridge window, you use a server-side conduit, you can launch your script using the compatible Python executable of your choice. (The example you referenced works in both client-side and server-side mode.) However, that does require you to run your Python code on the machine that's running MWServer, so it's not helpful when you're connecting to a remote system.
I tried by switching to python 3.6 and 2.7 and this is what I got
SystemError: initialization of _mworks raised unreported exception
Huh. I don't think I've seen that error before. The _mworks module imports numpy, so maybe numpy is failing to import for some reason?
I tried several combinations of python and mworks versions and could not manage to read datafiles neither online nor offilen.
Reading data files online (i.e. while they're still being written) isn't supported. However, you certainly should be able to read them offline. Can you tell me more about the errors you were encountering?
Regarding the "initialization of _mworks raised unreported exception" error, is it possible that you're seeing this issue?
I wanted to ask you in advance if you could give me a hint on how to set up the Python Bridge script and how to setup the mwel experiment itself to work with the bridge.
I've posted an updated Python bridge plotting demo on GitHub. It should be a good starting point for working with the Python bridge in the nightly build.
The Conduit class (in file conduit.py) hides some of the hairier details and sets things up so that any matplotlib windows you open remain responsive. You should be able to use it with multiple experiments without modification.
The experiment-specific Python file (python_bridge_plotting_demo.py) defines an event handler function that receives updated values for variables of interest, processes them in some way, and then draws one or more plots. It also invokes Conduit.main, passing it the custom function and the list of variable names to monitor. (Note that the function should not call pyplot.show, as that's handled by Conduit.main.)
The only thing that the experiment file (python_bridge_plotting_demo.mwel) needs to do is tell the Python script when to start/stop collecting events. This is done via two variables (called start and stop in the example). Assigning a value to the first variable tells the script to begin collecting events. Assigning a value to the second variable tells the script to stop collection events and invoke the event handler function on the collected events. The example assigns start/stop at the beginning/end of each trial, respectively.
To use the example, first load the experiment, then load the experiment-specific Python file via the Python script bridge window. The first time you load the script, you'll also have to select the Python executable to use (e.g. python3 in your local Anaconda installation).
Also, is it the bridge going to be kept in future versions of MWorks?