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