Approach-Avoidance Training, appearance of picture only if response was correct


Approach-Avoidance Training, appearance of picture only if response...
Author
Message
charlotte.w
charlotte.w
Partner Member (564 reputation)Partner Member (564 reputation)Partner Member (564 reputation)Partner Member (564 reputation)Partner Member (564 reputation)Partner Member (564 reputation)Partner Member (564 reputation)Partner Member (564 reputation)Partner Member (564 reputation)
Group: Forum Members
Posts: 14, Visits: 34
Dear all,

for a study in which we want to use the Approach-Avoidance Task as a training, I want to change the settings such that the picture only disappears if the joystick has been moved to the correct direction. For example, if participants are instructed to push away all alcohol-related pictures, pulling an alcohol-related picture should not work (--> user is forced to move the Joystick in the intended direction).
I used the AAT millisecond script as a template and adapted it; however, I didn´t manage to program the feature I wanted.

Furthermore, I would like to have a black screen during practice and training trials, but the command shape.backgroundcolor.color = black did not work.

Attached please find the script.

Thanks a lot for your help in advance.

Best
Charlotte

Attachments
AAT Training v2.iqx (230 views, 46.00 KB)
Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 13K, Visits: 104K
charlotte.w - 8/27/2019
Dear all,

for a study in which we want to use the Approach-Avoidance Task as a training, I want to change the settings such that the picture only disappears if the joystick has been moved to the correct direction. For example, if participants are instructed to push away all alcohol-related pictures, pulling an alcohol-related picture should not work (--> user is forced to move the Joystick in the intended direction).
I used the AAT millisecond script as a template and adapted it; however, I didn´t manage to program the feature I wanted.

Furthermore, I would like to have a black screen during practice and training trials, but the command shape.backgroundcolor.color = black did not work.

Attached please find the script.

Thanks a lot for your help in advance.

Best
Charlotte

If you have a script that requires external files (here: lots of images) to run, please provide all files required.

Also, please document and explain all the changes you made so far and why.

Edited 5 Years Ago by Dave
Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 13K, Visits: 104K

> Furthermore, I would like to have a black screen during practice and training trials, but the command shape.backgroundcolor.color = black did not work.

There is no such <shape> in the script you attached, so I'm not sure what effect this could have had. Either way, if you want a black screen color, set /screencolor to black in the script's <defaults>.

<defaults>
/ canvasaspectratio = (4,3)
/ minimumversion = "5.0.0.0"
/ inputdevice = joystick
/ joystickthreshold = 30
/ fontstyle = ("Arial", 3%, false, false, false, false, 5, 1)
/ txbgcolor = white
/ txcolor = black
/ screencolor = black
</defaults>

Now, as for preventing a trial from ending if the move is in the wrong direction. What you need to do is prevent the endincrease and enddecrease trial elements from running if the move is in the wrong direction. Those trials are called from the regular increase and decrease trials. Let's look at the practice trials for illustration.

*********ZOOM FEATURE: trial increase/decrease the size of the rectangles depending on participant's response*********

<trial practicedecrease>
/ ontrialbegin = [
if (values.expcondition == 1 && values.targetformat == "p"){
trial.practicedecrease.insertstimulustime(text.error, 0);
}else if (values.expcondition == 2 && values.targetformat == "l"){
trial.practicedecrease.insertstimulustime(text.error, 0);
};
picture.practicetarget.height = picture.practicetarget.height - values.joystick_change/1000 * expressions.maxheightchange_px;
]
/ stimulusframes = [1 = clearscreen, practicetarget]
/ validresponse = (change)
/ monkeyresponse = ("back", "forward")
/ ontrialend = [
values.joystick_change = abs(values.joystick_y - joystick.y);
trial.practicedecrease.resetstimulusframes();
]
/ branch = [
if (monkey.monkeymode == 1) {
values.endtime = script.elapsedtime;
values.finalresponse = "PUSH";
trial.intertrialinterval;
} else if (joystick.y <= -1000) {
values.joystick_y = joystick.y;
values.endtime = script.elapsedtime;
values.finalresponse = "PUSH";
trial.enddecrease_practice;
} else if (joystick.y <= values.joystick_y) {
values.joystick_y = joystick.y;
trial.practicedecrease;
} else if (joystick.y > values.joystick_y) {
values.joystick_y = joystick.y;
values.changedirection += 1;
trial.practiceincrease;
};
]
/ recorddata = false
</trial>

<trial practiceincrease>
/ ontrialbegin = [
if (values.expcondition == 1 && values.targetformat == "L"){
trial.practiceincrease.insertstimulustime(text.error, 0);
} else if (values.expcondition == 2 && values.targetformat == "R"){
trial.practiceincrease.insertstimulustime(text.error, 0);
};
picture.practicetarget.height = picture.practicetarget.height + values.joystick_change/1000 * expressions.maxheightchange_px;
]
/ stimulusframes = [1 = practicetarget]
/ validresponse = (change)
/ monkeyresponse = ("back", "forward")
/ ontrialend = [
values.joystick_change = abs(values.joystick_y - joystick.y);
trial.practiceincrease.resetstimulusframes();
]
/ branch = [
if (monkey.monkeymode == 1) {
values.endtime = script.elapsedtime;
values.finalresponse = "PULL";
trial.intertrialinterval;
} else if (joystick.y >= 1000) {
values.joystick_y = joystick.y;
values.endtime = script.elapsedtime;
values.finalresponse = "PULL";
trial.endincrease_practice;
} else if (joystick.y >= values.joystick_y) {
values.joystick_y = joystick.y;
trial.practiceincrease;
} else if (joystick.y < values.joystick_y) {
values.joystick_y = joystick.y;
values.changedirection += 1;
trial.practicedecrease;
};
]
/ recorddata = false
</trial>


Note: trials show the last size of the picture
<trial endincrease_practice>
/ ontrialbegin = [
picture.practicetarget.height = picture.practicetarget.height + values.joystick_change/1000 * expressions.maxheightchange_px;
]
/ stimulusframes = [1 = practicetarget]
/ timeout = 0
/ branch = [trial.joystickrest]
/ recorddata = false
</trial>

<trial enddecrease_practice>
/ ontrialbegin = [
picture.practicetarget.height = picture.practicetarget.height - values.joystick_change/1000 * expressions.maxheightchange_px;
]
/ stimulusframes = [1 = clearscreen, practicetarget]
/ timeout = 0
/ branch = [trial.joystickrest]
/ recorddata = false
</trial>

So, all you need to do is make this /branch not work if the direction is wrong:

/ branch = [
if (monkey.monkeymode == 1) {
values.endtime = script.elapsedtime;
values.finalresponse = "PUSH";
trial.intertrialinterval;
} else if (joystick.y <= -1000) {
values.joystick_y = joystick.y;
values.endtime = script.elapsedtime;
values.finalresponse = "PUSH";
trial.enddecrease_practice;
...

That's actually easy, because the increase and decrease trials determine when the direction is wrong to display an error message -- i.e. the relevant logic is already mostly in place. Simply introduce a new variable, let's call it wrongdirection and set it to either true (direction is wrong) or false (direction is not wrong):

<values>
/ wrongdirection = false
</values>

<trial practicedecrease>
/ ontrialbegin = [
if (values.expcondition == 1 && values.targetformat == "p"){
trial.practicedecrease.insertstimulustime(text.error, 0);
values.wrongdirection = true;
}else if (values.expcondition == 2 && values.targetformat == "l"){
trial.practicedecrease.insertstimulustime(text.error, 0);
values.wrongdirection = true;
} else {
values.wrongdirection = false;
};
picture.practicetarget.height = picture.practicetarget.height - values.joystick_change/1000 * expressions.maxheightchange_px;
]
/ stimulusframes = [1 = clearscreen, practicetarget]
...
</trial>

Then just prevent the /branch if the direction is wrong.

<trial practicedecrease>
/ ontrialbegin = [
if (values.expcondition == 1 && values.targetformat == "p"){
trial.practicedecrease.insertstimulustime(text.error, 0);
values.wrongdirection = true;
}else if (values.expcondition == 2 && values.targetformat == "l"){
trial.practicedecrease.insertstimulustime(text.error, 0);
values.wrongdirection = true;
} else {
values.wrongdirection = false;
};
picture.practicetarget.height = picture.practicetarget.height - values.joystick_change/1000 * expressions.maxheightchange_px;
]
/ stimulusframes = [1 = clearscreen, practicetarget]
/ validresponse = (change)
/ monkeyresponse = ("back", "forward")
/ ontrialend = [
values.joystick_change = abs(values.joystick_y - joystick.y);
trial.practicedecrease.resetstimulusframes();
]
/ branch = [
if (monkey.monkeymode == 1) {
values.endtime = script.elapsedtime;
values.finalresponse = "PUSH";
trial.intertrialinterval;
} else if (joystick.y <= -1000 && !values.wrongdirection) {
values.joystick_y = joystick.y;
values.endtime = script.elapsedtime;
values.finalresponse = "PUSH";
trial.enddecrease_practice;
} else if (joystick.y <= values.joystick_y) {
values.joystick_y = joystick.y;
trial.practicedecrease;
} else if (joystick.y > values.joystick_y) {
values.joystick_y = joystick.y;
values.changedirection += 1;
trial.practiceincrease;
};
]
/ recorddata = false
</trial>

You can do the same thing for the test trials.

charlotte.w
charlotte.w
Partner Member (564 reputation)Partner Member (564 reputation)Partner Member (564 reputation)Partner Member (564 reputation)Partner Member (564 reputation)Partner Member (564 reputation)Partner Member (564 reputation)Partner Member (564 reputation)Partner Member (564 reputation)
Group: Forum Members
Posts: 14, Visits: 34
Dave - 8/27/2019

> Furthermore, I would like to have a black screen during practice and training trials, but the command shape.backgroundcolor.color = black did not work.

There is no such <shape> in the script you attached, so I'm not sure what effect this could have had. Either way, if you want a black screen color, set /screencolor to black in the script's <defaults>.

<defaults>
/ canvasaspectratio = (4,3)
/ minimumversion = "5.0.0.0"
/ inputdevice = joystick
/ joystickthreshold = 30
/ fontstyle = ("Arial", 3%, false, false, false, false, 5, 1)
/ txbgcolor = white
/ txcolor = black
/ screencolor = black
</defaults>

Now, as for preventing a trial from ending if the move is in the wrong direction. What you need to do is prevent the endincrease and enddecrease trial elements from running if the move is in the wrong direction. Those trials are called from the regular increase and decrease trials. Let's look at the practice trials for illustration.

*********ZOOM FEATURE: trial increase/decrease the size of the rectangles depending on participant's response*********

<trial practicedecrease>
/ ontrialbegin = [
if (values.expcondition == 1 && values.targetformat == "p"){
trial.practicedecrease.insertstimulustime(text.error, 0);
}else if (values.expcondition == 2 && values.targetformat == "l"){
trial.practicedecrease.insertstimulustime(text.error, 0);
};
picture.practicetarget.height = picture.practicetarget.height - values.joystick_change/1000 * expressions.maxheightchange_px;
]
/ stimulusframes = [1 = clearscreen, practicetarget]
/ validresponse = (change)
/ monkeyresponse = ("back", "forward")
/ ontrialend = [
values.joystick_change = abs(values.joystick_y - joystick.y);
trial.practicedecrease.resetstimulusframes();
]
/ branch = [
if (monkey.monkeymode == 1) {
values.endtime = script.elapsedtime;
values.finalresponse = "PUSH";
trial.intertrialinterval;
} else if (joystick.y <= -1000) {
values.joystick_y = joystick.y;
values.endtime = script.elapsedtime;
values.finalresponse = "PUSH";
trial.enddecrease_practice;
} else if (joystick.y <= values.joystick_y) {
values.joystick_y = joystick.y;
trial.practicedecrease;
} else if (joystick.y > values.joystick_y) {
values.joystick_y = joystick.y;
values.changedirection += 1;
trial.practiceincrease;
};
]
/ recorddata = false
</trial>

<trial practiceincrease>
/ ontrialbegin = [
if (values.expcondition == 1 && values.targetformat == "L"){
trial.practiceincrease.insertstimulustime(text.error, 0);
} else if (values.expcondition == 2 && values.targetformat == "R"){
trial.practiceincrease.insertstimulustime(text.error, 0);
};
picture.practicetarget.height = picture.practicetarget.height + values.joystick_change/1000 * expressions.maxheightchange_px;
]
/ stimulusframes = [1 = practicetarget]
/ validresponse = (change)
/ monkeyresponse = ("back", "forward")
/ ontrialend = [
values.joystick_change = abs(values.joystick_y - joystick.y);
trial.practiceincrease.resetstimulusframes();
]
/ branch = [
if (monkey.monkeymode == 1) {
values.endtime = script.elapsedtime;
values.finalresponse = "PULL";
trial.intertrialinterval;
} else if (joystick.y >= 1000) {
values.joystick_y = joystick.y;
values.endtime = script.elapsedtime;
values.finalresponse = "PULL";
trial.endincrease_practice;
} else if (joystick.y >= values.joystick_y) {
values.joystick_y = joystick.y;
trial.practiceincrease;
} else if (joystick.y < values.joystick_y) {
values.joystick_y = joystick.y;
values.changedirection += 1;
trial.practicedecrease;
};
]
/ recorddata = false
</trial>


Note: trials show the last size of the picture
<trial endincrease_practice>
/ ontrialbegin = [
picture.practicetarget.height = picture.practicetarget.height + values.joystick_change/1000 * expressions.maxheightchange_px;
]
/ stimulusframes = [1 = practicetarget]
/ timeout = 0
/ branch = [trial.joystickrest]
/ recorddata = false
</trial>

<trial enddecrease_practice>
/ ontrialbegin = [
picture.practicetarget.height = picture.practicetarget.height - values.joystick_change/1000 * expressions.maxheightchange_px;
]
/ stimulusframes = [1 = clearscreen, practicetarget]
/ timeout = 0
/ branch = [trial.joystickrest]
/ recorddata = false
</trial>

So, all you need to do is make this /branch not work if the direction is wrong:

/ branch = [
if (monkey.monkeymode == 1) {
values.endtime = script.elapsedtime;
values.finalresponse = "PUSH";
trial.intertrialinterval;
} else if (joystick.y <= -1000) {
values.joystick_y = joystick.y;
values.endtime = script.elapsedtime;
values.finalresponse = "PUSH";
trial.enddecrease_practice;
...

That's actually easy, because the increase and decrease trials determine when the direction is wrong to display an error message -- i.e. the relevant logic is already mostly in place. Simply introduce a new variable, let's call it wrongdirection and set it to either true (direction is wrong) or false (direction is not wrong):

<values>
/ wrongdirection = false
</values>

<trial practicedecrease>
/ ontrialbegin = [
if (values.expcondition == 1 && values.targetformat == "p"){
trial.practicedecrease.insertstimulustime(text.error, 0);
values.wrongdirection = true;
}else if (values.expcondition == 2 && values.targetformat == "l"){
trial.practicedecrease.insertstimulustime(text.error, 0);
values.wrongdirection = true;
} else {
values.wrongdirection = false;
};
picture.practicetarget.height = picture.practicetarget.height - values.joystick_change/1000 * expressions.maxheightchange_px;
]
/ stimulusframes = [1 = clearscreen, practicetarget]
...
</trial>

Then just prevent the /branch if the direction is wrong.

<trial practicedecrease>
/ ontrialbegin = [
if (values.expcondition == 1 && values.targetformat == "p"){
trial.practicedecrease.insertstimulustime(text.error, 0);
values.wrongdirection = true;
}else if (values.expcondition == 2 && values.targetformat == "l"){
trial.practicedecrease.insertstimulustime(text.error, 0);
values.wrongdirection = true;
} else {
values.wrongdirection = false;
};
picture.practicetarget.height = picture.practicetarget.height - values.joystick_change/1000 * expressions.maxheightchange_px;
]
/ stimulusframes = [1 = clearscreen, practicetarget]
/ validresponse = (change)
/ monkeyresponse = ("back", "forward")
/ ontrialend = [
values.joystick_change = abs(values.joystick_y - joystick.y);
trial.practicedecrease.resetstimulusframes();
]
/ branch = [
if (monkey.monkeymode == 1) {
values.endtime = script.elapsedtime;
values.finalresponse = "PUSH";
trial.intertrialinterval;
} else if (joystick.y <= -1000 && !values.wrongdirection) {
values.joystick_y = joystick.y;
values.endtime = script.elapsedtime;
values.finalresponse = "PUSH";
trial.enddecrease_practice;
} else if (joystick.y <= values.joystick_y) {
values.joystick_y = joystick.y;
trial.practicedecrease;
} else if (joystick.y > values.joystick_y) {
values.joystick_y = joystick.y;
values.changedirection += 1;
trial.practiceincrease;
};
]
/ recorddata = false
</trial>

You can do the same thing for the test trials.

Great, thanks for your fast reply! I incorporated the changes in the practice trials and it worked :)!
However, when I tried to make the changes in the experimental trials, the code is different, therefore, I was wondering where the branch can be made not working?
**********************************************************************
ZOOM trials that control the size changes of the target stimuli
as dictated by response; zoom trials come to an end when the
joystick is fully extended
**********************************************************************

<trial decrease>
/ ontrialbegin = [
picture.targetstimulus.height = picture.targetstimulus.height - values.joystick_change/1000 * expressions.maxheightchange_px;
]
/ stimulusframes = [1 = clearscreen, targetstimulus]
/ validresponse = (change)
/ monkeyresponse = ("back", "forward")
/ ontrialend = [
values.joystick_change = abs(values.joystick_y - joystick.y);
]
/ branch = [
if (monkey.monkeymode == 1) {
values.endtime = script.elapsedtime;
values.finalresponse = "PUSH";
trial.intertrialinterval;
} else if (joystick.y <= -1000) {
values.joystick_y = joystick.y;
values.endtime = script.elapsedtime;
values.finalresponse = "PUSH";
trial.enddecrease;
} else if (joystick.y <= values.joystick_y) {
values.joystick_y = joystick.y;
trial.decrease;
} else if (joystick.y > values.joystick_y) {
values.joystick_y = joystick.y;
values.changedirection += 1;
trial.increase;
};
]
/ recorddata = false
</trial>


<trial increase>
/ ontrialbegin = [
picture.targetstimulus.height = picture.targetstimulus.height + values.joystick_change/1000 * expressions.maxheightchange_px;
]
/ stimulusframes = [1 = targetstimulus]
/ validresponse = (change)
/ monkeyresponse = ("back", "forward")
/ ontrialend = [
values.joystick_change = abs(values.joystick_y - joystick.y);
]
/ branch = [
if (monkey.monkeymode == 1) {
values.endtime = script.elapsedtime;
values.finalresponse = "PULL";
trial.intertrialinterval;
} else if (joystick.y >= 1000) {
values.joystick_y = joystick.y;
values.endtime = script.elapsedtime;
values.finalresponse = "PULL";
trial.endincrease;
} else if (joystick.y >= values.joystick_y) {
values.joystick_y = joystick.y;
trial.increase;
} else if (joystick.y < values.joystick_y) {
values.joystick_y = joystick.y;
values.changedirection += 1;
trial.decrease;
};
]
/ recorddata = false
</trial>


Note: trials show the last size of the picture
<trial endincrease>
/ ontrialbegin = [
picture.targetstimulus.height = picture.targetstimulus.height + values.joystick_change/1000 * expressions.maxheightchange_px
]
/ stimulusframes = [1 = targetstimulus]
/ timeout = 0
/ branch = [trial.joystickrest]
/ recorddata = false
</trial>

<trial enddecrease>
/ ontrialbegin = [
picture.targetstimulus.height = picture.targetstimulus.height - values.joystick_change/1000 * expressions.maxheightchange_px;
]
/ stimulusframes = [1 = clearscreen, targetstimulus]
/ timeout = 0
/ branch = [trial.joystickrest]
/ recorddata = false
</trial>

Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 13K, Visits: 104K
charlotte.w - 8/27/2019
Dave - 8/27/2019

> Furthermore, I would like to have a black screen during practice and training trials, but the command shape.backgroundcolor.color = black did not work.

There is no such <shape> in the script you attached, so I'm not sure what effect this could have had. Either way, if you want a black screen color, set /screencolor to black in the script's <defaults>.

<defaults>
/ canvasaspectratio = (4,3)
/ minimumversion = "5.0.0.0"
/ inputdevice = joystick
/ joystickthreshold = 30
/ fontstyle = ("Arial", 3%, false, false, false, false, 5, 1)
/ txbgcolor = white
/ txcolor = black
/ screencolor = black
</defaults>

Now, as for preventing a trial from ending if the move is in the wrong direction. What you need to do is prevent the endincrease and enddecrease trial elements from running if the move is in the wrong direction. Those trials are called from the regular increase and decrease trials. Let's look at the practice trials for illustration.

*********ZOOM FEATURE: trial increase/decrease the size of the rectangles depending on participant's response*********

<trial practicedecrease>
/ ontrialbegin = [
if (values.expcondition == 1 && values.targetformat == "p"){
trial.practicedecrease.insertstimulustime(text.error, 0);
}else if (values.expcondition == 2 && values.targetformat == "l"){
trial.practicedecrease.insertstimulustime(text.error, 0);
};
picture.practicetarget.height = picture.practicetarget.height - values.joystick_change/1000 * expressions.maxheightchange_px;
]
/ stimulusframes = [1 = clearscreen, practicetarget]
/ validresponse = (change)
/ monkeyresponse = ("back", "forward")
/ ontrialend = [
values.joystick_change = abs(values.joystick_y - joystick.y);
trial.practicedecrease.resetstimulusframes();
]
/ branch = [
if (monkey.monkeymode == 1) {
values.endtime = script.elapsedtime;
values.finalresponse = "PUSH";
trial.intertrialinterval;
} else if (joystick.y <= -1000) {
values.joystick_y = joystick.y;
values.endtime = script.elapsedtime;
values.finalresponse = "PUSH";
trial.enddecrease_practice;
} else if (joystick.y <= values.joystick_y) {
values.joystick_y = joystick.y;
trial.practicedecrease;
} else if (joystick.y > values.joystick_y) {
values.joystick_y = joystick.y;
values.changedirection += 1;
trial.practiceincrease;
};
]
/ recorddata = false
</trial>

<trial practiceincrease>
/ ontrialbegin = [
if (values.expcondition == 1 && values.targetformat == "L"){
trial.practiceincrease.insertstimulustime(text.error, 0);
} else if (values.expcondition == 2 && values.targetformat == "R"){
trial.practiceincrease.insertstimulustime(text.error, 0);
};
picture.practicetarget.height = picture.practicetarget.height + values.joystick_change/1000 * expressions.maxheightchange_px;
]
/ stimulusframes = [1 = practicetarget]
/ validresponse = (change)
/ monkeyresponse = ("back", "forward")
/ ontrialend = [
values.joystick_change = abs(values.joystick_y - joystick.y);
trial.practiceincrease.resetstimulusframes();
]
/ branch = [
if (monkey.monkeymode == 1) {
values.endtime = script.elapsedtime;
values.finalresponse = "PULL";
trial.intertrialinterval;
} else if (joystick.y >= 1000) {
values.joystick_y = joystick.y;
values.endtime = script.elapsedtime;
values.finalresponse = "PULL";
trial.endincrease_practice;
} else if (joystick.y >= values.joystick_y) {
values.joystick_y = joystick.y;
trial.practiceincrease;
} else if (joystick.y < values.joystick_y) {
values.joystick_y = joystick.y;
values.changedirection += 1;
trial.practicedecrease;
};
]
/ recorddata = false
</trial>


Note: trials show the last size of the picture
<trial endincrease_practice>
/ ontrialbegin = [
picture.practicetarget.height = picture.practicetarget.height + values.joystick_change/1000 * expressions.maxheightchange_px;
]
/ stimulusframes = [1 = practicetarget]
/ timeout = 0
/ branch = [trial.joystickrest]
/ recorddata = false
</trial>

<trial enddecrease_practice>
/ ontrialbegin = [
picture.practicetarget.height = picture.practicetarget.height - values.joystick_change/1000 * expressions.maxheightchange_px;
]
/ stimulusframes = [1 = clearscreen, practicetarget]
/ timeout = 0
/ branch = [trial.joystickrest]
/ recorddata = false
</trial>

So, all you need to do is make this /branch not work if the direction is wrong:

/ branch = [
if (monkey.monkeymode == 1) {
values.endtime = script.elapsedtime;
values.finalresponse = "PUSH";
trial.intertrialinterval;
} else if (joystick.y <= -1000) {
values.joystick_y = joystick.y;
values.endtime = script.elapsedtime;
values.finalresponse = "PUSH";
trial.enddecrease_practice;
...

That's actually easy, because the increase and decrease trials determine when the direction is wrong to display an error message -- i.e. the relevant logic is already mostly in place. Simply introduce a new variable, let's call it wrongdirection and set it to either true (direction is wrong) or false (direction is not wrong):

<values>
/ wrongdirection = false
</values>

<trial practicedecrease>
/ ontrialbegin = [
if (values.expcondition == 1 && values.targetformat == "p"){
trial.practicedecrease.insertstimulustime(text.error, 0);
values.wrongdirection = true;
}else if (values.expcondition == 2 && values.targetformat == "l"){
trial.practicedecrease.insertstimulustime(text.error, 0);
values.wrongdirection = true;
} else {
values.wrongdirection = false;
};
picture.practicetarget.height = picture.practicetarget.height - values.joystick_change/1000 * expressions.maxheightchange_px;
]
/ stimulusframes = [1 = clearscreen, practicetarget]
...
</trial>

Then just prevent the /branch if the direction is wrong.

<trial practicedecrease>
/ ontrialbegin = [
if (values.expcondition == 1 && values.targetformat == "p"){
trial.practicedecrease.insertstimulustime(text.error, 0);
values.wrongdirection = true;
}else if (values.expcondition == 2 && values.targetformat == "l"){
trial.practicedecrease.insertstimulustime(text.error, 0);
values.wrongdirection = true;
} else {
values.wrongdirection = false;
};
picture.practicetarget.height = picture.practicetarget.height - values.joystick_change/1000 * expressions.maxheightchange_px;
]
/ stimulusframes = [1 = clearscreen, practicetarget]
/ validresponse = (change)
/ monkeyresponse = ("back", "forward")
/ ontrialend = [
values.joystick_change = abs(values.joystick_y - joystick.y);
trial.practicedecrease.resetstimulusframes();
]
/ branch = [
if (monkey.monkeymode == 1) {
values.endtime = script.elapsedtime;
values.finalresponse = "PUSH";
trial.intertrialinterval;
} else if (joystick.y <= -1000 && !values.wrongdirection) {
values.joystick_y = joystick.y;
values.endtime = script.elapsedtime;
values.finalresponse = "PUSH";
trial.enddecrease_practice;
} else if (joystick.y <= values.joystick_y) {
values.joystick_y = joystick.y;
trial.practicedecrease;
} else if (joystick.y > values.joystick_y) {
values.joystick_y = joystick.y;
values.changedirection += 1;
trial.practiceincrease;
};
]
/ recorddata = false
</trial>

You can do the same thing for the test trials.

Great, thanks for your fast reply! I incorporated the changes in the practice trials and it worked :)!
However, when I tried to make the changes in the experimental trials, the code is different, therefore, I was wondering where the branch can be made not working?
**********************************************************************
ZOOM trials that control the size changes of the target stimuli
as dictated by response; zoom trials come to an end when the
joystick is fully extended
**********************************************************************

<trial decrease>
/ ontrialbegin = [
picture.targetstimulus.height = picture.targetstimulus.height - values.joystick_change/1000 * expressions.maxheightchange_px;
]
/ stimulusframes = [1 = clearscreen, targetstimulus]
/ validresponse = (change)
/ monkeyresponse = ("back", "forward")
/ ontrialend = [
values.joystick_change = abs(values.joystick_y - joystick.y);
]
/ branch = [
if (monkey.monkeymode == 1) {
values.endtime = script.elapsedtime;
values.finalresponse = "PUSH";
trial.intertrialinterval;
} else if (joystick.y <= -1000) {
values.joystick_y = joystick.y;
values.endtime = script.elapsedtime;
values.finalresponse = "PUSH";
trial.enddecrease;
} else if (joystick.y <= values.joystick_y) {
values.joystick_y = joystick.y;
trial.decrease;
} else if (joystick.y > values.joystick_y) {
values.joystick_y = joystick.y;
values.changedirection += 1;
trial.increase;
};
]
/ recorddata = false
</trial>


<trial increase>
/ ontrialbegin = [
picture.targetstimulus.height = picture.targetstimulus.height + values.joystick_change/1000 * expressions.maxheightchange_px;
]
/ stimulusframes = [1 = targetstimulus]
/ validresponse = (change)
/ monkeyresponse = ("back", "forward")
/ ontrialend = [
values.joystick_change = abs(values.joystick_y - joystick.y);
]
/ branch = [
if (monkey.monkeymode == 1) {
values.endtime = script.elapsedtime;
values.finalresponse = "PULL";
trial.intertrialinterval;
} else if (joystick.y >= 1000) {
values.joystick_y = joystick.y;
values.endtime = script.elapsedtime;
values.finalresponse = "PULL";
trial.endincrease;
} else if (joystick.y >= values.joystick_y) {
values.joystick_y = joystick.y;
trial.increase;
} else if (joystick.y < values.joystick_y) {
values.joystick_y = joystick.y;
values.changedirection += 1;
trial.decrease;
};
]
/ recorddata = false
</trial>


Note: trials show the last size of the picture
<trial endincrease>
/ ontrialbegin = [
picture.targetstimulus.height = picture.targetstimulus.height + values.joystick_change/1000 * expressions.maxheightchange_px
]
/ stimulusframes = [1 = targetstimulus]
/ timeout = 0
/ branch = [trial.joystickrest]
/ recorddata = false
</trial>

<trial enddecrease>
/ ontrialbegin = [
picture.targetstimulus.height = picture.targetstimulus.height - values.joystick_change/1000 * expressions.maxheightchange_px;
]
/ stimulusframes = [1 = clearscreen, targetstimulus]
/ timeout = 0
/ branch = [trial.joystickrest]
/ recorddata = false
</trial>

In the same way as in the practice trials. You just need to add the corresponding /ontrialbegin logic to the test trials.

Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 13K, Visits: 104K
Dave - 8/27/2019
charlotte.w - 8/27/2019
Dave - 8/27/2019

> Furthermore, I would like to have a black screen during practice and training trials, but the command shape.backgroundcolor.color = black did not work.

There is no such <shape> in the script you attached, so I'm not sure what effect this could have had. Either way, if you want a black screen color, set /screencolor to black in the script's <defaults>.

<defaults>
/ canvasaspectratio = (4,3)
/ minimumversion = "5.0.0.0"
/ inputdevice = joystick
/ joystickthreshold = 30
/ fontstyle = ("Arial", 3%, false, false, false, false, 5, 1)
/ txbgcolor = white
/ txcolor = black
/ screencolor = black
</defaults>

Now, as for preventing a trial from ending if the move is in the wrong direction. What you need to do is prevent the endincrease and enddecrease trial elements from running if the move is in the wrong direction. Those trials are called from the regular increase and decrease trials. Let's look at the practice trials for illustration.

*********ZOOM FEATURE: trial increase/decrease the size of the rectangles depending on participant's response*********

<trial practicedecrease>
/ ontrialbegin = [
if (values.expcondition == 1 && values.targetformat == "p"){
trial.practicedecrease.insertstimulustime(text.error, 0);
}else if (values.expcondition == 2 && values.targetformat == "l"){
trial.practicedecrease.insertstimulustime(text.error, 0);
};
picture.practicetarget.height = picture.practicetarget.height - values.joystick_change/1000 * expressions.maxheightchange_px;
]
/ stimulusframes = [1 = clearscreen, practicetarget]
/ validresponse = (change)
/ monkeyresponse = ("back", "forward")
/ ontrialend = [
values.joystick_change = abs(values.joystick_y - joystick.y);
trial.practicedecrease.resetstimulusframes();
]
/ branch = [
if (monkey.monkeymode == 1) {
values.endtime = script.elapsedtime;
values.finalresponse = "PUSH";
trial.intertrialinterval;
} else if (joystick.y <= -1000) {
values.joystick_y = joystick.y;
values.endtime = script.elapsedtime;
values.finalresponse = "PUSH";
trial.enddecrease_practice;
} else if (joystick.y <= values.joystick_y) {
values.joystick_y = joystick.y;
trial.practicedecrease;
} else if (joystick.y > values.joystick_y) {
values.joystick_y = joystick.y;
values.changedirection += 1;
trial.practiceincrease;
};
]
/ recorddata = false
</trial>

<trial practiceincrease>
/ ontrialbegin = [
if (values.expcondition == 1 && values.targetformat == "L"){
trial.practiceincrease.insertstimulustime(text.error, 0);
} else if (values.expcondition == 2 && values.targetformat == "R"){
trial.practiceincrease.insertstimulustime(text.error, 0);
};
picture.practicetarget.height = picture.practicetarget.height + values.joystick_change/1000 * expressions.maxheightchange_px;
]
/ stimulusframes = [1 = practicetarget]
/ validresponse = (change)
/ monkeyresponse = ("back", "forward")
/ ontrialend = [
values.joystick_change = abs(values.joystick_y - joystick.y);
trial.practiceincrease.resetstimulusframes();
]
/ branch = [
if (monkey.monkeymode == 1) {
values.endtime = script.elapsedtime;
values.finalresponse = "PULL";
trial.intertrialinterval;
} else if (joystick.y >= 1000) {
values.joystick_y = joystick.y;
values.endtime = script.elapsedtime;
values.finalresponse = "PULL";
trial.endincrease_practice;
} else if (joystick.y >= values.joystick_y) {
values.joystick_y = joystick.y;
trial.practiceincrease;
} else if (joystick.y < values.joystick_y) {
values.joystick_y = joystick.y;
values.changedirection += 1;
trial.practicedecrease;
};
]
/ recorddata = false
</trial>


Note: trials show the last size of the picture
<trial endincrease_practice>
/ ontrialbegin = [
picture.practicetarget.height = picture.practicetarget.height + values.joystick_change/1000 * expressions.maxheightchange_px;
]
/ stimulusframes = [1 = practicetarget]
/ timeout = 0
/ branch = [trial.joystickrest]
/ recorddata = false
</trial>

<trial enddecrease_practice>
/ ontrialbegin = [
picture.practicetarget.height = picture.practicetarget.height - values.joystick_change/1000 * expressions.maxheightchange_px;
]
/ stimulusframes = [1 = clearscreen, practicetarget]
/ timeout = 0
/ branch = [trial.joystickrest]
/ recorddata = false
</trial>

So, all you need to do is make this /branch not work if the direction is wrong:

/ branch = [
if (monkey.monkeymode == 1) {
values.endtime = script.elapsedtime;
values.finalresponse = "PUSH";
trial.intertrialinterval;
} else if (joystick.y <= -1000) {
values.joystick_y = joystick.y;
values.endtime = script.elapsedtime;
values.finalresponse = "PUSH";
trial.enddecrease_practice;
...

That's actually easy, because the increase and decrease trials determine when the direction is wrong to display an error message -- i.e. the relevant logic is already mostly in place. Simply introduce a new variable, let's call it wrongdirection and set it to either true (direction is wrong) or false (direction is not wrong):

<values>
/ wrongdirection = false
</values>

<trial practicedecrease>
/ ontrialbegin = [
if (values.expcondition == 1 && values.targetformat == "p"){
trial.practicedecrease.insertstimulustime(text.error, 0);
values.wrongdirection = true;
}else if (values.expcondition == 2 && values.targetformat == "l"){
trial.practicedecrease.insertstimulustime(text.error, 0);
values.wrongdirection = true;
} else {
values.wrongdirection = false;
};
picture.practicetarget.height = picture.practicetarget.height - values.joystick_change/1000 * expressions.maxheightchange_px;
]
/ stimulusframes = [1 = clearscreen, practicetarget]
...
</trial>

Then just prevent the /branch if the direction is wrong.

<trial practicedecrease>
/ ontrialbegin = [
if (values.expcondition == 1 && values.targetformat == "p"){
trial.practicedecrease.insertstimulustime(text.error, 0);
values.wrongdirection = true;
}else if (values.expcondition == 2 && values.targetformat == "l"){
trial.practicedecrease.insertstimulustime(text.error, 0);
values.wrongdirection = true;
} else {
values.wrongdirection = false;
};
picture.practicetarget.height = picture.practicetarget.height - values.joystick_change/1000 * expressions.maxheightchange_px;
]
/ stimulusframes = [1 = clearscreen, practicetarget]
/ validresponse = (change)
/ monkeyresponse = ("back", "forward")
/ ontrialend = [
values.joystick_change = abs(values.joystick_y - joystick.y);
trial.practicedecrease.resetstimulusframes();
]
/ branch = [
if (monkey.monkeymode == 1) {
values.endtime = script.elapsedtime;
values.finalresponse = "PUSH";
trial.intertrialinterval;
} else if (joystick.y <= -1000 && !values.wrongdirection) {
values.joystick_y = joystick.y;
values.endtime = script.elapsedtime;
values.finalresponse = "PUSH";
trial.enddecrease_practice;
} else if (joystick.y <= values.joystick_y) {
values.joystick_y = joystick.y;
trial.practicedecrease;
} else if (joystick.y > values.joystick_y) {
values.joystick_y = joystick.y;
values.changedirection += 1;
trial.practiceincrease;
};
]
/ recorddata = false
</trial>

You can do the same thing for the test trials.

Great, thanks for your fast reply! I incorporated the changes in the practice trials and it worked :)!
However, when I tried to make the changes in the experimental trials, the code is different, therefore, I was wondering where the branch can be made not working?
**********************************************************************
ZOOM trials that control the size changes of the target stimuli
as dictated by response; zoom trials come to an end when the
joystick is fully extended
**********************************************************************

<trial decrease>
/ ontrialbegin = [
picture.targetstimulus.height = picture.targetstimulus.height - values.joystick_change/1000 * expressions.maxheightchange_px;
]
/ stimulusframes = [1 = clearscreen, targetstimulus]
/ validresponse = (change)
/ monkeyresponse = ("back", "forward")
/ ontrialend = [
values.joystick_change = abs(values.joystick_y - joystick.y);
]
/ branch = [
if (monkey.monkeymode == 1) {
values.endtime = script.elapsedtime;
values.finalresponse = "PUSH";
trial.intertrialinterval;
} else if (joystick.y <= -1000) {
values.joystick_y = joystick.y;
values.endtime = script.elapsedtime;
values.finalresponse = "PUSH";
trial.enddecrease;
} else if (joystick.y <= values.joystick_y) {
values.joystick_y = joystick.y;
trial.decrease;
} else if (joystick.y > values.joystick_y) {
values.joystick_y = joystick.y;
values.changedirection += 1;
trial.increase;
};
]
/ recorddata = false
</trial>


<trial increase>
/ ontrialbegin = [
picture.targetstimulus.height = picture.targetstimulus.height + values.joystick_change/1000 * expressions.maxheightchange_px;
]
/ stimulusframes = [1 = targetstimulus]
/ validresponse = (change)
/ monkeyresponse = ("back", "forward")
/ ontrialend = [
values.joystick_change = abs(values.joystick_y - joystick.y);
]
/ branch = [
if (monkey.monkeymode == 1) {
values.endtime = script.elapsedtime;
values.finalresponse = "PULL";
trial.intertrialinterval;
} else if (joystick.y >= 1000) {
values.joystick_y = joystick.y;
values.endtime = script.elapsedtime;
values.finalresponse = "PULL";
trial.endincrease;
} else if (joystick.y >= values.joystick_y) {
values.joystick_y = joystick.y;
trial.increase;
} else if (joystick.y < values.joystick_y) {
values.joystick_y = joystick.y;
values.changedirection += 1;
trial.decrease;
};
]
/ recorddata = false
</trial>


Note: trials show the last size of the picture
<trial endincrease>
/ ontrialbegin = [
picture.targetstimulus.height = picture.targetstimulus.height + values.joystick_change/1000 * expressions.maxheightchange_px
]
/ stimulusframes = [1 = targetstimulus]
/ timeout = 0
/ branch = [trial.joystickrest]
/ recorddata = false
</trial>

<trial enddecrease>
/ ontrialbegin = [
picture.targetstimulus.height = picture.targetstimulus.height - values.joystick_change/1000 * expressions.maxheightchange_px;
]
/ stimulusframes = [1 = clearscreen, targetstimulus]
/ timeout = 0
/ branch = [trial.joystickrest]
/ recorddata = false
</trial>

In the same way as in the practice trials. You just need to add the corresponding /ontrialbegin logic to the test trials.

For example, in the decrease test trial, that would simply be:

<trial decrease>
/ ontrialbegin = [
if (values.expcondition == 1 && values.targetformat == "p"){
values.wrongdirection = true;
} else if (values.expcondition == 2 && values.targetformat == "l"){
values.wrongdirection = true;
} else {
values.wrongdirection = false;
};

picture.targetstimulus.height = picture.targetstimulus.height - values.joystick_change/1000 * expressions.maxheightchange_px;
]
/ stimulusframes = [1 = clearscreen, targetstimulus]
/ validresponse = (change)
/ monkeyresponse = ("back", "forward")
/ ontrialend = [
values.joystick_change = abs(values.joystick_y - joystick.y);
]
/ branch = [
if (monkey.monkeymode == 1) {
values.endtime = script.elapsedtime;
values.finalresponse = "PUSH";
trial.intertrialinterval;
} else if (joystick.y <= -1000 && !values.wrongdirection) {
values.joystick_y = joystick.y;
values.endtime = script.elapsedtime;
values.finalresponse = "PUSH";
trial.enddecrease;
} else if (joystick.y <= values.joystick_y) {
values.joystick_y = joystick.y;
trial.decrease;
} else if (joystick.y > values.joystick_y) {
values.joystick_y = joystick.y;
values.changedirection += 1;
trial.increase;
};
]
/ recorddata = false
</trial>

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search