Millisecond Forums

Set absolute stimuli size

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

By lukasg - 1/29/2022

Hello all,

For my experiment it is important that stimuli are of the same exact size, irrespective of the screen they are being presented on. I am hesitant to set the canvas size to a particular value because it requires me to set a minimum screen size for eligible participants. Instead, I was hoping to set the size of my stimuli, as well as the distance between them. My attempt looks as follows:

<list t_x>
/ items = (display.getmmx(display.width/2, 1) - 10mm, display.getmmx(display.width/2, 1), display.getmmx(display.width/2, 1) + 10mm)
display.getmmx(pixels, monitor)
display.getmmx(pixels, monitor)
/ poolsize = 60
</list>

<text t>
/ items = targets
/ select = values.t
/ hposition = values.t_x
/ txcolor = values.t_color
/ erase = false
</text>



The above code is not doing as I intended (one letter position in the centre, one 10mm to the left, one 10mm to the right). How can I achieve this?

All the best,
Lukas
By lukasg - 1/31/2022

/ hposition = 1px * (display.canvaswidth/2) - 10 * expressions.ratio_pxpermm
In search for a solution I came across previous entries on absolute stimuli sizes. However, I do not see how I can translate this to the present example. The recurring issue is that display.canvaswidth and others provide the total pixel width. Thus, the physical distance in cm will differ across screens?

e.g.:

/ hposition = 1px * (display.canvaswidth/2) - 10 * expressions.ratio_pxpermm


Instead, I would two letters to presented at a horizontal distance of 2cm, for instance.
By Dave - 1/31/2022

lukasg - 1/31/2022
/ hposition = 1px * (display.canvaswidth/2) - 10 * expressions.ratio_pxpermm
In search for a solution I came across previous entries on absolute stimuli sizes. However, I do not see how I can translate this to the present example. The recurring issue is that display.canvaswidth and others provide the total pixel width. Thus, the physical distance in cm will differ across screens?

e.g.:

/ hposition = 1px * (display.canvaswidth/2) - 10 * expressions.ratio_pxpermm


Instead, I would two letters to presented at a horizontal distance of 2cm, for instance.

<block myblock>
/ onblockbegin = [
    values.c = 1mm*display.getmmx(display.width/2);
    values.l = values.c - 10mm;
    values.r = values.c + 10mm;
]

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

<values>
/ c = 0
/ l = 0
/ r = 0
</values>


<trial mytrial>
/ stimulusframes = [1=center, left, right]
/ validresponse = (57)
</trial>

<text center>
/ items = ("0")
/ hposition = values.c
</text>

<text left>
/ items = ("-10")
/ hposition = values.l
</text>

<text right>
/ items = ("+10")
/ hposition = values.r
</text>
By lukasg - 1/31/2022

Dave - 1/31/2022

<block myblock>
/ onblockbegin = [
    values.c = 1mm*display.getmmx(display.width/2);
    values.l = values.c - 10mm;
    values.r = values.c + 10mm;
]

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

<values>
/ c = 0
/ l = 0
/ r = 0
</values>


<trial mytrial>
/ stimulusframes = [1=center, left, right]
/ validresponse = (57)
</trial>

<text center>
/ items = ("0")
/ hposition = values.c
</text>

<text left>
/ items = ("-10")
/ hposition = values.l
</text>

<text right>
/ items = ("+10")
/ hposition = values.r
</text>

Great, exactly what I was looking for. I do have a follow-up question. It appears the code takes the dimensions of my primary screen (laptop). As a result, the stimuli are shifted when presenting the experiment on an external monitor. Is there a way to ensure the mm dimensions are taken from the screen that the experiment is running on?
By Dave - 1/31/2022

lukasg - 1/31/2022
Dave - 1/31/2022

<block myblock>
/ onblockbegin = [
    values.c = 1mm*display.getmmx(display.width/2);
    values.l = values.c - 10mm;
    values.r = values.c + 10mm;
]

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

<values>
/ c = 0
/ l = 0
/ r = 0
</values>


<trial mytrial>
/ stimulusframes = [1=center, left, right]
/ validresponse = (57)
</trial>

<text center>
/ items = ("0")
/ hposition = values.c
</text>

<text left>
/ items = ("-10")
/ hposition = values.l
</text>

<text right>
/ items = ("+10")
/ hposition = values.r
</text>

Great, exactly what I was looking for. I do have a follow-up question. It appears the code takes the dimensions of my primary screen (laptop). As a result, the stimuli are shifted when presenting the experiment on an external monitor. Is there a way to ensure the mm dimensions are taken from the screen that the experiment is running on?

The getmmx() function allows you to specify the monitor.

https://www.millisecond.com/support/docs/v6/html/language/functions/getmmx.htm
By lukasg - 1/31/2022

Dave - 1/31/2022
lukasg - 1/31/2022
Dave - 1/31/2022

<block myblock>
/ onblockbegin = [
    values.c = 1mm*display.getmmx(display.width/2);
    values.l = values.c - 10mm;
    values.r = values.c + 10mm;
]

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

<values>
/ c = 0
/ l = 0
/ r = 0
</values>


<trial mytrial>
/ stimulusframes = [1=center, left, right]
/ validresponse = (57)
</trial>

<text center>
/ items = ("0")
/ hposition = values.c
</text>

<text left>
/ items = ("-10")
/ hposition = values.l
</text>

<text right>
/ items = ("+10")
/ hposition = values.r
</text>

Great, exactly what I was looking for. I do have a follow-up question. It appears the code takes the dimensions of my primary screen (laptop). As a result, the stimuli are shifted when presenting the experiment on an external monitor. Is there a way to ensure the mm dimensions are taken from the screen that the experiment is running on?

The getmmx() function allows you to specify the monitor.

https://www.millisecond.com/support/docs/v6/html/language/functions/getmmx.htm

But there is no way of selecting the screen the experiment is being presented on? This may be the 1st screen for some participants and the 2nd or 3rd for others?
By Dave - 1/31/2022

lukasg - 1/31/2022
Dave - 1/31/2022
lukasg - 1/31/2022
Dave - 1/31/2022

<block myblock>
/ onblockbegin = [
    values.c = 1mm*display.getmmx(display.width/2);
    values.l = values.c - 10mm;
    values.r = values.c + 10mm;
]

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

<values>
/ c = 0
/ l = 0
/ r = 0
</values>


<trial mytrial>
/ stimulusframes = [1=center, left, right]
/ validresponse = (57)
</trial>

<text center>
/ items = ("0")
/ hposition = values.c
</text>

<text left>
/ items = ("-10")
/ hposition = values.l
</text>

<text right>
/ items = ("+10")
/ hposition = values.r
</text>

Great, exactly what I was looking for. I do have a follow-up question. It appears the code takes the dimensions of my primary screen (laptop). As a result, the stimuli are shifted when presenting the experiment on an external monitor. Is there a way to ensure the mm dimensions are taken from the screen that the experiment is running on?

The getmmx() function allows you to specify the monitor.

https://www.millisecond.com/support/docs/v6/html/language/functions/getmmx.htm

But there is no way of selecting the screen the experiment is being presented on? This may be the 1st screen for some participants and the 2nd or 3rd for others?

The experiment will run on what the respective user has set as their primary display. That's the only safe and reasonable choice and most people will not have multiple displays attached.
By lukasg - 2/15/2022


Dave - 1/31/2022
lukasg - 1/31/2022
/ hposition = 1px * (display.canvaswidth/2) - 10 * expressions.ratio_pxpermm
In search for a solution I came across previous entries on absolute stimuli sizes. However, I do not see how I can translate this to the present example. The recurring issue is that display.canvaswidth and others provide the total pixel width. Thus, the physical distance in cm will differ across screens?

e.g.:

/ hposition = 1px * (display.canvaswidth/2) - 10 * expressions.ratio_pxpermm


Instead, I would two letters to presented at a horizontal distance of 2cm, for instance.

<block myblock>
/ onblockbegin = [
    values.c = 1mm*display.getmmx(display.width/2);
    values.l = values.c - 10mm;
    values.r = values.c + 10mm;
]

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

<values>
/ c = 0
/ l = 0
/ r = 0
</values>


<trial mytrial>
/ stimulusframes = [1=center, left, right]
/ validresponse = (57)
</trial>

<text center>
/ items = ("0")
/ hposition = values.c
</text>

<text left>
/ items = ("-10")
/ hposition = values.l
</text>

<text right>
/ items = ("+10")
/ hposition = values.r
</text>

Hello,

To obtain the physical center of the screen and place stimuli at a set distance (in mm) I have used the following code:

</values>
/ center = 0
/ left = 0
/ right = 0
</values>

<list t_x>
/ items = (values.center, values.left, values.right)
/ poolsize = 60
</list>

<list d_x>
/ items = (values.center, values.left, values.right)
/ selectionrate = always
/ not = (values.t_x)
</list>

<text t>
/ items = targets
/ select = values.t
/ hposition = values.t_x
/ txcolor = values.t_color
/ erase = false
/ fontstyle = ("Arial", 1.05cm, false, false, false, false, 5, 0)
</text>

<text d1>
/ items = distractors
/ select = values.d1
/ hposition = values.d1_x
/ txcolor = values.d1_color
/ erase = false
/ fontstyle = ("Arial", 1.05cm, false, false, false, false, 5, 0)
</text>

<text d2>
/ items = distractors
/ select = values.d2
/ hposition = values.d2_x
/ txcolor = values.d2_color
/ erase = false
/ fontstyle = ("Arial", 1.05cm, false, false, false, false, 5, 0)
</text>

<text dig1>
/ items = digits
/ select = values.dig1
/ hposition = values.center - 25mm
/ txcolor = black
/ erase = false
/ fontstyle = ("Arial", 1.05cm, false, false, false, false, 5, 0)
</text>

<text dig2>
/ items = digits
/ select = values.dig2
/ hposition = values.center + 25mm
/ txcolor = black
/ erase = false
/ fontstyle = ("Arial", 1.05cm, false, false, false, false, 5, 0)
</text>



/ onexptbegin = [
    defaults.finishpage = "INSERT PROLIFIC LINK";
    
//values.center = 1mm*display.getmmx(display.width/2);
    values.center = 1mm*display.getmmx(display.width/2,2);
values.left = values.center - 13mm;
values.right = values.center + 13mm;
]


While the rest of the experiment is displayed perfectly fine in the centre of the screen, the stimuli are displayed with an offset to the right - where do I go wrong?

By Dave - 2/15/2022

lukasg - 2/15/2022

Dave - 1/31/2022
lukasg - 1/31/2022
/ hposition = 1px * (display.canvaswidth/2) - 10 * expressions.ratio_pxpermm
In search for a solution I came across previous entries on absolute stimuli sizes. However, I do not see how I can translate this to the present example. The recurring issue is that display.canvaswidth and others provide the total pixel width. Thus, the physical distance in cm will differ across screens?

e.g.:

/ hposition = 1px * (display.canvaswidth/2) - 10 * expressions.ratio_pxpermm


Instead, I would two letters to presented at a horizontal distance of 2cm, for instance.

<block myblock>
/ onblockbegin = [
    values.c = 1mm*display.getmmx(display.width/2);
    values.l = values.c - 10mm;
    values.r = values.c + 10mm;
]

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

<values>
/ c = 0
/ l = 0
/ r = 0
</values>


<trial mytrial>
/ stimulusframes = [1=center, left, right]
/ validresponse = (57)
</trial>

<text center>
/ items = ("0")
/ hposition = values.c
</text>

<text left>
/ items = ("-10")
/ hposition = values.l
</text>

<text right>
/ items = ("+10")
/ hposition = values.r
</text>

Hello,

To obtain the physical center of the screen and place stimuli at a set distance (in mm) I have used the following code:

</values>
/ center = 0
/ left = 0
/ right = 0
</values>

<list t_x>
/ items = (values.center, values.left, values.right)
/ poolsize = 60
</list>

<list d_x>
/ items = (values.center, values.left, values.right)
/ selectionrate = always
/ not = (values.t_x)
</list>

<text t>
/ items = targets
/ select = values.t
/ hposition = values.t_x
/ txcolor = values.t_color
/ erase = false
/ fontstyle = ("Arial", 1.05cm, false, false, false, false, 5, 0)
</text>

<text d1>
/ items = distractors
/ select = values.d1
/ hposition = values.d1_x
/ txcolor = values.d1_color
/ erase = false
/ fontstyle = ("Arial", 1.05cm, false, false, false, false, 5, 0)
</text>

<text d2>
/ items = distractors
/ select = values.d2
/ hposition = values.d2_x
/ txcolor = values.d2_color
/ erase = false
/ fontstyle = ("Arial", 1.05cm, false, false, false, false, 5, 0)
</text>

<text dig1>
/ items = digits
/ select = values.dig1
/ hposition = values.center - 25mm
/ txcolor = black
/ erase = false
/ fontstyle = ("Arial", 1.05cm, false, false, false, false, 5, 0)
</text>

<text dig2>
/ items = digits
/ select = values.dig2
/ hposition = values.center + 25mm
/ txcolor = black
/ erase = false
/ fontstyle = ("Arial", 1.05cm, false, false, false, false, 5, 0)
</text>



/ onexptbegin = [
    defaults.finishpage = "INSERT PROLIFIC LINK";
    
//values.center = 1mm*display.getmmx(display.width/2);
    values.center = 1mm*display.getmmx(display.width/2,2);
values.left = values.center - 13mm;
values.right = values.center + 13mm;
]


While the rest of the experiment is displayed perfectly fine in the centre of the screen, the stimuli are displayed with an offset to the right - where do I go wrong?


It's not possible to say based on an incomplete code snippet. My guess would be you're wrong in using display.width, and ought to use display.canvaswidth.
By lukasg - 2/15/2022

Dave - 2/15/2022

It's not possible to say based on an incomplete code snippet. My guess would be you're wrong in using display.width, and ought to use display.canvaswidth.

I have attached the entire script. Changing to canvaswidth did not resolve the issue.
By lukasg - 2/15/2022

lukasg - 2/15/2022

I have attached the entire script. Changing to canvaswidth did not resolve the issue.

I managed to fix it. Thanks for your help.
By Dave - 2/15/2022


In the script you attached, you had

values.center = 1mm * display.getmmx(display.canvaswidth,1);

but it needs to be

values.center = 1mm * display.getmmx(display.canvaswidth/2,1);

if you want the center.
By lukasg - 2/15/2022

Dave - 2/15/2022

In the script you attached, you had

values.center = 1mm * display.getmmx(display.canvaswidth,1);

but it needs to be

values.center = 1mm * display.getmmx(display.canvaswidth/2,1);

if you want the center.

Yes indeed, that's what I noticed as well- thanks.