EyeLink: source files to BIDS derivatives¶
Pyxations uses BIDS TSV.GZ/JSON as its canonical on-disk representation and Polars in memory.
In [1]:
Copied!
from pathlib import Path
from pyxations import Experiment, compute_derivatives_for_dataset, dataset_to_bids
from pathlib import Path
from pyxations import Experiment, compute_derivatives_for_dataset, dataset_to_bids
In [2]:
Copied!
repo = next(
path
for path in (Path.cwd(), *Path.cwd().parents)
if (path / "pyproject.toml").is_file()
)
source = repo / "examples" / "eyelink_visual_search"
output = repo / "generated"
raw_bids = dataset_to_bids(
output, source, "eyelink-visual-search", format_name="eyelink", overwrite=True
)
derivatives = compute_derivatives_for_dataset(
raw_bids,
"eyelink",
detection_algorithm="eyelink",
msg_keywords=["begin", "end", "press"],
start_msgs={"search": ["beginning_of_stimuli"]},
end_msgs={"search": ["end_of_stimuli"]},
num_processes=1,
overwrite=True,
)
derivatives
repo = next(
path
for path in (Path.cwd(), *Path.cwd().parents)
if (path / "pyproject.toml").is_file()
)
source = repo / "examples" / "eyelink_visual_search"
output = repo / "generated"
raw_bids = dataset_to_bids(
output, source, "eyelink-visual-search", format_name="eyelink", overwrite=True
)
derivatives = compute_derivatives_for_dataset(
raw_bids,
"eyelink",
detection_algorithm="eyelink",
msg_keywords=["begin", "end", "press"],
start_msgs={"search": ["beginning_of_stimuli"]},
end_msgs={"search": ["end_of_stimuli"]},
num_processes=1,
overwrite=True,
)
derivatives
Out[2]:
PosixPath('/home/runner/work/pyxations/pyxations/generated/eyelink-visual-search_derivatives')
The analysis hierarchy reads the canonical derivative tables and exposes Polars DataFrames.
In [3]:
Copied!
experiment = Experiment(raw_bids)
experiment.load_data("eyelink")
experiment.samples().head()
experiment = Experiment(raw_bids)
experiment.load_data("eyelink")
experiment.samples().head()
Out[3]:
shape: (5, 16)
| tSample | LX | LY | LPupil | Line_number | RX | RY | RPupil | Rate_recorded | Eyes_recorded | bad | phase | trial_number | trial_label | session_id | subject_id |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| f64 | f64 | f64 | f64 | i64 | f64 | f64 | f64 | f64 | str | bool | str | i64 | str | str | str |
| 0.0 | 919.0 | 515.5 | 844.0 | 2699 | 959.8 | 537.6 | 812.0 | 1000.0 | "LR" | false | "search" | 0 | "" | "second" | "0001" |
| 1.0 | 917.2 | 515.9 | 844.0 | 2700 | 958.9 | 538.3 | 811.0 | 1000.0 | "LR" | false | "search" | 0 | "" | "second" | "0001" |
| 2.0 | 914.2 | 516.6 | 845.0 | 2701 | 958.1 | 539.1 | 814.0 | 1000.0 | "LR" | false | "search" | 0 | "" | "second" | "0001" |
| 3.0 | 911.5 | 518.6 | 845.0 | 2702 | 957.2 | 539.5 | 817.0 | 1000.0 | "LR" | false | "search" | 0 | "" | "second" | "0001" |
| 4.0 | 910.4 | 520.4 | 846.0 | 2703 | 955.7 | 539.8 | 817.0 | 1000.0 | "LR" | false | "search" | 0 | "" | "second" | "0001" |
Plotting a trial renders its scanpath. Figures are written under the
derivative dataset's figures/, which its .bidsignore excludes, so
plotting never invalidates the dataset.
In [4]:
Copied!
trial = experiment["0001"]["second"][0]
trial.plot_scanpath(screen_height=1080, screen_width=1920, display=True)
trial = experiment["0001"]["second"][0]
trial.plot_scanpath(screen_height=1080, screen_width=1920, display=True)