
: 2022, Volume 2 - 2 - CC-BY: © Pernet et al.
O R I G I N A L R E S E A R C H A R T I C L E
robust method that uses different weights across trials, such
that Cov(e) =
σ
2
V, with V a diagonal matrix:
y = X
β
+
e, E
(
e
)
= 0,
Cov(
e
) =
σV
(1)
with y an n-dimensional vector (number of trials), X the
n*p design matrix,
β
a p-dimensional vector (number of
predictors in X) and e the error vector of dimension n.
The WLS estimators can then be obtained using an OLS
on transformed data (equations 2 and 3):
Wy = WX
β
+ We, E(e) = 0, Cov(e) =
σ
I (2)
β
= (XTWX)−1XTWy (3)
with W a 1*n vector of weights.
When applied to MEEG data, a standard mass-univariate
WLS entails obtaining a weight for each trial but also
each dimension analysed, i.e. channels, frequencies and
time frames. Following such procedure, a trial could be
considered as an outlier or be assigned a low weight,
for a single frequency or time frame, which is implausi-
ble given the well-known correlations of MEEG data over
space, frequencies and time. We propose here that a
single or a few consecutive data points should never be
agged as outliers or weighted down, and that a single
weight per trial (and channel) should be derived instead,
with weights taking into account the whole temporal or
spectral pro le. In the following, we demonstrate how
the principal component projection (PCP) method (4) can
be used in this context, and how those weights can then
be used in the context of the general linear model (WLS),
applied here to event-related potentials. Such weight-
ing should not be taken to bypass data preprocessing.
Because measurement artefacts and physiological arte-
facts are typically several orders of magnitude stronger
than the signal of interest, and often span consecutive
trials, they require dedicated algorithms. After data
preprocessing, residual signal artefacts might however
remain. In addition, natural and unintended experimen-
tal variations might also exist among all trials, and the
weighting scheme aims to account for these.
METHOD
Trial-based weighted least squares
The new WLS solution consists of computing rst-level
general linear model (GLM) beta estimates using weights
from the PCP algorithm (4). As such, the estimation proce-
dure follows the usual steps of weighting schemes, like a
standard iterative reweighted least squares (IRLS) solution:
1. After the OLS solution is computed, an adjust-
ment is performed on residuals by multiplying them
by −
1/ 1where h is a vector of leverage points
(i.e. the diagonal of the hat matrix H = X(X, X)−1 X where
X is the design matrix re ecting experimental condi-
tions). This adjustment is necessary because leverage
points are the most in uential on the regression space,
i.e. they tend to have low residual values (5).
2. Residuals are then standardized using a robust esti-
mator of dispersion, the median absolute deviation
(MAD) to the median, and re-adjusted by the tun-
ing function. Here, we used the bisquare function. A
series of weights is next obtained either based on
distances (PCP method) or minimizing the error term
(IRLS) with, in both cases, high weights for data points
having high residuals (with a correction for leverage).
3. The solution is then computed following equation 3.
Unlike IRLS, WLS weights are not derived for each
time frames independently but by looking at the multi-
variate distances in the principal component space (step
2 above) and thus deriving a unique weight for all time
frames. An illustration of the method is shown in gure 1.
Trial weights are computed as a distance among trials pro-
jected onto the main (≥99%) principal components space.
Here, the principal components computed over the f time
frames are those directions that maximize the variance
across trials for uncorrelated (orthogonal) time periods ( g-
ure 1B). Outlier trials are points in the f-dimensional space
that are far away from the bulk. By virtue of the principal
component analysis (PCA), these outlier trials become
more visible along the principal component axes than in
the original data space. Weights ( gure 1E) for each trial
are obtained using both the Euclidean norm ( gure 1C, dis-
tance location) and the kurtosis weighted Euclidean norm
( gure 1D, distance scatter) in this reduced PCA space (see
Ref. (4) for details). Weights are then applied to each trial
(at each data points) on the original data (i.e. there is no
data reduction). We exploit this simple technique because
it is computationally fast given the rich dimensional space
of EEG data and because it does not assume the data to
originate from a particular distribution. The PCP algorithm
is implemented in the limo_pcout.m function and the WLS
solution in the limo_WLS.m function, both distributed
with the LIMO MEEG toolbox (https://limo-eeg-toolbox.
github.io/limo_meeg/).
Simulation-based analyses
A. Outlier detection and effectiveness of the weighting
scheme
Simulated event-related potentials (ERPs) were generated
to evaluate the classi cation accuracy of the PCP meth-
od and to estimate the robustness-to-outliers and signal-
to-noise ratio (SNR) of the WLS solution in comparison
to an OLS solution and a standard IRLS solution, which
minimizes residuals at each time frame separately (imple-
mented in limo_IRLS.m). To do so, we manipulated the
following: (1) the percentage of outliers, using 10%, 20%,
30%, 40% or 50% of outliers; (2) the SNR (de ned relative
to the mean over time of the background activity); and (3)
the type of outliers. The rst set of outliers were de ned