Questions Approach-Avoidance Task: keypress


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

is it possible to combine the AAT with keypress as response device instead of the joystick or mouse? And if so, how can I ensure that the keypress is linked to the zoom effect such that if the key is pressed, the picture increases/decreases and if the key press is stopped the movement of the Picture is also stopped?

Best
Charlotte

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 - Tuesday, March 5, 2019
Hi,

is it possible to combine the AAT with keypress as response device instead of the joystick or mouse? And if so, how can I ensure that the keypress is linked to the zoom effect such that if the key is pressed, the picture increases/decreases and if the key press is stopped the movement of the Picture is also stopped?

Best
Charlotte

It's possible, but you'll have to make some extensive modifications to the script. When a given key is pressed, you'll want to start the zoom in or zoom out sequence, depending on which key was pressed. You'll have to decide on some fixed time and size change for each zoom step, and those <trial> elements ought to be set up to detect a key release and then stop the sequence accordingly. When you're working with a regular keyboard, keys are identified by their respective keyboard scan code (see Tools -> Keyboard Scancodes...). A key release is specified by prepending a minus sign to the respective scan code, i.e.

<trial press>
...
/ validresponse = (57)
</trial>

would detect a press on the space bar, while

<trial release>
...
/ validresponse = (-57)
</trial>

would detect the space bar's release.

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 - Tuesday, March 5, 2019
charlotte.w - Tuesday, March 5, 2019
Hi,

is it possible to combine the AAT with keypress as response device instead of the joystick or mouse? And if so, how can I ensure that the keypress is linked to the zoom effect such that if the key is pressed, the picture increases/decreases and if the key press is stopped the movement of the Picture is also stopped?

Best
Charlotte

It's possible, but you'll have to make some extensive modifications to the script. When a given key is pressed, you'll want to start the zoom in or zoom out sequence, depending on which key was pressed. You'll have to decide on some fixed time and size change for each zoom step, and those <trial> elements ought to be set up to detect a key release and then stop the sequence accordingly. When you're working with a regular keyboard, keys are identified by their respective keyboard scan code (see Tools -> Keyboard Scancodes...). A key release is specified by prepending a minus sign to the respective scan code, i.e.

<trial press>
...
/ validresponse = (57)
</trial>

would detect a press on the space bar, while

<trial release>
...
/ validresponse = (-57)
</trial>

would detect the space bar's release.

Hi Dave,

thanks for your reply. Probably, the following code would have to be changed?
<trial AAT_4>
/inputdevice = mouse
/ ontrialbegin = [values.selectstimulus = list.category4.nextvalue]
/ ontrialbegin = [values.targetcategory = 2; values.targetformat = "p"]
/ ontrialbegin = [picture.targetstimulus.height = values.startheight_B]

/ ontrialbegin = [values.starttime = script.elapsedtime; values.endtime = 0]
/ ontrialbegin = [values.completeRT = 0; values.changedirection = 0; values.finalresponse=""]

/ stimulusframes = [1 = targetstimulus]
/ validresponse = (mousemove)
/isvalidresponse = [(trial.AAT_4.responsey > (values.mouse_y + values.pixeltolerance)) ||
(trial.AAT_4.responsey < (values.mouse_y - values.pixeltolerance)) ]
/ iscorrectresponse = [(values.expcondition == 1 && trial.AAT_4.responsey > values.mouse_y) ||
(values.expcondition == 2 && trial.AAT_4.responsey < values.mouse_y)]

/ errormessage = true(error,500)
/ontrialend = [if (trial.AAT_4.responsey < values.mouse_y) values.response = 1 else values.response = 2]
/ ontrialend = [values.mouse_change = abs(values.mouse_y - trial.AAT_4.responsey)]
/ ontrialend = [values.mouse_y = trial.AAT_4.responsey]

/ ontrialend = [if (trial.AAT_4.correct) values.sumRTcorrect_4 += trial.AAT_4.latency]
/ ontrialend = [values.sumRT_4 += trial.AAT_4.latency]

/ ontrialend = [values.trialcode = "AAT_4"]
/ ontrialend = [values.RT = trial.AAT_4.latency]
/ ontrialend = [values.correct = trial.AAT_4.correct]
/ ontrialend = [values.stimulus = picture.targetstimulus.currentitem]

/ontrialend = [if (values.response == 1) values.initialresponse = "PUSH"
else values.initialresponse = "PULL"]

/ branch = [if (values.response == 1) trial.decrease else trial.increase]
/recorddata = false
</trial>

And for the change of picture size:
<trial decrease>
/inputdevice = mouse
/ ontrialbegin = [picture.targetstimulus.height = picture.targetstimulus.height - values.mouse_change/(values.maxheight/2) * expressions.maxheightchange_px]

/ stimulusframes = [1 = eraser, targetstimulus]
/validresponse = (mousemove)
/ontrialend = [values.mouse_change = abs(values.mouse_y - trial.decrease.responsey)]

/ontrialend = [trial.decrease.resetstimulusframes()]

/branch = [if (script.subjectid == "monkey") {values.endtime = script.elapsedtime; values.finalresponse = "PUSH"; trial.intertrialinterval}]

/branch = [if (trial.decrease.responsey <= 1)
{if( 1 == values.targetcategory) {values.mouse_y = trial.decrease.responsey; values.endtime = script.elapsedtime; values.finalresponse = "PUSH"; trial.enddecrease} else { trial.maxdecrease }}]
/branch = [if (trial.decrease.responsey <= values.mouse_y)
{values.mouse_y = trial.decrease.responsey; trial.decrease}]
/branch = [if (trial.decrease.responsey > values.mouse_y)
{values.mouse_y = trial.decrease.responsey; values.changedirection += 1; trial.increase}]

/ recorddata = false
</trial>

<trial maxdecrease>
/inputdevice = mouse
/ontrialbegin = [picture.targetstimulus.height = picture.targetstimulus.height + values.mouse_change/(values.maxheight/2) * expressions.maxheightchange_px]
/stimulusframes = [1 = targetstimulus, hint_please_pull]
/validresponse = (mousemove)
/isvalidresponse = [trial.maxdecrease.responsey > values.mouse_y]
/ontrialend = [values.mouse_change = abs(values.mouse_y - trial.maxdecrease.responsey); values.mouse_y = trial.maxdecrease.responsey; trial.maxdecrease.resetstimulusframes()]
/branch = [trial.increase]
/recorddata = false
</trial>

<trial enddecrease>
/ontrialbegin = [picture.targetstimulus.height = picture.targetstimulus.height - values.mouse_change/(values.maxheight/2) * expressions.maxheightchange_px]
/stimulusframes = [1 = eraser, targetstimulus]
/timeout = 0
/branch = [trial.intertrialinterval]
/recorddata = false
</trial>

But I have no idea how this could be changed according to key press. How would you combine the key press with the size of the picture? Duration of key press?

Best
Charlotte

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 - Friday, March 8, 2019
Dave - Tuesday, March 5, 2019
charlotte.w - Tuesday, March 5, 2019
Hi,

is it possible to combine the AAT with keypress as response device instead of the joystick or mouse? And if so, how can I ensure that the keypress is linked to the zoom effect such that if the key is pressed, the picture increases/decreases and if the key press is stopped the movement of the Picture is also stopped?

Best
Charlotte

It's possible, but you'll have to make some extensive modifications to the script. When a given key is pressed, you'll want to start the zoom in or zoom out sequence, depending on which key was pressed. You'll have to decide on some fixed time and size change for each zoom step, and those <trial> elements ought to be set up to detect a key release and then stop the sequence accordingly. When you're working with a regular keyboard, keys are identified by their respective keyboard scan code (see Tools -> Keyboard Scancodes...). A key release is specified by prepending a minus sign to the respective scan code, i.e.

<trial press>
...
/ validresponse = (57)
</trial>

would detect a press on the space bar, while

<trial release>
...
/ validresponse = (-57)
</trial>

would detect the space bar's release.

Hi Dave,

thanks for your reply. Probably, the following code would have to be changed?
<trial AAT_4>
/inputdevice = mouse
/ ontrialbegin = [values.selectstimulus = list.category4.nextvalue]
/ ontrialbegin = [values.targetcategory = 2; values.targetformat = "p"]
/ ontrialbegin = [picture.targetstimulus.height = values.startheight_B]

/ ontrialbegin = [values.starttime = script.elapsedtime; values.endtime = 0]
/ ontrialbegin = [values.completeRT = 0; values.changedirection = 0; values.finalresponse=""]

/ stimulusframes = [1 = targetstimulus]
/ validresponse = (mousemove)
/isvalidresponse = [(trial.AAT_4.responsey > (values.mouse_y + values.pixeltolerance)) ||
(trial.AAT_4.responsey < (values.mouse_y - values.pixeltolerance)) ]
/ iscorrectresponse = [(values.expcondition == 1 && trial.AAT_4.responsey > values.mouse_y) ||
(values.expcondition == 2 && trial.AAT_4.responsey < values.mouse_y)]

/ errormessage = true(error,500)
/ontrialend = [if (trial.AAT_4.responsey < values.mouse_y) values.response = 1 else values.response = 2]
/ ontrialend = [values.mouse_change = abs(values.mouse_y - trial.AAT_4.responsey)]
/ ontrialend = [values.mouse_y = trial.AAT_4.responsey]

/ ontrialend = [if (trial.AAT_4.correct) values.sumRTcorrect_4 += trial.AAT_4.latency]
/ ontrialend = [values.sumRT_4 += trial.AAT_4.latency]

/ ontrialend = [values.trialcode = "AAT_4"]
/ ontrialend = [values.RT = trial.AAT_4.latency]
/ ontrialend = [values.correct = trial.AAT_4.correct]
/ ontrialend = [values.stimulus = picture.targetstimulus.currentitem]

/ontrialend = [if (values.response == 1) values.initialresponse = "PUSH"
else values.initialresponse = "PULL"]

/ branch = [if (values.response == 1) trial.decrease else trial.increase]
/recorddata = false
</trial>

And for the change of picture size:
<trial decrease>
/inputdevice = mouse
/ ontrialbegin = [picture.targetstimulus.height = picture.targetstimulus.height - values.mouse_change/(values.maxheight/2) * expressions.maxheightchange_px]

/ stimulusframes = [1 = eraser, targetstimulus]
/validresponse = (mousemove)
/ontrialend = [values.mouse_change = abs(values.mouse_y - trial.decrease.responsey)]

/ontrialend = [trial.decrease.resetstimulusframes()]

/branch = [if (script.subjectid == "monkey") {values.endtime = script.elapsedtime; values.finalresponse = "PUSH"; trial.intertrialinterval}]

/branch = [if (trial.decrease.responsey <= 1)
{if( 1 == values.targetcategory) {values.mouse_y = trial.decrease.responsey; values.endtime = script.elapsedtime; values.finalresponse = "PUSH"; trial.enddecrease} else { trial.maxdecrease }}]
/branch = [if (trial.decrease.responsey <= values.mouse_y)
{values.mouse_y = trial.decrease.responsey; trial.decrease}]
/branch = [if (trial.decrease.responsey > values.mouse_y)
{values.mouse_y = trial.decrease.responsey; values.changedirection += 1; trial.increase}]

/ recorddata = false
</trial>

<trial maxdecrease>
/inputdevice = mouse
/ontrialbegin = [picture.targetstimulus.height = picture.targetstimulus.height + values.mouse_change/(values.maxheight/2) * expressions.maxheightchange_px]
/stimulusframes = [1 = targetstimulus, hint_please_pull]
/validresponse = (mousemove)
/isvalidresponse = [trial.maxdecrease.responsey > values.mouse_y]
/ontrialend = [values.mouse_change = abs(values.mouse_y - trial.maxdecrease.responsey); values.mouse_y = trial.maxdecrease.responsey; trial.maxdecrease.resetstimulusframes()]
/branch = [trial.increase]
/recorddata = false
</trial>

<trial enddecrease>
/ontrialbegin = [picture.targetstimulus.height = picture.targetstimulus.height - values.mouse_change/(values.maxheight/2) * expressions.maxheightchange_px]
/stimulusframes = [1 = eraser, targetstimulus]
/timeout = 0
/branch = [trial.intertrialinterval]
/recorddata = false
</trial>

But I have no idea how this could be changed according to key press. How would you combine the key press with the size of the picture? Duration of key press?

Best
Charlotte

From the trial that takes the intitial key press, you need to /branch to the trial that increases or decreases size respectively.

Those latter trials, you need to give a fixed duration and each instance of that trial needs to in- or decrease the size by a fixed amount you need to decide on.

Those trials you need to set up to detect key releases. If no response / no release is detected in those trials, they ought to just keep /branch'ing to themselves until the maximum (or minimum, respectively) size is reached.

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 - Friday, March 8, 2019
charlotte.w - Friday, March 8, 2019
Dave - Tuesday, March 5, 2019
charlotte.w - Tuesday, March 5, 2019
Hi,

is it possible to combine the AAT with keypress as response device instead of the joystick or mouse? And if so, how can I ensure that the keypress is linked to the zoom effect such that if the key is pressed, the picture increases/decreases and if the key press is stopped the movement of the Picture is also stopped?

Best
Charlotte

It's possible, but you'll have to make some extensive modifications to the script. When a given key is pressed, you'll want to start the zoom in or zoom out sequence, depending on which key was pressed. You'll have to decide on some fixed time and size change for each zoom step, and those <trial> elements ought to be set up to detect a key release and then stop the sequence accordingly. When you're working with a regular keyboard, keys are identified by their respective keyboard scan code (see Tools -> Keyboard Scancodes...). A key release is specified by prepending a minus sign to the respective scan code, i.e.

<trial press>
...
/ validresponse = (57)
</trial>

would detect a press on the space bar, while

<trial release>
...
/ validresponse = (-57)
</trial>

would detect the space bar's release.

Hi Dave,

thanks for your reply. Probably, the following code would have to be changed?
<trial AAT_4>
/inputdevice = mouse
/ ontrialbegin = [values.selectstimulus = list.category4.nextvalue]
/ ontrialbegin = [values.targetcategory = 2; values.targetformat = "p"]
/ ontrialbegin = [picture.targetstimulus.height = values.startheight_B]

/ ontrialbegin = [values.starttime = script.elapsedtime; values.endtime = 0]
/ ontrialbegin = [values.completeRT = 0; values.changedirection = 0; values.finalresponse=""]

/ stimulusframes = [1 = targetstimulus]
/ validresponse = (mousemove)
/isvalidresponse = [(trial.AAT_4.responsey > (values.mouse_y + values.pixeltolerance)) ||
(trial.AAT_4.responsey < (values.mouse_y - values.pixeltolerance)) ]
/ iscorrectresponse = [(values.expcondition == 1 && trial.AAT_4.responsey > values.mouse_y) ||
(values.expcondition == 2 && trial.AAT_4.responsey < values.mouse_y)]

/ errormessage = true(error,500)
/ontrialend = [if (trial.AAT_4.responsey < values.mouse_y) values.response = 1 else values.response = 2]
/ ontrialend = [values.mouse_change = abs(values.mouse_y - trial.AAT_4.responsey)]
/ ontrialend = [values.mouse_y = trial.AAT_4.responsey]

/ ontrialend = [if (trial.AAT_4.correct) values.sumRTcorrect_4 += trial.AAT_4.latency]
/ ontrialend = [values.sumRT_4 += trial.AAT_4.latency]

/ ontrialend = [values.trialcode = "AAT_4"]
/ ontrialend = [values.RT = trial.AAT_4.latency]
/ ontrialend = [values.correct = trial.AAT_4.correct]
/ ontrialend = [values.stimulus = picture.targetstimulus.currentitem]

/ontrialend = [if (values.response == 1) values.initialresponse = "PUSH"
else values.initialresponse = "PULL"]

/ branch = [if (values.response == 1) trial.decrease else trial.increase]
/recorddata = false
</trial>

And for the change of picture size:
<trial decrease>
/inputdevice = mouse
/ ontrialbegin = [picture.targetstimulus.height = picture.targetstimulus.height - values.mouse_change/(values.maxheight/2) * expressions.maxheightchange_px]

/ stimulusframes = [1 = eraser, targetstimulus]
/validresponse = (mousemove)
/ontrialend = [values.mouse_change = abs(values.mouse_y - trial.decrease.responsey)]

/ontrialend = [trial.decrease.resetstimulusframes()]

/branch = [if (script.subjectid == "monkey") {values.endtime = script.elapsedtime; values.finalresponse = "PUSH"; trial.intertrialinterval}]

/branch = [if (trial.decrease.responsey <= 1)
{if( 1 == values.targetcategory) {values.mouse_y = trial.decrease.responsey; values.endtime = script.elapsedtime; values.finalresponse = "PUSH"; trial.enddecrease} else { trial.maxdecrease }}]
/branch = [if (trial.decrease.responsey <= values.mouse_y)
{values.mouse_y = trial.decrease.responsey; trial.decrease}]
/branch = [if (trial.decrease.responsey > values.mouse_y)
{values.mouse_y = trial.decrease.responsey; values.changedirection += 1; trial.increase}]

/ recorddata = false
</trial>

<trial maxdecrease>
/inputdevice = mouse
/ontrialbegin = [picture.targetstimulus.height = picture.targetstimulus.height + values.mouse_change/(values.maxheight/2) * expressions.maxheightchange_px]
/stimulusframes = [1 = targetstimulus, hint_please_pull]
/validresponse = (mousemove)
/isvalidresponse = [trial.maxdecrease.responsey > values.mouse_y]
/ontrialend = [values.mouse_change = abs(values.mouse_y - trial.maxdecrease.responsey); values.mouse_y = trial.maxdecrease.responsey; trial.maxdecrease.resetstimulusframes()]
/branch = [trial.increase]
/recorddata = false
</trial>

<trial enddecrease>
/ontrialbegin = [picture.targetstimulus.height = picture.targetstimulus.height - values.mouse_change/(values.maxheight/2) * expressions.maxheightchange_px]
/stimulusframes = [1 = eraser, targetstimulus]
/timeout = 0
/branch = [trial.intertrialinterval]
/recorddata = false
</trial>

But I have no idea how this could be changed according to key press. How would you combine the key press with the size of the picture? Duration of key press?

Best
Charlotte

From the trial that takes the intitial key press, you need to /branch to the trial that increases or decreases size respectively.

Those latter trials, you need to give a fixed duration and each instance of that trial needs to in- or decrease the size by a fixed amount you need to decide on.

Those trials you need to set up to detect key releases. If no response / no release is detected in those trials, they ought to just keep /branch'ing to themselves until the maximum (or minimum, respectively) size is reached.

Here's a simplifies example to illustrate:

<values>
/ height = 0px
/ width = 0px
</values>

<text stimulus>
/ items = (" ")
/ size = (values.width, values.height)
/ erase = false
/ txbgcolor = blue
</text>

<trial start>
/ ontrialbegin = [
values.height = 0.5px*display.canvasheight;
values.width = 0.5*display.canvasheight;
]
/ stimulusframes = [1=clearscreen, stimulus]
/ validresponse = (200, 208)
/ branch = [
if(trial.start.response == 200) trial.increase else trial.decrease
]
</trial>

<trial increase>
/ ontrialbegin = [
values.height += 10px;
values.width += 10px;
]
/ stimulusframes = [1=clearscreen, stimulus]
/ validresponse = (-200, 208, 0)
/ timeout = 100
/ branch = [
if(values.height >= display.canvasheight - 10) {
trial.endincrease;
}
]
/ branch = [
if(trial.increase.response == 0) {
trial.increase;
} else if (trial.increase.response == -200) {
trial.pause;
} else if (trial.increase.response == 208) {
trial.decrease;
}
]
</trial>

<trial decrease>
/ ontrialbegin = [
values.height -= 10px;
values.width -= 10px;
]
/ stimulusframes = [1=clearscreen, stimulus]
/ validresponse = (-208, 200, 0)
/ timeout = 100
/ branch = [
if(values.height <= 10) {
trial.enddecrease;
}
]
/ branch = [
if(trial.decrease.response == 0) {
trial.decrease;
} else if (trial.decrease.response == -208) {
trial.pause;
} else if (trial.decrease.response == 200) {
trial.increase;
}
]
</trial>

<trial pause>
/ stimulusframes = [1=clearscreen, stimulus]
/ validresponse = (200, 208)
/ branch = [
if(trial.pause.response == 200) trial.increase else trial.decrease
]
</trial>

<trial endincrease>
/ stimulusframes = [1=clearscreen, stimulus]
/ validresponse = (0)
/ trialduration = 500
</trial>

<trial enddecrease>
/ stimulusframes = [1=clearscreen, stimulus]
/ validresponse = (0)
/ trialduration = 500
</trial>

<block example>
/ trials = [1-4=start;]
</block>

Press the UP arrow key on your keyboard to increase size, use the DOWN arrow key to decrease size.





GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search