Millisecond Forums

Questions about clicking pictures

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

By Sophia - 3/25/2013

Hi,



I am programming a sorting task to ask participants to click one picture among several pictures on the screen. When participants click one picture, I want to have a highlighted yellow frame appearing around the choosing picture. Please help to instruct how to do it. 



Meanwhile, I want to have a red frame constantly appear around the target picture. How to input a red frame here? Please help!



Thanks so much!!

By Dave - 3/25/2013

Use <shape> elements positioned behind your <picture> elements. When the respective picture is clicked on, change the color of the shape to the desired value.

By Sophia - 3/25/2013

Thanks Dave. 


Now I know how to input a border of the target pictures.



But how to do this one? : "When the respective picture is clicked on, change the color of the shape to the desired value."


Sorry I dont know the language to do it. I need your further instructions. Thanks!

By Dave - 3/25/2013

Here's a minimal example:


<block myblock>
/ trials = [1=mytrial]
</block>

<trial mytrial>
/ stimulusframes = [1=f1,f2,p1,p2, done]
/ inputdevice = mouse
/ validresponse = (p1,p2,done)
/ ontrialend = [if(trial.mytrial.response=="p1")shape.f1.color=blue]
/ ontrialend = [if(trial.mytrial.response=="p2")shape.f2.color=blue]
/ branch = [if(trial.mytrial.response!="done")trial.mytrial]
</trial>

<text p1>
/ items = ("picture 1")
/ position = (40%,50%)
/ size = (100px, 100px)
/ erase = false
</text>

<shape f1>
/ shape = rectangle
/ position = (40%,50%)
/ size = (110px, 110px)
/ erase = false
</shape>

<text p2>
/ items = ("picture 2")
/ position = (60%,50%)
/ size = (100px, 100px)
/ erase = false
</text>

<shape f2>
/ shape = rectangle
/ position = (60%,50%)
/ size = (110px, 110px)
/ erase = false
</shape>

<text done>
/ items = ("Click here when done...")
/ position = (50%,90%)
/ erase = false
</text>


If you need a more comprehensive example, I recommend you work through the Information Sampling Task which uses a similar mechanic.

By Sophia - 3/25/2013

Thanks so much!

By Sophia - 3/27/2013

Hi Dave,



I got another question. 


When I click one picture in one trial, the frame will appear. But the frame will last forever!  I need the frame to disappear when I click next. Then start another trial. 


Please help. Thanks!

By Dave - 3/27/2013

You simply need to reset the respective shape element's color to whatever you need at the beginning of a trial then.

By Sophia - 3/27/2013


<trial picture1>


/ inputdevice = mouse


/ ontrialbegin = [shape.left.color=black]


/ontrialbegin = [shape.right.color=black]


/ stimulusframes = [1=left,right,targetborder,left1,target1,right1,done]


/ validresponse = (left1, right1,done)


/ontrialend = [if(trial.picture1.response=="left1")shape.left.color=red]


/ontrialend = [if(trial.picture1.response=="right1")shape.right.color=red]


/ branch = [if(trial.picture1.response!="done")trial.picture1]


</trial>




If I define the shape color as black at the beginning of each trial like this, then the shape color will not change to red when I click it. 


I am confused.

By Dave - 3/27/2013


If I define the shape color as black at the beginning of each trial like this, then the shape color will not change to red when I click it. 


I am confused.



You are reverting any changes you made within a single trial. That's why.


1st run of the trial -> click on left shape -> left shape is set to red


2nd run of the trial -> left shape is set to back to black *before it is ever displayed*.


By Sophia - 3/27/2013

then how to write it?? 

By Dave - 3/27/2013

Depends on what exactly you want to do. E.g. how long you want a selected picture to remain highlighted.


For starters


/ontrialend = [if(trial.picture1.response=="left1")shape.left.color=red else shape.left.color=black]


etc.

By Sophia - 3/27/2013

It works perfectly. Thanks!!!


By Sophia - 3/29/2013

Hi Dave,



I got another problem. Please help!


I need a fixation cross before each trial. So I changed stimulusframs into stimulustims. But now it turned out very weird. It showed a blank page after I click the picture and the frame stayed after the trial together with the fixation cross. 




<trial picture1>


/ inputdevice = mouse


/stimulustimes = [0=ready; 700=left,right,targetborder,left1,target1,right1,done]


/ validresponse = (left1, right1,done)


/ontrialend = [if(trial.picture1.response=="left1")shape.left.color=red else shape.left.color=black]


/ontrialend = [if(trial.picture1.response=="right1")shape.right.color=red else shape.right.color=black]


/ branch = [if(trial.picture1.response!="done")trial.picture1]


</trial>


By Dave - 3/29/2013

Sophia,


nothing weird here. The stimuli are all set to /erase=false, so the remain visible. You have to take care of getting rid of them yourself. See the "How to erase stimuli" topic in the Inquisit documentation.


Also, you will at least need *two* different <trial> elements. One to show the initial fixation cross and pictures prior to selections, followed by another one to display the selection result (i.e., the "highlighted" picture). Else you need to rework things and use /responsemessage attributes.


Before you go about doing any of that though, please work through the various tutorials in the Inquisit documentation as well as the Task Library script I mentioned earlier.