Page 1 of 1

Accessing State Vector Values

Posted: 31 Jul 2014, 00:56
by cdocon
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.

Re: Accessing State Vector Values

Posted: 31 Jul 2014, 09:56
by boulay
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?

Re: Accessing State Vector Values

Posted: 31 Jul 2014, 13:42
by cdocon
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.

Re: Accessing State Vector Values

Posted: 31 Jul 2014, 14:35
by boulay
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();
?

Re: Accessing State Vector Values

Posted: 31 Jul 2014, 14:45
by boulay

Re: Accessing State Vector Values

Posted: 31 Jul 2014, 17:49
by cdocon
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!