From f7181a154fbdd1a9185b32ddc1ef4161e89dc5d9 Mon Sep 17 00:00:00 2001 From: innaamogolonova Date: Wed, 22 Jul 2026 08:49:38 -0700 Subject: [PATCH] pop_topoplot: fix ERP map channel alignment when channels lack locations Build SIGTMPAVG as a full nbchan-row array so each located channel's mean maps to its true channel row. Previously only located channels were passed (a shorter vector) alongside the full chanlocs, so datasets with interspersed no-location channels (e.g. EOG) shifted the plotted data onto wrong electrodes. --- functions/popfunc/pop_topoplot.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/functions/popfunc/pop_topoplot.m b/functions/popfunc/pop_topoplot.m index a943e5958..19a59b144 100644 --- a/functions/popfunc/pop_topoplot.m +++ b/functions/popfunc/pop_topoplot.m @@ -255,7 +255,8 @@ if isempty(nonEmptyChans) nonEmptyChans = 1:EEG.nbchan; end - SIGTMPAVG = mean(SIGTMP(nonEmptyChans,pos,:),3); + SIGTMPAVG = nan(EEG.nbchan, length(pos)); + SIGTMPAVG(nonEmptyChans,:) = mean(SIGTMP(nonEmptyChans,pos,:),3); SIGTMPAVG(nonEmptyChans, nanpos) = NaN; if isempty(maplimits)