MatlabSignalProcessing

This forum deals with BCI2000 configuration issues.
sanbelluzo
Posts: 9
Joined: 23 Jan 2013, 17:06

Re: MatlabSignalProcessing

Post by sanbelluzo » 03 Sep 2013, 17:11

Hi there!!

Thx for everything!! But i've still problems, i don't know how, but after several trials, it generated the BCI executable from Visual.., but when i debug the project it showed me "win32". I did it anyway, but when i tried to run "MatlabSignalProcessing" it show me the following error:


2013-09-03T17:51:08 - BCI2000 Started
2013-09-03T17:51:09 - Started "SignalGenerator"
2013-09-03T17:51:09 - SignalSource: Waiting for configuration ...
2013-09-03T17:51:09 - Started "MatlabSignalProcessing"
2013-09-03T17:51:09 [SignalProcessing] MatlabFilter::Constructor: Could not load library "libeng": <n/a>
2013-09-03T17:51:09 [SignalProcessing] MatlabFilter::Constructor: Could not connect to Matlab engine. Please make sure that Matlab is available on your machine.
On Windows, Matlab's bin/win32 directory must be on your system's %PATH% variable, and "Matlab /regserver" must have been executed with administrative privileges.
2013-09-03T17:51:09 - Started "FeedbackDemo"
2013-09-03T17:51:09 - Script error: C:\BCI2000\batch\MatlabDemo_SignalGenerator.bat, line 35: Wait aborted
Function: Script::ReportError()
File: ..\..\..\..\..\src\core\Operator\OperatorLib\ScriptParser\Script.cpp
Line: 105
2013-09-03T17:51:09 - Application: Waiting for configuration ...



So... i think, my mistake was run the Cmake with "VisualStudio 9 2008", instead of "VisualStudio64 9 2008" because when i did it, the file that create give me the next error:


The project consists entirely of configurations that require support for platforms wich are not installed on this machine. The project cannot be load.


:x :x :x :x :x :x :x :x :x :x :x

hehehehe!! :lol:

I want to hit my computer lol!!

So.. any idea??? :?: :?: :?: :?:

boulay
Posts: 382
Joined: 25 Dec 2011, 21:14

Re: MatlabSignalProcessing

Post by boulay » 03 Sep 2013, 21:07

Open a command prompt and type

Code: Select all

where libeng*
It should look something like this:

Code: Select all

C:\Users\Chad>where libeng*
C:\Program Files\MATLAB\R2012a\bin\win64\libeng.dll
*EDIT*
And please tell me the result.

boulay
Posts: 382
Joined: 25 Dec 2011, 21:14

Re: MatlabSignalProcessing

Post by boulay » 04 Sep 2013, 05:52

Send me a message with your e-mail address and I'll send you the MatlabSignalProcessing.exe that I compiled for Win7 x64.

boulay
Posts: 382
Joined: 25 Dec 2011, 21:14

Re: MatlabSignalProcessing

Post by boulay » 04 Sep 2013, 12:02

I just re-downloaded the BCI2000 source code from scratch,
then ran BCI2000\build\"Make VS2008 Win64 Project Files",
then built MatlabSignalProcessing in Release x64,
then ran BCI2000\batch\MatlabDemo_SignalGenerator.bat
And it worked.

I sent you the executable that I built.

If you are concerned about having accidentally overwritten some of your BCI2000 modules with incorrectly built ones, then you should try deleting your BCI2000 folder and replacing it with the contents of the pre-built binaries from the website http://bci2000.org/downloads/bin/BCI2000Contrib.exe, then put the file I sent you in the BCI2000/prog directory.

boulay
Posts: 382
Joined: 25 Dec 2011, 21:14

Re: MatlabSignalProcessing

Post by boulay » 04 Sep 2013, 12:04

My SMTP server didn't want to send the attachment. I'll try attaching here.
Attachments
MatlabSignalProcessing.zip
MatlabSignalProcessing module for Win7 x64
(490.31 KiB) Downloaded 757 times

sanbelluzo
Posts: 9
Joined: 23 Jan 2013, 17:06

Re: MatlabSignalProcessing

Post by sanbelluzo » 05 Sep 2013, 22:38

Hi!!

Thank you so much!!! It's working!! :D

sanbelluzo
Posts: 9
Joined: 23 Jan 2013, 17:06

Re: MatlabSignalProcessing

Post by sanbelluzo » 10 Sep 2013, 17:38

Hi!!

I have another little problem, maybe u can help me again hehe!

I want to use Matlab and BCI2000 in real time. For example take the signals with BCI and then make the signal prossesing using Matlab and then with that information send (for example) to a robot a command.

How can i do for connecting the socket TCP from Matlab with BCI?? how can i do like a buffer of 2 or 3 seconds and then refresh it??

Thanks!!

boulay
Posts: 382
Joined: 25 Dec 2011, 21:14

Re: MatlabSignalProcessing

Post by boulay » 10 Sep 2013, 21:59

BCI2000 likes to keep the signal processing separate from the application. This means that the signal processing module outputs the processed signal without any knowledge of what the signal will be used for. Similarly, the application accepts some control signal without having any idea where it comes from (joystick, brain signal, EMG, whatever). This is a good architecture and it has saved me a lot of time in the past. I recommend that you follow it if possible.

You may have noticed that the example in BCI2000\prog\matlab\bci_Process.m begins with the following:

Code: Select all

function out_signal = bci_Process( in_signal )
This is a Matlab function declaration. The function accepts the argument 'in_signal' and outputs 'out_signal'. This function will be called by BCI2000 for every block of data after the data have been acquired from the source. In your function implementation, you have to do something with in_signal and assign the result of your processing to out_signal. BCI2000 will receive the value of out_signal and pass it along to the next step (i.e., the application).

Your application will also have a method that will receive this signal an do something to the feedback. For example, see FeedbackDemoTask.cpp

Code: Select all

FeedbackDemoTask::DoFeedback( const GenericSignal& ControlSignal, bool& doProgress)
{
  mCursorPosX += mCursorSpeedX;
  mCursorPosY -= mCursorSpeedY * ControlSignal( 0, 0 );
The Cursor's y position is changed according to the first entry in ControlSignal. ControlSignal is from the otuput of MatlabSignalProcessing.
More info: http://www.bci2000.org/wiki/index.php/P ... pplication

You would need to write your own application to control the robot. Are you comfortable doing that in C++?
If not, you can use Python, or you can write a simple C++ application that will connect you to another application. See here: http://www.bci2000.org/wiki/index.php/T ... _Connector

If you want to use Matlab to update your robot you can do that too. However, the only way I know how to do that would be to do it as part of your signal processing, and thus you lose the separation between signal processing and feedback. This might be OK for the short-term but it will be inflexible in the long run.

By the way, Juergen recently updated the MatlabFilter to fix a bug and improve performance. I think he still needs to fix something but I will post a compiled 64-bit version after it is done.

*Edit*
About the buffer, that depends on what you need the buffer for.
If it is part of your signal processing then you will need the buffer in Matlab and will thus use Matlab global variables. During Preflight or Initialize you can create a buffer of the needed size and assign it to a global variable. Then in Process you will have access to this global variable and you can use it as you like.
If it is part of your application then how you implement the buffer will depend on how the application is designed. If you are using C++ then I would suggest taking a look at the Normalizer filter to see how it is used there.

gschalk
Posts: 615
Joined: 28 Jan 2003, 12:37

Re: MatlabSignalProcessing

Post by gschalk » 11 Sep 2013, 11:08

What Chad is describing is a realization of synchronous Matlab processing, i.e., processing of blocks of data as they are "p[roduced" by the data acquisition device. As an alternative, for asynchronous processing, you may want to look into the FieldTrip buffer (described on the Wiki).

Gerv

boulay
Posts: 382
Joined: 25 Dec 2011, 21:14

Re: MatlabSignalProcessing

Post by boulay » 13 Sep 2013, 05:18

I'm attaching the updated MatlabSignalProcessing for 64-bit with "vastly improved performance".
Attachments
MatlabSignalProcessing.zip
MatlabSignalProcessing for 64-bit Matlab.
(502.6 KiB) Downloaded 749 times

Locked

Who is online

Users browsing this forum: No registered users and 0 guests