Repository navigation
Phase 1: MIR core metric (mutual information reduction) - #153
neuromechanist merged 6 commits into
Conversation
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## feature/issue-133-epic-mir-pmi-metrics #153 +/- ##
==========================================================================
+ Coverage 80.11% 80.40% +0.28%
==========================================================================
Files 14 16 +2
Lines 2102 2143 +41
Branches 357 363 +6
==========================================================================
+ Hits 1684 1723 +39
- Misses 303 304 +1
- Partials 115 116 +1
🚀 New features to boost your workflow:
|
Review summary (4 parallel Sonnet reviewers: code, tests, comments, silent-failures)code-reviewer: no issues; confirmed algorithmic parity against the actual upstream getMIR.m/getent4 line-by-line, including the subtle variance-before-correction statement order. silent-failure-hunter (3 critical, empirically verified by executing the code):
pr-test-analyzer (1 critical + several important):
comment-analyzer (1 critical + several precision fixes):
Tests: 11/11 new (up from 5), full suite 197 passed / 9 skipped / 6 deselected / 1 xfailed (pre-existing) -- no regressions. ruff/ty clean. |
e2ff460
into
feature/issue-133-epic-mir-pmi-metrics
Summary
Ports the MIR (Mutual Information Reduction) separation-quality metric from
getMIR.minbigdelys/pre_ICA_cleaning(Apache-2.0, permits a direct port with attribution). AddspyAMICA.metrics.mir(unmixing, data, nbins=None) -> (mir_nats, variance)as a standalone, backend-agnostic function.The
_marginal_entropieshelper (a port ofgetMIR.m's nestedgetent4) usesnp.unique(binned, return_counts=True)rather thannp.histogram, since the MATLAB source's run-length-of-sorted-values method only ever reports occupied bins, which is what keepslog(p)finite.This does not port the 2023 NEMAR-pipeline
mir(data, linT)adaptation directly, since that version has a real scope bug (its body referenceseig(W)and/N, neither of which are its own parameters, and only resolves via MATLAB's nested-function shared workspace) and depends on a GPL-licensed sphering routine out of scope for this BSD-3-Clause project. Instead,mir()takes an explicitunmixingmatrix; composing pyAMICA's own sphere-then-unmixing pipeline into that matrix is deferred to the API-wiring phase (#137).Not included in this phase: wiring
mir()into theAMICA/AMICATorchNGclasses (model.mir(X)) -- that's phase 4, issue #137.Closes #134
Part of epic #133
Test plan
pyAMICA/tests/test_metrics_mir.py(new): 5 tests against the real bundled sample EEG data (no synthetic/mock data), including an exact closed-form check (scaled-identity unmixing gives MIR ~= 0 and a provably-exact variance) and an independentnp.histogram-based re-derivation of the entropy estimator.uv run pytest pyAMICA/tests/test_metrics_mir.py -v: 5 passed.uv run pytest pyAMICA/tests/ -q -m "not slow": 191 passed, 9 skipped, 6 deselected, 1 xfailed (pre-existing) -- no regressions.uv run ruff check/uv run ruff format/uv run ty check: all clean.