[Eeglablist] ICA components distorted after rereferencing, saving and reloading

Cedric Cannard ccannard at protonmail.com
Fri Jul 25 10:59:18 PDT 2025


Hi Tomko,

There may be an error in the tutorial web page. Makoto, Scott, or Arno, please correct me if I'm wrong here. 

If I recall correctly, we do not recommend in the paper to re-reference after ICA. Instead, we emphasize correcting the average referencing before ICA and taking the data rank into account while computing ICA, so that ICA operates on a properly rank-full dataset and avoids generating "ghost ICs".

see these quotes: 
"To avoid this issue, we propose two solutions: 1) apply the correct average referencing, and 2) calculate the effective data rank that is used for PCA dimension reduction in applying ICA."
"The correct method, i.e., including the initial reference when re-referencing and then discarding the initial reference channel, resulted in a successful rank-full decomposition."

Now to address your questions more directly:

EEGLAB stores the ICA decomposition using:
- EEG.icaweights and EEG.icasphere: together they define the unmixing matrix,
- EEG.icawinv: the mixing matrix (inverse of the unmixing matrix),
- EEG.data: the referenced data ICA was trained on.
When you apply pop_reref(EEG, []) after ICA, it modifies EEG.data, but does not update the ICA weights or sphere, nor does it recompute EEG.icaact if it exists. So now the ICA decomposition no longer corresponds to the modified data (that is if operations were done between your last referencing and post-ICA referencing). If you save the set like this, ICA reconstruction is no longer valid when reloading.
--> This is why the ICs appear corrupted after reloading — the weights are applied to differently referenced data than they were trained on.

Why does the issue only happen when MARA doesn’t reject any components? I haven't used MARA before, but my guess is that when MARA rejects components, EEGLAB calls pop_subcomp() which updates EEG.data to reflect the projection of the ICA decomposition with removed components. This may result in reinitializing the ICA fields in a way that masks the corruption caused by re-referencing.

But when no components are rejected (gcompreject = 0), EEG.data is left unchanged from ICA, and then your subsequent call to pop_reref corrupts the ICA-to-data correspondence.


> Can you confirm whether re-referencing after MARA might break the ICA structure?

Yes. 

> Would you recommend re-referencing before ICA, especially if PCA is already used to adjust for rank deficiency?

Yes (see above correction about the paper and recommendations). You should also interpolate bad channels before ICA (before calculating the data rank).

> Do you have any suggestions on how to safely apply re-referencing post-ICA?

If for some reason you must re-reference after ICA (e.g., for visualization), do one of the following:

% Backup ICA weights before re-referencing
icaweights = EEG.icaweights;
icasphere = EEG.icasphere;

% Apply re-referencing (this alters EEG.data!)
EEG = pop_reref(EEG, []);

% Re-apply ICA on new data manually
EEG.icaact = icaweights * icasphere * EEG.data;


Cedric Cannard



On Thursday, July 24th, 2025 at 12:47 PM, Tomko Settgast via eeglablist <eeglablist at sccn.ucsd.edu> wrote:

> Dear EEGLAB team,
> 
> I encountered a puzzling issue while applying common average referencing (CAR) after ICA, as currently recommended in the EEGlab tutorial (https://urldefense.com/v3/__https://eeglab.org/tutorials/06_RejectArtifacts/RunICA.html*issues-with-data-rank-deficiencies__;Iw!!Mih3wA!Hy4Uj5ky7Dr8niY5yJBllkYbV8sC-8D2mnYBuaJiqvb2aYgEkuwDK9M_9PyFCOjmtEKMU505X4gXGbOKz39zcB4VawTXegSozL76zYdG$ ) to address rank deficiencies.
> 
> In one specific dataset, ICA components appear strongly corrupted after saving and reloading the dataset, although they looked perfectly normal before saving. This issue does not occur in other datasets processed by the same automated pipeline.
> 
> Steps to reproduce:
> 
> 1. Run runica and perform MARA artifact rejection.
> 2. Apply CAR using pop_reref(EEG, []) after ICA (as recommended).
> * The components looked completely normal at this point (see attached ICsBeforeSaving.gif)
> 3. Save the dataset using pop_saveset.
> 4. Close EEGLAB, reload the dataset, and inspect ICA components with pop_eegplot .
> * After reloading, the ICA time series look heavily distorted (see attached ICsAfterReload.gif)
> 
> To investigate further, I saved the EEG structure as .mat immediately before saving with pop_saveset and compared it with the EEG structure after reloading the saved dataset.
> There are mismatches between the ICA matrices in these two structures - which aligns with the visual differences in the component time series.
> 
> For a better understanding:
> 
> * MARA did not reject components for this dataset (0 entries in gcompreject).
> * The ICA was computed with proper PCA reduction to the data rank (rank = 10), following the recommendations in Kim et al. (2023) (https://urldefense.com/v3/__https://doi.org/10.3389/frsip.2023.1064138__;!!Mih3wA!Hy4Uj5ky7Dr8niY5yJBllkYbV8sC-8D2mnYBuaJiqvb2aYgEkuwDK9M_9PyFCOjmtEKMU505X4gXGbOKz39zcB4VawTXegSozNk76r1m$ ), so ghost components are unlikely.
> * I am aware that common average re-referencing is commonly not recommended for datasets with a low number of channels but we were trying to follow the guidelines expressed by Hu et al. (2018; 10.1088/1741-2552/aaa13f)
> * The issue seems to occur only in this particular dataset - as far as I can trust my visual comparison.
> In other datasets where MARA rejected components, I did not encounter this behavior (again, only checked visually) - even though the same pipeline and re-referencing strategy was applied.
> 
> After discussing the issue with ChatGPT, the suggestion came up that applying re-referencing after ICA might silently disrupt the ICA-to-data mapping, and this mismatch only becomes apparent after saving and reloading the dataset.
> 
> However, what I find particularly confusing is that this issue only occurs when MARA does not reject any components - which would normally indicate better signal quality.
> 
> My questions:
> 
> * Can you confirm whether re-referencing after MARA-based component rejection might break the ICA structure in this way?
> * Is this a known issue with pop_reref in combination with ICA, and MARA?
> * Would you recommend re-referencing before ICA, especially if PCA is already used to adjust for rank deficiency?
> * Do you have any suggestions on how to safely apply re-referencing post-ICA without compromising the ICA decomposition?
> 
> I'd be happy to share the script or provide further information if helpful.
> 
> Thank you very much in advance for your time and support!
> 
> Best regards,
> Tomko
> 
> Tomko Settgast, MSc
> Section Intervention Psychology
> University of Würzburg
> 
> _______________________________________________
> To unsubscribe, send an empty email to eeglablist-unsubscribe at sccn.ucsd.edu or visit https://sccn.ucsd.edu/mailman/listinfo/eeglablist .


More information about the eeglablist mailing list