Reading BCI2000 data by MATLAB and throguh UDP port
Posted: 28 May 2015, 17:47
Hello all,
I am testing BCI2000 for UDP connection for my future application. I ran BCI2000 with SignalGenerator, ARSignalProcessing, and CursorTask modules. Then, by using AppConnector help, and binding UDP ports in a MATLAB script by a code that I found online as follows:
--------------------------------------------------------------
u = udp( 'localhost', XXXXX, 'LocalPort' , YYYYY, 'Terminator' ,'CR/LF' , 'Timeout' , 10);
fopen (u);
v=fgetl(u);
while (v~=-1)
disp(v)
v=fgetl(u);
end
fclose (u);
delete (u);
-------------------------------------------------------------
I can see the continuous changes of states and data in command window in MATLAB. I am not professional in socket programming and I do not have any idea how I can manipulate and use these data. For the start, I have some questions. Any help will be appreciated.
1- I know that the line "while (v~=-1)" in code is for getting continuous data until timeout, but why this guy has used (-1)? Do I need to consider some changes in BCI2000 before running this code?
2- In the command window, I can see two repetitive lines as follows:
Signal (0,0) ####
Signal (1,0) ####
I think these are control signals from BCI2000 which are sent to CursorTask application module for x and y direction, respectively. Am I right? If yes, I am not sure why the indexes are in this way: (0,0) and (1,0)?
3- How can I filter these control signals for my application?
4- Instead of using script file in MATLAB, how we can use MATLAB simulink (UDP blocks) to bind the UPD ports and get these control signals in simulink environment in real-time.
5- It seems by starting BCI2000, these signals are sent through UDP port and to the MATLAB. But, we know that the real control time by the subject will happen after PreRunDuration+PreFeedbackDuration. I am not sure what is the best way to tell the external application (in MATLAB) to start when the FeedbackDuration time starts (in BCI2000).
Thanks,
Reza
I am testing BCI2000 for UDP connection for my future application. I ran BCI2000 with SignalGenerator, ARSignalProcessing, and CursorTask modules. Then, by using AppConnector help, and binding UDP ports in a MATLAB script by a code that I found online as follows:
--------------------------------------------------------------
u = udp( 'localhost', XXXXX, 'LocalPort' , YYYYY, 'Terminator' ,'CR/LF' , 'Timeout' , 10);
fopen (u);
v=fgetl(u);
while (v~=-1)
disp(v)
v=fgetl(u);
end
fclose (u);
delete (u);
-------------------------------------------------------------
I can see the continuous changes of states and data in command window in MATLAB. I am not professional in socket programming and I do not have any idea how I can manipulate and use these data. For the start, I have some questions. Any help will be appreciated.
1- I know that the line "while (v~=-1)" in code is for getting continuous data until timeout, but why this guy has used (-1)? Do I need to consider some changes in BCI2000 before running this code?
2- In the command window, I can see two repetitive lines as follows:
Signal (0,0) ####
Signal (1,0) ####
I think these are control signals from BCI2000 which are sent to CursorTask application module for x and y direction, respectively. Am I right? If yes, I am not sure why the indexes are in this way: (0,0) and (1,0)?
3- How can I filter these control signals for my application?
4- Instead of using script file in MATLAB, how we can use MATLAB simulink (UDP blocks) to bind the UPD ports and get these control signals in simulink environment in real-time.
5- It seems by starting BCI2000, these signals are sent through UDP port and to the MATLAB. But, we know that the real control time by the subject will happen after PreRunDuration+PreFeedbackDuration. I am not sure what is the best way to tell the external application (in MATLAB) to start when the FeedbackDuration time starts (in BCI2000).
Thanks,
Reza