Skip to content

[GUI] Edit BIDS event field mappings in the public metadata table - #1050

Open
arnodelorme wants to merge 3 commits into
agent/issue-875-file-taskinfofrom
agent/issue-875-file-eventinfo
Open

arnodelorme wants to merge 3 commits into
agent/issue-875-file-taskinfofrom
agent/issue-875-file-eventinfo

Conversation

@arnodelorme

@arnodelorme arnodelorme commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

The public event editor opens the metadata table for a single recording and for a dataset collection. Add and remove custom event fields, edit unit names and prefixes, and retain terminology URLs in exported sidecars. The standard event fields are protected from removal. Stacked on #1048 (agent/issue-875-file-taskinfo).

EEGLAB, EEGPrep before, EEGPrep after

Native geometry and same-input distances

Measurements and verification

Native client dimensions on jamming were 800.0 × 500.0 px in MATLAB, 278 × 244 before and 824 × 480 after. Native MATLAB is 800 × 500 pixels. The actual Qt table went from 278 × 244 to 824 × 480 pixels. Three submitted GUI cases stored exactly the entered event descriptions in both programs. Levels remain editable inline in EEGPrep. The two File/BIDS suites passed 114 tests with 5 deselected. The Qt capture used the guarded checkout on PYTHONPATH.

Closes #1051. Part of #875.

Full inventory report for the project team. pop_eventinfo (p. 13). PDF · Editable Word.

@arnodelorme

Copy link
Copy Markdown
Collaborator Author

🤖 Review before taking this out of draft.

State. The updated parent (#1048) is merged in (686fc2fac). On the Mac 285 tests pass and jamming passes 307 geometry tests.

What I checked. The event table has the eight columns of pop_eventinfo.m line 80 (with Unit Prefix and TermURL), the four core fields cannot be renamed, and fields can be added and removed.

Finding that matters for the merge. This also changes the files that are written: events.json gains TermURL, the unit prefix is joined to the unit, and the four core fields get default descriptions. These are sensible, but they change the export output, so a comparison of one exported events.json with EEGLAB's should be attached before merge.

Verdict: ready for review.

@arnodelorme
arnodelorme marked this pull request as ready for review December 2, 2026 05:50

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Code review skipped — your organization has no extra usage available to pay for this review.

If your organization's extra usage balance is empty, an organization admin can add extra usage credits at claude.ai/admin-settings/usage. If its monthly spend limit was reached, an admin can raise it on the same page. If neither applies, contact Anthropic support.

Once extra usage is available, someone with write access to this repository can comment @claude review on this pull request to trigger a review.

@claude

claude Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @arnodelorme's task in 1m 25s —— View job


Code review

  • Overall assessment: Needs changes. The table, protected core rows, and add/remove all work as described. However, pressing Ok without editing anything now changes events.json.
  • Highest-risk area: the new _event_rows defaults in bids_tools.py, together with pop_exportbids._write_events_json.
  • Merge recommendation: Needs changes.

Blocking

None.

Important

  1. Pressing Ok without edits overwrites the exporter's core sidecar entries (bids_tools._event_rows, L911-916).

    • _write_events_json starts from its own defaults: onset/duration Units: "s", and sample "1-based sample index of the event onset". It then replaces each key with whatever is stored.
    • Previously, pressing Ok in the table stored nothing for onset/duration/sample/value.
    • Now the new defaults are stored and exported. onset and duration get "Units": "second", and sample loses the 1-based note.
    • onset also gets "EEGLABField": "From sample". That is a GUI label, not an EEG.event field.
    • BIDS asks for CMIXF unit symbols (s), so this is a regression in the written file, not just in what the GUI shows.
    • Fix: make the table defaults match the exporter's ("s", the 1-based wording). Leave onset's eeglab_field empty or use a real field name. Better still, define the four core defaults once and import them in both modules.
  2. The unit prefix is folded into Units and lost when the table is reopened (bids_tools._event_table, L897-902).

    • On reopen, Unit Prefix is empty and Unit Name shows the joined string.
    • A prefix entered with no unit name is silently dropped.
    • Spelled-out entries give non-CMIXF output (milli + second → millisecond).
    • The join happens only in the Qt path. event_fields=[{"UnitPrefix": ...}] loses the prefix because _event_field_map never reads it.
    • Fix: store UnitPrefix separately and join it only in _write_events_json.

Nits

  • The removal loop at bids_tools.py:179-182 calls dataset.get on every entry of datasets. The _fan_out helper next to it skips entries that are not dicts. Use the same guard in both.
  • In _event_rows, trial_type, stim_file and response_time used to fall back to their own name for eeglab_field. Now they fall back to "", so EEGLABField disappears from their exported entries. If that was not intended, keep the old fallback.

Test gaps

  • Nothing covers the export changes. Suggested test: call pop_eventinfo(eeg, event_fields=[{"bids_field": "rt", "Units": "s", "UnitPrefix": "m", "TermURL": "https://..."}]), export, then assert on the rt entry in *_events.json.
  • A regression test for finding 1: open the table, press Ok without editing, export, and assert onset.Units == "s".

EEGLAB parity notes

  • The vendored pop_eventinfo.m is not in this checkout (src/eegprep/eeglab/plugins/ is missing), so I could not check the column labels or the default EEGLAB Field values against the source.
  • Before merging, please attach the events.json comparison with EEGLAB that the earlier comment asked for. It should also settle what onset and sample should show as their EEGLAB Field.

I posted the two Important findings as inline comments as well.

Comment on lines +911 to +916
defaults = {
"onset": ("From sample", "Event onset", "Time from the start of the recording to the event onset.", "second"),
"duration": ("duration", "Event duration", "Duration of the event in seconds.", "second"),
"sample": ("latency", "Sample", "Sample at which the event starts.", ""),
"value": ("type", "Event marker", "Marker value associated with the event.", ""),
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Important: pressing Ok without edits now changes the exported events.json.

_write_events_json starts from its own defaults: onset/duration "Units": "s", and sample "1-based sample index of the event onset". It then replaces each key with whatever is stored. Before this PR, pressing Ok left these four keys unstored. Now these defaults are stored, so the sidecar gets:

  • "Units": "second" for onset and duration. BIDS asks for CMIXF symbols, so this should be s.
  • "EEGLABField": "From sample" for onset. That is a GUI label, not an EEG.event field.
  • a sample description without the 1-based note.

Fix: match the exporter's defaults ("s", the 1-based wording) and leave onset's eeglab_field empty. Better still, define the four core defaults once and import them in both modules.

Comment on lines +897 to +902
result = _read_table(table, _EVENT_COLUMNS)
for row in result:
prefix = row.pop("UnitPrefix", "")
if prefix and row.get("Units"):
row["Units"] = prefix + row["Units"]
return result

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Important: the prefix does not survive a round trip.

  • It is joined into Units here. When the table is reopened, Unit Prefix is empty and Unit Name shows the joined string.
  • A prefix entered without a unit name is silently dropped.
  • The join happens only in the Qt path, so event_fields=[{"UnitPrefix": ...}] loses the prefix entirely: _event_field_map never reads it.

Fix: keep UnitPrefix in _event_field_map and in the stored dict, and do the join only in _write_events_json.

This branch has not been deployed

No deployments
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.

1 participant