# Saving eye positions

**URL:** <https://mworks.discourse.group/t/saving-eye-positions/881>\
**Category:** Support\
**Created:** [April 3, 2023, 8:28pm UTC](https://mworks.discourse.group/t/saving-eye-positions/881 "2023-04-03T20:28:54Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yoon\_Bai](https://avatars.discourse-cdn.com/v4/letter/y/9fc348/32.png) [@Yoon\_Bai](https://mworks.discourse.group/u/Yoon_Bai)\
**Post date:** [April 3, 2023, 8:28pm UTC](https://mworks.discourse.group/t/saving-eye-positions/881/1 "2023-04-03T20:28:54Z")

</div>

Hi Chris,

Could you help me with the following (adding Sarah and Alina in the loop in case it helps)?

I am presenting videos and wondered if there is a stereotypical pattern of eye movements according to the content of the video. Do you have any suggestions or a code snippet that would help me reconstruct the gaze pattern post hoc?

Also, is there anything to be aware of if I adjust the eye tracker’s sampling frequency (e.g., data\_interval = 2 ms)? I would like to get a sense of the minimum sampling frequency required for my analyses.

In case it helps, here is the dropbox link containing the MWorks experiment w/ videos:

> **[5\_Physion](https://www.dropbox.com/sh/wjfn8nhpcr8210s/AACDBikwtasWu7AIeQ3IXTXta?dl=0)**
>
> Shared with Dropbox

Thanks,  
Yoon

---

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [April 4, 2023, 2:36pm UTC](https://mworks.discourse.group/t/saving-eye-positions/881/2 "2023-04-04T14:36:44Z")

</div>

Invited @sgouldin on April 4, 2023, 2:36pm UTC



---

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [April 4, 2023, 2:36pm UTC](https://mworks.discourse.group/t/saving-eye-positions/881/3 "2023-04-04T14:36:44Z")

</div>

Invited @Alina\_Peter on April 4, 2023, 2:36pm UTC



---

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [April 4, 2023, 2:36pm UTC](https://mworks.discourse.group/t/saving-eye-positions/881/4 "2023-04-04T14:36:44Z")

</div>

Forwarded the above email



---

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [April 4, 2023, 2:46pm UTC](https://mworks.discourse.group/t/saving-eye-positions/881/5 "2023-04-04T14:46:17Z")

</div>

Made this topic public on April 4, 2023, 2:46pm UTC



---

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [April 4, 2023, 3:39pm UTC](https://mworks.discourse.group/t/saving-eye-positions/881/6 "2023-04-04T15:39:14Z")

</div>

Hi Yoon,

> I am presenting videos and wondered if there is a stereotypical pattern of eye movements according to the content of the video. Do you have any suggestions or a code snippet that would help me reconstruct the gaze pattern post hoc?

I’m not sure exactly what you want. Are you hoping to draw an eye trace (similar to what you see in MWClient’s eye window) on top of each video, so that you can see where the gaze is as the video plays? If so, the event file should have all the information you need, but making use of it will take some work.

You can get the details of what part of a video is playing at a given time from [#stimDisplayUpdate](https://mworks.github.io/documentation/latest/reference/sysvars.html#stimdisplayupdate). The timestamp of an SDU event is the predicted time when the update should start appearing on the display. You can compare this directly to the times of `eye_h` and `eye_v` events and thereby plot the eye position (or eye trace) for each frame of the video.

The value of an SDU event is a list of dictionaries, each of which contains the parameters of all stimuli displayed during that update. For a video file, the `filename` parameter tells you which video was playing, and the `current_video_time_seconds` parameter gives you the timestamp in the video of the frame being displayed. You could use this in concert with MATLAB’s [VideoReader](https://www.mathworks.com/help/matlab/import_export/read-video-files.html) to extract and display the frame. (There’s probably some equivalent in Python, but I don’t know what it is.) You’d also want to use `pos_x`, `pos_y`, and `size_x` to position and scale the video, so that you can draw the eye trace correctly on top of it.

Once you have an image of each video frame with a superimposed eye trace, you should be able to put them together in to a movie. Something like MATLAB’s [movie](https://www.mathworks.com/help/matlab/ref/movie.html) function should work.

Does this sound like what you want?

> Also, is there anything to be aware of if I adjust the eye tracker’s sampling frequency (e.g., data\_interval = 2 ms)? I would like to get a sense of the minimum sampling frequency required for my analyses.

The [data\_interval](https://mworks.github.io/documentation/latest/components/eyelink_device.html#data-interval) parameter just sets how often MWorks polls the EyeLink for new data. If you increase its value, you’ll still get the same number of eye samples, but MWorks will receive them in larger batches. If you really want to change the tracker’s sampling frequency, you’ll need to do that on the EyeLink PC.

As for whether it’s wise or helpful to change the sampling frequency, I really don’t know. Maybe the EyeLink docs could provide some guidance?

Cheers,  
Chris

---

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [April 28, 2023, 3:26pm UTC](https://mworks.discourse.group/t/saving-eye-positions/881/7 "2023-04-28T15:26:17Z")

</div>

Closed on April 28, 2023, 3:26pm UTC


