[Eeglablist] How to save EEG values with artifact ICs removed

Samuel Armstrong samuel.armstrong at uq.edu.au
Mon May 1 19:22:03 PDT 2023


Hi Cedric,

Success! It seems I might have been misinformed (or simply confused) about how ICA transforms the data. From what I can now see, Brainstorm doesn’t carry across the ICA matrices from EEGLAB, but the values do appear to reflect the artefact-subtracted data.

Greatly appreciate your prompt advice on this!

Cheers,

Sam

--
Sam Armstrong
M +614 24 449 609
E samuel.armstrong at uq.edu.au<mailto:samuel.armstrong at uq.edu.au>


From: Cedric Cannard <ccannard at protonmail.com>
Date: Thursday, 27 April 2023 at 2:33 am
To: Samuel Armstrong <samuel.armstrong at uq.edu.au>
Cc: EEGLAB List <eeglablist at sccn.ucsd.edu>
Subject: Re: [Eeglablist] How to save EEG values with artifact ICs removed
Hi Sam,

I am well familiar with transfering ICA weights from one dataset to another. If you try the code I sent, you will see the data are being transformed, the bad components are substracted from the actual signal. This is for sure since the code only plots the actual signal (EEG.data) without any kind of ICA information.
So, either you didn't remove the bad components correctly before saving, or the data is transformed back when saving the .set file or when it is imported in Brainstorm, (using ICA information stored in the .set file). But that is surprising to me, but possible. For scenario 2, import the .set file back in EEGLAB and take a look. Are the data still without ICs your removed or are htey back to raw? If looking like they are still removed in EEGLAB, then the problem occurs during importation in Brainstorm. Wherever the problem is, try emptying all ICA information after substracting the bad ICs and before saving the .set file like this:

EEG.icaact = [];
EEG.icawinv = [];
EEG.icasphere = [];
EEG.icaweights = [];
EEG.icachansind = [];
EEG = eeg_checkset(EEG);

Curious to hear if this solves it.

Cedric


------- Original Message -------
On Wednesday, April 26th, 2023 at 4:51 AM, Samuel Armstrong <samuel.armstrong at uq.edu.au> wrote:


Hi Cedric,

Thanks again for responding. Unfortunately, what you suggested didn’t work – I’ve attached an image of  data imported into Brainstorm with and without ICs removed in EEGlab (not sure if they will work). These images show that the signal is the same for both datasets. Also, I didn’t think it was the EEG data itself that was transformed, but rather that  the application of the IC weight matrix to the data (with artefactual ICs removed)  is what reduced the impact of artefacts on the data. For example, you can conduct ICA with 1-Hz HP filter on one dataset and then apply the IC weight matrix etc to data that has been filtered at 0.1 Hz HP. Thus, since brainstorm disregards the IC matrix for sets imported from EEGLAB, artifacts are still apparent in the EEG recordings.

Moving back to my original question, I’m wondering if there is a way to force EEGLAB to save the data values in a way so that the IC matrix isn’t required. That is, I’m looking to try and find a way that I can import IC-artefact-subtracted data that has been preprocessed using EEGlab.

Again, any ideas (from anyone at all) would be greatly appreciated.

Cheers,

Sam



Sam Armstrong
M +614 24 449 609
E samuel.armstrong at uq.edu.au<mailto:samuel.armstrong at uq.edu.au>


From: Cedric Cannard <ccannard at protonmail.com>
Date: Wednesday, 26 April 2023 at 3:19 am
To: Samuel Armstrong <samuel.armstrong at uq.edu.au>, EEGLAB List <eeglablist at sccn.ucsd.edu>
Subject: Re: [Eeglablist] How to save EEG values with artifact ICs removed
Hi Samuel,

If you follow my instructions it should work. When you remove the components from the data with Tools > Remove components from data, the actual data are transformed. When you save your file, the signal will be considered as raw data. You can test this by plotting one channel before and after, without using EEGLAB functions to be sure.
For example:
% Run ICA and tag bad components
figure; plot(EEG.data(1,1:EEG.srate*10)); hold on; % plot 10 s of data from a frontal channel before removing (make sure to take a channel and period where you can see large eye blinks here to see the difference clearly)
% Remove them (Tools > Remove components)
plot(EEG.data(1,1:EEG.srate*10)); legend('raw', 'after removing components'); % plot again and compare visually

Cedric


------- Original Message -------
On Tuesday, April 25th, 2023 at 2:01 AM, Samuel Armstrong <samuel.armstrong at uq.edu.au> wrote:
Hi Cedric,

Thanks again for getting back to me. This is starting to seem a little like more of a Brainstorm question, but hear me out. Based on the comments in the Brainstorm forum (for e.g. see links below), “Brainstorm can’t import ICA decompositions from other programs. The only thing you can do is import pre-processed files, which are handled as ‘raw’ files. In this ccase, you need to make sure the EEG values have been saved with the artefact IC removed.’

https://urldefense.com/v3/__https://neuroimage.usc.edu/forums/t/ica-components-into-brainstorm/35637/2__;!!Mih3wA!BD3r1VpX15jNC1hKyn1Q5SD6KV3RXtPCLIJ6QMlbu5lKorqNu2tdE4EY7PnXQnWbTce81uzsIBiiDaMRngK_MX3wM-1qL4yPXiPh$ 
https://urldefense.com/v3/__https://neuroimage.usc.edu/forums/t/ica-weights-in-file/35991__;!!Mih3wA!BD3r1VpX15jNC1hKyn1Q5SD6KV3RXtPCLIJ6QMlbu5lKorqNu2tdE4EY7PnXQnWbTce81uzsIBiiDaMRngK_MX3wM-1qL0Uwdeyb$ 

I’ve tried a few different ways to correct for this issue, however any artefacts that are removed using ICA in EEGlab will return when the dataset is imported into Brainstorm. However, given there are studies that have completed their preprocessing with ICA (to remove blinks etc) in EEGLAB and then exported the data into Brainstorm (see links below), I’m curious as to how this might be achieved. From what I can gather, unless you force EEGLAB to write the .set file with the ICA cleaning applied, the ICs would not be applied to the Brainstorm dataset, and thus the artefacts would still be present.

https://urldefense.com/v3/__https://www.frontiersin.org/articles/10.3389/fnins.2018.00309/full__;!!Mih3wA!BD3r1VpX15jNC1hKyn1Q5SD6KV3RXtPCLIJ6QMlbu5lKorqNu2tdE4EY7PnXQnWbTce81uzsIBiiDaMRngK_MX3wM-1qLxBBiWMn$ 
https://urldefense.com/v3/__https://www.ncbi.nlm.nih.gov/pmc/articles/PMC9226558/__;!!Mih3wA!BD3r1VpX15jNC1hKyn1Q5SD6KV3RXtPCLIJ6QMlbu5lKorqNu2tdE4EY7PnXQnWbTce81uzsIBiiDaMRngK_MX3wM-1qL0UTPtYT$ 

Interested in any ideas people might have to solve this issue.

Cheers,

Sam


--
Sam Armstrong
M +614 24 449 609
E samuel.armstrong at uq.edu.au<mailto:samuel.armstrong at uq.edu.au>


From: Cedric Cannard <ccannard at protonmail.com>
Date: Tuesday, 25 April 2023 at 1:23 pm
To: Samuel Armstrong <samuel.armstrong at uq.edu.au>
Subject: Re: [Eeglablist] How to save EEG values with artifact ICs removed
Hi Samuel,

Oh ok, in that case, simply substrate the bad components from your data, visually/manually (see here https://urldefense.com/v3/__https://eeglab.org/tutorials/06_RejectArtifacts/RunICA.html*studying-and-flagging-artifactual-ica-components__;Iw!!Mih3wA!BD3r1VpX15jNC1hKyn1Q5SD6KV3RXtPCLIJ6QMlbu5lKorqNu2tdE4EY7PnXQnWbTce81uzsIBiiDaMRngK_MX3wM-1qLwR-bdDT$ )
or automatically with ICLabel (see here: https://urldefense.com/v3/__https://eeglab.org/tutorials/06_RejectArtifacts/RunICA.html*subtracting-ica-components-from-data__;Iw!!Mih3wA!BD3r1VpX15jNC1hKyn1Q5SD6KV3RXtPCLIJ6QMlbu5lKorqNu2tdE4EY7PnXQnWbTce81uzsIBiiDaMRngK_MX3wM-1qL07KcSKE$ )

Then save file as .set file, you should be able ton import the clean file in Brainstorm.

Cedric


On Mon, Apr 24, 2023 at 17:46, Samuel Armstrong <samuel.armstrong at uq.edu.au<mailto:On%20Mon,%20Apr%2024,%202023%20at%2017:46,%20Samuel%20Armstrong%20%3c%3ca%20href=>> wrote:
Hi Cedric,

Thanks for responding. I tried what you suggested, but didn’t achieve the outcome I was looking for, so I think my question was probably a little unclear.

What I am trying to do is save the EEG set that contains data reflecting the ICartefact-subtracted values. I want to import my data into brainstorm… but since brainstorm doesn’t recognise the ICA weight matrices, I’m trying to figure out a work around.

There appears to be papers available where people used EEGLAB to perform ICA on their data, and then subsequently import that data into Brainstorm, but I’m not sure how they managed to import artefact-corrected data since brainstorm doesn’t appear to recognise the ICA decomposition.

Any ideas or suggestions?

Cheers,

Sam


--
Sam Armstrong
M +614 24 449 609
E samuel.armstrong at uq.edu.au<mailto:samuel.armstrong at uq.edu.au>


From: Cedric Cannard <ccannard at protonmail.com>
Date: Tuesday, 25 April 2023 at 4:57 am
To: Samuel Armstrong <samuel.armstrong at uq.edu.au>
Cc: EEGLAB List <eeglablist at sccn.ucsd.edu>
Subject: Re: [Eeglablist] How to save EEG values with artifact ICs removed
Dear Sam,

The official recommendations from the EEGLAB tutorial are to tag the bad components at subject level, and then remove them at the STUDY level (simply check the 2nd little box in the "Precompute measures" window, see here for example: https://urldefense.com/v3/__https://github.com/sccn/eeglab/issues__;!!Mih3wA!BD3r1VpX15jNC1hKyn1Q5SD6KV3RXtPCLIJ6QMlbu5lKorqNu2tdE4EY7PnXQnWbTce81uzsIBiiDaMRngK_MX3wM-1qL5pbIEoQ$ ).

If you want to remove them for each file to inspect visually for example, simply save your .set file after doing so. Go to "File" > "Save current dataset as" > choose file name and destination and save.

Then you import the .set files in your STUDY for group analysis. And don't check the little box if you already removed the bad components.

Cedric



------- Original Message -------
On Monday, April 24th, 2023 at 12:59 AM, Samuel Armstrong via eeglablist <eeglablist at sccn.ucsd.edu> wrote:


> Hello all,
>
> Ive had a bit of a search in the past topics, but can’t find anything, so Just after a bit of help with this one, please.
>
> I have a bunch of preprocessed data and I want to save these datasets so that the EEG values are permanently saved with the artefact ICs removed. Just wondering if anyone can suggest how I might be able to do this?
>
> Best,
>
> Sam
>
>
> --
> Sam Armstrong
> DipCWD, BPsych(Hons I), MPhil(CogNeuro)
> PhD Candidate
>
> Surgical Treatment and Rehabilitation Service (STARS)
> Herston Health Precinct
> Brisbane QLD 4029 Australia
>
> School of Psychology | School of Health and Rehabilitation Sciences
> The University of Queensland
> Brisbane Qld 4072 Australia
>
> M +614 24 449 609
> E samuel.armstrong at uq.edu.aumailto:samuel.armstrong at uq.edu.au
>
> W https://urldefense.com/v3/__https://psychology.uq.edu.au__;!!Mih3wA!EaX3_HdC2Fsqp6r2jyErox-vCKF4u5BTP4-YhB7XoBAKlZKuRCcLACmp_GyrGl-OApyMs_ThpZilZY_XNd0qO0iKz7avrKst4udO$<https://urldefense.com/v3/__https:/psychology.uq.edu.au__;!!Mih3wA!EaX3_HdC2Fsqp6r2jyErox-vCKF4u5BTP4-YhB7XoBAKlZKuRCcLACmp_GyrGl-OApyMs_ThpZilZY_XNd0qO0iKz7avrKst4udO$>
>
> The University of Queensland (UQ) acknowledges the Traditional Owners and their custodianship of the lands on which UQ operates. We pay our respects to their Ancestors and their descendants, who continue cultural and spiritual connections to Country. We recognise their valuable contributions to Australian and global society.
>
> CRICOS 00025B • TEQSA PRV12080
>
> [signature_605933061]
>
> This email (including any attached files) is intended solely for the addressee and may contain confidential information of The University of Queensland. If you are not the addressee, you are notified that any transmission, distribution, printing or photocopying of this email is prohibited. If you have received this email in error, please delete and notify me. Unless explicitly stated, the opinions expressed in this email do not represent the official position of The University of Queensland.
> P Please consider the environment before printing this email
>
> Hello all,
>
> Ive had a bit of a search in the past topics, but can’t find anything, so Just after a bit of help with this one, please.
>
> I have a bunch of preprocessed data and I want to save these datasets so that the EEG values are permanently saved with the artefact ICs removed. Just wondering if anyone can suggest how I might be able to do this?
>
> Best,
>
> Sam
>
>
>
>
> _______________________________________________
> Eeglablist page: http://sccn.ucsd.edu/eeglab/eeglabmail.html
> To unsubscribe, send an empty email to eeglablist-unsubscribe at sccn.ucsd.edu
> For digest mode, send an email with the subject "set digest mime" to eeglablist-request at sccn.ucsd.edu





More information about the eeglablist mailing list