Accessing State Vector Values

Forum for software developers to discuss BCI2000 software development
Locked
cdocon
Posts: 8
Joined: 26 Jun 2014, 19:31

Accessing State Vector Values

Post by cdocon » 31 Jul 2014, 00:56

Hi,

I'm building a filter where I want to be able to access values in the state vector, specifically the StimulusCode value when running the StimulusPresentation task as outlined in the Mu Rhythm Tutorial. At present, I am putting

Code: Select all

 State( "StimulusCode" ); 
in the filter's preflight function, and

Code: Select all

int curStimulusCode = State("StimulusCode").AsUnsigned();
bciout << "StimulusCode: " << curStimulusCode;
in the Process function in an attempt to simply write the current stimulus code to the bci standard output. The result shown in blank, however in the .dat file the Stimulus Code is present. I was hoping someone could explain where I am going wrong and how best to access the state being presented to the user. If it helps, I am developing on Windows 7 under Visual Studio 2010 using revision 4736.

Thanks.

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

Re: Accessing State Vector Values

Post by boulay » 31 Jul 2014, 09:56

Have you tried without the .AsUnsigned() ? Just looking through some BCI2000 core modules, I never see that used.

What if you try

Code: Select all

bciout << "StimulusCode: " << State("StimulusCode");
Does that work?

cdocon
Posts: 8
Joined: 26 Jun 2014, 19:31

Re: Accessing State Vector Values

Post by cdocon » 31 Jul 2014, 13:42

I tried but it did not make a difference. What is strange is that I even tried manually setting the state prior to reading like so:

Code: Select all

State("StimulusCode") = 1;
int curStimulusCode = State("StimulusCode");
bciout << "StimulusCode: " << curStimulusCode;
but the result is the same - simlpy outputting a blank value on the standard output:

Code: Select all

StimulusCode: .
To me this indicates that I am missing some particular read/write notation, but cannot find anything in the wiki.

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

Re: Accessing State Vector Values

Post by boulay » 31 Jul 2014, 14:35

Obviously I don't know the answer. I'm just trying to help you work through it. Does the following work?

Code: Select all

State("StimulusCode") = 1;
//int curStimulusCode = State("StimulusCode");
int curStimulusCode = 1;
bciout << "StimulusCode: " << curStimulusCode;
Just to make sure bciout recognizes the int. I expect this to work, but if it does not then it would go a long way to helping to identify the problem.

Assuming that works, then what about

Code: Select all

bciout << "StimulusCode: " << State("StimulusCode").Value();
?

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

Re: Accessing State Vector Values

Post by boulay » 31 Jul 2014, 14:45


cdocon
Posts: 8
Joined: 26 Jun 2014, 19:31

Re: Accessing State Vector Values

Post by cdocon » 31 Jul 2014, 17:49

Got it! Turns out bciout won't print the value to the standard output unless followed by an endl. What was confusing me was bciout would still print the string literal part. Your suggestion about trying a plain int is what put me on the right path, thanks for your help!

Locked

Who is online

Users browsing this forum: Google [Bot] and 3 guests