Skip to content

[GUI] Select MFF event fields from the recording - #1029

Open
arnodelorme wants to merge 2 commits into
agent/issue-875-file-readegifrom
agent/issue-875-file-mffimport
Open

arnodelorme wants to merge 2 commits into
agent/issue-875-file-readegifrom
agent/issue-875-file-mffimport

Conversation

@arnodelorme

@arnodelorme arnodelorme commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

The selected MFF file supplies the available event fields and the default code field. Multiple fields can be selected together. EEGPrep joins their values with underscores and records the selection in replayable history. Stacked on #1021 (agent/issue-875-file-readegi).

Format or settings window, MATLAB and EEGPrep before and after

Native height differences and histogram of normalized numerical distances

Measurements and verification

Native client geometry on jamming was 278.4 × 333.1 px in MATLAB, 356 × 138 before and 279 × 333 after. Screenshots use each toolkit’s captured frame. The three cases used code, code with label, and label with description on the same sample MFF folder. The 257 × 300 × 2 EEG arrays had normalized distance 1.80e-16 in every case. All ten generated event types matched MATLAB in every case. The largest absolute event-latency difference was 0.00130 samples. The focused File menu run passed the MFF metadata, GUI workflow and optional-dependency regression suites. Both source trees passed the capture safeguards.

Closes #1030. Part of #875.

Full inventory report for the project team. pop_mffimport (p. 28). PDF · Editable Word.

@arnodelorme

Copy link
Copy Markdown
Collaborator Author

🤖 Review before taking this out of draft.

State. The updated parent (#1021) is merged in (95c50a838). On the Mac 283 tests pass and jamming passes 307 geometry tests.

What I checked. The field list now comes from the recording, several fields can be selected, and the description reports a comparison with MATLAB on three selections (ten event types identical, largest latency difference 0.0013 sample).

Findings.

  1. More than a form. Continuous files now get their track events, urevent is rebuilt and event types are joined from the chosen fields. This changes what the import returns, so it needs the EEGLAB reference run and Arno's approval before merge. The 0.0013 sample latency difference should be named in that request.
  2. History format. The command is now written pop_mffimport('file', typefield=['code', 'label']), a Python keyword form. Before it was 'typefield', 'code' and format_history_value already writes a list as {'code' 'label'}. Is the Python form needed for the console replay? If not, the EEGLAB form should stay.
  3. The check of typefield moved after the file is read, so a wrong name is reported late on a large recording. Minor.

Verdict: ready for review, not ready to merge before point 1 is settled.

@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 46s —— View job


Code review

  • Overall assessment: The multi-field listbox, joining fields with underscores, and the dialog spec match pop_mffimport.m, and the segmented path is covered by the new test. There are two changed-code problems and one test gap.
  • Highest-risk area: the new continuous-file event path in pop_mffimport (lines 66–73), plus the history string format.
  • Merge recommendation: Needs changes. As your earlier comment said, this PR also changes import output, so it still needs the EEGLAB reference run and Arno's approval.

Blocking

None.

Important

1. The history command is no longer EEGLAB-style. pop_mffimport.py#L97-L99

  • What changed: the command is now written as EEG = pop_mffimport('…', typefield=['code', 'label']);.
  • Why it matters:
    • MATLAB cannot run this line. It would end up in EEG.history of every saved .set file, and in ALLCOM.
    • AGENTS.md says pop functions return EEGLAB-style history commands.
  • The Python form is not needed for console replay. _console_python_command already converts MATLAB cells to lists (_matlab_cells_to_python_lists) and 'key', value pairs to keywords (_keywordize_console_pop_calls). That conversion is how the old 'typefield', 'code' form replayed. format_history_value already writes a list of strings as {'code' 'label'}.
  • Suggested fix:
    command = f"EEG = pop_mffimport({format_history_value(path)}, 'typefield', {format_history_value(value)});"
    The new test, test_mff_multiselect_combines_event_fields_and_replays, will then check that the EEGLAB form replays with two fields.

2. Continuous files: track events replace every event MNE produced, and nothing tests this or compares it with MATLAB. pop_mffimport.py#L65-L74

  • What changed: when any Events*.xml exists, eeg["event"] = tracks throws away the events that mne_raw_to_eeg built from raw.annotations (_file_io.py:289-298).
  • Why it matters: for a continuous recording with acquisition pauses, MNE marks each gap with an annotation (I believe BAD_ACQ_SKIP; I could not check the installed MNE in this run). That marker is now dropped. mff_import.m adds a boundary event at each gap, so after this change the dataset has no gap marker at all.
  • No coverage or parity evidence:
    • tests/fixtures/testmff.mff contains categories.xml, so it is segmented. Neither the new test nor test_real_testmff_matches_eeglab_epochs reaches this branch.
    • The MATLAB comparison in the description (257 × 300 × 2) is also segmented-only.
  • Suggested fix: keep the annotation-derived gap and boundary events, either by merging them with tracks before _sort_events or by converting them to boundary. Add a continuous MFF fixture with a pause, and include it in the EEGLAB reference run.

Nits

3. typefield handling left unused by this change. pop_mffimport.py#L486-L491

  • Both callers now pass the literal "code" (lines 64 and 68).
  • As a result, the typefield parameter of _epochs_from_categories, _track_events and _track_event always holds "code". The label and mffkeys branches of _event_type can no longer run.
  • AGENTS.md says: "Remove imports, variables, functions, and files that your change made unused."
  • Suggested fix: remove the parameter and have _event_type return code or label or "event".

4. typefield errors now arrive late and with less guidance (line 86, already noted in your earlier comment).

  • A wrong name such as typefield="Code" is now only rejected after the whole recording is read. The old check also accepted any letter case.
  • The new message does not tell the user how to fix it. The repo convention is to name the problem, the function and the fix.
  • Suggested fix: list available in the message, e.g. "... Choose one of: code, label, mffkey_FILE, ...".

Test gaps

  • No test covers the continuous branch (see Refactor #2). The fixture needed is a continuous .mff (no categories.xml) with Events*.xml. The test should assert that:
    • the track events are there,
    • their latencies match MATLAB,
    • the gap or boundary markers survive.

EEGLAB parity notes

  • The mffmatlabio plugin is not in src/eegprep/eeglab/plugins/, so I could not cite pop_mffimport.m line numbers. The listbox (min 0, max 2), the code default, the exclusion of type/latency/duration/urevent/epoch/begintime, and the underscore join all match how I understand upstream behaves.
  • Joining code with an empty label gives stm+_, as in MATLAB. The test checks this exact output, which is good.
  • urevent is now rebuilt from event and keeps the epoch field in segmented data. EEGLAB's urevent has no epoch field. This is minor and does not block.

Checked for correctness bugs, EEGLAB parity, data structure compatibility, tests for changed behavior, and CLAUDE.md/AGENTS.md compliance. I wrote all findings here rather than as inline comments, because this run can only post through this one comment.

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