Hi everyone!
I'm fairly new to OpenVibe, but I just had a quick question that I can't seem to find the answer to in the documentation.
Is it possible for OpenVibe to send processed signals to MATLAB in realtime? I would like to use signals processed via OpenVibe to control an Arduino. If it is possible, could anyone show me how this is accomplished via the MATLAB scripting box?
Thank you!
MATLAB and OpenVibe in real time

 Posts: 775
 Joined: Tue Dec 04, 2012 3:53 pm
 Location: INRIA Rennes, FRANCE
Re: MATLAB and OpenVibe in real time
The Matlab scripting box does online processing. Like all openvibe boxes, the box processes data by chunks that it receives. Roughly, when a stream chunk is available at the box input, the matlab process script is called to do something with the chunk, after which the control is returned from matlab. What kind of 'realtime' behavior this routing has in terms of latencies, jitter, etc you'd need to measure in your specific situation. The kernel tries to keep the processing real time but if data is coming in faster than your components can process, there is little it can do.
We've controlled Arduino before with python. Although there is a python scripting box available, the user had developed a solution to use LSL to send classifier predictions to a python script which was running independent of openvibe.
Cheers,
Jussi
We've controlled Arduino before with python. Although there is a python scripting box available, the user had developed a solution to use LSL to send classifier predictions to a python script which was running independent of openvibe.
Cheers,
Jussi
Re: MATLAB and OpenVibe in real time
Hello,
I am using openvibe to feed data into matlab for processing and then will give it to openvibe for handplay scenario.
My question is which variable (in which .m file) i need to use as input in matlab for my coding and which output should be available at the end so that it works without any problem with openvibe.
Many thanks in advance.
I am using openvibe to feed data into matlab for processing and then will give it to openvibe for handplay scenario.
My question is which variable (in which .m file) i need to use as input in matlab for my coding and which output should be available at the end so that it works without any problem with openvibe.
Many thanks in advance.

 Posts: 775
 Joined: Tue Dec 04, 2012 3:53 pm
 Location: INRIA Rennes, FRANCE
Re: MATLAB and OpenVibe in real time
Among the scenarios bundled with openvibe, there are matlab tutorials, one of them called 'signal filter'. You should be able to use that as a starting point. The basic logic of buffer handling is there.
Happy hacking,
Jussi
Happy hacking,
Jussi
Re: MATLAB and OpenVibe in real time
Hello Jussi,
I managed to integrate my Matlab script into openvibe via Scripting box and solved thousand problems.
Nowadays, in designer console it says " couldn't reach real time, ... 5 sec late" and the number is increasing although Most interestingly i was able to get real time when i tried to run the program first time.
What could make the program to experience nonreal time after first try? Do you have any idea?
Do i need to clean anything at the end?
Thanks.
HAkan
I managed to integrate my Matlab script into openvibe via Scripting box and solved thousand problems.
Nowadays, in designer console it says " couldn't reach real time, ... 5 sec late" and the number is increasing although Most interestingly i was able to get real time when i tried to run the program first time.
What could make the program to experience nonreal time after first try? Do you have any idea?
Do i need to clean anything at the end?
Thanks.
HAkan

 Posts: 775
 Joined: Tue Dec 04, 2012 3:53 pm
 Location: INRIA Rennes, FRANCE
Re: MATLAB and OpenVibe in real time
Thats a good question! If the matlab script is slow, you can add 'tic' and 'toc' functions to your .m scripts to see where it spends its time. Maybe this well help you narrow down whats the problem. Perhaps some buffer is growing every time and needs to be zeroed after process() exits?
Happy hacking,
Jussi
Happy hacking,
Jussi
Re: MATLAB and OpenVibe in real time
Ok i will try your suggestion. I suspect it related to be VRML in Matlab.
In your code, you use actxserver in order to use MAtlab as automation server. I am trying to bring variables into my another matlab version, that's why trying to use "GetWorkspaceData" function. However it requires handle name(Handle = actxserver('......'). How can i reach this?
Thanks.
Hakan
In your code, you use actxserver in order to use MAtlab as automation server. I am trying to bring variables into my another matlab version, that's why trying to use "GetWorkspaceData" function. However it requires handle name(Handle = actxserver('......'). How can i reach this?
Thanks.
Hakan
Re: MATLAB and OpenVibe in real time
Dear all,
I have a very similar problem and was wondering if any of you were able to make Matlab or Python work really in realtime. We are trying to utilize a Matlab or Python scripting box within our scenarios which include data acquisition from a generic driver for now and a BioSemi system in the future. However, whenever we use a loop inside the Process function of either box to read the incoming stimulations, we face delays that quickly accumulate and result in the Graz MIBCI Interface or our own visual interface to not show up in real time. Since this issue arises with two different scenarios based on Matlab and Python scripting boxes, we suspect the delay in streaming of data chunks could be due to the clock frequency of these boxes and the epoch sample count. However, we have not been able to resolve this issue to obtain realtime data streaming and visual interfaces while doing data acquisition. Any help or hint on how to find a workaround for this problem is highly and deeply appreciated
Thanks in advance,
Mastaneh
I have a very similar problem and was wondering if any of you were able to make Matlab or Python work really in realtime. We are trying to utilize a Matlab or Python scripting box within our scenarios which include data acquisition from a generic driver for now and a BioSemi system in the future. However, whenever we use a loop inside the Process function of either box to read the incoming stimulations, we face delays that quickly accumulate and result in the Graz MIBCI Interface or our own visual interface to not show up in real time. Since this issue arises with two different scenarios based on Matlab and Python scripting boxes, we suspect the delay in streaming of data chunks could be due to the clock frequency of these boxes and the epoch sample count. However, we have not been able to resolve this issue to obtain realtime data streaming and visual interfaces while doing data acquisition. Any help or hint on how to find a workaround for this problem is highly and deeply appreciated
Thanks in advance,
Mastaneh