Writing new state to BCI2000 via Fieldtrip

Forum for software developers to discuss BCI2000 software development
Locked
teristam
Posts: 3
Joined: 12 Jan 2010, 04:27

Writing new state to BCI2000 via Fieldtrip

Post by teristam » 12 Jan 2010, 04:40

Hello everyone!

I would like to know how to write a new state back to BCI2000 using the fieldtrip buffer in matlab. The new state will be used as trigger signal for offline analysis after collecting the data.

I have tried introducing new state name in the FTStatesFromBuffer field, and then use write_event() from Fieldtrip to write to the state. But when I try to set the configuration in BCI2000, it complains "FieldTripBufferFilter::Preflight: State "AlphaPower" is inaccessible." (AlphaPower is the new state I try to introduce).

P.S. I am able to modified existing state, e.g. Feedback, from Fieldtrip, but not able to create new state. I try to follow the instruction at http://www.bci2000.org/wiki/index.php/U ... cripting#1 to create new state using operator script. The operator log reported that a new state is added to the list, but I am not able to see it in the States dialogue of the operator window. Changing the state via the operator script buttons doesn't work either.




Any idea is much appreciated.

Thanks a lot!

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

States

Post by gschalk » 12 Jan 2010, 07:07

Hi,

You may have used the Operator scripting to try to create a state after the system has been started, which is not possible (if the Operator tells you it did create it, this is a bug). You have to create a state on system startup. Perhaps the best way to do this is to use command line options:

http://www.bci2000.org/wiki/index.php/U ... ne_Options

Let me know if this helped.

Gerv

teristam
Posts: 3
Joined: 12 Jan 2010, 04:27

Post by teristam » 13 Jan 2010, 04:17

Thank you so much for the reply!

I have written the following batch file trying to introduce the new state Artifact into the BCI2000:

Code: Select all

cd prog
start operat.exe --OnConnect "-INSERT STATE Artifact 1 0; SETCONFIG" --OnSetConfig "-SET STATE Running 1"
start SignalGenerator.exe 127.0.0.1
start FieldTripBuffer.exe 127.0.0.1
start MFCdemo.exe 127.0.0.1
cd ..
I then write the following scripts for two operator window buttons:

Code: Select all

STATE Artifact 1

Code: Select all

STATE Artifact 0
This is the operator log file after I try to press the buttons to change the Artiface state:
13/1/2010 17:12:39 - BCI2000 started
13/1/2010 17:12:39 - Executing script after all modules connected ...
13/1/2010 17:12:39 - unnamed script: Added state Artifact to list
13/1/2010 17:12:39 - Operator set configuration
13/1/2010 17:12:39 - unnamed script: Set configuration
13/1/2010 17:12:39 - User Application confirmed new parameters ...
13/1/2010 17:12:40 - Signal Processing confirmed new parameters ...
13/1/2010 17:12:40 - Source confirmed new parameters ...
13/1/2010 17:12:40 - Executing OnSetConfig script ...
13/1/2010 17:12:40 - Operator started operation
13/1/2010 17:12:40 - unnamed script: Set state Running to 1 ... OK
13/1/2010 17:12:51 - unnamed script: Set state Artifact to 1 ... Error
13/1/2010 17:12:51 - unnamed script: Set state Artifact to 0 ... Error
I was not able to add new state to BCI2000 even though I tried to insert the state using the --OnConnect option.

mellinger
Posts: 1341
Joined: 12 Feb 2003, 11:06

Post by mellinger » 13 Jan 2010, 09:08

Hi,

you need to specify four numbers in the state definition:

Code: Select all

INSERT STATE Artifact 1 0 0 0
The example in the documentation was wrong. In addition, the operator module would always report successful adding of the state, even if it could not parse the state definition correctly.
I fixed both errors.

Thanks for reporting, and sorry for the inconvenience,

Juergen

teristam
Posts: 3
Joined: 12 Jan 2010, 04:27

Post by teristam » 14 Jan 2010, 01:55

Really thanks a lot! Now it works! :D

mellinger
Posts: 1341
Joined: 12 Feb 2003, 11:06

Post by mellinger » 04 Mar 2010, 11:47

The behavior of the INSERT STATE scripting command has been changed to comply with the original documentation.
Now, BCI2000 V2 and V3 both allow specifying a state by its name, bit width, and initial value:

Code: Select all

INSERT STATE Artifact 1 0

Locked

Who is online

Users browsing this forum: No registered users and 0 guests