By clairez - 9/10/2013
Hi!
I have a question about mouse events: I want participants to click with the right or left mouse button on a stimulus.
Now I know that you can set the validresponse to a stimulus name, in which case the subject may click on the area of the screen occupied by the stimulus. And I know you can set the validresponse to lbuttondown or rbuttondown. But can you set it to something that allows for the combination I want?
I appreciate your help!
|
By Dave - 9/10/2013
#1: No easy way to do this, since a trial accepts a single response. I.e., it's *either* left/right button *or* leftclick on stimulus.
#2: Perhaps possible by implementing something along the lines of a pointinrect() function via <expressions> and then check whether response is left/right button AND mouse coordinates are in the correct region (i.e., the respective stimulus) via /isvalidresponse.
EDIT: Since this is kind of fun, short example outlining #2 above:
<expressions> / isleft = if((mouse.x/display.width>=0.10) && (mouse.x/display.width<=0.40) && (mouse.y/display.height>=0.20) && (mouse.y/display.height<=0.80)) true else false / isright = if((mouse.x/display.width>=0.60) && (mouse.x/display.width<=0.90) && (mouse.y/display.height>=0.20) && (mouse.y/display.height<=0.80)) true else false </expressions>
<trial mytrial> / posttrialpause = 500 / stimulusframes = [1=leftstim, rightstim] / inputdevice = mouse / validresponse = (lbuttondown,rbuttondown) / isvalidresponse = [trial.mytrial.response=="lbuttondown" && expressions.isleft] / isvalidresponse = [trial.mytrial.response=="rbuttondown" && expressions.isright] </trial>
<text leftstim> / items = ("left") / txbgcolor = (blue) / size = (30%, 60%) / position = (25%, 50%) </text>
<text rightstim> / items = ("right") / txbgcolor = (blue) / size = (30%, 60%) / position = (75%, 50%) </text>
<block myblock> / trials = [1-4=mytrial] </block>
<data> / columns = [trialnum, latency, response, mouse.x, mouse.y, expressions.isleft, expressions.isright] / separatefiles = true </data>
|
By clairez - 9/11/2013
Hi Dave,
Thank you! I'm trying to understand this. The index in the inquisit help doesn't give away too much about the mouse element, so the script is very helpful. I still don't quite get it, though. I would appreciate your help.
It looks like in the expressions you set particular values for the x and y coordinates of the display of the mouse cursor. The x coordinate for isleft is between 0.10 (10%) and 0.40 (40%). The x coordinate for the position of the left stimulus 25% (0.25), and because the stimulus is 30% in size, if I understand this correctly, its display should span the x coordinates 0.25 to 0.55. Is that right? But then the mouse isn't on the stimulus when it's in the isleft location.
I think with that script I'll run into another problem: My stimuli are supposed to appear all over the place (below is an example for how I set the stimulus location). So I can't pre-specify the locations where the mouse cursor will be on the stimulus.
<shape smallgreen> / shape=circle / size=(30,30) / color=(0,255,0) / hposition = hcounter / vposition = vcounter </shape>
<counter vcounter> / select = noreplace(10-90) </counter>
<counter hcounter> / select = noreplace(10-90) </counter>
|
By Dave - 9/11/2013
The x coordinate for the position of the left stimulus 25% (0.25), and because the stimulus is 30% in size, if I understand this correctly, its display should span the x coordinates 0.25 to 0.55. Is that right?
No. By default, stims are positioned aligned to their center. The center is at 25%, the stim is 30% wide. Simple math then shows it spans from 10% to 40%. Which, BTW, you can easily test: Does the script accept any response outside the area spanned by the stimulus?
My stimuli are supposed to appear all over the place (below is an example for how I set the stimulus location). So I can't pre-specify the locations where the mouse cursor will be on the stimulus.
Then you must extend the approach and compute the boundaries on the fly at runtime (i.e. use values). They need not be known in advance. And if your stims are circles, you may be better off computing Euclidean distance from the circle's center. The Spatial Delayed Response Task script does that sort of stuff. I recommend working through it.
|
By clairez - 9/11/2013
Thanks, Dave!
|
By clairez - 9/11/2013
Hi Dave,
I decided to make a task a little simpler. But I still have one major difficulty: The correct response on each trial (clicking on a stimulus with the left mouse or not clicking on it) is determined by the previous trial. So what I wanted to do is create a value and, at the end of each trial, set that to 1 if the next trial warrants a response and to 0 when it doesn't.
Now I'm trying to specify the correct response such that it clicking on the stimulus is correct only IF the value responsecode is 1. Is that at all possible?
Thanks in advance!
|
By clairez - 9/11/2013
P.S. I tried this
<trial largeblueWM> / inputdevice = mouse / validresponse = (smallgreen; noresponse) / iscorrectresponse = [trial.largeblue.response==largeblue && values.responsecode==1] / stimulustimes = [1=largeblue; 1500 = white] / timeout = 1500 / responsetime = 10 /ontrialend = [values.responsecode==0] / errormessage = true(errortext, 500) </trial>
|
By Dave - 9/11/2013
Now I'm trying to specify the correct response such that it clicking on the stimulus is correct only IF the value responsecode is 1. Is that at all possible?
Yes, via /iscorrectresponse.
|
By clairez - 9/11/2013
Thanks! I did that (see above), and the script runs, but it doesn't record correct responses as correct.
Here is what I did:
1. I created a variable responsecode and set the value to 0
<values userparams> / responsecode = 0 </values>
2. In the first trial, no response is required, and I set value.responsecude to 1.
<trial starttrial> / inputdevice = mouse / validresponse = (smallgreen; noresponse) / stimulustimes = [1=smallgreen; 1500 = white] / timeout = 1500 / responsetime = 10 /ontrialend = [values.responsecode==1] </trial>
3. At the next trials, I specify iscorrectresponse such that clicking on the stimulus is correct only when value.responsecode==1. At the end of the trial, I update the responsecode. Here two example trials (participants are supposed to click on a stimulus if the last stimulus was green but not blue).
<trial smallgreenWM> / inputdevice = mouse / validresponse = (smallgreen; noresponse) / iscorrectresponse = [trial.smallgreenWM.response==smallgreen && values.responsecode==1] / stimulustimes = [1=smallgreen; 1500 = white] / timeout = 1500 / responsetime = 10 /ontrialend = [values.responsecode==1] / errormessage = true(errortext, 500) </trial>
<trial smallblueWM> / inputdevice = mouse / validresponse = (smallblue; noresponse) / iscorrectresponse = [trial.smallblueWM.response==smallblue && values.responsecode==1] / stimulustimes = [1=smallblue; 1500 = white] / timeout = 1500 / responsetime = 10 /ontrialend = [values.responsecode=0] / errormessage = true(errortext, 500) </trial>
When I look at the data, I see that correct is always 0 regardless of how I respond. The same happens when I set values.responsecode=1 at the beginning.
|
By Dave - 9/11/2013
2. In the first trial, no response is required, and I set value.responsecude to 1. <trial starttrial> / inputdevice = mouse / validresponse = (smallgreen; noresponse) / stimulustimes = [1=smallgreen; 1500 = white] / timeout = 1500 / responsetime = 10 /ontrialend = [values.responsecode==1] </trial>
== is not assignment. = is.
|
By clairez - 9/11/2013
Oh, ok. But the problem remains. It still does not record count any response as correct.
|
By Dave - 9/11/2013
#1: The == vs. = confusion applies to all your trials, not just the one I highlighted.
#2: I also believe you are missing proper double quotes in your /iscorrectresponse logic. E.g.
/ iscorrectresponse = [trial.smallblueWM.response==smallblue && values.responsecode==1]
should rather be
/ iscorrectresponse = [trial.smallblueWM.response=="smallblue" && values.responsecode==1]
i.e., the response property returns a string here. Again this goes for all your trials.
Tip: When something doesn't work as you intend, check syntax, and if unsure about proper syntax, take a step back and make a tiny demo script testing only the core logic you're having trouble with. Once you've sorted it out, port to the real thing. Never use the full, actual script for testing such things.
|
By clairez - 9/11/2013
Thanks!
The reason why I didn't think about the quotation marks is that I run a second condition where I use /correctresponse = (smallgreen) and that works fine. But the quotations were indeed the problem with the /iscorrectresponse.
I fixed it and ran into another problem with the correct response. I had specified only one correct response option, that is, clicking on the stimulus if value.responsecode==1. But noresponse should be correct when value.responsecode==0. I tried to work with the or statement
/iscorrectresponse = [trial.smallgreen.response=="smallgreen" && values.responsecode==1 | trial.smallgreen.response=="noresponse" && values.responsecode==0]
but here I get an error message. I tried looking this up in the forum, in other people's scripts, and in the help index, but don't get any step further. So could you help me out once more here, please?
Thanks in advance, I really appreciate your quick replies!
Below is my demoscript. If you could take a look at it, that would be awesome!
____________________________________
<values userparams> / responsecode = 0 </values>
<page intro>Click on a circle when the circle BEFORE was GREEN. Don't click when the circle BEFORE was BLUE. </page>
<counter vcounter> / select = noreplace(10-90) </counter>
<counter hcounter> / select = noreplace(10-90) </counter>
<shape smallgreen> / shape=circle / size=(30,30) / color=(0,255,0) / hposition = hcounter / vposition = vcounter </shape>
<shape smallblue> / shape=circle / size=(30,30) / color=(0, 0, 255) / hposition = hcounter / vposition = vcounter </shape>
<shape white> / size=(100%,100%) / color=(white) </shape>
<text errortext> /items = ("wrong") / fontstyle = ("Al Bayan", 3.33%, false, false, false, false, 5, 0) / txcolor = (220, 20, 60) </text>
<trial starttrial> / inputdevice = mouse / validresponse = (smallgreen; noresponse) / stimulustimes = [1=smallgreen; 2000 = white] / timeout = 2000 / responsetime = 10 /ontrialend = [values.responsecode=1] </trial>
<trial smallgreen> / inputdevice = mouse / validresponse = (smallgreen; noresponse) / iscorrectresponse = [trial.smallgreen.response=="smallgreen" && values.responsecode==1] / stimulustimes = [1=smallgreen; 2000 = white] / timeout = 2000 / responsetime = 10 /ontrialend = [values.responsecode=1] / errormessage = true(errortext, 500) </trial>
<trial smallblue> / inputdevice = mouse / validresponse = (smallblue; noresponse) / iscorrectresponse = [trial.smallblue.response=="smallblue" && values.responsecode==1] / stimulustimes = [1=smallblue; 2000 = white] / timeout = 2000 / responsetime = 10 /ontrialend = [values.responsecode=0] / errormessage = true(errortext, 500) </trial>
<block balls> / preinstructions = (intro) / trials = [1= starttrial; 2-13 = noreplace(smallgreen, smallblue)] </block>
<expt> / blocks = [1 = balls] </expt>
|
By Dave - 9/11/2013
/iscorrectresponse = [trial.smallgreen.response=="smallgreen" && values.responsecode==1 | trial.smallgreen.response=="noresponse" && values.responsecode==0]
#1: | is not a logical OR. || is. See the operators reference in the documentation.
#2: trial.sometrial.response=="noresponse" is invalid syntax / does not exist. It's trial.sometrial.respose==0.
#3: You'll probably want to separate the above into *two* /iscorrectresponse attributes. The compound statement does not make sense logically (given how computers evaluate logical AND and OR operators*), or more precisely, I doesn't mean what you think it means.
/ iscorrectresponse = [trial.smallgreen.response=="smallgreen" && values.responsecode==1]
/ iscorrectresponse = [trial.smallgreen.response==0 && values.responsecode==0]
* Looking up truth tables on wikipedia is a good starting point.
|
By clairez - 9/12/2013
Thanks, Dave,
The first thing I usually do is look at the documentation or the help index. It is helpful, but very limited. I don't even know where to find things like | or || functions there, or when to use "noresponse" and when "0" instead. I searched the forum too, because I don't want to ask questions that have already been answered. I find many helpful things, but just not the answers I'm looking for.
I tried to work with the two /iscorrectresponse lines you suggested, but the / iscorrectresponse = [trial.trialname.response==0 && values.responsecode==0] doesn't quite work. It solved one problem: No-go trials are now no longer counted as incorrect when I don't respond, which is what I wanted. But it now counts any trial as correct when I click on the stimulus, regardless of whether the responsecode is 0 or 1. So it seems as if trial.trialname.response==0 && values.responsecode==0 makes ANY response correct, rather than just no response.
|
By Dave - 9/12/2013
I don't even know where to find things like | or || functions there
It's all in the language reference, which actually is pretty extensive (if you were to print it out, I'd estimate you'd get around 1000 pages). Logical operators are covered in the operators topic, as mentioned previously. The topic will come up first if you search the documentation for e.g. "logical" or a host of other terms.
Not sure about your /iscorrectresponse issue. This works perfectly fine for me:
<expressions> / rcode = sequence(1,1,0,0) </expressions>
<values> / responsecode = 0 </values>
<text debug> / items = ("<%values.responsecode%>") </text>
<text cmsg> / items = ("correct") </text>
<text emsg> / items = ("error") </text>
<trial mytrial> / inputdevice = mouse / ontrialbegin = [values.responsecode=expressions.rcode] / stimulusframes = [1=debug] / validresponse = (lbuttondown, noresponse) / iscorrectresponse = [{trial.mytrial.response=="0" && values.responsecode==0}] / iscorrectresponse = [{trial.mytrial.response=="lbuttondown" && values.responsecode==1}] / timeout = 5000 / correctmessage = true(cmsg, 0) / errormessage = true(emsg, 0) / posttrialpause = 500 </trial>
<block myblock> / trials = [1-4=mytrial] </block>
|
By clairez - 9/12/2013
This is just confusing. When I type the 0 in quotations, like you did now (and as below, it doesn't count ANY response omissions as correct. When I don't use the quotations, it works fine with response omissions, but now it counts ALL responses as correct.
<trial smallblue> / inputdevice = mouse / validresponse = (smallblue; noresponse) / iscorrectresponse = [trial.smallblue.response=="smallblue" && values.responsecode==1] / iscorrectresponse = [trial.smallblue.response=="0" && values.responsecode==0] / stimulustimes = [1=smallblue; 2000 = white] / timeout = 2000 / responsetime = 10 /ontrialend = [values.responsecode=0] / errormessage = true(errortext, 500) </trial>
|
By Dave - 9/12/2013
<trial smallblue> / inputdevice = mouse / validresponse = (smallblue; noresponse) / iscorrectresponse = [trial.smallblue.response=="smallblue" && values.responsecode==1] / iscorrectresponse = [trial.smallblue.response=="0" && values.responsecode==0] / stimulustimes = [1=smallblue; 2000 = white] / timeout = 2000 / responsetime = 10 /ontrialend = [values.responsecode=0] / errormessage = true(errortext, 500) </trial>
#1: response separator is usually ',' not ';'
#2: change order of the two attributes (cf. the example in my previous reply)
#3: just making sure you understand that /ontrialend is executed when the trial is over, i.e., it does not affect the currently running trial and its /iscorrectresponse logic
#4: check your script for other subtle errors
#5: systematically log data (including values.responsecode) and check for errors
|
By clairez - 9/12/2013
Hi Dave,
I checked all of this. The ; and the order didn't make a difference.
I'm aware that the /ontrialend doesn't affect the /iscorrectresponse logic on the same trial. It's sort of an n-back task. On each trial, the subject has to click or not click based on whether the last trial was a green or blue stimulus trial. So with the /ontrialend I just set the responsecode value to 0 or 1 for the next trial.
I checked the results, and everytime I click on the stimulus, no matter what the responsecode, it's recorded as a correct response.
I don't know how to log the value.responsecode. Would be convenient to have, but I know already (based on what was counted as correct or error in previous versions) that the responsecode is updated correctly after each trial, so that's not the problem.
This is the demo script I'm working with now:
<values userparams> / responsecode = 0 </values>
<page intro>Click on a circle when the circle BEFORE was GREEN. Don't click when the circle BEFORE was BLUE. </page>
*********************** ITEMS *****************
<counter vcounter> / select = noreplace(10-90) </counter>
<counter hcounter> / select = noreplace(10-90) </counter>
<shape smallgreen> / shape=circle / size=(30,30) / color=(0,255,0) / hposition = hcounter / vposition = vcounter </shape>
<shape smallblue> / shape=circle / size=(30,30) / color=(0, 0, 255) / hposition = hcounter / vposition = vcounter </shape>
<shape white> / size=(100%,100%) / color=(white) </shape>
<text errortext> /items = ("wrong") / fontstyle = ("Al Bayan", 3.33%, false, false, false, false, 5, 0) / txcolor = (220, 20, 60) </text>
<trial starttrial> / inputdevice = mouse / validresponse = (smallgreen; noresponse) / stimulustimes = [1=smallgreen; 2000 = white] / timeout = 2000 / responsetime = 10 /ontrialend = [values.responsecode=1] </trial>
<trial smallgreen> / inputdevice = mouse / validresponse = (smallgreen, noresponse) / iscorrectresponse = [values.responsecode==1 && trial.smallgreen.response=="smallgreen"] / iscorrectresponse = [values.responsecode==0 && trial.smallgreen.response==0] / stimulustimes = [1=smallgreen; 2000 = white] / timeout = 2000 / responsetime = 10 /ontrialend = [values.responsecode=1] / errormessage = true(errortext, 500) </trial>
<trial smallblue> / inputdevice = mouse / validresponse = (smallblue, noresponse) / iscorrectresponse = [values.responsecode==1 && trial.smallblue.response=="smallblue"] / iscorrectresponse = [values.responsecode==0 && trial.smallblue.response==0] / stimulustimes = [1=smallblue; 2000 = white] / timeout = 2000 / responsetime = 10 /ontrialend = [values.responsecode=0] / errormessage = true(errortext, 500) </trial>
<block balls> / preinstructions = (intro) / trials = [1= starttrial; 2-13 = noreplace(smallgreen, smallblue)] </block>
<expt> / blocks = [1 = balls] </expt>
|
By Dave - 9/12/2013
Here, I fixed it for you:
<values> / responsecode = 0 </values>
<page intro>Click on a circle when the circle BEFORE was GREEN. Don't click when the circle BEFORE was BLUE. </page>
*********************** ITEMS *****************
<counter vcounter> / select = noreplace(10-90) </counter>
<counter hcounter> / select = noreplace(10-90) </counter>
<shape smallgreen> / shape=circle / size=(30,30) / color=(0,255,0) / hposition = hcounter / vposition = vcounter </shape>
<shape smallblue> / shape=circle / size=(30,30) / color=(0, 0, 255) / hposition = hcounter / vposition = vcounter </shape>
<shape white> / size=(100%,100%) / color=(white) </shape>
<text errortext> / items = ("wrong") / fontstyle = ("Al Bayan", 3.33%, false, false, false, false, 5, 0) / txcolor = (220, 20, 60) </text>
<trial starttrial> / inputdevice = mouse / validresponse = (smallgreen, noresponse) / stimulustimes = [1=smallgreen] / timeout = 2000 / responsetime = 10 / ontrialend = [values.responsecode=1] </trial>
<trial smallgreen> / inputdevice = mouse / validresponse = (smallgreen, noresponse) / iscorrectresponse = [values.responsecode==0 && trial.smallgreen.response=="0"] / iscorrectresponse = [values.responsecode==1 && trial.smallgreen.response=="smallgreen"] / stimulustimes = [1=smallgreen, debug] / timeout = 2000 / responsetime = 10 / ontrialend = [values.responsecode=1] / errormessage = true(errortext, 500) </trial>
<trial smallblue> / inputdevice = mouse / validresponse = (smallblue, noresponse) / iscorrectresponse = [values.responsecode==0 && trial.smallblue.response=="0"] / iscorrectresponse = [values.responsecode==1 && trial.smallblue.response=="smallblue"] / stimulustimes = [1=smallblue, debug] / timeout = 2000 / responsetime = 10 / ontrialend = [values.responsecode=0] / errormessage = true(errortext, 500) </trial>
<block balls> / preinstructions = (intro) / trials = [1= starttrial; 2-13 = noreplace(smallgreen, smallblue)] </block>
<expt> / blocks = [1 = balls] </expt>
<data> / columns = [trialnum, trialcode, response, correct, values.responsecode] / separatefiles = true </data>
<text debug> / items = ("<%values.responsecode%>") / position = (50%, 10%) </text>
|
By clairez - 9/12/2013
Thanks a lot!
So it was the order of the /iscorrectresponse lines.
|
|