Skip to content

MAPA: accept ch_mask with per-sample sensor_indices - #1550

Merged
bruAristimunha merged 2 commits into
masterfrom
feat/mapa-ch-mask
Nov 6, 2026
Merged

bruAristimunha merged 2 commits into
masterfrom
feat/mapa-ch-mask

Conversation

@julien-gadonneix

Copy link
Copy Markdown
Collaborator

MAPA accepts a ch_mask of real channels with per-sample sensor_indices, (batch, n_chans, 3), so one batch can mix recordings with different montages and channel counts, as the iEEG foundation models of #1487.

  • Attention never crosses arrays, so the real channels of all samples are encoded as one recording whose arrays are numbered apart per sample; padded channels (even NaN) are never read and pooling skips them.
  • return_features also returns "tokens", (batch, n_chans, n_tokens, dim), zero for padded channels, as iEEG foundation models: return the per-token output, padded channels zeroed #1540. The shared (n_chans, 3) path is unchanged; ch_mask needs per-sample sensor_indices and pooling="mean".

Testing

  • MAPA added to test_ch_mask.py (_CASES: each recording matches running alone, eager and scripted, no gradient into padding, tokens zero) and to _CH_MASK_EXTRAS; strict xfail in test_registered_model_ch_mask_training (the loader routes no sensor_indices); pytest test/unit_tests/models/test_ch_mask.py test/unit_tests/models/test_model_contract.py test/unit_tests/training/test_ch_mask_training.py -k ch_mask: 67 passed, 3 xfailed
  • pytest test/unit_tests/models -k "mapa or MAPA": 70 passed
  • pre-commit run --files <changed files>: passed

Copilot AI balanced review requested due to automatic review settings November 5, 2026 23:15

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Copilot AI balanced review requested due to automatic review settings November 5, 2026 23:16

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@bruAristimunha bruAristimunha left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Seems fine for me, but can we plan where we can use the new functions too in another PR?

@bruAristimunha
bruAristimunha merged commit e031f8f into master Nov 6, 2026
8 of 9 checks passed
bruAristimunha added a commit to bruAristimunha/braindecode that referenced this pull request Nov 9, 2026
bruAristimunha added a commit to bruAristimunha/braindecode that referenced this pull request Nov 9, 2026
Brings in the ch_mask series (braindecode#1545 braindecode#1548 braindecode#1540 braindecode#1549 braindecode#1542 braindecode#1543 braindecode#1544 braindecode#1550), braindecode#1557 and braindecode#1559 (master dba9d42). No conflicts; NOTICE.txt and docs/whats_new.rst carry only this PR's additions over master.
@bruAristimunha
bruAristimunha deleted the feat/mapa-ch-mask branch November 22, 2026 23:02
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.

3 participants