This article applies to:
This sample demonstrates how to use the distance formula for pixels, the MouseResponseData type, and canvas drawing commands. The experiment presents image stimuli, records onscreen mouse click responses, calculates the number of pixels between the center of the stimulus and the mouse click/touchscreen response coordinates, and then draws a line that connects these two points.
E-Basic script supports a variety of mathematical functions. E-Basic allows you to calculate square roots, absolute values, exponents, etc. You are able to combine these mathematical functions with your numeric variables to recreate common mathematical formulas in E-Basic. One formula you are able to recreate in E-Prime is the distance formula:
This formula is useful for paradigms that judge distance errors (i.e., to calculate the distance between a mouse click or touchscreen response coordinate and a stimulus that is now offscreen). This method is also adoptable for eye tracking paradigms using E-Prime eye tracker Extension packages. You would use this when you want to calculate the distance between the onscreen gaze coordinates for a given sample and the center of your stimulus, for example.
NOTE: This sample uses XAlign and YAlign = Center to simplify the calculation of the centermost pixel of the image, see E-STUDIO: Frame . When you use an attribute reference in a positional property field, E-Studio appends ":[default]" to the end of the attribute reference, where "[default]" refers to the default setting for the property, see INFO: Use of Colon in E-Studio . For example, the X and Y properties for the SlideImage sub-object say "[XPos]:center" and "[YPos]:center".
If you use exact pixel coordinates, this provides higher precision in your distance calculations than using small Buttons (in E-Prime 3.0) or the HitTest function in script on small Slide sub-objects. This is useful when a visual stimulus has any visual sub-components of interest (i.e., to calculate the distance between the gaze coordinates and the mouth, ears, nose or eyes of a face image stimulus).
NOTE: The Width of the SlideImage sub-object is set to 25% and the Height is set to 44% in order to best maintain the image's round shape when you run at a 1024x768 resolution for a typical 16:9 aspect ratio, be aware that a monitor with a native resolution that does not have a 16:9 aspect ratio may yield unusual results for these current dimensions, see INFO: Use of percentage value instead of pixel values .