Millisecond Forums

button box translation

https://forums.millisecond.com/Topic34599.aspx

By nrouhani - 8/8/2022

hello, 

i am preparing an fMRI task where the buttons on the button box are associated with particular keys. is there a way to translate the button box input to another output key in inquisit? for example, one button is 'a', and i would like to print this response as 1 (instead of 'a') on the screen (participants must see their response on the screen during the task).

thank you!
By Dave - 8/8/2022

nrouhani - 8/8/2022
hello, 

i am preparing an fMRI task where the buttons on the button box are associated with particular keys. is there a way to translate the button box input to another output key in inquisit? for example, one button is 'a', and i would like to print this response as 1 (instead of 'a') on the screen (participants must see their response on the screen during the task).

thank you!

You can always use <values> and /ontrialend logic.
By nrouhani - 8/8/2022

Dave - 8/8/2022
nrouhani - 8/8/2022
hello, 

i am preparing an fMRI task where the buttons on the button box are associated with particular keys. is there a way to translate the button box input to another output key in inquisit? for example, one button is 'a', and i would like to print this response as 1 (instead of 'a') on the screen (participants must see their response on the screen during the task).

thank you!

You can always use <values> and /ontrialend logic.

Particpants will see their answer being printed on the screen during the trial ("openended" trial). can i change the values before that, so the right value will be printed on screen?
By Dave - 8/8/2022

nrouhani - 8/8/2022
Dave - 8/8/2022
nrouhani - 8/8/2022
hello, 

i am preparing an fMRI task where the buttons on the button box are associated with particular keys. is there a way to translate the button box input to another output key in inquisit? for example, one button is 'a', and i would like to print this response as 1 (instead of 'a') on the screen (participants must see their response on the screen during the task).

thank you!

You can always use <values> and /ontrialend logic.

Particpants will see their answer being printed on the screen during the trial ("openended" trial). can i change the values before that, so the right value will be printed on screen?

No. What you can do is something like this

<values>
/ keypressed = 0
</values>

<block myblock>
/ trials = [1-4 = mytrial]
</block>

<trial mytrial>
/ ontrialend = [
    if (trial.mytrial.response == 30) {
        values.keypressed = 1;
    } else if (trial.mytrial.response == 31) {
        values.keypressed = 2;
    } else if (trial.mytrial.response == 32) {
        values.keypressed = 3;
    } else if (trial.mytrial.response == 33) {
        values.keypressed = 4;
    }
]
/ stimulusframes = [1=mytext]
/ validresponse = ("a", "s", "d", "f")
/ branch = [
    trial.youpressed;
]
</trial>

<trial youpressed>
/ stimulusframes = [1=key]
/ trialduration = 1000
/ validresponse = (0)
</trial>

<text mytext>
/ items = ("Press one of the keys 'a', 's', 'd', or 'f'")
</text>

<text key>
/ items = ("You pressed key #<%values.keypressed%>")
</text>


but if the response box sends the code for an "A", then that's what the box sends. Inquisit cannot change that.

By nrouhani - 8/8/2022

Dave - 8/8/2022
nrouhani - 8/8/2022
Dave - 8/8/2022
nrouhani - 8/8/2022
hello, 

i am preparing an fMRI task where the buttons on the button box are associated with particular keys. is there a way to translate the button box input to another output key in inquisit? for example, one button is 'a', and i would like to print this response as 1 (instead of 'a') on the screen (participants must see their response on the screen during the task).

thank you!

You can always use <values> and /ontrialend logic.

Particpants will see their answer being printed on the screen during the trial ("openended" trial). can i change the values before that, so the right value will be printed on screen?

No. What you can do is something like this

<values>
/ keypressed = 0
</values>

<block myblock>
/ trials = [1-4 = mytrial]
</block>

<trial mytrial>
/ ontrialend = [
    if (trial.mytrial.response == 30) {
        values.keypressed = 1;
    } else if (trial.mytrial.response == 31) {
        values.keypressed = 2;
    } else if (trial.mytrial.response == 32) {
        values.keypressed = 3;
    } else if (trial.mytrial.response == 33) {
        values.keypressed = 4;
    }
]
/ stimulusframes = [1=mytext]
/ validresponse = ("a", "s", "d", "f")
/ branch = [
    trial.youpressed;
]
</trial>

<trial youpressed>
/ stimulusframes = [1=key]
/ trialduration = 1000
/ validresponse = (0)
</trial>

<text mytext>
/ items = ("Press one of the keys 'a', 's', 'd', or 'f'")
</text>

<text key>
/ items = ("You pressed key #<%values.keypressed%>")
</text>


but if the response box sends the code for an "A", then that's what the box sends. Inquisit cannot change that.


thank you, so I would not be able to translate the button presses to the correct values with an openended trial like below?

<openended estimate_art>
/ position = (50, 50)
/ buttonlabel = "please enter estimate"
/ fontstyle = ("Arial",20)
/ inputdevice = keyboard
/ validresponse = (noresponse)
/ stimulustimes = [0=sceneStim_current, estimateQ, leftHand, rightHand]
/ linelength = 3
/ range = (0,100)
/ numlines = 1
/ responsefontstyle = ("Arial",80)
/ posttrialpause = list.jitter_estimateList.nextvalue
/ trialduration = 3000 + list.jitter_estimateList.currentvalue
/ branch = [
trial.outcome_art
]
</openended>
By Dave - 8/8/2022

nrouhani - 8/8/2022
Dave - 8/8/2022
nrouhani - 8/8/2022
Dave - 8/8/2022
nrouhani - 8/8/2022
hello, 

i am preparing an fMRI task where the buttons on the button box are associated with particular keys. is there a way to translate the button box input to another output key in inquisit? for example, one button is 'a', and i would like to print this response as 1 (instead of 'a') on the screen (participants must see their response on the screen during the task).

thank you!

You can always use <values> and /ontrialend logic.

Particpants will see their answer being printed on the screen during the trial ("openended" trial). can i change the values before that, so the right value will be printed on screen?

No. What you can do is something like this

<values>
/ keypressed = 0
</values>

<block myblock>
/ trials = [1-4 = mytrial]
</block>

<trial mytrial>
/ ontrialend = [
    if (trial.mytrial.response == 30) {
        values.keypressed = 1;
    } else if (trial.mytrial.response == 31) {
        values.keypressed = 2;
    } else if (trial.mytrial.response == 32) {
        values.keypressed = 3;
    } else if (trial.mytrial.response == 33) {
        values.keypressed = 4;
    }
]
/ stimulusframes = [1=mytext]
/ validresponse = ("a", "s", "d", "f")
/ branch = [
    trial.youpressed;
]
</trial>

<trial youpressed>
/ stimulusframes = [1=key]
/ trialduration = 1000
/ validresponse = (0)
</trial>

<text mytext>
/ items = ("Press one of the keys 'a', 's', 'd', or 'f'")
</text>

<text key>
/ items = ("You pressed key #<%values.keypressed%>")
</text>


but if the response box sends the code for an "A", then that's what the box sends. Inquisit cannot change that.


thank you, so I would not be able to translate the button presses to the correct values with an openended trial like below?

<openended estimate_art>
/ position = (50, 50)
/ buttonlabel = "please enter estimate"
/ fontstyle = ("Arial",20)
/ inputdevice = keyboard
/ validresponse = (noresponse)
/ stimulustimes = [0=sceneStim_current, estimateQ, leftHand, rightHand]
/ linelength = 3
/ range = (0,100)
/ numlines = 1
/ responsefontstyle = ("Arial",80)
/ posttrialpause = list.jitter_estimateList.nextvalue
/ trialduration = 3000 + list.jitter_estimateList.currentvalue
/ branch = [
trial.outcome_art
]
</openended>

Correct. The bottom line is, don't use an openended, build whatever you need to build using standard trial elements.
By Dave - 8/8/2022

Dave - 8/8/2022
nrouhani - 8/8/2022
Dave - 8/8/2022
nrouhani - 8/8/2022
Dave - 8/8/2022
nrouhani - 8/8/2022
hello, 

i am preparing an fMRI task where the buttons on the button box are associated with particular keys. is there a way to translate the button box input to another output key in inquisit? for example, one button is 'a', and i would like to print this response as 1 (instead of 'a') on the screen (participants must see their response on the screen during the task).

thank you!

You can always use <values> and /ontrialend logic.

Particpants will see their answer being printed on the screen during the trial ("openended" trial). can i change the values before that, so the right value will be printed on screen?

No. What you can do is something like this

<values>
/ keypressed = 0
</values>

<block myblock>
/ trials = [1-4 = mytrial]
</block>

<trial mytrial>
/ ontrialend = [
    if (trial.mytrial.response == 30) {
        values.keypressed = 1;
    } else if (trial.mytrial.response == 31) {
        values.keypressed = 2;
    } else if (trial.mytrial.response == 32) {
        values.keypressed = 3;
    } else if (trial.mytrial.response == 33) {
        values.keypressed = 4;
    }
]
/ stimulusframes = [1=mytext]
/ validresponse = ("a", "s", "d", "f")
/ branch = [
    trial.youpressed;
]
</trial>

<trial youpressed>
/ stimulusframes = [1=key]
/ trialduration = 1000
/ validresponse = (0)
</trial>

<text mytext>
/ items = ("Press one of the keys 'a', 's', 'd', or 'f'")
</text>

<text key>
/ items = ("You pressed key #<%values.keypressed%>")
</text>


but if the response box sends the code for an "A", then that's what the box sends. Inquisit cannot change that.


thank you, so I would not be able to translate the button presses to the correct values with an openended trial like below?

<openended estimate_art>
/ position = (50, 50)
/ buttonlabel = "please enter estimate"
/ fontstyle = ("Arial",20)
/ inputdevice = keyboard
/ validresponse = (noresponse)
/ stimulustimes = [0=sceneStim_current, estimateQ, leftHand, rightHand]
/ linelength = 3
/ range = (0,100)
/ numlines = 1
/ responsefontstyle = ("Arial",80)
/ posttrialpause = list.jitter_estimateList.nextvalue
/ trialduration = 3000 + list.jitter_estimateList.currentvalue
/ branch = [
trial.outcome_art
]
</openended>

Correct. The bottom line is, don't use an openended, build whatever you need to build using standard trial elements.

So, if you have a response box with a limited number of buttons, let's say six, you'll need to come up with a way to enable people to enter any digit between 0 and 100, such as 37. That's not doable with some simple remapping of letters to digits to begin with. Instead, you can think of building something like this:

<values>
/ estimate = 0
</values>

<block myblock>
/ trials = [1 = mytrial]
</block>

<trial mytrial>
/ ontrialend = [
    if (trial.mytrial.response == 30) {
        values.estimate += 10;
    } else if (trial.mytrial.response == 31) {
        values.estimate -= 10;
    } else if (trial.mytrial.response == 32) {
        values.estimate += 1;
    } else if (trial.mytrial.response == 33) {
        values.estimate -= 1;
    };
    if (values.estimate < 0) {
        values.estimate = 0;
    };
    if (values.estimate > 100) {
        values.estimate = 100;
    };
]
/ stimulusframes = [1=mytext, estimate]
/ validresponse = ("a", "s", "d", "f", "g")
/ branch = [
    if (trial.mytrial.response != 34) {
        trial.mytrial;
    } else {
        trial.yourestimate;
    }    
]
/ recorddata = false
</trial>

<trial yourestimate>
/ stimulusframes = [1=estimate]
/ trialduration = 1000
/ validresponse = (0)
</trial>

<text mytext>
/ items = ("a' = increase by 10
's' = decrease by 10
'd' = increase by 1
'f' = decrease by 1
'g' = submit response")
/ position = (50%, 10%)
/ erase = false
</text>

<text estimate>
/ items = ("Estimate: <%values.estimate%>")
/ erase = false
/ size = (40%, 10%)
</text>

By nrouhani - 8/8/2022

Dave - 8/8/2022
Dave - 8/8/2022
nrouhani - 8/8/2022
Dave - 8/8/2022
nrouhani - 8/8/2022
Dave - 8/8/2022
nrouhani - 8/8/2022
hello, 

i am preparing an fMRI task where the buttons on the button box are associated with particular keys. is there a way to translate the button box input to another output key in inquisit? for example, one button is 'a', and i would like to print this response as 1 (instead of 'a') on the screen (participants must see their response on the screen during the task).

thank you!

You can always use <values> and /ontrialend logic.

Particpants will see their answer being printed on the screen during the trial ("openended" trial). can i change the values before that, so the right value will be printed on screen?

No. What you can do is something like this

<values>
/ keypressed = 0
</values>

<block myblock>
/ trials = [1-4 = mytrial]
</block>

<trial mytrial>
/ ontrialend = [
    if (trial.mytrial.response == 30) {
        values.keypressed = 1;
    } else if (trial.mytrial.response == 31) {
        values.keypressed = 2;
    } else if (trial.mytrial.response == 32) {
        values.keypressed = 3;
    } else if (trial.mytrial.response == 33) {
        values.keypressed = 4;
    }
]
/ stimulusframes = [1=mytext]
/ validresponse = ("a", "s", "d", "f")
/ branch = [
    trial.youpressed;
]
</trial>

<trial youpressed>
/ stimulusframes = [1=key]
/ trialduration = 1000
/ validresponse = (0)
</trial>

<text mytext>
/ items = ("Press one of the keys 'a', 's', 'd', or 'f'")
</text>

<text key>
/ items = ("You pressed key #<%values.keypressed%>")
</text>


but if the response box sends the code for an "A", then that's what the box sends. Inquisit cannot change that.


thank you, so I would not be able to translate the button presses to the correct values with an openended trial like below?

<openended estimate_art>
/ position = (50, 50)
/ buttonlabel = "please enter estimate"
/ fontstyle = ("Arial",20)
/ inputdevice = keyboard
/ validresponse = (noresponse)
/ stimulustimes = [0=sceneStim_current, estimateQ, leftHand, rightHand]
/ linelength = 3
/ range = (0,100)
/ numlines = 1
/ responsefontstyle = ("Arial",80)
/ posttrialpause = list.jitter_estimateList.nextvalue
/ trialduration = 3000 + list.jitter_estimateList.currentvalue
/ branch = [
trial.outcome_art
]
</openended>

Correct. The bottom line is, don't use an openended, build whatever you need to build using standard trial elements.

So, if you have a response box with a limited number of buttons, let's say six, you'll need to come up with a way to enable people to enter any digit between 0 and 100, such as 37. That's not doable with some simple remapping of letters to digits to begin with. Instead, you can think of building something like this:

<values>
/ estimate = 0
</values>

<block myblock>
/ trials = [1 = mytrial]
</block>

<trial mytrial>
/ ontrialend = [
    if (trial.mytrial.response == 30) {
        values.estimate += 10;
    } else if (trial.mytrial.response == 31) {
        values.estimate -= 10;
    } else if (trial.mytrial.response == 32) {
        values.estimate += 1;
    } else if (trial.mytrial.response == 33) {
        values.estimate -= 1;
    };
    if (values.estimate < 0) {
        values.estimate = 0;
    };
    if (values.estimate > 100) {
        values.estimate = 100;
    };
]
/ stimulusframes = [1=mytext, estimate]
/ validresponse = ("a", "s", "d", "f", "g")
/ branch = [
    if (trial.mytrial.response != 34) {
        trial.mytrial;
    } else {
        trial.yourestimate;
    }    
]
/ recorddata = false
</trial>

<trial yourestimate>
/ stimulusframes = [1=estimate]
/ trialduration = 1000
/ validresponse = (0)
</trial>

<text mytext>
/ items = ("a' = increase by 10
's' = decrease by 10
'd' = increase by 1
'f' = decrease by 1
'g' = submit response")
/ position = (50%, 10%)
/ erase = false
</text>

<text estimate>
/ items = ("Estimate: <%values.estimate%>")
/ erase = false
/ size = (40%, 10%)
</text>


thank you!