Conversion to BIDS
Reading EyeLink, Tobii, GazePoint and webcam recordings, normalizing their
behavioral tables, and writing the raw BIDS dataset. The original vendor files
are preserved verbatim under the dataset's archival sourcedata/.
bids_formatting
The dataset-level entry points: dataset_to_bids converts a folder of
recordings, and compute_derivatives_for_dataset computes derivatives from the
resulting raw dataset.
Raw-to-BIDS conversion and Polars-native derivative orchestration.
compute_derivatives_for_dataset(bids_dataset_folder, dataset_format, detection_algorithm='remodnav', num_processes=1, force_best_eye=True, overwrite=False, behavioral_columns=None, **kwargs)
Compute canonical BIDS derivatives for every raw BIDS session.
Processing is serial by default to avoid process-startup and serialization
costs for small datasets. Set num_processes above one for large
collections of independent sessions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bids_dataset_folder
|
str or Path
|
Root of the raw BIDS dataset. |
required |
dataset_format
|
('eyelink', 'gaze', 'tobii', 'webgazer')
|
Source format represented by the dataset. |
"eyelink"
|
detection_algorithm
|
('eyelink', 'engbert', 'remodnav')
|
Event source or detector used for every session. |
"eyelink"
|
num_processes
|
int
|
Number of independent session workers. |
1
|
force_best_eye
|
bool
|
Whether to retain only the best validated EyeLink eye. |
True
|
overwrite
|
bool
|
Whether to replace existing derivative sessions. |
False
|
behavioral_columns
|
sequence of str
|
Behavioral fields propagated into trial-level derivative tables. |
None
|
**kwargs
|
object
|
Detector, segmentation, quality, and metadata options. |
{}
|
Returns:
| Type | Description |
|---|---|
Path
|
Root of the generated BIDS Derivatives dataset. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If |
Source code in pyxations/bids_formatting.py
611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 | |
dataset_to_bids(target_folder_path, files_folder_path, dataset_name, session_substrings=1, format_name='eyelink', *, task_name='eyetracking', authors=None, behavioral_column_map=None, overwrite=False)
Convert vendor recordings and associated behavior to raw BIDS.
PsychoPy logs are used when no behavioral CSV or TSV exists for the
recording. behavioral_column_map can map fields from any behavioral
source onto experiment-level names without changing the archived source.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target_folder_path
|
str or Path
|
Parent directory in which to create the dataset. |
required |
files_folder_path
|
str or Path
|
Directory containing vendor recordings and associated behavior. |
required |
dataset_name
|
str
|
Output directory and BIDS dataset name. |
required |
session_substrings
|
int
|
Number of underscore-separated filename tokens used for the session. |
1
|
format_name
|
('eyelink', 'gaze', 'tobii', 'webgazer')
|
Vendor reader used for the source recordings. |
"eyelink"
|
task_name
|
str
|
Fallback BIDS task label. |
"eyetracking"
|
authors
|
sequence of str
|
Dataset authors stored in BIDS metadata. |
None
|
behavioral_column_map
|
mapping of str to str
|
Mapping from source behavioral fields to experiment concepts. |
None
|
overwrite
|
bool
|
Whether to replace an existing non-empty output dataset. |
False
|
Returns:
| Type | Description |
|---|---|
Path
|
Root of the generated raw BIDS dataset. |
Source code in pyxations/bids_formatting.py
process_bids_session(raw_session_path, dataset_format, detection_algorithm, session_folder_path, force_best_eye, **kwargs)
Compute and write one derivative session from normalized raw BIDS.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_session_path
|
str or Path
|
Raw BIDS session directory to process. |
required |
dataset_format
|
('eyelink', 'gaze', 'tobii', 'webgazer')
|
Source format recorded in the raw dataset. |
"eyelink"
|
detection_algorithm
|
('eyelink', 'engbert', 'remodnav')
|
Event source or detector used for the derivative. |
"eyelink"
|
session_folder_path
|
str or Path
|
Destination derivative session directory. |
required |
force_best_eye
|
bool
|
Whether to retain only the eye with the best EyeLink validation. |
required |
**kwargs
|
object
|
Detector, trial-segmentation, quality, and behavioral options. |
{}
|
Source code in pyxations/bids_formatting.py
366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 | |
process_session(raw_session_path, dataset_format, detection_algorithm, session_folder_path, force_best_eye, overwrite, **kwargs)
Process one raw BIDS session unless its requested output already exists.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_session_path
|
str or Path
|
Raw BIDS session directory. |
required |
dataset_format
|
('eyelink', 'gaze', 'tobii', 'webgazer')
|
Source format recorded in the raw dataset. |
"eyelink"
|
detection_algorithm
|
('eyelink', 'engbert', 'remodnav')
|
Event source or detector to use. |
"eyelink"
|
session_folder_path
|
str or Path
|
Destination derivative session directory. |
required |
force_best_eye
|
bool
|
Whether to retain only the best validated EyeLink eye. |
required |
overwrite
|
bool
|
Whether to replace an existing derivative session. |
required |
**kwargs
|
object
|
Options forwarded to :func: |
{}
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in pyxations/bids_formatting.py
bids
The raw BIDS reader and writer, plus the wrapper around the official BIDS Validator used to check that generated datasets are valid.
BIDS eye-tracking writing and validation utilities.
The writer targets the eye-tracking additions in BIDS 1.11.1. Vendor files are
kept under sourcedata while standardized, per-eye physiological recordings
are written to the raw BIDS dataset.
BIDSValidationError
EyeRecording
dataclass
Canonical sample-level recording for one eye.
Source code in pyxations/bids.py
normalized()
Validate the recording and return a canonical copy of it.
Checks that the required sample columns are present, that the recorded eye is one of the accepted labels and that the sampling frequency is positive, then returns an equivalent recording with a float sampling frequency.
Returns:
| Type | Description |
|---|---|
EyeRecording
|
A validated copy, ready to be written to BIDS. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the |
Source code in pyxations/bids.py
SourceRecordingBundle
dataclass
Normalized raw-BIDS content extracted from one vendor recording.
Source code in pyxations/bids.py
bids_label(value, *, fallback)
Normalize a value for use as a BIDS entity label.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
str
|
Candidate entity value. |
required |
fallback
|
str
|
Value used when normalization removes every character. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Alphanumeric BIDS entity label. |
Source code in pyxations/bids.py
read_bids_task_events(session_path)
Read and combine BIDS task-event tables for one raw session.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session_path
|
str or Path
|
Raw BIDS session directory containing |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
Combined event rows, including their source BIDS filenames. |
Source code in pyxations/bids.py
read_raw_bids_session(session_path)
Load normalized samples and source events from a raw BIDS session.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session_path
|
str or Path
|
Raw BIDS session directory containing physiological recordings. |
required |
Returns:
| Type | Description |
|---|---|
SessionTables
|
Samples, tracker events, behavior, metadata, and recording properties. |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If the session contains no raw BIDS physiological recordings. |
ValueError
|
If per-eye streams disagree about their sampling frequency. |
Source code in pyxations/bids.py
1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 | |
validate_bids_dataset(dataset_path, *, command=None)
Validate a dataset with the official BIDS Validator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset_path
|
str or Path
|
BIDS dataset root to validate. |
required |
command
|
sequence of str
|
Explicit validator command. By default, discover a native validator or use the pinned Deno invocation. |
None
|
Returns:
| Type | Description |
|---|---|
CompletedProcess
|
Successful validator process result. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If no validator executable or Deno runtime is available. |
BIDSValidationError
|
If validation reports one or more errors. |
FileNotFoundError
|
If |
Source code in pyxations/bids.py
validator_command()
Return the available official BIDS Validator command.
Returns:
| Type | Description |
|---|---|
list of str or None
|
Native validator command, Deno invocation, or |
Source code in pyxations/bids.py
webgazer_trial_numbering(source)
Map jsPsych trial_index values to sequential trial numbers.
A jsPsych export numbers every screen it presented, including instructions
and calibration, so the trials that carry gaze are an arbitrary subset such
as 29, 30, 31, 33. Every other Pyxations input format numbers trials
0, 1, 2, ... in presentation order, so the raw jsPsych indices are
renumbered to match and the originals are kept in source_trial_index.
The same mapping is applied to gaze samples and to the behavioral events table, which are read from the same source file by different code paths; were they to disagree, no trial would find its behavioral row.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
DataFrame
|
The WebGazer export, read verbatim. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Mapping of original |
Source code in pyxations/bids.py
write_bids_dataset(target_folder_path, files_folder_path, dataset_name, *, session_substrings=1, format_name='eyelink', task_name='eyetracking', authors=None, behavioral_column_map=None, overwrite=False)
Convert supported vendor recordings into a validated BIDS layout.
Original vendor files are retained under sourcedata. Standardized
sample-level recordings are emitted as per-eye physiological files.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target_folder_path
|
str or Path
|
Parent directory in which to create the dataset. |
required |
files_folder_path
|
str or Path
|
Directory containing vendor recordings and associated behavior. |
required |
dataset_name
|
str
|
Name of the output dataset directory and BIDS dataset. |
required |
session_substrings
|
int
|
Number of underscore-separated filename tokens used for the session. |
1
|
format_name
|
('eyelink', 'gaze', 'tobii', 'webgazer')
|
Vendor input reader to use. |
"eyelink"
|
task_name
|
str
|
Fallback BIDS task label when the filename has no |
"eyetracking"
|
authors
|
sequence of str
|
Dataset authors stored in |
None
|
behavioral_column_map
|
mapping of str to str
|
Source-independent mapping from behavioral columns to task concepts. |
None
|
overwrite
|
bool
|
Whether to replace an existing non-empty output dataset. |
False
|
Returns:
| Type | Description |
|---|---|
Path
|
Root of the generated raw BIDS dataset. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the format, session configuration, source recordings, or overwrite relationship is invalid. |
FileNotFoundError
|
If the source directory does not exist or EyeLink conversion is needed
but |
FileExistsError
|
If the output exists and |
Source code in pyxations/bids.py
1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 | |
behavior
Normalizing behavioral CSV or TSV tables into BIDS events.tsv, with
source-independent column mapping.
Source-independent behavioral table ingestion and column normalization.
normalize_behavioral_events(events, *, column_map=None)
Map source columns onto experiment-level behavioral concepts.
Mapping is intentionally independent of the source format. This lets a PsychoPy log, CSV, TSV, or future adapter satisfy the same experiment schema without embedding task semantics in the format parser.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
events
|
DataFrame
|
Behavioral event table in its source-specific schema. |
required |
column_map
|
mapping of str to str
|
Mapping from source column names to experiment-level names. |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
The original table when no mapping is supplied, otherwise a table with the requested column names. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If a source column is absent or the mapping would create duplicates. |
Source code in pyxations/behavior.py
read_behavioral_events(path, *, column_map=None)
Read a CSV, TSV, or PsychoPy log as a behavioral event table.
The returned table retains source values and applies the same optional experiment-level column mapping regardless of its input format. BIDS timing normalization is performed later by the dataset writer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str or Path
|
Behavioral CSV, TSV, or PsychoPy log to read. |
required |
column_map
|
mapping of str to str
|
Mapping from source column names to experiment-level names. |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
Parsed behavioral events in the source-independent tabular form. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the file extension is unsupported or the column mapping is invalid. |
Source code in pyxations/behavior.py
psychopy
Parsing standard PsychoPy New trial logs. This does not require PsychoPy to
be installed, and PsychoPy-local timestamps are retained without assuming they
are synchronized to the eye-tracker clock.
PsychoPy text-log parsing without requiring PsychoPy at runtime.
psychopy_log_to_events(log_file_path)
Parse PsychoPy .log trials into a BIDS-ready Polars table.
The parser creates one row for every New trial record. It retains the
TrialHandler condition mapping, subsequent component property updates, and
keypresses observed before the next trial. Component updates use columns
such as trial_image_image; repeated updates retain their last value.
PsychoPy timestamps use a separate clock that is not necessarily
synchronized with the eye tracker. They are therefore stored as
psychopy_onset and psychopy_trial_interval. Canonical BIDS
onset and duration remain missing rather than claiming a false
synchronization.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log_file_path
|
str or Path
|
PsychoPy text log to parse. |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
One row per logged trial, or an empty table when no trial markers are present. |
Source code in pyxations/psychopy.py
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | |