Skip to content

Commit acab264

Browse files
scott-hubertylarsonerdrammockbritta-wstnr
authored
Function to convert eyegaze units to radians (#12237)
Co-authored-by: Eric Larson <[email protected]> Co-authored-by: Daniel McCloy <[email protected]> Co-authored-by: Britta Westner <[email protected]>
1 parent 87df00d commit acab264

21 files changed

+509
-62
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,14 @@ repos:
1111
name: ruff lint mne preview
1212
args: ["--fix", "--preview", "--select=NPY201"]
1313
files: ^mne/
14-
- id: ruff-format
15-
name: ruff format mne
16-
files: ^mne/
1714
- id: ruff
18-
name: ruff lint tutorials and examples
15+
name: ruff lint doc, tutorials, and examples
1916
# D103: missing docstring in public function
2017
# D400: docstring first line must end with period
2118
args: ["--ignore=D103,D400", "--fix"]
22-
files: ^tutorials/|^examples/
19+
files: ^doc/|^tutorials/|^examples/
2320
- id: ruff-format
24-
name: ruff format tutorials and examples
25-
files: ^tutorials/|^examples/
21+
files: ^mne/|^doc/|^tutorials/|^examples/
2622

2723
# Codespell
2824
- repo: https://github.com/codespell-project/codespell

doc/api/preprocessing.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ Projections:
162162
Calibration
163163
read_eyelink_calibration
164164
set_channel_types_eyetrack
165+
convert_units
166+
get_screen_visual_angle
165167
interpolate_blinks
166168

167169
EEG referencing:
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Added a helper function :func:`mne.preprocessing.eyetracking.convert_units` to convert eyegaze data from pixel-on-screen values to radians of visual angle. Also added a helper function :func:`mne.preprocessing.eyetracking.get_screen_visual_angle` to get the visual angle that the participant screen subtends, by `Scott Huberty`_.
2+

doc/conf.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,13 @@
2929
from mne.tests.test_docstring_parameters import error_ignores
3030
from mne.utils import (
3131
_assert_no_instances,
32-
linkcode_resolve, # noqa, analysis:ignore
32+
linkcode_resolve,
3333
run_subprocess,
3434
sizeof_fmt,
3535
)
3636
from mne.viz import Brain # noqa
3737

38+
assert linkcode_resolve is not None # avoid flake warnings, used by numpydoc
3839
matplotlib.use("agg")
3940
faulthandler.enable()
4041
os.environ["_MNE_BROWSER_NO_BLOCK"] = "true"
@@ -62,12 +63,12 @@
6263

6364
# We need to triage which date type we use so that incremental builds work
6465
# (Sphinx looks at variable changes and rewrites all files if some change)
65-
copyright = (
66+
copyright = ( # noqa: A001
6667
f'2012–{td.year}, MNE Developers. Last updated <time datetime="{td.isoformat()}" class="localized">{td.strftime("%Y-%m-%d %H:%M %Z")}</time>\n' # noqa: E501
6768
'<script type="text/javascript">$(function () { $("time.localized").each(function () { var el = $(this); el.text(new Date(el.attr("datetime")).toLocaleString([], {dateStyle: "medium", timeStyle: "long"})); }); } )</script>' # noqa: E501
6869
)
6970
if os.getenv("MNE_FULL_DATE", "false").lower() != "true":
70-
copyright = f"2012–{td.year}, MNE Developers. Last updated locally."
71+
copyright = f"2012–{td.year}, MNE Developers. Last updated locally." # noqa: A001
7172

7273
# The version info for the project you're documenting, acts as replacement for
7374
# |version| and |release|, also used in various other places throughout the
@@ -293,6 +294,7 @@
293294
"RawNIRX": "mne.io.Raw",
294295
"RawPersyst": "mne.io.Raw",
295296
"RawSNIRF": "mne.io.Raw",
297+
"Calibration": "mne.preprocessing.eyetracking.Calibration",
296298
# dipy
297299
"dipy.align.AffineMap": "dipy.align.imaffine.AffineMap",
298300
"dipy.align.DiffeomorphicMap": "dipy.align.imwarp.DiffeomorphicMap",
@@ -445,16 +447,18 @@
445447
# -- Sphinx-gallery configuration --------------------------------------------
446448

447449

448-
class Resetter(object):
450+
class Resetter:
449451
"""Simple class to make the str(obj) static for Sphinx build env hash."""
450452

451453
def __init__(self):
452454
self.t0 = time.time()
453455

454456
def __repr__(self):
457+
"""Make a stable repr."""
455458
return f"<{self.__class__.__name__}>"
456459

457460
def __call__(self, gallery_conf, fname, when):
461+
"""Do the reset."""
458462
import matplotlib.pyplot as plt
459463

460464
try:
@@ -1753,7 +1757,7 @@ def reset_warnings(gallery_conf, fname):
17531757
def check_existing_redirect(path):
17541758
"""Make sure existing HTML files are redirects, before overwriting."""
17551759
if path.is_file():
1756-
with open(path, "r") as fid:
1760+
with open(path) as fid:
17571761
for _ in range(8):
17581762
next(fid)
17591763
line = fid.readline()

doc/sphinxext/contrib_avatars.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ def generate_contrib_avatars(app, config):
1515
MNE_ADD_CONTRIBUTOR_IMAGE=true in your environment to generate it.</p>"""
1616
else:
1717
from selenium import webdriver
18+
from selenium.common.exceptions import WebDriverException
1819
from selenium.webdriver.common.by import By
1920
from selenium.webdriver.support.ui import WebDriverWait
20-
from selenium.common.exceptions import WebDriverException
2121

2222
try:
2323
options = webdriver.ChromeOptions()

doc/sphinxext/gen_commands.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
# Copyright the MNE-Python contributors.
33
import glob
44
from importlib import import_module
5-
import os
65
from pathlib import Path
76

8-
from mne.utils import _replace_md5, ArgvSetter
7+
from mne.utils import ArgvSetter, _replace_md5
98

109

1110
def setup(app):

doc/sphinxext/gen_names.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def generate_name_links_rst(app=None):
2525
)
2626
with open(out_fname, "w", encoding="utf8") as fout:
2727
fout.write(":orphan:\n\n")
28-
with open(names_path, "r") as fin:
28+
with open(names_path) as fin:
2929
for line in fin:
3030
if line.startswith(".. _"):
3131
fout.write(f"- {line[4:]}")

doc/sphinxext/gh_substitutions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from docutils.parsers.rst.roles import set_classes
55

66

7-
def gh_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
7+
def gh_role(name, rawtext, text, lineno, inliner, options={}, content=[]): # noqa: B006
88
"""Link to a GitHub issue.
99
1010
adapted from

doc/sphinxext/mne_substitutions.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
from docutils.parsers.rst import Directive
55
from docutils.statemachine import StringList
66

7-
from mne.defaults import DEFAULTS
87
from mne._fiff.pick import (
9-
_PICK_TYPES_DATA_DICT,
10-
_DATA_CH_TYPES_SPLIT,
118
_DATA_CH_TYPES_ORDER_DEFAULT,
9+
_DATA_CH_TYPES_SPLIT,
10+
_PICK_TYPES_DATA_DICT,
1211
)
12+
from mne.defaults import DEFAULTS
1313

1414

1515
class MNESubstitution(Directive): # noqa: D101

doc/sphinxext/newcontrib_substitutions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from docutils.nodes import reference, strong, target
44

55

6-
def newcontrib_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
6+
def newcontrib_role(name, rawtext, text, lineno, inliner, options={}, content=[]): # noqa: B006
77
"""Create a role to highlight new contributors in changelog entries."""
88
newcontrib = f"new contributor {text}"
99
alias_text = f" <{text}_>"

0 commit comments

Comments
 (0)