Correct picture name not saving in the 'response' column following mouse click on picture


Author
Message
pops
pops
Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)
Group: Forum Members
Posts: 69, Visits: 85
I am about to start editing an experiment file so wanted to fix this issue in it before I started. Last time I ran the experiment there was one place where the data file did not correctly record the image being shown. Luckily I could still work out and recode behaviour, but I think in the interests of making future code available to others etc it would be better to get things saving correctly. Below is the critical bit of the code. In the data file, if participants click on the monster image during the trial, then it records a *different* monster image name in the 'response' column. As there is only one image on screen at a time I can recode it as simply 'clicked on image yes/no' but it's a bit unnerving (I've extensively tested it and luckily the 'values.picname' and 'values.monsterType' variables are recording correctly). It seems totally random as to the picname that appears in the 'response' column in the datafile. I think the errors come about due to the rather complex counterbalancing? Or perhaps it is because I am using multiple ontrialbegin commands in the trial? Any advice appreciated.

<item monsterImages>
/ 1 ="M1.GIF"
/ 2 ="M2.GIF"
/ 3 ="M3.GIF"
/ 4 ="M4.GIF"
</item>

<list counterB>
/ items = (1,2,3,4)
/ selectionmode =random
/ selectionrate = experiment
</list>

<expressions>
/pic2 = if (values.counterbalance==3) {4} else {mod(values.counterbalance + 1, 4)}
/pic3 = if (values.counterbalance==2) {4} else {mod(values.counterbalance + 2, 4)}
/pic4 = if (values.counterbalance==1) {4} else {mod(values.counterbalance + 3, 4)}
</expressions>

<list transferTrialType>
/items = (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20)
/ selectionmode = random
/ selectionrate = trial
/replace=false
</list>

<values>
/monsterType = " "
/picName = ""
</values>

<picture goToWinIcePic>
/ items = monsterImages
/ select = values.counterbalance
</picture>

<picture goToWinChocPic>
/ items = monsterImages
/ select = expressions.pic2
</picture>

...

<trial transferTrial>
/ inputdevice = mouse
/ ontrialbegin = [
    values.trialType = list.transferTrialType.nextvalue;
    trial.transferTrial.insertstimulustime(shape.eraser, parameters.fixationduration);
        {lots of other commands here using 'if (mod(values.trialType, 4)==x', but not involving the variables below}
      ]
/ ontrialbegin = [    
        if (mod(values.trialType, 4)==1){
        trial.transferTrial.insertstimulustime(picture.goToWinIcePic, parameters.fixationduration);
        values.picName = picture.goToWinIcePic.currentitem; values.monsterType = "goToWinIce"}
        else if (mod(values.trialType, 4)==2){
        trial.transferTrial.insertstimulustime(picture.nogoToWinIcePic, parameters.fixationduration);
        values.picName = picture.nogoToWinIcePic.currentitem;values.monsterType = "nogoToWinIce"}
.......
        ]
    / validresponse = (goToWinChocPic,nogoToWinChocPic, goToWinIcePic, nogoToWinIcePic, noresponse)
    / ontrialend = [trial.transferTrial.resetstimulusframes();]
</trial>

<block transferTrials>
/ onblockbegin = [values.blockCount +=1; values.trialcount = 0;]
/ trials = [1-20 = transferTrial]
</block>

<expt>
/ blocks = [1 = instrumTrials; 2 = pavlovianTrials; 3 = transferTrials]
/onexptbegin = [values.counterbalance = list.counterB.nextvalue;]
</expt>


Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 12K, Visits: 98K
pops - 2/3/2022
I am about to start editing an experiment file so wanted to fix this issue in it before I started. Last time I ran the experiment there was one place where the data file did not correctly record the image being shown. Luckily I could still work out and recode behaviour, but I think in the interests of making future code available to others etc it would be better to get things saving correctly. Below is the critical bit of the code. In the data file, if participants click on the monster image during the trial, then it records a *different* monster image name in the 'response' column. As there is only one image on screen at a time I can recode it as simply 'clicked on image yes/no' but it's a bit unnerving (I've extensively tested it and luckily the 'values.picname' and 'values.monsterType' variables are recording correctly). It seems totally random as to the picname that appears in the 'response' column in the datafile. I think the errors come about due to the rather complex counterbalancing? Or perhaps it is because I am using multiple ontrialbegin commands in the trial? Any advice appreciated.

<item monsterImages>
/ 1 ="M1.GIF"
/ 2 ="M2.GIF"
/ 3 ="M3.GIF"
/ 4 ="M4.GIF"
</item>

<list counterB>
/ items = (1,2,3,4)
/ selectionmode =random
/ selectionrate = experiment
</list>

<expressions>
/pic2 = if (values.counterbalance==3) {4} else {mod(values.counterbalance + 1, 4)}
/pic3 = if (values.counterbalance==2) {4} else {mod(values.counterbalance + 2, 4)}
/pic4 = if (values.counterbalance==1) {4} else {mod(values.counterbalance + 3, 4)}
</expressions>

<list transferTrialType>
/items = (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20)
/ selectionmode = random
/ selectionrate = trial
/replace=false
</list>

<values>
/monsterType = " "
/picName = ""
</values>

<picture goToWinIcePic>
/ items = monsterImages
/ select = values.counterbalance
</picture>

<picture goToWinChocPic>
/ items = monsterImages
/ select = expressions.pic2
</picture>

...

<trial transferTrial>
/ inputdevice = mouse
/ ontrialbegin = [
    values.trialType = list.transferTrialType.nextvalue;
    trial.transferTrial.insertstimulustime(shape.eraser, parameters.fixationduration);
        {lots of other commands here using 'if (mod(values.trialType, 4)==x', but not involving the variables below}
      ]
/ ontrialbegin = [    
        if (mod(values.trialType, 4)==1){
        trial.transferTrial.insertstimulustime(picture.goToWinIcePic, parameters.fixationduration);
        values.picName = picture.goToWinIcePic.currentitem; values.monsterType = "goToWinIce"}
        else if (mod(values.trialType, 4)==2){
        trial.transferTrial.insertstimulustime(picture.nogoToWinIcePic, parameters.fixationduration);
        values.picName = picture.nogoToWinIcePic.currentitem;values.monsterType = "nogoToWinIce"}
.......
        ]
    / validresponse = (goToWinChocPic,nogoToWinChocPic, goToWinIcePic, nogoToWinIcePic, noresponse)
    / ontrialend = [trial.transferTrial.resetstimulusframes();]
</trial>

<block transferTrials>
/ onblockbegin = [values.blockCount +=1; values.trialcount = 0;]
/ trials = [1-20 = transferTrial]
</block>

<expt>
/ blocks = [1 = instrumTrials; 2 = pavlovianTrials; 3 = transferTrials]
/onexptbegin = [values.counterbalance = list.counterB.nextvalue;]
</expt>


Perhaps you could post code that one can actually run to see the issue (your description is not exactly clear) and also provide the images and any other files said code requires to run.

What's especially confusing is your statement that "it records a *different* monster image name in the 'response' column." since the response column does not record image names. It records the response given, which in the case of <trial transferTrial> is a click on one of the objects defined in its /validresponse.

/ validresponse = (goToWinChocPic,nogoToWinChocPic, goToWinIcePic, nogoToWinIcePic, noresponse)

The response options listed are checked in the order given, left to right. So, if goToWinChocPic and nogoToWinChocPic overlap in size / position, a *perceived* click on the latter is actually a click on the former if the click occurred in the area where the two objects overlap. Whether that is the case in your script cannot be ascertained, since you have not provided the relevant information -- runnable code, including the images.

pops
pops
Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)
Group: Forum Members
Posts: 69, Visits: 85

Ah sorry for confusion - only one of the monster pictures is shown on each trial. So the participant can only click on one. But yes, I've defined them all as valid responses which may be the confusion. I'll add a pared down version of the script. Thank youl.

pops
pops
Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)
Group: Forum Members
Posts: 69, Visits: 85
pops - 2/3/2022

Ah sorry for confusion - only one of the monster pictures is shown on each trial. So the participant can only click on one. But yes, I've defined them all as valid responses which may be the confusion. I'll add a pared down version of the script. Thank youl.

By 'monster pictures' I mean the objects that these appear in in the trial which are the goToWinIcePic, goToWinChocPic etc.

Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 12K, Visits: 98K
pops - 2/3/2022
pops - 2/3/2022

Ah sorry for confusion - only one of the monster pictures is shown on each trial. So the participant can only click on one. But yes, I've defined them all as valid responses which may be the confusion. I'll add a pared down version of the script. Thank youl.

By 'monster pictures' I mean the objects that these appear in in the trial which are the goToWinIcePic, goToWinChocPic etc.

Okay, thanks for the clarification. As I mentioned before, your question is not answerable based on a non-functioning code snippet. Please provide something that actually runs and shows the issue.
Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 12K, Visits: 98K
Dave - 2/3/2022
pops - 2/3/2022
pops - 2/3/2022

Ah sorry for confusion - only one of the monster pictures is shown on each trial. So the participant can only click on one. But yes, I've defined them all as valid responses which may be the confusion. I'll add a pared down version of the script. Thank youl.

By 'monster pictures' I mean the objects that these appear in in the trial which are the goToWinIcePic, goToWinChocPic etc.

Okay, thanks for the clarification. As I mentioned before, your question is not answerable based on a non-functioning code snippet. Please provide something that actually runs and shows the issue.

> only one of the monster pictures is shown on each trial. So the participant can only click on one.

Since they're all defined as valid responses, a click on the location of a given picture object will be accepted even if that object happens to be not shown in the given trial. And since /validresponse options are evaluated in the order given (see my first response), that's the likely reason for the confusion.

Here's an example:

<shape redr>
/ shape = rectangle
/ color = red
/ size = (500px, 500px)
/ position = (50%, 50%)
</shape>

<shape greenr>
/ shape = rectangle
/ color = green
/ size = (500px, 500px)
/ position = (50%, 50%)
</shape>

<trial clicktrial>
/ pretrialpause = 500
/ ontrialbegin = [
    if (trial.clicktrial.trialcount == 0) {
        trial.clicktrial.insertstimulusframe(shape.redr, 1);
    } else {
        trial.clicktrial.insertstimulusframe(shape.greenr, 1);
    };
]
/ ontrialend = [
    trial.clicktrial.resetstimulusframes();
]
/ validresponse = (redr, greenr, noresponse)
/ inputdevice = mouse
/ timeout = 5000
</trial>

<block myblock>
/ trials = [1-2 = clicktrial]
</block>


There are two rectangles, equal in size and position, different in color.
The first trial will show the red square. Clicking on it will record "redr" in the response column.
The second trial will show the green square. Clicking on it will also record "redr" in the response column.
(This is actually by design and useful in certain situations.)

If one does not want this behavior, the way to avoid it is to use a variable:

<shape redr>
/ shape = rectangle
/ color = red
/ size = (500px, 500px)
/ position = (50%, 50%)
</shape>

<shape greenr>
/ shape = rectangle
/ color = green
/ size = (500px, 500px)
/ position = (50%, 50%)
</shape>

<values>
/ valid = ""
</values>

<trial clicktrial>
/ pretrialpause = 500
/ ontrialbegin = [
    trial.clicktrial.resetstimulusframes();
    if (trial.clicktrial.trialcount == 0) {
        trial.clicktrial.insertstimulusframe(shape.redr, 1);
        values.valid = "redr";
    } else {
        trial.clicktrial.insertstimulusframe(shape.greenr, 1);
        values.valid = "greenr";
    };
]
/ ontrialend = [
    trial.clicktrial.resetstimulusframes();
]
/ validresponse = (values.valid, noresponse)
/ inputdevice = mouse
/ timeout = 5000
</trial>

<block myblock>
/ trials = [1-2 = clicktrial]
</block>




pops
pops
Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)Esteemed Member (2.3K reputation)
Group: Forum Members
Posts: 69, Visits: 85
That fixed the issue (defining the valid response with /ontrialbegin and referencing that at the /validresponse = part of the script). Thank you so much!

Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 12K, Visits: 98K
pops - 2/3/2022
That fixed the issue (defining the valid response with /ontrialbegin and referencing that at the /validresponse = part of the script). Thank you so much!

Great! Thanks for letting me know.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search