Skip to content

mir() misses auto-detected rank reduction in _pca_reduced #283

Closed

Description

@neuromechanist

Found while writing PR #282's annotation x rank-reduction tests: AMICATorchNG._pca_reduced() (torch_impl/core.py ~:2430) decides PCA-reduction incompatibility by checking 'self.pcakeep is not None or self.pcadb is not None' — the explicit parameters only. A fit whose rank reduction came from AUTOMATIC numerical-rank detection (mineig/mineig_rel, no explicit pcakeep/pcadb) slips past the guard, and AMICAICA.mir() then dies with an opaque numpy.linalg.LinAlgError ('Last 2 dimensions of the array must be square') instead of the documented ValueError ('mir() is incompatible with PCA reduction'). The minimal repro is in PR #282's body (rank-16-projected real EEG through the MNE wrapper with mineig_rel-based detection).

Fix direction: derive reducedness from the fitted geometry (non-square sphere / n_components_ < n_channels) rather than from which parameter caused it, per backend-parity check the numpy backend's equivalent guard for the same hole, and add the regression test PR #282 deliberately left out.

Found by the #261 test work; the failing path affects exactly the Maxwell-filtered MEG configuration the external tester runs. Related: #261, #223, #221.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions