Millisecond Forums

How to put response frames (windows) on a picture?

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

By atolopilo - 4/10/2021

Hi,

I try to implement some kind of a face in the crowd task. I've seen a lot of that kind of script but none of them fits mine. In every trial, Participant has to indicate 1 of 4 faces presented on a matrix by clicking on it.

Previously, I assigned specific keys to image position in a matrix (e.g. "w" for 1, "e" for 2, etc.) and marked them on a keyboard but because of switching from stationary lab to online study, I would prefer to change this "technique".

I would like to set a response as a mouse click on a chosen pic, e.g. participant wants to choose face 2 (in the matrix) so just clicks on this particular face (+ it would be saved as "2" in my results). Additionally, It would be great if the face (box) that participant has a cursor on it (in that particular moment) was illuminated.

I guess that I need to add some kind of "shape" or "mask" but have no idea where and how. My script is very basic: item -> picture -> trial -> block with 80 noreplace trials.

Thank You for all your help!

Typical matrix (it's one picture item, not 4 separate images):



Here is a scheme for my study:

By Dave - 4/12/2021


If you want response to be a click on a picture element, set the trials' /inputdevice to mouse and define the name of the displayed picture elements in /validresponse.
By atolopilo - 4/14/2021

Dave - 4/12/2021

If you want response to be a click on a picture element, set the trials' /inputdevice to mouse and define the name of the displayed picture elements in /validresponse.

How will I know which "area" of the picture someone clicked on?
By Dave - 4/14/2021

atolopilo - 4/14/2021
Dave - 4/12/2021

If you want response to be a click on a picture element, set the trials' /inputdevice to mouse and define the name of the displayed picture elements in /validresponse.

How will I know which "area" of the picture someone clicked on?

responsex and responsey and math based on the screen area inhabited by the image.

https://www.millisecond.com/support/docs/v5/html/language/properties/responsex.htm
https://www.millisecond.com/support/docs/v5/html/language/properties/responsey.htm
https://www.millisecond.com/support/docs/v5/html/language/properties/top.htm
https://www.millisecond.com/support/docs/v5/html/language/properties/left.htm

<picture examplepicture>
/ items = ("example.png")
/ position = (50%,50%)
/ size = (80%, 80%)
</picture>

<trial exampletrial>
/ stimulusframes = [1=examplepicture]
/ inputdevice = mouse
/ validresponse = (examplepicture)
/ ontrialend = [
    values.img_widthpx = picture.examplepicture.right - picture.examplepicture.left;
    values.img_heightpx = picture.examplepicture.bottom - picture.examplepicture.top;
    values.responsex_in_img = trial.exampletrial.responsex - picture.examplepicture.left;
    values.responsey_in_img = trial.exampletrial.responsey - picture.examplepicture.top;
    values.responsex_pct = (values.responsex_in_img/values.img_widthpx)*100;
    values.responsey_pct = (values.responsey_in_img/values.img_heightpx)*100;
]
</trial>

<values>
/ img_widthpx = 0
/ img_heightpx = 0
/ responsex_in_img = -1
/ responsey_in_img = -1
/ responsex_pct = -1
/ responsey_pct = -1
</values>

<block exampleblock>
/ trials = [1-4 = exampletrial]
</block>

<data>
/ columns = (date time subject group blocknum blockcode trialnum trialcode latency response trial.exampletrial.responsex trial.exampletrial.responsey
    values.responsex_in_img values.responsey_in_img values.responsex_pct values.responsey_pct
    values.img_widthpx values.img_heightpx)
/ separatefiles = true
</data>