Expressions in trial properties


Author
Message
mindwanderingjeremy
mindwanderingjeremy
New Member (44 reputation)New Member (44 reputation)New Member (44 reputation)New Member (44 reputation)New Member (44 reputation)New Member (44 reputation)New Member (44 reputation)New Member (44 reputation)New Member (44 reputation)
Group: Forum Members
Posts: 18, Visits: 38
Hi, 

I am attempting to code an Nback task in which a shape (either a square, triangle, or circle) is presented on each side of the screen with a little shape in the middle, and participants have to report whether the little shape in the middle of the screen was presented on the left or right in the previous trial.

I am trying to code it so that I only have to code a couple of trials (a target and a non-target trial) and the trial parameters (stimulusframes and correct response) change from trial to trial. However, I cannot work out how to properly use expressions in the trial properties.

This is how I am currently trying to achieve this.


<expressions>
/filllist = {
    if (values.lastIndex < values.N){
        list.target.insertitem(0, 1);
        values.lastIndex += 1;
        expressions.filllist;
    } else {
        list.target.insertitem(0, 1);
    };
</expressions>

<list target>
</list>

<list 1Tselect>
/items = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)
/replace = true
/selectionmode = values.currenttarget
/selectionrate = trial
</list>

<trial 1backtarget>
/stimulusframes =     [0 = Rfixline]
/validresponse = (30, 38, noresponse)
/isvalidresponse = [if(trial.1backtarget.response == 30 || trial.1backtarget.response == 38)
                    {
                        values.response = trial.1backtarget.response
                        values.latency = trial.1backtarget.latency;
                    }]
/ correctresponse = (        {if(list.1Tselect == 1) 30};
                                         {if(list.1Tselect == 2) 38};
                                         {if(list.1Tselect == 3) 30};
                                         {if(list.1Tselect == 4) 38};
                                         {if(list.1Tselect == 5) 30};
                                         {if(list.1Tselect == 6) 38};
                                         {if(list.1Tselect == 7) 30};
                                         {if(list.1Tselect == 8) 38};
                                         {if(list.1Tselect == 9) 30};
                                        {if(list.1Tselect == 10) 38};
                                        {if(list.1Tselect == 11) 30};
                                        {if(list.1Tselect == 12) 38};
                            )
/ ontrialbegin = [
    {if(list.1Tselect == 1) {values.sxpos = 25; values.txpos = 75;
    trial.1backtarget.insertstimulusframes(picture.redsquare, values.onset);
    trial.1backtarget.insertstimulusframes(picture.redtriangle, values.onset)}};
    {if(list.1Tselect == 2) {values.sxpos = 25; values.txpos = 75;
    trial.1backtarget.insertstimulusframes(picture.redsquare, values.onset);
    trial.1backtarget.insertstimulusframes(picture.redtriangle, values.onset)}};
    {if(list.1Tselect == 3) {values.sxpos = 25; values.cxpos = 75;
    trial.1backtarget.insertstimulusframes(picture.redsquare, values.onset);
    trial.1backtarget.insertstimulusframes(picture.redcircle, values.onset)}};
    {if(list.1Tselect == 4) {values.sxpos = 25; values.cxpos = 75;
    trial.1backtarget.insertstimulusframes(picture.redsquare, values.onset);
    trial.1backtarget.insertstimulusframes(picture.redcircle, values.onset)}};
    {if(list.1Tselect == 5) {values.txpos = 25; values.sxpos = 75;
    trial.1backtarget.insertstimulusframes(picture.redtriangle, values.onset);
    trial.1backtarget.insertstimulusframes(picture.redsquare, values.onset)}};
    {if(list.1Tselect == 6) {values.txpos = 25; values.sxpos = 75;
    trial.1backtarget.insertstimulusframes(picture.redtriangle, values.onset);
    trial.1backtarget.insertstimulusframes(picture.redsquare, values.onset)}};
    {if(list.1Tselect == 7) {values.txpos = 25; values.cxpos = 75;
    trial.1backtarget.insertstimulusframes(picture.redtriangle, values.onset);
    trial.1backtarget.insertstimulusframes(picture.redcircle, values.onset)}};
    {if(list.1Tselect == 8) {values.txpos = 25; values.cxpos = 75;
    trial.1backtarget.insertstimulusframes(picture.redtriangle, values.onset);
    trial.1backtarget.insertstimulusframes(picture.redcircle, values.onset)}};
    {if(list.1Tselect == 9) {values.cxpos = 25; values.txpos = 75;
    trial.1backtarget.insertstimulusframes(picture.redcircle, values.onset);
    trial.1backtarget.insertstimulusframes(picture.redtriangle, values.onset)}};
    {if(list.1Tselect == 10) {values.cxpos = 25; values.txpos = 75;
    trial.1backtarget.insertstimulusframes(picture.redcircle, values.onset);
    trial.1backtarget.insertstimulusframes(picture.redtriangle, values.onset)}};
    {if(list.1Tselect == 11) {values.cxpos = 25; values.sxpos = 75;
    trial.1backtarget.insertstimulusframes(picture.redcircle, values.onset);
    trial.1backtarget.insertstimulusframes(picture.redsquare, values.onset)}};
    {if(list.1Tselect == 12) {values.cxpos = 25; values.sxpos = 75;
    trial.1backtarget.insertstimulusframes(picture.redcircle, values.onset);
    trial.1backtarget.insertstimulusframes(picture.redsquare, values.onset)}};
    
    
    trial.1backTarget.insertstimulustime(shape.eraser, parameters.stimulusPresentationtime);
    
    if (values.N > 0){
    values.currenttarget = list.target.item(values.N);};
    list.1Tselect.nextvalue;

]
/ontrialend = [
        trial.1backtarget.resetstimulusframes();
        
        values.lastitem = list.1Tselect.currentvalue;
        list.target.insertitem(values.lastitem, 1);

]

/ beginresponsetime = 0
/ trialduration = parameters.SOA
</trial>

I also have other trials for non-targets and varying N-back which operate similarly.

If anyone knows how I can get this working that would be super helpful thank you!

Jeremy.
Dave
Dave
Supreme Being (911K reputation)Supreme Being (911K reputation)Supreme Being (911K reputation)Supreme Being (911K reputation)Supreme Being (911K reputation)Supreme Being (911K reputation)Supreme Being (911K reputation)Supreme Being (911K reputation)Supreme Being (911K reputation)
Group: Administrators
Posts: 11K, Visits: 65K
mindwanderingjeremy - 2/3/2021
Hi, 

I am attempting to code an Nback task in which a shape (either a square, triangle, or circle) is presented on each side of the screen with a little shape in the middle, and participants have to report whether the little shape in the middle of the screen was presented on the left or right in the previous trial.

I am trying to code it so that I only have to code a couple of trials (a target and a non-target trial) and the trial parameters (stimulusframes and correct response) change from trial to trial. However, I cannot work out how to properly use expressions in the trial properties.

This is how I am currently trying to achieve this.


<expressions>
/filllist = {
    if (values.lastIndex < values.N){
        list.target.insertitem(0, 1);
        values.lastIndex += 1;
        expressions.filllist;
    } else {
        list.target.insertitem(0, 1);
    };
</expressions>

<list target>
</list>

<list 1Tselect>
/items = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)
/replace = true
/selectionmode = values.currenttarget
/selectionrate = trial
</list>

<trial 1backtarget>
/stimulusframes =     [0 = Rfixline]
/validresponse = (30, 38, noresponse)
/isvalidresponse = [if(trial.1backtarget.response == 30 || trial.1backtarget.response == 38)
                    {
                        values.response = trial.1backtarget.response
                        values.latency = trial.1backtarget.latency;
                    }]
/ correctresponse = (        {if(list.1Tselect == 1) 30};
                                         {if(list.1Tselect == 2) 38};
                                         {if(list.1Tselect == 3) 30};
                                         {if(list.1Tselect == 4) 38};
                                         {if(list.1Tselect == 5) 30};
                                         {if(list.1Tselect == 6) 38};
                                         {if(list.1Tselect == 7) 30};
                                         {if(list.1Tselect == 8) 38};
                                         {if(list.1Tselect == 9) 30};
                                        {if(list.1Tselect == 10) 38};
                                        {if(list.1Tselect == 11) 30};
                                        {if(list.1Tselect == 12) 38};
                            )
/ ontrialbegin = [
    {if(list.1Tselect == 1) {values.sxpos = 25; values.txpos = 75;
    trial.1backtarget.insertstimulusframes(picture.redsquare, values.onset);
    trial.1backtarget.insertstimulusframes(picture.redtriangle, values.onset)}};
    {if(list.1Tselect == 2) {values.sxpos = 25; values.txpos = 75;
    trial.1backtarget.insertstimulusframes(picture.redsquare, values.onset);
    trial.1backtarget.insertstimulusframes(picture.redtriangle, values.onset)}};
    {if(list.1Tselect == 3) {values.sxpos = 25; values.cxpos = 75;
    trial.1backtarget.insertstimulusframes(picture.redsquare, values.onset);
    trial.1backtarget.insertstimulusframes(picture.redcircle, values.onset)}};
    {if(list.1Tselect == 4) {values.sxpos = 25; values.cxpos = 75;
    trial.1backtarget.insertstimulusframes(picture.redsquare, values.onset);
    trial.1backtarget.insertstimulusframes(picture.redcircle, values.onset)}};
    {if(list.1Tselect == 5) {values.txpos = 25; values.sxpos = 75;
    trial.1backtarget.insertstimulusframes(picture.redtriangle, values.onset);
    trial.1backtarget.insertstimulusframes(picture.redsquare, values.onset)}};
    {if(list.1Tselect == 6) {values.txpos = 25; values.sxpos = 75;
    trial.1backtarget.insertstimulusframes(picture.redtriangle, values.onset);
    trial.1backtarget.insertstimulusframes(picture.redsquare, values.onset)}};
    {if(list.1Tselect == 7) {values.txpos = 25; values.cxpos = 75;
    trial.1backtarget.insertstimulusframes(picture.redtriangle, values.onset);
    trial.1backtarget.insertstimulusframes(picture.redcircle, values.onset)}};
    {if(list.1Tselect == 8) {values.txpos = 25; values.cxpos = 75;
    trial.1backtarget.insertstimulusframes(picture.redtriangle, values.onset);
    trial.1backtarget.insertstimulusframes(picture.redcircle, values.onset)}};
    {if(list.1Tselect == 9) {values.cxpos = 25; values.txpos = 75;
    trial.1backtarget.insertstimulusframes(picture.redcircle, values.onset);
    trial.1backtarget.insertstimulusframes(picture.redtriangle, values.onset)}};
    {if(list.1Tselect == 10) {values.cxpos = 25; values.txpos = 75;
    trial.1backtarget.insertstimulusframes(picture.redcircle, values.onset);
    trial.1backtarget.insertstimulusframes(picture.redtriangle, values.onset)}};
    {if(list.1Tselect == 11) {values.cxpos = 25; values.sxpos = 75;
    trial.1backtarget.insertstimulusframes(picture.redcircle, values.onset);
    trial.1backtarget.insertstimulusframes(picture.redsquare, values.onset)}};
    {if(list.1Tselect == 12) {values.cxpos = 25; values.sxpos = 75;
    trial.1backtarget.insertstimulusframes(picture.redcircle, values.onset);
    trial.1backtarget.insertstimulusframes(picture.redsquare, values.onset)}};
    
    
    trial.1backTarget.insertstimulustime(shape.eraser, parameters.stimulusPresentationtime);
    
    if (values.N > 0){
    values.currenttarget = list.target.item(values.N);};
    list.1Tselect.nextvalue;

]
/ontrialend = [
        trial.1backtarget.resetstimulusframes();
        
        values.lastitem = list.1Tselect.currentvalue;
        list.target.insertitem(values.lastitem, 1);

]

/ beginresponsetime = 0
/ trialduration = parameters.SOA
</trial>

I also have other trials for non-targets and varying N-back which operate similarly.

If anyone knows how I can get this working that would be super helpful thank you!

Jeremy.

If you want help with this, you need to (1) explain clearly the reasoning behing the code you have, and (2) provide actually runnable code, not just a fragment. You also need to provide any and all files that code requires to run. Thanks.
mindwanderingjeremy
mindwanderingjeremy
New Member (44 reputation)New Member (44 reputation)New Member (44 reputation)New Member (44 reputation)New Member (44 reputation)New Member (44 reputation)New Member (44 reputation)New Member (44 reputation)New Member (44 reputation)
Group: Forum Members
Posts: 18, Visits: 38
Okay sorry, I thought posting the whole code in here would be too large. So I am coding an n-back task with 0-back and 1-back conditions. The N-back task will require participants to report whether a target shape (presented in the middle of the screen) is/was presented on the left or the right in 0-back (the current trial) or 1-back (the previous trial) conditions. There will also be non-target trials in each condition where participants do not have to make any response. 
This is my first time coding in inquisit so I am not yet finished the code. I am just trying to get the stimulus presentation and responses to work first before I code all of the data recording etc. So the code only includes the necessary elements for presenting stimuli in each condition.  I have also not coded any instructions yet. 


**************************************************************************************************************
**************************************************************************************************************
    EDITABLE PARAMETERS: change editable parameters here
**************************************************************************************************************
**************************************************************************************************************

<parameters>
/runPractice = true
/Debugmode = 0
/stimulusPresentationtime = 500
/SOA = 3000
</parameters>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE STIMULI: change editable stimuli here
**************************************************************************************************************
**************************************************************************************************************

<item bluesquare>
/1 = "blueSquare.gif"
</item>

<item bluetriangle>
/1= "blueTriangle.gif"
</item>

<item bluecircle>
/1= "blueCircle.gif"
</item>

<item redsquare>
/1 = "redSquare.gif"
</item>

<item redtriangle>
/1= "redTriangle.gif"
</item>

<item redcircle>
/1= "redCircle.gif"
</item>
**************************************************************************************************************
**************************************************************************************************************
    EDITABLE INSTRUCTIONS: change instructions here
**************************************************************************************************************
**************************************************************************************************************
***********INSTRUCTION SLIDES*****************************


**************************************************************************************************************
**************************************************************************************************************
    Editable Lists
**************************************************************************************************************
**************************************************************************************************************


**************************************************************************************************************
**************************************************************************************************************
    DEFAULTS
**************************************************************************************************************
**************************************************************************************************************

<defaults>
/canvasaspectratio = (4,3)
/minimumversion = "5.0.5.0"
/ fontstyle = ("Arial", 3%, false, false, false, false, 5, 1)
/txbgcolor = white
/ txcolor = (0, 0, 0)
/ screencolor = black
</defaults>


**************************************************************************************************************
**************************************************************************************************************
    VALUES: automatically updated
**************************************************************************************************************
**************************************************************************************************************
            
/completed:                0 = script was not completed (script was prematurely aborted); 1 = script was completed (all conditions run)

v_position:                contains the position of the current square
                            (1 = (25, 25), 2 = (50, 25), 3 = (75, 25), 4 = (25, 50), 5 = (75, 50), 6 = (25, 75), 7 = (50, 75), 8 = (75, 75))
N:                            the trial lag between a target and the stimulus it repeats
v_currenttarget:        contains the position of the current target square
                            (a target in N = 0 trials is a stimulus with the same stimulus number as stored in target0)
v_Hits:                    codes the number of correctly identifiying a square target
v_FalseA:                codes the number of times a participant identifies a square non-target as a square target
v_Misses:                codes the number of times a participant misses to identify a square target
v_CorrReject:            codes the number of times a participant correctly identifies a square non-target (and does nothing)
1response:                 codes the first response (if any)
2response:                codes the second response (if any)
1latency :                codes the latency (if any) of the first response
2latency     :                codes the latency (if any) of the second response
latency:                    contains trial latency data, stores the latency of the last given response (if any)
v_TotalHits:                the number of total hits across all experimental blocks for the visual modality
v_TotalFA:                the number of total false alarms across all experimental blocks for the visual modality
TotalBlocks:                the total number of experimental blocks run
DV:                        the dependent variable in Jaeggi et al (2010): the proportion of (((v_TotalHits - v_TotalFA) + (a_TotalHits - a_TotalFA))/2) /number of total blocks
startcounter:            counts the number of start trials run
repetitioncounter:    keeps track of the number of experimental blocks run on a level of N

<values >
/completed = 0

/stim = ""
/stimnumber = 0
/N = 1
/currenttarget = 0                     keeps track of current target for N-back 
/v_Hits = 0
/v_FalseA = 0
/v_Misses = 0
/v_CorrReject = 0
/sxpos = 0                                 square xposition updated in trials
/cxpos = 0                                 circle xposition updated in trials
/txpos = 0                                 triangle xposition updated in trials
/response = 0
/latency = 0
/v_TotalFA = 0
/v_TotalHits = 0
/TotalBlocks = 0
/DV = 0
/starttrialcounter = 0
/repetitioncounter = 0
/trial_Hitv = 0
/trial_Missv = 0
/trial_CRv = 0
/trial_FAv = 0
/trial_Hita = 0
/trial_Missa = 0
/trial_CRa = 0
/trial_FAa = 0
/onset = 0

/lastIndex = 0
/lastitem = ""
</values>

**************************************************************************************************************
**************************************************************************************************************
    EXPRESSIONS
**************************************************************************************************************
**************************************************************************************************************

/filllist:                recursive function that fills list.target with N items at the beginning of each new block

<expressions>
/filllist = {
    if (values.lastIndex < values.N){
        list.target.insertitem(0, 1);
        values.lastIndex += 1;
        expressions.filllist;
    } else {
        list.target.insertitem(0, 1);
    };
</expressions>

**************************************************************************************************************
**************************************************************************************************************
    INSTRUCTIONS
**************************************************************************************************************
**************************************************************************************************************
*********************INSTRUCTION IMAGE SELECTION********************************************************


********************INSTRUCTION TRIALS****************************************************************


**************************************************************************************************************
**************************************************************************************************************
    STIMULI
**************************************************************************************************************
**************************************************************************************************************

<picture bluesquare>
/items = bluesquare
/select = 1
/ position = (values.sxpos, 50)
/ size = (25%, 25%)
/ transparentcolor = black
</picture>

<picture lilbsquare>
/items = bluesquare
/select = 1
/ position = (50, 50)
/ size = (5%, 5%)
/ transparentcolor = black
</picture>

<picture bluetriangle>
/items = bluetriangle
/select = 1
/ position = (values.txpos, 50)
/ size = (25%, 25%)
/ transparentcolor = black
</picture>

<picture lilbtriangle>
/items = bluetriangle
/select = 1
/ position = (50, 50)
/ size = (5%, 5%)
/ transparentcolor = black
</picture>

<picture bluecircle>
/items = bluecircle
/select = 1
/ position = (values.cxpos, 50)
/ size = (25%, 25%)
/ transparentcolor = black
</picture>

<picture lilbcircle>
/items = bluecircle
/select = 1
/ position = (50, 50)
/ size = (5%, 5%)
/ transparentcolor = black
</picture>

<picture redsquare>
/items = redsquare
/select = 1
/ position = (values.sxpos, 50)
/ size = (25%, 25%)
/ transparentcolor = black
</picture>

<picture lilrsquare>
/items = redsquare
/select = 1
/ position = (50, 50)
/ size = (5%, 5%)
/ transparentcolor = black
</picture>

<picture redtriangle>
/items = redtriangle
/select = 1
/ position = (values.txpos, 50)
/ size = (25%, 25%)
/ transparentcolor = black
</picture>

<picture lilrtriangle>
/items = redtriangle
/select = 1
/ position = (50, 50)
/ size = (5%, 5%)
/ transparentcolor = black
</picture>

<picture redcircle>
/items = redcircle
/select = 1
/ position = (values.cxpos, 50)
/ size = (25%, 25%)
/ transparentcolor = black
</picture>

<picture lilrcircle>
/items = redcircle
/select = 1
/ position = (50, 50)
/ size = (5%, 5%)
/ transparentcolor = black
</picture>

****************************
ASSISTANT STIMULI
****************************

*****acts as an eraser after showing the key stimuli for 500ms, staying on for the remainder of the 3000ms dedicated to each trial
<shape eraser>
/ shape = rectangle
/ size = (30%, 30%)
/ color = black
/ position = (values.xpos, values.ypos)
</shape>
=
*****fixation lines
<text Bfixline>
/items = ("|")
/position = (50%, 50%)
/size = (15%, 15%)
/txcolor = blue
</text>

<text Rfixline>
/items = ("|")
/position = (50%, 50%)
/size = (15%, 15%)
/txcolor = red
</text>

********
Selection Lists
<list target>                                                                   automatically filled by expression.filllist
</list>

<list NTselect>                                                             list to index all options of shape presentations in non-target trials
/items = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)
/replace = true
/selectionmode = random
/selectionrate = trial
</list>
 
<list Tselect>                                                               list to index all options of shape presentations and correct responses in target trials
/items = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)
/replace = true
/selectionmode = random
/selectionrate = trial
</list>

<list 1Tselect>                                                            list to select previous trial as current target for shape presentations and correct responses in 1-back trials, selected by current target 
/items = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)
/replace = true
/selectionmode = values.currenttarget
/selectionrate = trial
</list>


**************************************************************************************************************
**************************************************************************************************************
    Trials    
**************************************************************************************************************
**************************************************************************************************************
<trial 0backNT>
/stimulusframes = [0 = Bfixline]                                                                                  In non-target trials I want to present a fixation line between the two shapes. No response
/validresponse = (noresponse)                                                                                    required.
/ correctresponse = (noresponse)
/ ontrialbegin = [
    {if(list.NTselect == 1 || list.NTselect == 2)                                                                       Attempt to use NTselect list to update which shapes are presented and their location on the
        {values.sxpos = 25; values.txpos = 75;                                                                       screen
        trial.0backNT.insertstimulusframes(picture.bluesquare, values.onset);
        trial.0backNT.insertstimulusframes(picture.bluetriangle, values.onset)}};
     {if(list.NTselect == 3 || list.NTselect == 4)
     {values.sxpos = 25; values.cxpos = 75;
         trial.0backNT.insertstimulusframes(picture.bluesquare, values.onset);
        trial.0backNT.insertstimulusframes(picture.bluecircle, values.onset)}};
    {if(list.NTselect == 5 || list.NTselect == 6)
    {values.txpos = 25; values.sxpos = 75;
         trial.0backNT.insertstimulusframes(picture.bluetriangle, values.onset);
        trial.0backNT.insertstimulusframes(picture.bluesquare, values.onset)}};
    {if(list.NTselect == 7 || list.NTselect == 8)
    {values.txpos = 25; values.cxpos = 75;
         trial.0backNT.insertstimulusframes(picture.bluetriangle, values.onset);
        trial.0backNT.insertstimulusframes(picture.bluecircle, values.onset)}};
    {if(list.NTselect == 9 || list.NTselect == 10)
    {values.cxpos = 25; values.txpos = 75;
         trial.0backNT.insertstimulusframes(picture.bluecircle, values.onset);
        trial.0backNT.insertstimulusframes(picture.bluetriangle, values.onset)}};
    {if(list.NTselect == 11 || list.NTselect == 12)
    {values.cxpos = 25; values.sxpos = 75;
         trial.0backNT.insertstimulusframes(picture.bluecircle, values.onset);
        trial.0backNT.insertstimulusframes(picture.bluesquare, values.onset)}};
    
    trial.0backNT.insertstimulustime(shape.eraser, parameters.stimulusPresentationtime);                                 eraser to cover stimuli after stimuluspresentationtime
    
    list.NTselect.nextvalue;                                                                                                                                     moves list to next value for next trial
    
    ]
/ontrialend = [
    trial.0backNT.resetstimulusframes();
    
]
/ beginresponsetime = 0
/ trialduration = parameters.SOA

</trial>

<trial 0backtarget>
/ validresponse = (30, 38, noresponse)
/ isvalidresponse = [ if(trial.0backtarget.response == 30 || trial.0backtarget.response == 38)                                                    In target trial,  participants must respond with 'a' for left
                    {                                                                                                                                                                                and 'l' for right. Attempted to use list.Tselect with if 
                        values.response = trial.0backtarget.response                                                                                                      expressions to index which response is correct and which 
                        values.latency = trial.0backtarget.latency;                                                                                                          shapes to present. 
                    }]
/ correctresponse = (        if(list.Tselect == 1) {30};
                            else if(list.Tselect == 2) {38};
                            else if(list.Tselect == 3) {30};
                            else if(list.Tselect == 4) {38};
                            else if(list.Tselect == 5) {30};
                            else if(list.Tselect == 6) {38};
                            else if(list.Tselect == 7) {30};
                            else if(list.Tselect == 8) {38};
                            else if(list.Tselect == 9) {30};
                            else if(list.Tselect == 10) {38};
                            else if(list.Tselect == 11) {30};
                            else(list.Tselect == 12) {38};
                            )
/ ontrialbegin = [
    {if(list.Tselect == 1) {values.sxpos = 25; values.txpos = 75;
    trial.0backtarget.insertstimulusframes(picture.bluesquare, values.onset);
    trial.0backtarget.insertstimulusframes(picture.bluetriangle, values.onset);
    trial.0backtarget.insertstimulusframe(picture.lilbsquare, values.onset)}};
    {if(list.Tselect == 2) {values.sxpos = 25; values.txpos = 75;
    trial.0backtarget.insertstimulusframes(picture.bluesquare, values.onset);
    trial.0backtarget.insertstimulusframes(picture.bluetriangle, values.onset);
    trial.0backtarget.insertstimulusframe(picture.lilbtriangle, values.onset)}};
    {if(list.Tselect == 3) {values.sxpos = 25; values.cxpos = 75;
    trial.0backtarget.insertstimulusframes(picture.bluesquare, values.onset);
    trial.0backtarget.insertstimulusframes(picture.bluecircle, values.onset);
    trial.0backtarget.insertstimulusframe(picture.lilbsquare, values.onset)}};
    {if(list.Tselect == 4) {values.sxpos = 25; values.cxpos = 75;
    trial.0backtarget.insertstimulusframes(picture.bluesquare, values.onset);
    trial.0backtarget.insertstimulusframes(picture.bluecircle, values.onset);
    trial.0backtarget.insertstimulusframe(picture.lilbcircle, values.onset)}};
    {if(list.Tselect == 5) {values.txpos = 25; values.sxpos = 75;
    trial.0backtarget.insertstimulusframes(picture.bluetriangle, values.onset);
    trial.0backtarget.insertstimulusframes(picture.bluesquare, values.onset);
    trial.0backtarget.insertstimulusframe(picture.lilbtriangle, values.onset)}};
    {if(list.Tselect == 6) {values.txpos = 25; values.sxpos = 75;
    trial.0backtarget.insertstimulusframes(picture.bluetriangle, values.onset);
    trial.0backtarget.insertstimulusframes(picture.bluesquare, values.onset);
    trial.0backtarget.insertstimulusframe(picture.lilbsquare, values.onset)}};
    {if(list.Tselect == 7) {values.txpos = 25; values.cxpos = 75;
    trial.0backtarget.insertstimulusframes(picture.bluetriangle, values.onset);
    trial.0backtarget.insertstimulusframes(picture.bluecircle, values.onset);
    trial.0backtarget.insertstimulusframe(picture.lilbtriangle, values.onset)}};
    {if(list.Tselect == 8) {values.txpos = 25; values.cxpos = 75;
    trial.0backtarget.insertstimulusframes(picture.bluetriangle, values.onset);
    trial.0backtarget.insertstimulusframes(picture.bluecircle, values.onset);
    trial.0backtarget.insertstimulusframe(picture.lilbcircle, values.onset)}};
    {if(list.Tselect == 9) {values.cxpos = 25; values.txpos = 75;
    trial.0backtarget.insertstimulusframes(picture.bluecircle, values.onset);
    trial.0backtarget.insertstimulusframes(picture.bluetriangle, values.onset);
    trial.0backtarget.insertstimulusframe(picture.lilbcircle, values.onset)}};
    {if(list.Tselect == 10) {values.cxpos = 25; values.txpos = 75;
    trial.0backtarget.insertstimulusframes(picture.bluecircle, values.onset);
    trial.0backtarget.insertstimulusframes(picture.bluetriangle, values.onset);
    trial.0backtarget.insertstimulusframe(picture.lilbtriangle, values.onset)}};
    {if(list.Tselect == 11) {values.cxpos = 25; values.sxpos = 75;
    trial.0backtarget.insertstimulusframes(picture.bluecircle, values.onset);
    trial.0backtarget.insertstimulusframes(picture.bluesquare, values.onset);
    trial.0backtarget.insertstimulusframe(picture.lilbcircle, values.onset)}};
    {if(list.Tselect == 12) {values.cxpos = 25; values.sxpos = 75;
    trial.0backtarget.insertstimulusframes(picture.bluecircle, values.onset);
    trial.0backtarget.insertstimulusframes(picture.bluesquare, values.onset);
    trial.0backtarget.insertstimulusframe(picture.lilbsquare, values.onset)}};
    
    trial.0backTarget.insertstimulustime(shape.eraser, parameters.stimulusPresentationtime);

    list.Tselect.nextvalue;
    
    
]
/ontrialend = [
        trial.0backtarget.resetstimulusframes();
        

]

/ beginresponsetime = 0
/ trialduration = parameters.SOA
</trial>

<trial 1backNT>                                                                                                                                           trial.1backNT is very simmilar to trial.0backNT but stimuli is red. 
/stimulusframes = [0 = Rfixline]                                                                                                                   
/validresponse = (noresponse)
/ correctresponse = (noresponse)
/ ontrialbegin = [
    {if(list.NTselect == 1 || list.NTselect == 2)
        {values.sxpos = 25; values.txpos = 75;
        trial.1backNT.insertstimulusframes(picture.redsquare, values.onset);
        trial.1backNT.insertstimulusframes(picture.redtriangle, values.onset);};};
     {if(list.NTselect == 3 || list.NTselect == 4)
     {values.sxpos = 25; values.cxpos = 75;
         trial.1backNT.insertstimulusframes(picture.redsquare, values.onset);
        trial.1backNT.insertstimulusframes(picture.redcircle, values.onset);};};
    {if(list.NTselect == 5 || list.NTselect == 6)
    {values.txpos = 25; values.sxpos = 75;
         trial.1backNT.insertstimulusframes(picture.redtriangle, values.onset);
        trial.1backNT.insertstimulusframes(picture.redsquare, values.onset);};};
    {if(list.NTselect == 7 || list.NTselect == 8)
    {values.txpos = 25; values.cxpos = 75;
         trial.1backNT.insertstimulusframes(picture.redtriangle, values.onset);
        trial.1backNT.insertstimulusframes(picture.redcircle, values.onset);};};
    {if(list.NTselect == 9 || list.NTselect == 10)
    {values.cxpos = 25; values.txpos = 75;
         trial.1backNT.insertstimulusframes(picture.redcircle, values.onset);
        trial.1backNT.insertstimulusframes(picture.redtriangle, values.onset);};};
    {if(list.NTselect == 11 || list.NTselect == 12)
    {values.cxpos = 25; values.sxpos = 75;
         trial.1backNT.insertstimulusframes(picture.redcircle, values.onset);
        trial.1backNT.insertstimulusframes(picture.redsquare, values.onset);};};
    
    trial.1backNT.insertstimulustime(shape.eraser, parameters.stimulusPresentationtime);
    
    
    if (values.N > 0){
    values.currenttarget = list.target.item(values.N);};                                                                               code which keeps track of each trial as it is presented so that when a 
                                                                                                                                                               trial.1backtarget is presented it will present the correct shape in the middle and 
        list.NTselect.nextvalue;                                                                                                                   have the correct response. 

    ]
/ ontrialend = [
            trial.1backNT.resetstimulusframes();
            values.lastitem = list.NTselect.currentvalue;
            list.target.insertitem(values.lastitem, 1);

]
/ beginresponsetime = 0
/ trialduration = parameters.SOA
</trial>

<trial 1backtarget>
/validresponse = (30, 38, noresponse)
/isvalidresponse = [if(trial.1backtarget.response == 30 || trial.1backtarget.response == 38)
                    {
                        values.response = trial.1backtarget.response
                        values.latency = trial.1backtarget.latency;
                    }]
/ correctresponse = (        {if(list.Tselect == 1) 30};
                            {if(list.Tselect == 2) 38};
                            {if(list.Tselect == 3) 30};
                            {if(list.Tselect == 4) 38};
                            {if(list.Tselect == 5) 30};
                            {if(list.Tselect == 6) 38};
                            {if(list.Tselect == 7) 30};
                            {if(list.Tselect == 8) 38};
                            {if(list.Tselect == 9) 30};
                            {if(list.Tselect == 10) 38};
                            {if(list.Tselect == 11) 30};
                            {if(list.Tselect == 12) 38};
                            )
/ ontrialbegin = [
    {if(list.1Tselect == 1) {values.sxpos = 25; values.txpos = 75;
    trial.1backtarget.insertstimulusframes(picture.redsquare, values.onset);
    trial.1backtarget.insertstimulusframes(picture.redtriangle, values.onset)}};
    {if(list.1Tselect == 2) {values.sxpos = 25; values.txpos = 75;
    trial.1backtarget.insertstimulusframes(picture.redsquare, values.onset);
    trial.1backtarget.insertstimulusframes(picture.redtriangle, values.onset)}};
    {if(list.1Tselect == 3) {values.sxpos = 25; values.cxpos = 75;
    trial.1backtarget.insertstimulusframes(picture.redsquare, values.onset);
    trial.1backtarget.insertstimulusframes(picture.redcircle, values.onset)}};
    {if(list.1Tselect == 4) {values.sxpos = 25; values.cxpos = 75;
    trial.1backtarget.insertstimulusframes(picture.redsquare, values.onset);
    trial.1backtarget.insertstimulusframes(picture.redcircle, values.onset)}};
    {if(list.1Tselect == 5) {values.txpos = 25; values.sxpos = 75;
    trial.1backtarget.insertstimulusframes(picture.redtriangle, values.onset);
    trial.1backtarget.insertstimulusframes(picture.redsquare, values.onset)}};
    {if(list.1Tselect == 6) {values.txpos = 25; values.sxpos = 75;
    trial.1backtarget.insertstimulusframes(picture.redtriangle, values.onset);
    trial.1backtarget.insertstimulusframes(picture.redsquare, values.onset)}};
    {if(list.1Tselect == 7) {values.txpos = 25; values.cxpos = 75;
    trial.1backtarget.insertstimulusframes(picture.redtriangle, values.onset);
    trial.1backtarget.insertstimulusframes(picture.redcircle, values.onset)}};
    {if(list.1Tselect == 8) {values.txpos = 25; values.cxpos = 75;
    trial.1backtarget.insertstimulusframes(picture.redtriangle, values.onset);
    trial.1backtarget.insertstimulusframes(picture.redcircle, values.onset)}};
    {if(list.1Tselect == 9) {values.cxpos = 25; values.txpos = 75;
    trial.1backtarget.insertstimulusframes(picture.redcircle, values.onset);
    trial.1backtarget.insertstimulusframes(picture.redtriangle, values.onset)}};
    {if(list.1Tselect == 10) {values.cxpos = 25; values.txpos = 75;
    trial.1backtarget.insertstimulusframes(picture.redcircle, values.onset);
    trial.1backtarget.insertstimulusframes(picture.redtriangle, values.onset)}};
    {if(list.1Tselect == 11) {values.cxpos = 25; values.sxpos = 75;
    trial.1backtarget.insertstimulusframes(picture.redcircle, values.onset);
    trial.1backtarget.insertstimulusframes(picture.redsquare, values.onset)}};
    {if(list.1Tselect == 12) {values.cxpos = 25; values.sxpos = 75;
    trial.1backtarget.insertstimulusframes(picture.redcircle, values.onset);
    trial.1backtarget.insertstimulusframes(picture.redsquare, values.onset)}};
    
    
    trial.1backTarget.insertstimulustime(shape.eraser, parameters.stimulusPresentationtime);
    
    if (values.N > 0){
    values.currenttarget = list.target.item(values.N);};
    list.1Tselect.nextvalue;

]
/ontrialend = [
        trial.1backtarget.resetstimulusframes();
        
        values.lastitem = list.1Tselect.currentvalue;
        list.target.insertitem(values.lastitem, 1);

]

/ beginresponsetime = 0
/ trialduration = parameters.SOA
</trial>

**************************************************************************************************************
**************************************************************************************************************
    BLOCKS
**************************************************************************************************************
**************************************************************************************************************

****************************Instruction blocks****************************************************************









*****************************EXP blocks***********************************************************************

<block 0back>
/ onblockbegin = [
    list.target.reset();
    values.lastIndex = 1;
    expressions.filllist;
    
    values.TotalBlocks += 1;
    values.starttrialcounter = 0;
    values.currenttarget = 0;
    values.v_Hits = 0;
    values.v_FalseA = 0;
    values.v_Misses = 0;
    values.v_CorrReject = 0;
    
]
/ trials = [1 - 20 = noreplace(0backNT, 0backNT, 0backNT, 0backtarget)]
/ onblockend = [

] record data here
/ screencolor = (0, 0, 0)
</block>

<block 1back>
/ onblockbegin = [
    list.target.reset();
    values.lastIndex = 1;
    expressions.filllist;
    
    values.TotalBlocks += 1;
    values.starttrialcounter = 0;
    values.currenttarget = 0;
    values.v_Hits = 0;
    values.v_FalseA = 0;
    values.v_Misses = 0;
    values.v_CorrReject = 0;
    
]
/ trials = [1 - 20 = noreplace(1backNT, 1backNT, 1backNT, 1backtarget)]
/ onblockend = [

] record data here
/ screencolor = (0, 0, 0)
</block>

**************************************************************************************************************
**************************************************************************************************************
    EXPERIMENT
**************************************************************************************************************
**************************************************************************************************************
<expt>
/ blocks = [
    1 = 0back;
    2 = 1back;
    3 = 0back;
    4 = 1back;
]
/onexptend = [values.completed = 1]
</expt>



The code still has a lot of errors that I can go through and fix. But if you could please help me work out the correct syntax and logic for telling inquisit to update the shapes and correct response per trial, and also to keep track of the previous trial in the 1-back condition in order to present the correct middle shape and list the correct response then that would be super helpful. Thankyou!

Dave
Dave
Supreme Being (911K reputation)Supreme Being (911K reputation)Supreme Being (911K reputation)Supreme Being (911K reputation)Supreme Being (911K reputation)Supreme Being (911K reputation)Supreme Being (911K reputation)Supreme Being (911K reputation)Supreme Being (911K reputation)
Group: Administrators
Posts: 11K, Visits: 65K
mindwanderingjeremy - 2/4/2021
Okay sorry, I thought posting the whole code in here would be too large. So I am coding an n-back task with 0-back and 1-back conditions. The N-back task will require participants to report whether a target shape (presented in the middle of the screen) is/was presented on the left or the right in 0-back (the current trial) or 1-back (the previous trial) conditions. There will also be non-target trials in each condition where participants do not have to make any response. 
This is my first time coding in inquisit so I am not yet finished the code. I am just trying to get the stimulus presentation and responses to work first before I code all of the data recording etc. So the code only includes the necessary elements for presenting stimuli in each condition.  I have also not coded any instructions yet. 


**************************************************************************************************************
**************************************************************************************************************
    EDITABLE PARAMETERS: change editable parameters here
**************************************************************************************************************
**************************************************************************************************************

<parameters>
/runPractice = true
/Debugmode = 0
/stimulusPresentationtime = 500
/SOA = 3000
</parameters>

**************************************************************************************************************
**************************************************************************************************************
    EDITABLE STIMULI: change editable stimuli here
**************************************************************************************************************
**************************************************************************************************************

<item bluesquare>
/1 = "blueSquare.gif"
</item>

<item bluetriangle>
/1= "blueTriangle.gif"
</item>

<item bluecircle>
/1= "blueCircle.gif"
</item>

<item redsquare>
/1 = "redSquare.gif"
</item>

<item redtriangle>
/1= "redTriangle.gif"
</item>

<item redcircle>
/1= "redCircle.gif"
</item>
**************************************************************************************************************
**************************************************************************************************************
    EDITABLE INSTRUCTIONS: change instructions here
**************************************************************************************************************
**************************************************************************************************************
***********INSTRUCTION SLIDES*****************************


**************************************************************************************************************
**************************************************************************************************************
    Editable Lists
**************************************************************************************************************
**************************************************************************************************************


**************************************************************************************************************
**************************************************************************************************************
    DEFAULTS
**************************************************************************************************************
**************************************************************************************************************

<defaults>
/canvasaspectratio = (4,3)
/minimumversion = "5.0.5.0"
/ fontstyle = ("Arial", 3%, false, false, false, false, 5, 1)
/txbgcolor = white
/ txcolor = (0, 0, 0)
/ screencolor = black
</defaults>


**************************************************************************************************************
**************************************************************************************************************
    VALUES: automatically updated
**************************************************************************************************************
**************************************************************************************************************
            
/completed:                0 = script was not completed (script was prematurely aborted); 1 = script was completed (all conditions run)

v_position:                contains the position of the current square
                            (1 = (25, 25), 2 = (50, 25), 3 = (75, 25), 4 = (25, 50), 5 = (75, 50), 6 = (25, 75), 7 = (50, 75), 8 = (75, 75))
N:                            the trial lag between a target and the stimulus it repeats
v_currenttarget:        contains the position of the current target square
                            (a target in N = 0 trials is a stimulus with the same stimulus number as stored in target0)
v_Hits:                    codes the number of correctly identifiying a square target
v_FalseA:                codes the number of times a participant identifies a square non-target as a square target
v_Misses:                codes the number of times a participant misses to identify a square target
v_CorrReject:            codes the number of times a participant correctly identifies a square non-target (and does nothing)
1response:                 codes the first response (if any)
2response:                codes the second response (if any)
1latency :                codes the latency (if any) of the first response
2latency     :                codes the latency (if any) of the second response
latency:                    contains trial latency data, stores the latency of the last given response (if any)
v_TotalHits:                the number of total hits across all experimental blocks for the visual modality
v_TotalFA:                the number of total false alarms across all experimental blocks for the visual modality
TotalBlocks:                the total number of experimental blocks run
DV:                        the dependent variable in Jaeggi et al (2010): the proportion of (((v_TotalHits - v_TotalFA) + (a_TotalHits - a_TotalFA))/2) /number of total blocks
startcounter:            counts the number of start trials run
repetitioncounter:    keeps track of the number of experimental blocks run on a level of N

<values >
/completed = 0

/stim = ""
/stimnumber = 0
/N = 1
/currenttarget = 0                     keeps track of current target for N-back 
/v_Hits = 0
/v_FalseA = 0
/v_Misses = 0
/v_CorrReject = 0
/sxpos = 0                                 square xposition updated in trials
/cxpos = 0                                 circle xposition updated in trials
/txpos = 0                                 triangle xposition updated in trials
/response = 0
/latency = 0
/v_TotalFA = 0
/v_TotalHits = 0
/TotalBlocks = 0
/DV = 0
/starttrialcounter = 0
/repetitioncounter = 0
/trial_Hitv = 0
/trial_Missv = 0
/trial_CRv = 0
/trial_FAv = 0
/trial_Hita = 0
/trial_Missa = 0
/trial_CRa = 0
/trial_FAa = 0
/onset = 0

/lastIndex = 0
/lastitem = ""
</values>

**************************************************************************************************************
**************************************************************************************************************
    EXPRESSIONS
**************************************************************************************************************
**************************************************************************************************************

/filllist:                recursive function that fills list.target with N items at the beginning of each new block

<expressions>
/filllist = {
    if (values.lastIndex < values.N){
        list.target.insertitem(0, 1);
        values.lastIndex += 1;
        expressions.filllist;
    } else {
        list.target.insertitem(0, 1);
    };
</expressions>

**************************************************************************************************************
**************************************************************************************************************
    INSTRUCTIONS
**************************************************************************************************************
**************************************************************************************************************
*********************INSTRUCTION IMAGE SELECTION********************************************************


********************INSTRUCTION TRIALS****************************************************************


**************************************************************************************************************
**************************************************************************************************************
    STIMULI
**************************************************************************************************************
**************************************************************************************************************

<picture bluesquare>
/items = bluesquare
/select = 1
/ position = (values.sxpos, 50)
/ size = (25%, 25%)
/ transparentcolor = black
</picture>

<picture lilbsquare>
/items = bluesquare
/select = 1
/ position = (50, 50)
/ size = (5%, 5%)
/ transparentcolor = black
</picture>

<picture bluetriangle>
/items = bluetriangle
/select = 1
/ position = (values.txpos, 50)
/ size = (25%, 25%)
/ transparentcolor = black
</picture>

<picture lilbtriangle>
/items = bluetriangle
/select = 1
/ position = (50, 50)
/ size = (5%, 5%)
/ transparentcolor = black
</picture>

<picture bluecircle>
/items = bluecircle
/select = 1
/ position = (values.cxpos, 50)
/ size = (25%, 25%)
/ transparentcolor = black
</picture>

<picture lilbcircle>
/items = bluecircle
/select = 1
/ position = (50, 50)
/ size = (5%, 5%)
/ transparentcolor = black
</picture>

<picture redsquare>
/items = redsquare
/select = 1
/ position = (values.sxpos, 50)
/ size = (25%, 25%)
/ transparentcolor = black
</picture>

<picture lilrsquare>
/items = redsquare
/select = 1
/ position = (50, 50)
/ size = (5%, 5%)
/ transparentcolor = black
</picture>

<picture redtriangle>
/items = redtriangle
/select = 1
/ position = (values.txpos, 50)
/ size = (25%, 25%)
/ transparentcolor = black
</picture>

<picture lilrtriangle>
/items = redtriangle
/select = 1
/ position = (50, 50)
/ size = (5%, 5%)
/ transparentcolor = black
</picture>

<picture redcircle>
/items = redcircle
/select = 1
/ position = (values.cxpos, 50)
/ size = (25%, 25%)
/ transparentcolor = black
</picture>

<picture lilrcircle>
/items = redcircle
/select = 1
/ position = (50, 50)
/ size = (5%, 5%)
/ transparentcolor = black
</picture>

****************************
ASSISTANT STIMULI
****************************

*****acts as an eraser after showing the key stimuli for 500ms, staying on for the remainder of the 3000ms dedicated to each trial
<shape eraser>
/ shape = rectangle
/ size = (30%, 30%)
/ color = black
/ position = (values.xpos, values.ypos)
</shape>
=
*****fixation lines
<text Bfixline>
/items = ("|")
/position = (50%, 50%)
/size = (15%, 15%)
/txcolor = blue
</text>

<text Rfixline>
/items = ("|")
/position = (50%, 50%)
/size = (15%, 15%)
/txcolor = red
</text>

********
Selection Lists
<list target>                                                                   automatically filled by expression.filllist
</list>

<list NTselect>                                                             list to index all options of shape presentations in non-target trials
/items = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)
/replace = true
/selectionmode = random
/selectionrate = trial
</list>
 
<list Tselect>                                                               list to index all options of shape presentations and correct responses in target trials
/items = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)
/replace = true
/selectionmode = random
/selectionrate = trial
</list>

<list 1Tselect>                                                            list to select previous trial as current target for shape presentations and correct responses in 1-back trials, selected by current target 
/items = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)
/replace = true
/selectionmode = values.currenttarget
/selectionrate = trial
</list>


**************************************************************************************************************
**************************************************************************************************************
    Trials    
**************************************************************************************************************
**************************************************************************************************************
<trial 0backNT>
/stimulusframes = [0 = Bfixline]                                                                                  In non-target trials I want to present a fixation line between the two shapes. No response
/validresponse = (noresponse)                                                                                    required.
/ correctresponse = (noresponse)
/ ontrialbegin = [
    {if(list.NTselect == 1 || list.NTselect == 2)                                                                       Attempt to use NTselect list to update which shapes are presented and their location on the
        {values.sxpos = 25; values.txpos = 75;                                                                       screen
        trial.0backNT.insertstimulusframes(picture.bluesquare, values.onset);
        trial.0backNT.insertstimulusframes(picture.bluetriangle, values.onset)}};
     {if(list.NTselect == 3 || list.NTselect == 4)
     {values.sxpos = 25; values.cxpos = 75;
         trial.0backNT.insertstimulusframes(picture.bluesquare, values.onset);
        trial.0backNT.insertstimulusframes(picture.bluecircle, values.onset)}};
    {if(list.NTselect == 5 || list.NTselect == 6)
    {values.txpos = 25; values.sxpos = 75;
         trial.0backNT.insertstimulusframes(picture.bluetriangle, values.onset);
        trial.0backNT.insertstimulusframes(picture.bluesquare, values.onset)}};
    {if(list.NTselect == 7 || list.NTselect == 8)
    {values.txpos = 25; values.cxpos = 75;
         trial.0backNT.insertstimulusframes(picture.bluetriangle, values.onset);
        trial.0backNT.insertstimulusframes(picture.bluecircle, values.onset)}};
    {if(list.NTselect == 9 || list.NTselect == 10)
    {values.cxpos = 25; values.txpos = 75;
         trial.0backNT.insertstimulusframes(picture.bluecircle, values.onset);
        trial.0backNT.insertstimulusframes(picture.bluetriangle, values.onset)}};
    {if(list.NTselect == 11 || list.NTselect == 12)
    {values.cxpos = 25; values.sxpos = 75;
         trial.0backNT.insertstimulusframes(picture.bluecircle, values.onset);
        trial.0backNT.insertstimulusframes(picture.bluesquare, values.onset)}};
    
    trial.0backNT.insertstimulustime(shape.eraser, parameters.stimulusPresentationtime);                                 eraser to cover stimuli after stimuluspresentationtime
    
    list.NTselect.nextvalue;                                                                                                                                     moves list to next value for next trial
    
    ]
/ontrialend = [
    trial.0backNT.resetstimulusframes();
    
]
/ beginresponsetime = 0
/ trialduration = parameters.SOA

</trial>

<trial 0backtarget>
/ validresponse = (30, 38, noresponse)
/ isvalidresponse = [ if(trial.0backtarget.response == 30 || trial.0backtarget.response == 38)                                                    In target trial,  participants must respond with 'a' for left
                    {                                                                                                                                                                                and 'l' for right. Attempted to use list.Tselect with if 
                        values.response = trial.0backtarget.response                                                                                                      expressions to index which response is correct and which 
                        values.latency = trial.0backtarget.latency;                                                                                                          shapes to present. 
                    }]
/ correctresponse = (        if(list.Tselect == 1) {30};
                            else if(list.Tselect == 2) {38};
                            else if(list.Tselect == 3) {30};
                            else if(list.Tselect == 4) {38};
                            else if(list.Tselect == 5) {30};
                            else if(list.Tselect == 6) {38};
                            else if(list.Tselect == 7) {30};
                            else if(list.Tselect == 8) {38};
                            else if(list.Tselect == 9) {30};
                            else if(list.Tselect == 10) {38};
                            else if(list.Tselect == 11) {30};
                            else(list.Tselect == 12) {38};
                            )
/ ontrialbegin = [
    {if(list.Tselect == 1) {values.sxpos = 25; values.txpos = 75;
    trial.0backtarget.insertstimulusframes(picture.bluesquare, values.onset);
    trial.0backtarget.insertstimulusframes(picture.bluetriangle, values.onset);
    trial.0backtarget.insertstimulusframe(picture.lilbsquare, values.onset)}};
    {if(list.Tselect == 2) {values.sxpos = 25; values.txpos = 75;
    trial.0backtarget.insertstimulusframes(picture.bluesquare, values.onset);
    trial.0backtarget.insertstimulusframes(picture.bluetriangle, values.onset);
    trial.0backtarget.insertstimulusframe(picture.lilbtriangle, values.onset)}};
    {if(list.Tselect == 3) {values.sxpos = 25; values.cxpos = 75;
    trial.0backtarget.insertstimulusframes(picture.bluesquare, values.onset);
    trial.0backtarget.insertstimulusframes(picture.bluecircle, values.onset);
    trial.0backtarget.insertstimulusframe(picture.lilbsquare, values.onset)}};
    {if(list.Tselect == 4) {values.sxpos = 25; values.cxpos = 75;
    trial.0backtarget.insertstimulusframes(picture.bluesquare, values.onset);
    trial.0backtarget.insertstimulusframes(picture.bluecircle, values.onset);
    trial.0backtarget.insertstimulusframe(picture.lilbcircle, values.onset)}};
    {if(list.Tselect == 5) {values.txpos = 25; values.sxpos = 75;
    trial.0backtarget.insertstimulusframes(picture.bluetriangle, values.onset);
    trial.0backtarget.insertstimulusframes(picture.bluesquare, values.onset);
    trial.0backtarget.insertstimulusframe(picture.lilbtriangle, values.onset)}};
    {if(list.Tselect == 6) {values.txpos = 25; values.sxpos = 75;
    trial.0backtarget.insertstimulusframes(picture.bluetriangle, values.onset);
    trial.0backtarget.insertstimulusframes(picture.bluesquare, values.onset);
    trial.0backtarget.insertstimulusframe(picture.lilbsquare, values.onset)}};
    {if(list.Tselect == 7) {values.txpos = 25; values.cxpos = 75;
    trial.0backtarget.insertstimulusframes(picture.bluetriangle, values.onset);
    trial.0backtarget.insertstimulusframes(picture.bluecircle, values.onset);
    trial.0backtarget.insertstimulusframe(picture.lilbtriangle, values.onset)}};
    {if(list.Tselect == 8) {values.txpos = 25; values.cxpos = 75;
    trial.0backtarget.insertstimulusframes(picture.bluetriangle, values.onset);
    trial.0backtarget.insertstimulusframes(picture.bluecircle, values.onset);
    trial.0backtarget.insertstimulusframe(picture.lilbcircle, values.onset)}};
    {if(list.Tselect == 9) {values.cxpos = 25; values.txpos = 75;
    trial.0backtarget.insertstimulusframes(picture.bluecircle, values.onset);
    trial.0backtarget.insertstimulusframes(picture.bluetriangle, values.onset);
    trial.0backtarget.insertstimulusframe(picture.lilbcircle, values.onset)}};
    {if(list.Tselect == 10) {values.cxpos = 25; values.txpos = 75;
    trial.0backtarget.insertstimulusframes(picture.bluecircle, values.onset);
    trial.0backtarget.insertstimulusframes(picture.bluetriangle, values.onset);
    trial.0backtarget.insertstimulusframe(picture.lilbtriangle, values.onset)}};
    {if(list.Tselect == 11) {values.cxpos = 25; values.sxpos = 75;
    trial.0backtarget.insertstimulusframes(picture.bluecircle, values.onset);
    trial.0backtarget.insertstimulusframes(picture.bluesquare, values.onset);
    trial.0backtarget.insertstimulusframe(picture.lilbcircle, values.onset)}};
    {if(list.Tselect == 12) {values.cxpos = 25; values.sxpos = 75;
    trial.0backtarget.insertstimulusframes(picture.bluecircle, values.onset);
    trial.0backtarget.insertstimulusframes(picture.bluesquare, values.onset);
    trial.0backtarget.insertstimulusframe(picture.lilbsquare, values.onset)}};
    
    trial.0backTarget.insertstimulustime(shape.eraser, parameters.stimulusPresentationtime);

    list.Tselect.nextvalue;
    
    
]
/ontrialend = [
        trial.0backtarget.resetstimulusframes();
        

]

/ beginresponsetime = 0
/ trialduration = parameters.SOA
</trial>

<trial 1backNT>                                                                                                                                           trial.1backNT is very simmilar to trial.0backNT but stimuli is red. 
/stimulusframes = [0 = Rfixline]                                                                                                                   
/validresponse = (noresponse)
/ correctresponse = (noresponse)
/ ontrialbegin = [
    {if(list.NTselect == 1 || list.NTselect == 2)
        {values.sxpos = 25; values.txpos = 75;
        trial.1backNT.insertstimulusframes(picture.redsquare, values.onset);
        trial.1backNT.insertstimulusframes(picture.redtriangle, values.onset);};};
     {if(list.NTselect == 3 || list.NTselect == 4)
     {values.sxpos = 25; values.cxpos = 75;
         trial.1backNT.insertstimulusframes(picture.redsquare, values.onset);
        trial.1backNT.insertstimulusframes(picture.redcircle, values.onset);};};
    {if(list.NTselect == 5 || list.NTselect == 6)
    {values.txpos = 25; values.sxpos = 75;
         trial.1backNT.insertstimulusframes(picture.redtriangle, values.onset);
        trial.1backNT.insertstimulusframes(picture.redsquare, values.onset);};};
    {if(list.NTselect == 7 || list.NTselect == 8)
    {values.txpos = 25; values.cxpos = 75;
         trial.1backNT.insertstimulusframes(picture.redtriangle, values.onset);
        trial.1backNT.insertstimulusframes(picture.redcircle, values.onset);};};
    {if(list.NTselect == 9 || list.NTselect == 10)
    {values.cxpos = 25; values.txpos = 75;
         trial.1backNT.insertstimulusframes(picture.redcircle, values.onset);
        trial.1backNT.insertstimulusframes(picture.redtriangle, values.onset);};};
    {if(list.NTselect == 11 || list.NTselect == 12)
    {values.cxpos = 25; values.sxpos = 75;
         trial.1backNT.insertstimulusframes(picture.redcircle, values.onset);
        trial.1backNT.insertstimulusframes(picture.redsquare, values.onset);};};
    
    trial.1backNT.insertstimulustime(shape.eraser, parameters.stimulusPresentationtime);
    
    
    if (values.N > 0){
    values.currenttarget = list.target.item(values.N);};                                                                               code which keeps track of each trial as it is presented so that when a 
                                                                                                                                                               trial.1backtarget is presented it will present the correct shape in the middle and 
        list.NTselect.nextvalue;                                                                                                                   have the correct response. 

    ]
/ ontrialend = [
            trial.1backNT.resetstimulusframes();
            values.lastitem = list.NTselect.currentvalue;
            list.target.insertitem(values.lastitem, 1);

]
/ beginresponsetime = 0
/ trialduration = parameters.SOA
</trial>

<trial 1backtarget>
/validresponse = (30, 38, noresponse)
/isvalidresponse = [if(trial.1backtarget.response == 30 || trial.1backtarget.response == 38)
                    {
                        values.response = trial.1backtarget.response
                        values.latency = trial.1backtarget.latency;
                    }]
/ correctresponse = (        {if(list.Tselect == 1) 30};
                            {if(list.Tselect == 2) 38};
                            {if(list.Tselect == 3) 30};
                            {if(list.Tselect == 4) 38};
                            {if(list.Tselect == 5) 30};
                            {if(list.Tselect == 6) 38};
                            {if(list.Tselect == 7) 30};
                            {if(list.Tselect == 8) 38};
                            {if(list.Tselect == 9) 30};
                            {if(list.Tselect == 10) 38};
                            {if(list.Tselect == 11) 30};
                            {if(list.Tselect == 12) 38};
                            )
/ ontrialbegin = [
    {if(list.1Tselect == 1) {values.sxpos = 25; values.txpos = 75;
    trial.1backtarget.insertstimulusframes(picture.redsquare, values.onset);
    trial.1backtarget.insertstimulusframes(picture.redtriangle, values.onset)}};
    {if(list.1Tselect == 2) {values.sxpos = 25; values.txpos = 75;
    trial.1backtarget.insertstimulusframes(picture.redsquare, values.onset);
    trial.1backtarget.insertstimulusframes(picture.redtriangle, values.onset)}};
    {if(list.1Tselect == 3) {values.sxpos = 25; values.cxpos = 75;
    trial.1backtarget.insertstimulusframes(picture.redsquare, values.onset);
    trial.1backtarget.insertstimulusframes(picture.redcircle, values.onset)}};
    {if(list.1Tselect == 4) {values.sxpos = 25; values.cxpos = 75;
    trial.1backtarget.insertstimulusframes(picture.redsquare, values.onset);
    trial.1backtarget.insertstimulusframes(picture.redcircle, values.onset)}};
    {if(list.1Tselect == 5) {values.txpos = 25; values.sxpos = 75;
    trial.1backtarget.insertstimulusframes(picture.redtriangle, values.onset);
    trial.1backtarget.insertstimulusframes(picture.redsquare, values.onset)}};
    {if(list.1Tselect == 6) {values.txpos = 25; values.sxpos = 75;
    trial.1backtarget.insertstimulusframes(picture.redtriangle, values.onset);
    trial.1backtarget.insertstimulusframes(picture.redsquare, values.onset)}};
    {if(list.1Tselect == 7) {values.txpos = 25; values.cxpos = 75;
    trial.1backtarget.insertstimulusframes(picture.redtriangle, values.onset);
    trial.1backtarget.insertstimulusframes(picture.redcircle, values.onset)}};
    {if(list.1Tselect == 8) {values.txpos = 25; values.cxpos = 75;
    trial.1backtarget.insertstimulusframes(picture.redtriangle, values.onset);
    trial.1backtarget.insertstimulusframes(picture.redcircle, values.onset)}};
    {if(list.1Tselect == 9) {values.cxpos = 25; values.txpos = 75;
    trial.1backtarget.insertstimulusframes(picture.redcircle, values.onset);
    trial.1backtarget.insertstimulusframes(picture.redtriangle, values.onset)}};
    {if(list.1Tselect == 10) {values.cxpos = 25; values.txpos = 75;
    trial.1backtarget.insertstimulusframes(picture.redcircle, values.onset);
    trial.1backtarget.insertstimulusframes(picture.redtriangle, values.onset)}};
    {if(list.1Tselect == 11) {values.cxpos = 25; values.sxpos = 75;
    trial.1backtarget.insertstimulusframes(picture.redcircle, values.onset);
    trial.1backtarget.insertstimulusframes(picture.redsquare, values.onset)}};
    {if(list.1Tselect == 12) {values.cxpos = 25; values.sxpos = 75;
    trial.1backtarget.insertstimulusframes(picture.redcircle, values.onset);
    trial.1backtarget.insertstimulusframes(picture.redsquare, values.onset)}};
    
    
    trial.1backTarget.insertstimulustime(shape.eraser, parameters.stimulusPresentationtime);
    
    if (values.N > 0){
    values.currenttarget = list.target.item(values.N);};
    list.1Tselect.nextvalue;

]
/ontrialend = [
        trial.1backtarget.resetstimulusframes();
        
        values.lastitem = list.1Tselect.currentvalue;
        list.target.insertitem(values.lastitem, 1);

]

/ beginresponsetime = 0
/ trialduration = parameters.SOA
</trial>

**************************************************************************************************************
**************************************************************************************************************
    BLOCKS
**************************************************************************************************************
**************************************************************************************************************

****************************Instruction blocks****************************************************************









*****************************EXP blocks***********************************************************************

<block 0back>
/ onblockbegin = [
    list.target.reset();
    values.lastIndex = 1;
    expressions.filllist;
    
    values.TotalBlocks += 1;
    values.starttrialcounter = 0;
    values.currenttarget = 0;
    values.v_Hits = 0;
    values.v_FalseA = 0;
    values.v_Misses = 0;
    values.v_CorrReject = 0;
    
]
/ trials = [1 - 20 = noreplace(0backNT, 0backNT, 0backNT, 0backtarget)]
/ onblockend = [

] record data here
/ screencolor = (0, 0, 0)
</block>

<block 1back>
/ onblockbegin = [
    list.target.reset();
    values.lastIndex = 1;
    expressions.filllist;
    
    values.TotalBlocks += 1;
    values.starttrialcounter = 0;
    values.currenttarget = 0;
    values.v_Hits = 0;
    values.v_FalseA = 0;
    values.v_Misses = 0;
    values.v_CorrReject = 0;
    
]
/ trials = [1 - 20 = noreplace(1backNT, 1backNT, 1backNT, 1backtarget)]
/ onblockend = [

] record data here
/ screencolor = (0, 0, 0)
</block>

**************************************************************************************************************
**************************************************************************************************************
    EXPERIMENT
**************************************************************************************************************
**************************************************************************************************************
<expt>
/ blocks = [
    1 = 0back;
    2 = 1back;
    3 = 0back;
    4 = 1back;
]
/onexptend = [values.completed = 1]
</expt>



The code still has a lot of errors that I can go through and fix. But if you could please help me work out the correct syntax and logic for telling inquisit to update the shapes and correct response per trial, and also to keep track of the previous trial in the 1-back condition in order to present the correct middle shape and list the correct response then that would be super helpful. Thankyou!

I asked you to please also provide any and all files the code requires to run. Could you please do that?

Note that you can attach files to a post via +Insert -> Add File, so it's not necessary to paste entire scripts into a post's body.

Thanks
mindwanderingjeremy
mindwanderingjeremy
New Member (44 reputation)New Member (44 reputation)New Member (44 reputation)New Member (44 reputation)New Member (44 reputation)New Member (44 reputation)New Member (44 reputation)New Member (44 reputation)New Member (44 reputation)
Group: Forum Members
Posts: 18, Visits: 38
Ah yes, great thats a lot easier thanks!
Attachments
redTriangle.gif (8 views, 77.00 KB)
redSquare.gif (7 views, 3.00 KB)
redCircle.gif (7 views, 100.00 KB)
blueTriangle.gif (8 views, 6.00 KB)
blueSquare.gif (7 views, 5.00 KB)
blueCircle.gif (7 views, 61.00 KB)
experiment.iqx (6 views, 27.00 KB)
Dave
Dave
Supreme Being (911K reputation)Supreme Being (911K reputation)Supreme Being (911K reputation)Supreme Being (911K reputation)Supreme Being (911K reputation)Supreme Being (911K reputation)Supreme Being (911K reputation)Supreme Being (911K reputation)Supreme Being (911K reputation)
Group: Administrators
Posts: 11K, Visits: 65K
mindwanderingjeremy - 2/4/2021
Ah yes, great thats a lot easier thanks!

Some explanations about what the code you have is actually supposed to do would be nice.

For example, this construct here is pretty unclear to me

<trial 0backNT>
...
/ ontrialbegin = [
    {if(list.NTselect == 1 || list.NTselect == 2)
...
</trial>

list.NTselect has no value, it does not sample any item from that list.

It's only after all that conditional logic that you actually sample an item from that list, here.

...
   {if(list.NTselect == 11 || list.NTselect == 12)
    {values.cxpos = 25; values.sxpos = 75;
         trial.0backNT.insertstimulusframes(picture.bluecircle, values.onset);
        trial.0backNT.insertstimulusframes(picture.bluesquare, values.onset)}};
    
    trial.0backNT.insertstimulustime(shape.eraser, parameters.stimulusPresentationtime);
    
    list.NTselect.nextvalue;
    
   ]

Why? Help me understand the reasoning here please, so I can tell you how to express it in correct syntax.

mindwanderingjeremy
mindwanderingjeremy
New Member (44 reputation)New Member (44 reputation)New Member (44 reputation)New Member (44 reputation)New Member (44 reputation)New Member (44 reputation)New Member (44 reputation)New Member (44 reputation)New Member (44 reputation)
Group: Forum Members
Posts: 18, Visits: 38
Dave - 2/4/2021
mindwanderingjeremy - 2/4/2021
Ah yes, great thats a lot easier thanks!

Some explanations about what the code you have is actually supposed to do would be nice.

For example, this construct here is pretty unclear to me

<trial 0backNT>
...
/ ontrialbegin = [
    {if(list.NTselect == 1 || list.NTselect == 2)
...
</trial>

list.NTselect has no value, it does not sample any item from that list.

It's only after all that conditional logic that you actually sample an item from that list, here.

...
   {if(list.NTselect == 11 || list.NTselect == 12)
    {values.cxpos = 25; values.sxpos = 75;
         trial.0backNT.insertstimulusframes(picture.bluecircle, values.onset);
        trial.0backNT.insertstimulusframes(picture.bluesquare, values.onset)}};
    
    trial.0backNT.insertstimulustime(shape.eraser, parameters.stimulusPresentationtime);
    
    list.NTselect.nextvalue;
    
   ]

Why? Help me understand the reasoning here please, so I can tell you how to express it in correct syntax.


I am attempting to tell the code to use certain conditions based on a number selected randomly from that list. I have 12 possible iterations of each trial type based on which shapes are presented on which side and which is the correct response. I thought that the list would automatically select a number given I have the list parameters set to random and select per trial. But I have no idea how to use inquisit code so I am merely guessing based on other experiments in the millisecond database how to do this.
mindwanderingjeremy
mindwanderingjeremy
New Member (44 reputation)New Member (44 reputation)New Member (44 reputation)New Member (44 reputation)New Member (44 reputation)New Member (44 reputation)New Member (44 reputation)New Member (44 reputation)New Member (44 reputation)
Group: Forum Members
Posts: 18, Visits: 38
Dave - 2/4/2021
mindwanderingjeremy - 2/4/2021
Dave - 2/4/2021
mindwanderingjeremy - 2/4/2021
Ah yes, great thats a lot easier thanks!

Some explanations about what the code you have is actually supposed to do would be nice.

For example, this construct here is pretty unclear to me

<trial 0backNT>
...
/ ontrialbegin = [
    {if(list.NTselect == 1 || list.NTselect == 2)
...
</trial>

list.NTselect has no value, it does not sample any item from that list.

It's only after all that conditional logic that you actually sample an item from that list, here.

...
   {if(list.NTselect == 11 || list.NTselect == 12)
    {values.cxpos = 25; values.sxpos = 75;
         trial.0backNT.insertstimulusframes(picture.bluecircle, values.onset);
        trial.0backNT.insertstimulusframes(picture.bluesquare, values.onset)}};
    
    trial.0backNT.insertstimulustime(shape.eraser, parameters.stimulusPresentationtime);
    
    list.NTselect.nextvalue;
    
   ]

Why? Help me understand the reasoning here please, so I can tell you how to express it in correct syntax.


I am attempting to tell the code to use certain conditions based on a number selected randomly from that list. I have 12 possible iterations of each trial type based on which shapes are presented on which side and which is the correct response. I thought that the list would automatically select a number given I have the list parameters set to random and select per trial. But I have no idea how to use inquisit code so I am merely guessing based on other experiments in the millisecond database how to do this.

Attached is a file with numerous syntax mistakes fixed, largely based on guesses.

Is this a joke?
Dave
Dave
Supreme Being (911K reputation)Supreme Being (911K reputation)Supreme Being (911K reputation)Supreme Being (911K reputation)Supreme Being (911K reputation)Supreme Being (911K reputation)Supreme Being (911K reputation)Supreme Being (911K reputation)Supreme Being (911K reputation)
Group: Administrators
Posts: 11K, Visits: 65K
mindwanderingjeremy - 2/4/2021
Dave - 2/4/2021
mindwanderingjeremy - 2/4/2021
Dave - 2/4/2021
mindwanderingjeremy - 2/4/2021
Ah yes, great thats a lot easier thanks!

Some explanations about what the code you have is actually supposed to do would be nice.

For example, this construct here is pretty unclear to me

<trial 0backNT>
...
/ ontrialbegin = [
    {if(list.NTselect == 1 || list.NTselect == 2)
...
</trial>

list.NTselect has no value, it does not sample any item from that list.

It's only after all that conditional logic that you actually sample an item from that list, here.

...
   {if(list.NTselect == 11 || list.NTselect == 12)
    {values.cxpos = 25; values.sxpos = 75;
         trial.0backNT.insertstimulusframes(picture.bluecircle, values.onset);
        trial.0backNT.insertstimulusframes(picture.bluesquare, values.onset)}};
    
    trial.0backNT.insertstimulustime(shape.eraser, parameters.stimulusPresentationtime);
    
    list.NTselect.nextvalue;
    
   ]

Why? Help me understand the reasoning here please, so I can tell you how to express it in correct syntax.


I am attempting to tell the code to use certain conditions based on a number selected randomly from that list. I have 12 possible iterations of each trial type based on which shapes are presented on which side and which is the correct response. I thought that the list would automatically select a number given I have the list parameters set to random and select per trial. But I have no idea how to use inquisit code so I am merely guessing based on other experiments in the millisecond database how to do this.

Attached is a file with numerous syntax mistakes fixed, largely based on guesses.

Is this a joke?

How do you mean
mindwanderingjeremy
mindwanderingjeremy
New Member (44 reputation)New Member (44 reputation)New Member (44 reputation)New Member (44 reputation)New Member (44 reputation)New Member (44 reputation)New Member (44 reputation)New Member (44 reputation)New Member (44 reputation)
Group: Forum Members
Posts: 18, Visits: 38
Look Dave, I understand it may be frustrating for you when someone is unclear about what theyre asking. I am trying my best to be as clear as possible given my complete lack of understanding of how inquisit works. I am attempting to learn this code on the fly to get an experiment running with no guidance. To revert back to my original question, I am not asking for you to fix my code for me, I am asking if it is possible to use conditional if statements in the trial parameters which refer to list numbers as a way of modifying which stimulus is presented in each trial. If you can do this, what are the syntax rules for using conditional if statements in trial parameters. If you cannot do this then I can think of another way of doing it. 

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search