Skip to content
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

ENH: eyetracking plot_heatmap function #11798

Merged
merged 40 commits into from
Oct 12, 2023
Merged

Conversation

scott-huberty
Copy link
Contributor

@scott-huberty scott-huberty commented Jul 12, 2023

Closes #11782.

What does this implement/fix?

Added a mne.viz.eyetracking namespace and added a function plot_gaze to plot a heatmap of the gaze position data.

Minimally Working Example from our test file:

import mne
from mne.datasets.testing import data_path

eyelink = data_path() / "eyetrack" / "test_eyelink.asc"
raw = mne.io.read_raw_eyelink(eyelink)
mne.preprocessing.eyetracking.interpolate_blinks(raw, interpolate_gaze=True)
epochs = mne.make_fixed_length_epochs(raw, duration=5, preload=True)
mne.viz.eyetracking.plot_gaze(epochs, width=1920, height=1080, sigma=2)

heatmap

Documentation Quick links

TODOS:

  • add a new tutorial "visualizing eye-tracking data", and a new dataset that would produce a more informative heatmap.

@scott-huberty scott-huberty marked this pull request as draft July 12, 2023 16:17
@larsoner
Copy link
Member

Looks like a good start, let me know when I should really look @scott-huberty !

@scott-huberty
Copy link
Contributor Author

Looks like a good start, let me know when I should really look @scott-huberty !

Alright! It's not ready yet and I'm a bit stuck on a few points, can I meet with you @britta-wstnr or one of the other devs tomorrow or next week?

1 similar comment
@scott-huberty
Copy link
Contributor Author

Looks like a good start, let me know when I should really look @scott-huberty !

Alright! It's not ready yet and I'm a bit stuck on a few points, can I meet with you @britta-wstnr or one of the other devs tomorrow or next week?

@larsoner
Copy link
Member

I can't meet tomorrow morning my time, which would be my only reasonable overlap with @britta-wstnr . So feel free to meet with her in my morning if you can and if not ping me on Discord and we can meet afternoon EDT

@britta-wstnr
Copy link
Member

@scott-huberty we can meet during dev meeting today?

@scott-huberty
Copy link
Contributor Author

@scott-huberty we can meet during dev meeting today?

Sure!

- took another pass at this function to simplify it. mainly, made
- plot_heatmap_array private
- added a second eyelink dataset for a heatmap tutorial
- added a new tutorial for plotting eyetracking heatmaps
- included a brief example of heatmap plotting in current tutorial
- the alpha parameter was missing from the docstring which caused a numpydoc error
- This is a tough one. In the "working with eye tracker data" tut, I DO want to baseline correct the pupil channel, but I DONT want to baseline correct eyegaze channels. I am not sure that it EVER makes sense to baseline correct eyegaze channels, given that they USUALLY represent a gaze coordinate, but I need to think about this more.
- I may open a separate ticket about this matter
@scott-huberty scott-huberty marked this pull request as ready for review September 22, 2023 12:18
@scott-huberty
Copy link
Contributor Author

scott-huberty commented Sep 22, 2023

Sorry for the delay on this! I think this is finally ready for review. @larsoner / @drammock I assume I'll mainly be corresponding with you next week for the code sprint. Could we carve out some time next week to look at this?

Also CC @britta-wstnr as my GSOC mentor and @mscheltienne .

Tutorials

Tests

Per the failing tests: I had a quick look and it seems related to a (new?) deprecation warning from Numba?

@larsoner
Copy link
Member

For the test can you add ignore:Code using Numba extension API.*: to mne/conftest.py ? Agreed it's unrelated to this PR but should get things green. I can't look at the code today but agree we should next week unless everyone else is happy today, in which case feel free to merge without me looking

@scott-huberty
Copy link
Contributor Author

For the test can you add ignore:Code using Numba extension API.*: to mne/conftest.py ?

Ok will do!

I can't look at the code today but agree we should next week unless everyone else is happy today, in which case feel free to merge without me looking

No rush on my side

@drammock
Copy link
Member

drammock commented Oct 3, 2023

The heatmap tutorial I've added currently sits in the Tutorials section. It could probably instead live in the How-to examples section (and maybe it would be a better fit there?). Do you have any opinion on where this tutorial should live?

Good question. It's how-to like in that it only really demonstrates how to do one thing. It's tutorial like in that the code and explanations are interleaved and somewhat verbose and there are demarcated sections. If this were in examples, it would be better IMO to omit details about the experimental paradigm, and probably just show 2 figures each with only 1 subplot: one full heatmap and one heatmap overlayed on an image. That would also let you get rid of the custom image plotting function, which would shorten the recipe. Basically for the recipes I advise to distill as much as possible down to the core commands necessary to complete the task; users can extrapolate to their use case from there.

If you're willing to do the distillations and move to the examples folder I think that would make sense. If you're sick of it LMK and I can probably find time to do it this week.

@scott-huberty
Copy link
Contributor Author

If you're willing to do the distillations and move to the examples folder I think that would make sense. If you're sick of it LMK and I can probably find time to do it this week.

No problem I can do that this week. I agree It will probably be a net-positive to simplify that tutorial so users can quickly get what they need.

@scott-huberty
Copy link
Contributor Author

scott-huberty commented Oct 10, 2023

Hey @drammock , another question. In mne.viz.eyetracking.heatmap I import from scipy.ndimage import gaussian_filter at the top of the file. should I instead be using lazy_loader to do:

import lazy
sp = lazy.load('scipy')
...
sp.ndimage.gaussian_filter( ... )

I'm still a little confused on how to use lazy_loader..

@drammock
Copy link
Member

should I instead be using lazy_loader

Nope. It's possible to do it that way, but not necessary. For us, lazy loader only ever gets used in the init files

Copy link
Member

@drammock drammock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a few nitpicks / small refinements. thanks @scott-huberty the conversion to a "recipe" style example went well I think!

examples/visualization/eyetracking_plot_heatmap.py Outdated Show resolved Hide resolved
examples/visualization/eyetracking_plot_heatmap.py Outdated Show resolved Hide resolved
mne/viz/__init__.py Outdated Show resolved Hide resolved
mne/viz/eyetracking/tests/test_heatmap.py Outdated Show resolved Hide resolved
scott-huberty and others added 3 commits October 10, 2023 16:01
Co-authored-by: Daniel McCloy <dan@mccloy.info>
Co-authored-by: Daniel McCloy <dan@mccloy.info>
@drammock drammock enabled auto-merge (squash) October 11, 2023 18:22
@drammock
Copy link
Member

@larsoner I'm happy with this one but you have requested changes here.

@drammock drammock merged commit c9d2006 into mne-tools:main Oct 12, 2023
28 checks passed
snwnde pushed a commit to snwnde/mne-python that referenced this pull request Mar 20, 2024
Co-authored-by: Eric Larson <larson.eric.d@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Daniel McCloy <dan@mccloy.info>
Co-authored-by: Mathieu Scheltienne <mathieu.scheltienne@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add function to plot heatmap of eye-tracking gaze position
5 participants