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
Preview Next Target Position
-
jawilson
- Posts: 109
- Joined: 28 Feb 2005, 16:31
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:
Add this line to the CursorFeedbackTask constructor, like:
Then, in the OnStartRun function, create as many targets as you like, and place them in mTargetCodes, using mBlockRandSeq.
Finally, in OnTrialBegin(), you need to set the TargetCode state, in order to override the default value, so the function should look like:
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
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;
Code: Select all
mCursorSpeedX( 1.0 ),
mCursorSpeedY( 1.0 ),
mCursorSpeedZ( 1.0 ),
mBlockRandSeq( RandomNumberGenerator )
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();
Code: Select all
CursorFeedbackTask::OnTrialBegin()
{
++mTrialCount;
State("TargetCode") = mTargetCodes[mTrialCount-1];
//use mTrialCount-1 since it uses 0-indexing
...
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
Who is online
Users browsing this forum: No registered users and 0 guests
