validresponse = LEFT mouse button + clicking ON SIMULUS?


Author
Message
clairez
clairez
Guru (5K reputation)Guru (5K reputation)Guru (5K reputation)Guru (5K reputation)Guru (5K reputation)Guru (5K reputation)Guru (5K reputation)Guru (5K reputation)Guru (5K reputation)
Group: Forum Members
Posts: 41, Visits: 49




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!


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: 13K, Visits: 108K

#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>


clairez
clairez
Guru (5K reputation)Guru (5K reputation)Guru (5K reputation)Guru (5K reputation)Guru (5K reputation)Guru (5K reputation)Guru (5K reputation)Guru (5K reputation)Guru (5K reputation)
Group: Forum Members
Posts: 41, Visits: 49

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>


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: 13K, Visits: 108K

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.


clairez
clairez
Guru (5K reputation)Guru (5K reputation)Guru (5K reputation)Guru (5K reputation)Guru (5K reputation)Guru (5K reputation)Guru (5K reputation)Guru (5K reputation)Guru (5K reputation)
Group: Forum Members
Posts: 41, Visits: 49

Thanks, Dave!


clairez
clairez
Guru (5K reputation)Guru (5K reputation)Guru (5K reputation)Guru (5K reputation)Guru (5K reputation)Guru (5K reputation)Guru (5K reputation)Guru (5K reputation)Guru (5K reputation)
Group: Forum Members
Posts: 41, Visits: 49

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!


clairez
clairez
Guru (5K reputation)Guru (5K reputation)Guru (5K reputation)Guru (5K reputation)Guru (5K reputation)Guru (5K reputation)Guru (5K reputation)Guru (5K reputation)Guru (5K reputation)
Group: Forum Members
Posts: 41, Visits: 49

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>


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: 13K, Visits: 108K

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.


clairez
clairez
Guru (5K reputation)Guru (5K reputation)Guru (5K reputation)Guru (5K reputation)Guru (5K reputation)Guru (5K reputation)Guru (5K reputation)Guru (5K reputation)Guru (5K reputation)
Group: Forum Members
Posts: 41, Visits: 49

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. 


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: 13K, Visits: 108K


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.



GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search