Using Matlab in BCI2000 Application Module
-
saimrasheed
- Posts: 18
- Joined: 08 Jul 2009, 12:38
Using Matlab in BCI2000 Application Module
Hi,
Following the link, http://www.bci2000.org/wiki/index.php/P ... sed_Filter it suggests that we can interact with Signal processing Module by developing and testing our own algorithms using Matlab.
1) Does that mean, we can only interact with Signal Processing module or we can also interact with Application module using Matlab ? For example, developing some virtual reality application in Matlab using Matlab's Virtual Reality Tool box and then to integrate it with BCI2000 Application module.
2) In case, if it is not possible to interact with application module using Matlab, What is the best approach (specially for the beginners, How to proceed or initiate) to develop a new application or to modify an existing application (like cursor task and P3 Speller task).
Thanking you in advance.
Following the link, http://www.bci2000.org/wiki/index.php/P ... sed_Filter it suggests that we can interact with Signal processing Module by developing and testing our own algorithms using Matlab.
1) Does that mean, we can only interact with Signal Processing module or we can also interact with Application module using Matlab ? For example, developing some virtual reality application in Matlab using Matlab's Virtual Reality Tool box and then to integrate it with BCI2000 Application module.
2) In case, if it is not possible to interact with application module using Matlab, What is the best approach (specially for the beginners, How to proceed or initiate) to develop a new application or to modify an existing application (like cursor task and P3 Speller task).
Thanking you in advance.
-
jawilson
- Posts: 109
- Joined: 28 Feb 2005, 16:31
Hello,
This is actually a very interesting idea, which I think could work with a little effort. Essentially, what you need to do is create a new Application module based on the MatlabSignalProcessing filter, located in src/core/SignalProcessing/matlab. Copy this folder to a new folder (src/contrib/Application/matlab might be a good location). Currently, it is setup to function in the signal processing module. You need to change it to work as an application module, which requires a few simple steps.
1. First, open the borland project file, and remove the PipeDefinition.cpp file from the project, and delete it from the folder.
2. Near the top of MatlabFilter.cpp, change RegisterFilter(2.c) to read:
RegisterFilter(3);
This places this module at the #3 position in the filter chain, which is the application, as opposed to #2, which is the signal processing module.
3. Open the MatlabSignalProcessing.bpr file in a text editor such as notepad or wordpad. Find the line that says:
<USERDEFINES value="MODTYPE=2" />
and change the 2 to a 3, which again tells the BCI2000 environment to treat this as an app module.
From there, everything else should be the same. You will update your VR display in the bci_Process function, and so on. I would recommend looking at:
http://www.bci2000.org/wiki/index.php/P ... sed_Filter
and
http://www.bci2000.org/wiki/index.php/P ... tlabFilter
as well, for info on actually creating the matlab function files.
I think this is all you should need to do; be aware, though, that I have not tested this, and there will likely be other problems you encounter. I will try this out in the next day or so, and see if I missed anything. If you try it and it fails (or succeeds!), report back here so we can determine if these steps work. Also, hopefully Juergen or the other BCI2000 developers can comment as well.
Good luck!
Adam[/i][/url]
This is actually a very interesting idea, which I think could work with a little effort. Essentially, what you need to do is create a new Application module based on the MatlabSignalProcessing filter, located in src/core/SignalProcessing/matlab. Copy this folder to a new folder (src/contrib/Application/matlab might be a good location). Currently, it is setup to function in the signal processing module. You need to change it to work as an application module, which requires a few simple steps.
1. First, open the borland project file, and remove the PipeDefinition.cpp file from the project, and delete it from the folder.
2. Near the top of MatlabFilter.cpp, change RegisterFilter(2.c) to read:
RegisterFilter(3);
This places this module at the #3 position in the filter chain, which is the application, as opposed to #2, which is the signal processing module.
3. Open the MatlabSignalProcessing.bpr file in a text editor such as notepad or wordpad. Find the line that says:
<USERDEFINES value="MODTYPE=2" />
and change the 2 to a 3, which again tells the BCI2000 environment to treat this as an app module.
From there, everything else should be the same. You will update your VR display in the bci_Process function, and so on. I would recommend looking at:
http://www.bci2000.org/wiki/index.php/P ... sed_Filter
and
http://www.bci2000.org/wiki/index.php/P ... tlabFilter
as well, for info on actually creating the matlab function files.
I think this is all you should need to do; be aware, though, that I have not tested this, and there will likely be other problems you encounter. I will try this out in the next day or so, and see if I missed anything. If you try it and it fails (or succeeds!), report back here so we can determine if these steps work. Also, hopefully Juergen or the other BCI2000 developers can comment as well.
Good luck!
Adam[/i][/url]
-
saimrasheed
- Posts: 18
- Joined: 08 Jul 2009, 12:38
-
saimrasheed
- Posts: 18
- Joined: 08 Jul 2009, 12:38
Hi Adam,
I am back to this post. I am not good at using Borland C++ Although I am taking some tutorials now. First of all, I would appreciate if you post the details with a short example. Moreover,
1) I have copied the matlab folder at src/contrib/Application/matlab.
2) Started C++ Builder 6
3) Opened 'MatlabSignalProcessing.bpr' file. Also, in the Matlab Folder there is PipeDefinition.cpp which I have deleted.
4) changed RegisterFilter(3) and ...MODTYPE=3..
5) I have gone thorugh the links you recommended, now having better understanding.
6) Do I need to write my code for VR display in BCI2000\prog\matlab\bci_process.m file ? or needs to create a seperate bci_Process.m in some other directory ?
7) managing directories is a bit confusing ?
Thanks
I am back to this post. I am not good at using Borland C++ Although I am taking some tutorials now. First of all, I would appreciate if you post the details with a short example. Moreover,
1) I have copied the matlab folder at src/contrib/Application/matlab.
2) Started C++ Builder 6
3) Opened 'MatlabSignalProcessing.bpr' file. Also, in the Matlab Folder there is PipeDefinition.cpp which I have deleted.
4) changed RegisterFilter(3) and ...MODTYPE=3..
5) I have gone thorugh the links you recommended, now having better understanding.
6) Do I need to write my code for VR display in BCI2000\prog\matlab\bci_process.m file ? or needs to create a seperate bci_Process.m in some other directory ?
7) managing directories is a bit confusing ?
Thanks
-
jawilson
- Posts: 109
- Joined: 28 Feb 2005, 16:31
Hello,
Here is a link to the MatlabAppDemo.zip I put together:
http://homepages.uc.edu/~wilso3jn/data/ ... ppDemo.zip
Place this in BCI2000/src/contrib/Application/. Let me know if you are unable to compile it. Inside is a folder called matlab. You should place this in the BCI2000/prog/ directory (if there is already one there, it is ok to overwrite it). It contains a short example of how to use Matlab for an application by plotting the control signal in a matlab plot. It is very basic, but should show you how to initialize and process the control signal. Finally, there is a bat file called MatlabAppDemo_SignalGenerator.bat, which shows how to start it up, and set the matlab program directory correctly.
Give these a try, and let me know if they work. I am very interested to see if you are able to get this working, so post back and let us know!
Adam
Here is a link to the MatlabAppDemo.zip I put together:
http://homepages.uc.edu/~wilso3jn/data/ ... ppDemo.zip
Place this in BCI2000/src/contrib/Application/. Let me know if you are unable to compile it. Inside is a folder called matlab. You should place this in the BCI2000/prog/ directory (if there is already one there, it is ok to overwrite it). It contains a short example of how to use Matlab for an application by plotting the control signal in a matlab plot. It is very basic, but should show you how to initialize and process the control signal. Finally, there is a bat file called MatlabAppDemo_SignalGenerator.bat, which shows how to start it up, and set the matlab program directory correctly.
Give these a try, and let me know if they work. I am very interested to see if you are able to get this working, so post back and let us know!
Adam
-
saimrasheed
- Posts: 18
- Joined: 08 Jul 2009, 12:38
Hi Adam, Thanks a lot. It started working and displayed the following messages. Probably I am close to it now
===
Operator set configuration
2/4/2010 11:04:41 AM - Normalizer::Preflight: State "Feedback" is inaccessible.
2/4/2010 11:04:41 AM - Normalizer::Preflight: State "Feedback" is inaccessible.
2/4/2010 11:04:41 AM - Normalizer::Preflight: State "TargetCode" is inaccessible.
2/4/2010 11:04:41 AM - Normalizer::Preflight: State "Feedback" is inaccessible.
2/4/2010 11:04:41 AM - Normalizer::Preflight: State "TargetCode" is inaccessible.
2/4/2010 11:04:45 AM - Source confirmed new parameters ...
===
===
Operator set configuration
2/4/2010 11:04:41 AM - Normalizer::Preflight: State "Feedback" is inaccessible.
2/4/2010 11:04:41 AM - Normalizer::Preflight: State "Feedback" is inaccessible.
2/4/2010 11:04:41 AM - Normalizer::Preflight: State "TargetCode" is inaccessible.
2/4/2010 11:04:41 AM - Normalizer::Preflight: State "Feedback" is inaccessible.
2/4/2010 11:04:41 AM - Normalizer::Preflight: State "TargetCode" is inaccessible.
2/4/2010 11:04:45 AM - Source confirmed new parameters ...
===
-
saimrasheed
- Posts: 18
- Joined: 08 Jul 2009, 12:38
Who is online
Users browsing this forum: No registered users and 0 guests
