OpenVibe & Matlab & Real-time

Come here to discuss about OpenViBE in general!
JavierJ
Posts: 3
Joined: Tue Apr 20, 2010 10:03 am

OpenVibe & Matlab & Real-time

Post by JavierJ »

Hello! We are a group of spanish students. We are trying to get a real-time EEG signal processing system based on an openEEG hardware , the openVibe software and Matlab. We don't know yet how to communicate openVibe with Matlab. It would be very precious to us if someone could help us. Thank you!

Regards.

yrenard
Site Admin
Posts: 645
Joined: Fri Sep 01, 2006 3:39 pm
Contact:

Re: OpenVibe & Matlab & Real-time

Post by yrenard »

Dear JavierJ,

first, thank you for your interest in OpenViBE and welcome on this board... I'm glad some people get interested in the Matlab/OpenViBE integration.

For now, Matlab can only be used with OpenViBE under Linux OS. Are you using Linux ? Then you should enable the build of the Matlab plugin branch, editing your linux-init_env_command file and adding the $OpenViBE_plugin_matlab to your OpenViBE_build_order (see around line 178). I expect this will build the Matlab box.

Additionally, this box being experimental, you will have to modify your configuration file to make it appear in the designer... Just edit your ~/.openviberc file and add the following line :

Code: Select all

Designer_ShowUnstable = true
You will find the Matlab box under Tools.

Tell us if you have any problem.
Best regards,
Yann

lbonnet
Site Admin
Posts: 417
Joined: Wed Oct 07, 2009 12:11 pm

Re: OpenVibe & Matlab & Real-time

Post by lbonnet »

Hello Javier and welcome on board !

Openvibe communicates with Matlab through a dedicated plugin (a.k.a. a dedicated box).

Basically, the Matlab box can execute matlab code, once you provide it your local matlab engine and matlab code. However, this box has not been fully tested yet (we didn't have enough feedback from potential users, but we are working on it) and is only available on the forge.

Thus you will have to download the source code using subversion, and build the sources. As Yann pointed at, you will have to do minor changes to the scripts so the matlab branch is being built.

Thanks for your interest in the project, and feel free to post more questions on the forum, we will do our best to answer it quickly.

Laurent
Follow us on twitter >> openvibebci

Checkout my (old) blog for some OpenViBE tips & tricks : here !

JavierJ
Posts: 3
Joined: Tue Apr 20, 2010 10:03 am

Re: OpenVibe & Matlab & Real-time

Post by JavierJ »

Thank you for the quick reply! We are not working with linux, due to the fact that we are not "good experienced" linux users. For now, we are studying if we can make it run, based on a simulink solution. If we don't find something interesting in simulink, maybe we will turn back to the linux implementation. I will keep you up to date if we start to develop the solution under matlab with open vibe.
Thank you for your attention!
Regards!

yrenard
Site Admin
Posts: 645
Joined: Fri Sep 01, 2006 3:39 pm
Contact:

Re: OpenVibe & Matlab & Real-time

Post by yrenard »

Dear JavierJ,

I believe porting the box to windows is very straight forward. I will give it a try immediately and keep you posted.

Best regards,
Yann

yrenard
Site Admin
Posts: 645
Joined: Fri Sep 01, 2006 3:39 pm
Contact:

Re: OpenVibe & Matlab & Real-time

Post by yrenard »

Dear JavierJ,

I just uploaded a few changes to the CMake / init-env-command scripts so that you can compile the MATLAB box on Windows.

Please follow those steps to get it working :
- update to the latest SVN repository,
- edit your win32-dependencies.cmd file and add the following line with whatever path meets your installation :

Code: Select all

SET OV_DEP_MATLAB=c:/program files/matlab/r2009b
- remove your win32-init_env_command.cmd file and update it with the new win32-init_env_command.cmd-skeleton
- edit your fresh win32-init_env_command.cmd file and request the compilation of the matlab plugin (see and uncomment around line 212)
- run win32-build.cmd

If any problem occurs, please send me the files I mentioned above and the output of your win32-build.cmd console.

You will find the box in the Tools section. In order to use it, provide a path where you put two .m files such as those ones :

Code: Select all

% bci_Initialize.m

function result = bci_Initialize(bci_context, matrix)
	[sample_count, channel_count] = size(matrix)
	result = zeros(sample_count, channel_count)
and

Code: Select all

% bci_Process.m

function result = bci_Process(bci_context, stimulation_set, matrix)
	plot(matrix)

	[sample_count, channel_count] = size(matrix)
	result = matrix
Tell me if it works.

Kinda regards,
Yann Renard

JavierJ
Posts: 3
Joined: Tue Apr 20, 2010 10:03 am

Re: OpenVibe & Matlab & Real-time

Post by JavierJ »

Hello Yann!
I already have the latest SVN repository version, but i can't find the win32-dependencies.cmd file.
Where is it?
Thank you!

lbonnet
Site Admin
Posts: 417
Joined: Wed Oct 07, 2009 12:11 pm

Re: OpenVibe & Matlab & Real-time

Post by lbonnet »

Hi Javier !

If I remember correctly, win32-dependencies.cmd is generated automatically when you install the dependencies (using the dependencies installer given in /trunk/scripts).

Best regards,

Laurent
Follow us on twitter >> openvibebci

Checkout my (old) blog for some OpenViBE tips & tricks : here !

Johann
Posts: 9
Joined: Wed Jul 07, 2010 3:31 pm

Re: OpenVibe & Matlab & Real-time

Post by Johann »

Hi,

I too am working on Open-ViBE + Matlab + an external VRPN server on the closest-to real-time basis possible. I succeeded in building Open-ViBE with the Matlab toolbox, but now I experience difficulties to use it.

To test the box, I used a simple Process.m file, which only divides the input matrix by 2:

Code: Select all

function result = bci_Process(bci_context, stimulation_set, matrix)

result = matrix./2;
I did not change Initialize.m:

Code: Select all

function result = bci_Initialize(bci_context, matrix)

[sample_count, channel_count] = size(matrix);

result = zeros(sample_count, channel_count);
On Open-ViBE I created a scenario in which I put:
GDF File Reader ----> Matlab Filter ----> GDF File Writer
(At first I wanted to use Signal Display, but it proved to be quite slow...)

Also : - The GDF I use is not corrupted because Matlab processes it with no difficulty.
- I did specify the working directory in the Matlab filter parameters.

Unfortunately the output GDF is empty.

What could be the problem? Thanks in advance.

yrenard
Site Admin
Posts: 645
Joined: Fri Sep 01, 2006 3:39 pm
Contact:

Re: OpenVibe & Matlab & Real-time

Post by yrenard »

Dear Johann,

Thank you for your interest in our software and welcome on this board.

I think you should rename your Process.m to bci_Process.m.

Tell me if that helps,
Yann

Johann
Posts: 9
Joined: Wed Jul 07, 2010 3:31 pm

Re: OpenVibe & Matlab & Real-time

Post by Johann »

Thank you, unfortunately I misspelled the name of the file on my last post; I did call the two files bci_Process.m and bci_Initialize.m

Any other idea?

yrenard
Site Admin
Posts: 645
Joined: Fri Sep 01, 2006 3:39 pm
Contact:

Re: OpenVibe & Matlab & Real-time

Post by yrenard »

Dear Johann,

what if you try to plot the input matrix ? is it working ?

Yann

Johann
Posts: 9
Joined: Wed Jul 07, 2010 3:31 pm

Re: OpenVibe & Matlab & Real-time

Post by Johann »

Thanks for your answer. Yes, the plotting of the matrix works, there are values and colors. It is quite slow and the cmd window indicates that it could not reach real-time, but it works.

The display of the signal is OK too (in scan mode though, because the scroll mode is really slow).

It obviously comes from the Matlab Filter, but I have no clue why...

yrenard
Site Admin
Posts: 645
Joined: Fri Sep 01, 2006 3:39 pm
Contact:

Re: OpenVibe & Matlab & Real-time

Post by yrenard »

Dear Johann,

what if you try the sample scripts I posted earlier in this thread ?

Yann

Johann
Posts: 9
Joined: Wed Jul 07, 2010 3:31 pm

Re: OpenVibe & Matlab & Real-time

Post by Johann »

Thanks again,


Nope, even with the simplest code, the output matrix is still empty. The Signal Display and the Matrix Display boxes show nothing, and an analysis under Matlab confirms it (plus the output file is only 244 bytes, every time - I guess it's the size of a basic empty GDF file, containing only the headers).

When I launch the process under OV, the Matlab Command window appears (it looks like Windows' cmd.exe window, written black on white), but nothing happens, it just stays blank.


Any other idea?

Post Reply