Preview Next Target Position

Forum for discussion on different user applications
Posts: 16
Joined: 23 Jan 2010, 17:19

Preview Next Target Position

Post by dsteines » 03 Feb 2010, 01:12


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!


Posts: 109
Joined: 28 Feb 2005, 16:31

Post by jawilson » 03 Feb 2010, 08:16

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
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

  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.

Posts: 16
Joined: 23 Jan 2010, 17:19

Post by dsteines » 07 Feb 2010, 00:18


This worked perfectly. Thanks very much.



Who is online

Users browsing this forum: No registered users and 2 guests