Skip to content

ENH: eyetracking plot_heatmap function #11798

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 40 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
4b256c6
ENH: eyetracking plot_heatmap function
scott-huberty Jul 12, 2023
318d974
FIX: next matplotlib
scott-huberty Jul 12, 2023
895f2ea
WIP: refactor heatmap code
scott-huberty Jul 19, 2023
e37dcd3
Merge remote-tracking branch 'upstream/main' into plot_gaze
scott-huberty Aug 12, 2023
d8575a9
Merge remote-tracking branch 'upstream/main' into plot_gaze
scott-huberty Sep 20, 2023
320fc39
ENH, DOC: refactor plot_gaze and add to API doc
scott-huberty Sep 21, 2023
09ce77d
DOC: update eyelink dataset and its description
scott-huberty Sep 21, 2023
26888cd
DOC: add a new eyetracking tutorial
scott-huberty Sep 21, 2023
2cfc3e1
TST: remove requires_pandas decorator from pytest
scott-huberty Sep 21, 2023
0e8985f
DOC: fix typo
scott-huberty Sep 21, 2023
26054f0
FIX, DOC: add alpha parameter to API docstring
scott-huberty Sep 21, 2023
aec89f8
DOC: in tutorial, dont baseline correct eyegaze channels
scott-huberty Sep 21, 2023
dd65afe
Merge branch 'main' into plot_gaze
larsoner Sep 25, 2023
29eb623
FIX: Need module
larsoner Sep 28, 2023
324d74e
Merge remote-tracking branch 'upstream/main' into plot_gaze
scott-huberty Sep 28, 2023
6962df9
FIX: Code suggestions from Eric
scott-huberty Sep 29, 2023
20e3056
TST: add a test
scott-huberty Sep 29, 2023
6bedba6
Apply suggestions from code review [ci skip]
scott-huberty Oct 2, 2023
d0a2caa
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 2, 2023
c421d50
FIX, DOC: Code suggestions from eric and mne.utils.doc addition
scott-huberty Oct 2, 2023
379abf0
FIX: doc_dict addition wasnt in alphabetical order
scott-huberty Oct 2, 2023
6531e53
DOC: be more memory efficient in eyetracking tutorial
scott-huberty Oct 2, 2023
3b17ec1
FIX: obvious typo....
scott-huberty Oct 2, 2023
6085bc5
FIX, DOC: More doc fixes...
scott-huberty Oct 2, 2023
8305a1d
Apply suggestions from code review [ci skip]
scott-huberty Oct 3, 2023
baaa7bc
FIX: fixed a mistake in _ensure_int parameter
scott-huberty Oct 4, 2023
b5c6079
Simplify tutorial
scott-huberty Oct 4, 2023
093a003
Move new tutorial to examples
scott-huberty Oct 4, 2023
7c693db
DOC: Rename tutorial, remove 30_ that was prepended to filename
scott-huberty Oct 4, 2023
bba5d7d
FIX: add py extension back to tutorial filename
scott-huberty Oct 4, 2023
927fdad
STY: remove unnecessary transpose
scott-huberty Oct 9, 2023
0c5b8f1
TST: set sigma to None in test and check that fig data match input data
scott-huberty Oct 9, 2023
df33e33
Merge remote-tracking branch 'upstream/main' into plot_gaze
scott-huberty Oct 9, 2023
7ecc759
Merge remote-tracking branch 'upstream/main' into plot_gaze
scott-huberty Oct 10, 2023
9896f2b
DOC, STY: split Eyelink dataset description
scott-huberty Oct 10, 2023
32a3e64
TST: Make test more direct
scott-huberty Oct 10, 2023
5add060
DOC: minor documentation revisions suggested by Dan
scott-huberty Oct 11, 2023
ea7e653
Update examples/visualization/eyetracking_plot_heatmap.py
drammock Oct 11, 2023
0e3e495
Merge branch 'main' into plot_gaze
larsoner Oct 12, 2023
d89ef77
FIX: Order
larsoner Oct 12, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions doc/documentation/datasets.rst
Original file line number Diff line number Diff line change
Expand Up @@ -481,17 +481,32 @@ EYELINK
=======
:func:`mne.datasets.eyelink.data_path`

Two small example datasets of eye-tracking data from SR Research EyeLink. the "eeg-et"
dataset contains both EEG (EGI) and eye-tracking (ASCII format) data recorded from a
Two small example datasets of eye-tracking data from SR Research EyeLink.

EEG-Eyetracking
^^^^^^^^^^^^^^^
:func:`mne.datasets.eyelink.data_path`. Data exists at ``/eeg-et/``.

Contains both EEG (EGI) and eye-tracking (ASCII format) data recorded from a
pupillary light reflex experiment, stored in separate files. 1 participant fixated
on the screen while short light flashes appeared. Event onsets were recorded by a
photodiode attached to the screen and were sent to both the EEG and eye-tracking
systems. The second dataset, in the "freeviewing" directory, contains only eye-tracking
data (ASCII format) from 1 participant who was free-viewing a natural scene.
systems.

.. topic:: Examples

* :ref:`tut-eyetrack`

Freeviewing
^^^^^^^^^^^
:func:`mne.datasets.eyelink.data_path`. Data exists at ``/freeviewing/``.

Contains eye-tracking data (ASCII format) from 1 participant who was free-viewing a
video of a natural scene. In some videos, the natural scene was pixelated such that
the people in the scene were unrecognizable.

.. topic:: Examples

* :ref:`tut-eyetrack-heatmap`

References
Expand Down
12 changes: 4 additions & 8 deletions examples/visualization/eyetracking_plot_heatmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

.. seealso:: :ref:`tut-importing-eyetracking-data`

.. seealso:: :ref:`tut-eyetrack`

"""

# %%
Expand All @@ -26,11 +28,6 @@
import mne
from mne.viz.eyetracking import plot_gaze


# define variables to pass to the plot_gaze function
px_width, px_height = 1920, 1080
cmap = plt.get_cmap("viridis")

task_fpath = mne.datasets.eyelink.data_path() / "freeviewing"
et_fpath = task_fpath / "sub-01_task-freeview_eyetrack.asc"
stim_fpath = task_fpath / "stim" / "naturalistic.png"
Expand All @@ -52,9 +49,6 @@
raw, events=events, event_id=event_dict, tmin=0, tmax=20, baseline=None
)

# %%
# .. seealso:: :ref:`tut-eyetrack`
#

# %%
# Plot a heatmap of the eye-tracking data
Expand All @@ -66,6 +60,8 @@
# screen resolution of the participant screen (1920x1080) as the width and height. We
# can also use the sigma parameter to smooth the plot.

px_width, px_height = 1920, 1080
cmap = plt.get_cmap("viridis")
plot_gaze(epochs["natural"], width=px_width, height=px_height, cmap=cmap, sigma=50)

# %%
Expand Down
7 changes: 3 additions & 4 deletions mne/viz/eyetracking/tests/test_heatmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ def test_plot_heatmap(axes):
epochs, width=width, height=height, axes=axes, cmap="Greys", sigma=None
)
img = fig.axes[0].images[0].get_array()
# We simulated a 2D histogram where only values of 960 and 540 are present
# Check that the heatmap data only contains these values
np.testing.assert_array_almost_equal(np.where(img.T)[0], data[0].mean()) # 960
np.testing.assert_array_almost_equal(np.where(img.T)[1], data[1].mean()) # 540
# We simulated a 2D histogram where only the central pixel (960, 540) was active
assert img.T[width // 2, height // 2] == 1 # central pixel is active
assert np.sum(img) == 1 # only the central pixel should be active