Skip to content

docs: add Geometry-Aware recentering example (cross-session double dissociation) - #1113

Open
rahimipour-meysam-NeurIPS wants to merge 5 commits into
NeuroTechX:developfrom
rahimipour-meysam-NeurIPS:add-geometry-aware-recentering
Open

docs: add Geometry-Aware recentering example (cross-session double dissociation)#1113
rahimipour-meysam-NeurIPS wants to merge 5 commits into
NeuroTechX:developfrom
rahimipour-meysam-NeurIPS:add-geometry-aware-recentering

Conversation

@rahimipour-meysam-NeurIPS

Copy link
Copy Markdown

What this adds

A single reproducible example, examples/advanced_examples/plot_geometry_aware_recentering.py, demonstrating unsupervised test-time tangent-space recentering (TangentSpace(tsupdate=True)) for cross-session EEG motor-imagery decoding.

The example reproduces a within/cross double dissociation: recentering gives a clear advantage under CrossSessionEvaluation (there is a between-session covariance shift to correct), while the same two pipelines (recenter on vs. off) are close to indistinguishable under WithinSessionEvaluation (no such shift exists there). This isolates recentering — rather than the choice of final classifier — as the mechanism behind the cross-session gain.

This follows the same pattern as plot_euclidean_alignment.py (#1109): no new class or module is introduced (the mechanism already exists in pyriemann via TangentSpace(tsupdate=True) and, more generally, pyriemann.transfer.TLCenter), just a documented, runnable demonstration using MOABB's own evaluation classes.

Background

The result reproduced here is from a manuscript currently in preparation:

Rahimipour, M., Yang, L., & Van Hulle, M. Simple Geometric Recentering Rivals Deep Sequence Models for Cross-Session EEG Motor-Imagery Decoding. In preparation, 2026.

The full study benchmarks this recentering pipeline against classical Riemannian baselines and deep sequence models (a bidirectional Mamba mixture-of-experts, an SPDNet-style network) across eight public MOABB datasets, with full statistical validation (Friedman omnibus, FDR/Holm-corrected Wilcoxon, Cohen's d, bootstrap CIs, Critical-Difference analysis). This PR only reproduces the core within/cross mechanism on a single dataset, as a self-contained gallery example — not the full benchmark.

I reached out to Sylvain Chevallier by email about this direction and he mentioned PRs to MOABB are welcome, which is what prompted this contribution.

Checklist

  • Example script runs end-to-end locally (BNCI2014_001, both CrossSessionEvaluation and WithinSessionEvaluation)
  • docs/source/whats_new.rst updated under "Enhancements"
  • No new dependencies (pyriemann and moabb evaluation classes only)
  • Happy to adjust dataset choice, formatting, or scope per maintainer feedback — this is my first contribution to MOABB and I'd welcome guidance on anything that doesn't match house style.

Meysam Rahimipour and others added 5 commits July 2, 2026 12:32
# Conflicts:
#	docs/source/whats_new.rst
The example constructed both CrossSessionEvaluation and WithinSessionEvaluation
with overwrite=True and no suffix=, so Results resolved them to the shared
suffix-less files

    results/LeftRightImagery/CrossSessionEvaluation/results_.hdf5
    results/LeftRightImagery/WithinSessionEvaluation/results_.hdf5

moabb/analysis/results.py:127-128 implements overwrite by opening that path
with h5py mode "w", which truncates the WHOLE file rather than just this
example expressions rows, and the Results object is built in
BaseEvaluation.__init__ (moabb/evaluations/base.py:465), so truncation happens
at construction time. Those two files are shared with
tutorial_2_using_mulitple_datasets.py, tutorial_3_benchmarking_multiple_pipelines.py
(both overwrite=False; tutorial_3 prose explicitly relies on reusing them) and
advanced_examples/plot_pre_processing_steps.py:140. sphinx-gallery runs examples
in parallel on a warm cache (docs/source/conf.py:209 + .github/workflows/docs.yml:182)
and BaseEvaluation.process returns the frame read back out of the HDF5, so a
mid-flight truncation hands another example an empty frame and, with neither
expected_failing_examples nor only_warn_on_example_error set, takes the whole
gallery down.

Adding suffix="geometry_aware" is the fix already used by
plot_riemannian_artifact_rejection.py (suffix="rar_tutorial"),
plot_select_electrodes_resample.py (suffix="resample") and
plot_use_an_X_y_dataset.py (suffix="motan").

Verified: the example now writes results_geometry_aware.hdf5 and a marker
planted in the shared results_.hdf5 survives the run; scores are unchanged.
Cosmetic only, no behaviour change (scores byte-identical before and after):

- Rename make_geometry_aware -> make_ts_pipeline and give it a docstring. The
  old name was actively misleading: make_geometry_aware(tsupdate=False) returns
  the pipeline that is NOT geometry-aware.
- Index within_means[name] / cross_means[name] directly instead of
  .get(name, np.nan), so a pipeline missing from the results raises a loud
  KeyError instead of silently rendering a blank bar.
- Reuse the cross_means already bound three lines earlier for the final print
  instead of recomputing the same groupby, matching the within_means line above.
- whats_new.rst: use a double-backtick literal for the example path instead of
  the :file: role. :file: appears nowhere else in whats_new.rst on develop; the
  established form is the literal, cf. the plot_riemannian_artifact_rejection.py
  bullet four lines above.
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.

2 participants