Millisecond Forums

Referencing previous trials

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

By crstevenson - 7/14/2020

Hi!

I've set up a popup so if a participant responds in less than 300ms to a given trial, they see a message that tells them to slow down. Is there a way to make this only show up if they respond in less than 300ms to 3 trials in a row? I thought of setting a parameter that basically says if the last 2 trials were less than 300ms, then show the message. However I'm not sure how to reference the previous 2 trials.

Any help is appreciated! Thanks!
By Dave - 7/14/2020

crstevenson - 7/14/2020
Hi!

I've set up a popup so if a participant responds in less than 300ms to a given trial, they see a message that tells them to slow down. Is there a way to make this only show up if they respond in less than 300ms to 3 trials in a row? I thought of setting a parameter that basically says if the last 2 trials were less than 300ms, then show the message. However I'm not sure how to reference the previous 2 trials.

Any help is appreciated! Thanks!

Create a variable (a <values> entry). Whenever a trial's latency is below 300ms, increase the variable by one /ontrialend. If the latency is above 300ms, set the variable to zero /ontrialend. If the variable is equal to 3, branch to your reminder trial and reset the variable to zero.
By crstevenson - 7/14/2020

Dave - 7/14/2020
crstevenson - 7/14/2020
Hi!

I've set up a popup so if a participant responds in less than 300ms to a given trial, they see a message that tells them to slow down. Is there a way to make this only show up if they respond in less than 300ms to 3 trials in a row? I thought of setting a parameter that basically says if the last 2 trials were less than 300ms, then show the message. However I'm not sure how to reference the previous 2 trials.

Any help is appreciated! Thanks!

Create a variable (a <values> entry). Whenever a trial's latency is below 300ms, increase the variable by one /ontrialend. If the latency is above 300ms, set the variable to zero /ontrialend. If the variable is equal to 3, branch to your reminder trial and reset the variable to zero.

Thanks so much! I've added the new variable and the following to each trial, but for some reason when I test it out, I still get the slow down message each time I respond in less than 300ms. Perhaps I used the reset function wrong?
<values>
...
/ toofast = 0
...
</values>

<trial targetAleft>
/ validresponse = ("E", "I")
/ correctresponse = ("E")
/ stimulusframes = [1 = targetA]
/ posttrialpause = parameters.ISI
/ ontrialend = [    
    if(trial.targetAleft.latency < 300 && script.currenttrial != "toofast") {values.toofast +=1;
        
    } else {values.toofast = 0;

        
    };
]
/ branch = [
    if ((parameters.showtoofast == true) && (trial.targetAleft.latency < parameters.toofastlatency) && (values.toofast = 3)) {
        return trial.toofast; reset(values.toofast)

    }]
</trial>

I also have this in each block:

<block compatiblepractice_AFArts_WMMath>
/ bgstim = (targetBleftmixed, attributeBleft, targetArightmixed, attributeAright)
/ trials = [
    1,3,5,7,9,11,13,15,17,19= random(targetBleft, targetAright);
    2,4,6,8,10,12,14,16,18,20 = random(attributeBL, attributeAR)]
/ errormessage = true(error,200)
/ responsemode = correct
/ onblockbegin = [
parameters.showtoofast = true;
]
/ ontrialend = [values.n1a += 1;
    if(block.compatiblepractice_AFArts_WMMath.latency <= 10000 && block.compatiblepractice_AFArts_WMMath.currenttrialnumber != 1 && script.currenttrial != "toofast") {
        values.sum1a += block.compatiblepractice_AFArts_WMMath.latency;
        values.ss1a += (block.compatiblepractice_AFArts_WMMath.latency * block.compatiblepractice_AFArts_WMMath.latency);
        values.n_correct += block.compatiblepractice_AFArts_WMMath.correct;
    };
    
    if(block.compatiblepractice_AFArts_WMMath.latency < 300 && script.currenttrial != "toofast") {values.toofast +=1;
        
    } else {values.toofast = 0;
        
    };

    
    if(block.compatiblepractice_AFArts_WMMath.latency < 300 && script.currenttrial != "toofast") {
        list.RT300.appenditem(1);
    } else {
        list.RT300.appenditem(0);
    };
]
</block>
By Dave - 7/14/2020

crstevenson - 7/14/2020
Dave - 7/14/2020
crstevenson - 7/14/2020
Hi!

I've set up a popup so if a participant responds in less than 300ms to a given trial, they see a message that tells them to slow down. Is there a way to make this only show up if they respond in less than 300ms to 3 trials in a row? I thought of setting a parameter that basically says if the last 2 trials were less than 300ms, then show the message. However I'm not sure how to reference the previous 2 trials.

Any help is appreciated! Thanks!

Create a variable (a <values> entry). Whenever a trial's latency is below 300ms, increase the variable by one /ontrialend. If the latency is above 300ms, set the variable to zero /ontrialend. If the variable is equal to 3, branch to your reminder trial and reset the variable to zero.

Thanks so much! I've added the new variable and the following to each trial, but for some reason when I test it out, I still get the slow down message each time I respond in less than 300ms. Perhaps I used the reset function wrong?
<values>
...
/ toofast = 0
...
</values>

<trial targetAleft>
/ validresponse = ("E", "I")
/ correctresponse = ("E")
/ stimulusframes = [1 = targetA]
/ posttrialpause = parameters.ISI
/ ontrialend = [    
    if(trial.targetAleft.latency < 300 && script.currenttrial != "toofast") {values.toofast +=1;
        
    } else {values.toofast = 0;

        
    };
]
/ branch = [
    if ((parameters.showtoofast == true) && (trial.targetAleft.latency < parameters.toofastlatency) && (values.toofast = 3)) {
        return trial.toofast; reset(values.toofast)

    }]
</trial>

I also have this in each block:

<block compatiblepractice_AFArts_WMMath>
/ bgstim = (targetBleftmixed, attributeBleft, targetArightmixed, attributeAright)
/ trials = [
    1,3,5,7,9,11,13,15,17,19= random(targetBleft, targetAright);
    2,4,6,8,10,12,14,16,18,20 = random(attributeBL, attributeAR)]
/ errormessage = true(error,200)
/ responsemode = correct
/ onblockbegin = [
parameters.showtoofast = true;
]
/ ontrialend = [values.n1a += 1;
    if(block.compatiblepractice_AFArts_WMMath.latency <= 10000 && block.compatiblepractice_AFArts_WMMath.currenttrialnumber != 1 && script.currenttrial != "toofast") {
        values.sum1a += block.compatiblepractice_AFArts_WMMath.latency;
        values.ss1a += (block.compatiblepractice_AFArts_WMMath.latency * block.compatiblepractice_AFArts_WMMath.latency);
        values.n_correct += block.compatiblepractice_AFArts_WMMath.correct;
    };
    
    if(block.compatiblepractice_AFArts_WMMath.latency < 300 && script.currenttrial != "toofast") {values.toofast +=1;
        
    } else {values.toofast = 0;
        
    };

    
    if(block.compatiblepractice_AFArts_WMMath.latency < 300 && script.currenttrial != "toofast") {
        list.RT300.appenditem(1);
    } else {
        list.RT300.appenditem(0);
    };
]
</block>

First: Why are you increasing the variable twice? Once at the block-level and once at the trial-level? That doesn't seem right. Do one of those only. Since most of your logic resides at the block-level, I'd suggest you do the increase there, not at the trial-level.

Second: reset(values.toofast) is not a thing. You ought to do values.toofast = 0, just like you already do in your /ontrialend logic.

Third: Your /branch is wrong. "=" is the assignment operator. "==" is the logical comparison operator, which is what you need here. I.e.

/ branch = [
  if ((parameters.showtoofast == true) && (trial.targetAleft.latency < parameters.toofastlatency) && (values.toofast == 3)) {
   values.toofast = 0;
   return trial.toofast;
  }]

Fourth: Including "trial.targetAleft.latency < parameters.toofastlatency" again in the /branch condition seems redundant. That check has already been performed by increasing the variable if latency < 300. The /branch can be condensed to

/ branch = [
if (parameters.showtoofast == true && values.toofast == 3) {
values.toofast = 0;
 return trial.toofast;
}]
By crstevenson - 7/16/2020

Dave - 7/14/2020
crstevenson - 7/14/2020
Dave - 7/14/2020
crstevenson - 7/14/2020
Hi!

I've set up a popup so if a participant responds in less than 300ms to a given trial, they see a message that tells them to slow down. Is there a way to make this only show up if they respond in less than 300ms to 3 trials in a row? I thought of setting a parameter that basically says if the last 2 trials were less than 300ms, then show the message. However I'm not sure how to reference the previous 2 trials.

Any help is appreciated! Thanks!

Create a variable (a <values> entry). Whenever a trial's latency is below 300ms, increase the variable by one /ontrialend. If the latency is above 300ms, set the variable to zero /ontrialend. If the variable is equal to 3, branch to your reminder trial and reset the variable to zero.

Thanks so much! I've added the new variable and the following to each trial, but for some reason when I test it out, I still get the slow down message each time I respond in less than 300ms. Perhaps I used the reset function wrong?
<values>
...
/ toofast = 0
...
</values>

<trial targetAleft>
/ validresponse = ("E", "I")
/ correctresponse = ("E")
/ stimulusframes = [1 = targetA]
/ posttrialpause = parameters.ISI
/ ontrialend = [    
    if(trial.targetAleft.latency < 300 && script.currenttrial != "toofast") {values.toofast +=1;
        
    } else {values.toofast = 0;

        
    };
]
/ branch = [
    if ((parameters.showtoofast == true) && (trial.targetAleft.latency < parameters.toofastlatency) && (values.toofast = 3)) {
        return trial.toofast; reset(values.toofast)

    }]
</trial>

I also have this in each block:

<block compatiblepractice_AFArts_WMMath>
/ bgstim = (targetBleftmixed, attributeBleft, targetArightmixed, attributeAright)
/ trials = [
    1,3,5,7,9,11,13,15,17,19= random(targetBleft, targetAright);
    2,4,6,8,10,12,14,16,18,20 = random(attributeBL, attributeAR)]
/ errormessage = true(error,200)
/ responsemode = correct
/ onblockbegin = [
parameters.showtoofast = true;
]
/ ontrialend = [values.n1a += 1;
    if(block.compatiblepractice_AFArts_WMMath.latency <= 10000 && block.compatiblepractice_AFArts_WMMath.currenttrialnumber != 1 && script.currenttrial != "toofast") {
        values.sum1a += block.compatiblepractice_AFArts_WMMath.latency;
        values.ss1a += (block.compatiblepractice_AFArts_WMMath.latency * block.compatiblepractice_AFArts_WMMath.latency);
        values.n_correct += block.compatiblepractice_AFArts_WMMath.correct;
    };
    
    if(block.compatiblepractice_AFArts_WMMath.latency < 300 && script.currenttrial != "toofast") {values.toofast +=1;
        
    } else {values.toofast = 0;
        
    };

    
    if(block.compatiblepractice_AFArts_WMMath.latency < 300 && script.currenttrial != "toofast") {
        list.RT300.appenditem(1);
    } else {
        list.RT300.appenditem(0);
    };
]
</block>

First: Why are you increasing the variable twice? Once at the block-level and once at the trial-level? That doesn't seem right. Do one of those only. Since most of your logic resides at the block-level, I'd suggest you do the increase there, not at the trial-level.

Second: reset(values.toofast) is not a thing. You ought to do values.toofast = 0, just like you already do in your /ontrialend logic.

Third: Your /branch is wrong. "=" is the assignment operator. "==" is the logical comparison operator, which is what you need here. I.e.

/ branch = [
  if ((parameters.showtoofast == true) && (trial.targetAleft.latency < parameters.toofastlatency) && (values.toofast == 3)) {
   values.toofast = 0;
   return trial.toofast;
  }]

Fourth: Including "trial.targetAleft.latency < parameters.toofastlatency" again in the /branch condition seems redundant. That check has already been performed by increasing the variable if latency < 300. The /branch can be condensed to

/ branch = [
if (parameters.showtoofast == true && values.toofast == 3) {
values.toofast = 0;
 return trial.toofast;
}]

This clarified things so much - thank you!!