#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

# Is it possible to record the distance between stimuli and where participant clicked?

Hi,

I've already posted this question on MouseTracking forum but I have a feeling my problem may be solved with a simple solution than the complex MouseTracking plug-in. (I tried to take down my question in the other forum but I am not sure how. Please feel free to instruct on that too, haha).

Anyhow, I am trying to build a relative size judgement task where participants will be asked to estimate the height of the goalkeeper (example image attached).

Participants will be asked to click on the pole where they believe the goalkeeper's height would be relative to the soccer ball. With classic mouse function, it records the coordinate (x,y) relative to the whole screen rather than the distance from the bottom bar to the point they clicked. If the bar stayed in that position, I can simply calculate the distance by subtraction clicked-coordinate and position of the bar. However, I am planning to change the position of the pole for each trial.

If anyone knows how I can record distance between a fixed point (i.e., bottom bar) that changes every trial and where the participant clicked, I would greatly appreciate your help.

Thank you very much for your time.

Cheers,

So So

• Hi @SoSo ,

To change the position of the pole on each trial, you need to specify its position, right? So there will probably be two variables, say `pole_x` and `pole_y` , that indicate the center of the pole. And you will have two variables, `cursor_x` and `cursor_y` , that indicate where the participant clicked. And that's all you need!

You can use this to determine afterwards, for example in LibreOffice Calc, what the distance between the pole and the click was (using Pythagoras). Or if you want to be fancy, you can do it in the run phase of a simple `inline_script` after the response has been collected, like so:

```var.distance_to_pole = xy_distance(var.pole_x, var.pole_y, var.cursor_x, var.cursor_y)
```

— Sebastiaan

• Hello @sebastiaan

Yes! That's what I was looking to do.

So, you mean I can assign the pole at different coordinates (pole_x, pole_y) for every trial on sketchpad? So the (pole_x, pole_y) value is already defined even before participant respond. I am not super familiar with how to write inline script so I will have to educate myself and try it out.

On another note, I have another question. I hope you don't mind me asking on the same thread. First image shows the experiment that is running and the second image shows the inline script ("process_team").

1) Why am I able to write numbers but not letters on the experimental screen? How do I edit the script so that it accepts letters?

2) Why am I able to write numbers that were not specified on the script? On the keyboard response, I did allow all numbers to be accepted (0 to 9) but on the script I only included 0,1,2,3,4,5. So why is it still being shown on experimental screen although not specified on script?

Note, this is the inline script that is inserted before the block ("constant_4"). And the inline script above is called "process_team".

Cheers, So So

• Hi So So,

So, you mean I can assign the pole at different coordinates (pole_x, pole_y) for every trial on sketchpad? So the (pole_x, pole_y) value is already defined even before participant respond.

If you want the pole to have a different position on every trial, then yes, you can make it variable. The way to do so is what Sebastiaan described, that is, having 2 variables that code the x and y coordinate of the pole. In the beginner's tutorial step 6, it is explained how to use variables in sketchpads. Let us know if this is not enough to clear things up.

I am not super familiar with how to write inline script so I will have to educate myself and try it out.

Always a good idea :)

On another note, I have another question. I hope you don't mind me asking on the same thread.

Can you share the experiment here? That will make it easier to find out what is happening in your code.

Best,

Eduard

• Dear Eduard,

I have attached only the part where I was having trouble. Basically, I want to ask "What is your favourite football team?" and to accept answers in letters. And I would like to ask the question at the end of the experiment.

Thank you so much!

So So

• Hi Soso,

I removed the parts of your script that dealt with specifying which input to accept, and that works (see attached). I don't think you need to implement any restrictions.

Did you solve the other issue, that is, did you manage to make the location of the pole variable?

Cheers,

Lotje

Did you like my answer? Feel free to