You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Duplicate positions: when two sensors share a position, the Green's matrix gets 0*log(0) = NaN off the diagonal. np.linalg.solve returns NaN without raising, so the except LinAlgError -> pinv branch never runs and the whole map is NaN. Suggest checking for coincident positions (or non-finite G) before solve, or catching non-finite solutions and falling back to pinv as intended.
Non-finite values: topoplot drops a sensor with a non-finite value from the positions but not from the values, so later values shift onto the wrong sensors. EEGLAB's topoplot.m drops both. Suggest dropping the same indices from both arrays.
The interpolation-square test (x <= intrad) & (y <= intrad) without abs matches EEGLAB's topoplot.m, so no change there.
CI: no workflow runs were triggered on the branch; a maintainer needs to approve/trigger them. Core-function change, so the EEGLAB reference workflow (eeglab-reference.yml) also needs a run before merge.
Research
griddata_v4 leaves 0*log(0)=NaN off-diagonal for coincident sensors; np.linalg.solve returns NaN silently, so the pinv branch never runs. MATLAB griddata (which topoplot.m calls with v4) averages values at duplicate points before gdatav4.
topoplot removes NaN/Inf-valued channels from plotchans and subsets Th/Rd/x/y by it, but never subsets datavector/ContourVals, so datavector[intchans] indexes a different array. topoplot.m does Values = Values(plotchans). plotchans is also built via list(set(...)), which is unordered; topoplot.m uses sorted setdiff.
Relevant code
src/eegprep/functions/sigprocfunc/topoplot.py#L28-L47 - Green matrix + solve/pinv
src/eegprep/functions/sigprocfunc/topoplot.py#L179-L194 - plotchans filtering without value subset
src/eegprep/functions/sigprocfunc/topoplot.py#L213-L216 - values indexed by pltchans/intchans
Fix
griddata_v4 merges exactly coincident positions with np.unique(..., return_inverse=True) and averages their values using np.bincount. topoplot sorts plotchans and applies datavector[plotchans] / ContourVals[plotchans] along with the position subset.
Activity
claude commentedon Nov 23, 2026
🤖 Plan:
tests/test_topoplot.py(both failed before the fix)griddata_v4duplicates +topoplotvalue alignmenttests/test_topoplot.py,test_pop_topoplot.py,test_envtopo.pypasseeglab-reference.yml) also needs a run before merge.Research
griddata_v4leaves0*log(0)=NaNoff-diagonal for coincident sensors;np.linalg.solvereturns NaN silently, so thepinvbranch never runs. MATLABgriddata(which topoplot.m calls withv4) averages values at duplicate points beforegdatav4.topoplotremoves NaN/Inf-valued channels fromplotchansand subsetsTh/Rd/x/yby it, but never subsetsdatavector/ContourVals, sodatavector[intchans]indexes a different array. topoplot.m doesValues = Values(plotchans).plotchansis also built vialist(set(...)), which is unordered; topoplot.m uses sortedsetdiff.Relevant code
src/eegprep/functions/sigprocfunc/topoplot.py#L28-L47- Green matrix + solve/pinvsrc/eegprep/functions/sigprocfunc/topoplot.py#L179-L194- plotchans filtering without value subsetsrc/eegprep/functions/sigprocfunc/topoplot.py#L213-L216- values indexed by pltchans/intchansFix
griddata_v4merges exactly coincident positions withnp.unique(..., return_inverse=True)and averages their values usingnp.bincount.topoplotsortsplotchansand appliesdatavector[plotchans]/ContourVals[plotchans]along with the position subset.