Page 1 of 1

Preview Next Target Position

Posted: 03 Feb 2010, 01:12
by dsteines
Hello,

I am developing a basic cursor control application in which the subject moves a cursor to a target on either the left or right side of a screen. I would like to place an indicator next to the target indicating the next target (the target after the one the subject is currently trying to hit). Is there a way to access the next target that will be shown?

Thanks for your help!

David

Posted: 03 Feb 2010, 08:16
by jawilson
David,
This is certainly possible with a few modifications to the code. Currently, the next target is chosen blockwise randomly at the start of the trial, so it is impossible to get the NEXT target during the current trial. This is simple to modify, though. All code refers to the CursorFeedbackTask.cpp file.
All you need to do is generate the targets ahead of time, and store them in a vector. BCI2000 uses a class called BlockRandSeq (just include BlockRandSeq.h) for the random target generation. So, create a class variable in CursorFeedbackTask.h; also, create a class variable to hold the targets:

Code: Select all

BlockRandSeq    mBlockRandSeq;
vector<int> mTargetCodes;
Add this line to the CursorFeedbackTask constructor, like:

Code: Select all

mCursorSpeedX( 1.0 ),
mCursorSpeedY( 1.0 ),
mCursorSpeedZ( 1.0 ),
mBlockRandSeq( RandomNumberGenerator )
Then, in the OnStartRun function, create as many targets as you like, and place them in mTargetCodes, using mBlockRandSeq.

Code: Select all

mBlockRandSeq.SetBlockSize( Parameter( "NumberTargets" ) );
for (int i = 0; i < 100; i++) // change 100 to whatever you want, if you think there will be more targets
   mTargetCodes.push_back(mBlockRandSeq.NextElement();
Finally, in OnTrialBegin(), you need to set the TargetCode state, in order to override the default value, so the function should look like:

Code: Select all

CursorFeedbackTask::OnTrialBegin()
{
  ++mTrialCount;
  State("TargetCode") = mTargetCodes[mTrialCount-1];
  //use mTrialCount-1 since it uses 0-indexing
 ...  
Then, during a trial, you can access the next target code with mTargetCodes[mTrialCount].

That should do it! Note, I haven't tested this at all, and there may be problems/errors in the code, but conceptually I think this will work. Let us know if you have further questions.
Adam

Posted: 07 Feb 2010, 00:18
by dsteines
Adam,

This worked perfectly. Thanks very much.

David