ICA components differences in EEGLAB and brainstorm

Hi dear Francois,

I want to remove EEG bad artifacts such as eye blink and ECG using EEGLAB because this software has methods for automatic detection of ICA bad components. At first, I performed some preprocess steps and also ICA computation in BRAINSTORM . Then, I saved the ICA weight and sphere matrices and then upload preprocessed data, channel file, and mentioned matrices in EEGLAB. I checked that if time course and topography plot of ICA components are the same in BRAINSTORM and EEGLAB, while the weight and sphere matrices are the same. The first 30 components were same but others were different in time course and topography.
In real, I want to detect ICA bad components using EEGLAB while using BRAINSTORM software for visualizing time courses of components because BRAINSTORM provides easier way for plotting ICA components by considering the fat that my data size is big. After detecting bad components, I want to select those in BRAINSTORM (by selecting the check boxes) and save results and continue my process in BRAINSTORM .
Unfortunately, when the components provided by two software are different I can not use BRAINSTORM component visualizing tool and select components in BRAINSTORM which are introduced as bad in EEGLAB.

I hope to that the brainstorm provides some techniques for automatic detection of ICA bad components in close future.

My questions are:
What are the differences between EEGLAB and BRAINSTORM software for plotting topography and component time course computation?
How can I get the same components (not only in their shape but also in their order) by both softwares?

Warm regards,
Talesh

1 Like

The function runica.m from EEGLAB, used in Brainstorm, has a random initialization. Two consecutive execution with the exact same inputs will always lead to slightly different results.
See line 815 in the version of runica included in Brainstorm.
You would have to edit this part to initialize the random number generator always in the same way.

Dear Francois, I am thankful for your answer but as I said I uploaded the weight and sphere matrix computed by brainstorm into the EEGLAB so I think it is reasonable to observe the same topography plot and time courses of ICA components in EEGLAB and brainstorm. I did not run again ICA in EEGLA. I saved the brainstorm preprocessed data as mat file and load that data, channel file, and ICA weight and sphere matrices ,which were computed by brainstorm, in EEGLAB and then used SASICA plugin to detect bad components. Again, I say that I used the weight and sphere matrices computed by brainstorm and only loaded them in EEGLAB.

I think after computing weight and sphere matrices, brainstorm approach for plotting component topography and also extracting components from recorded data is different with that of EEGLAB. If I am thinking in a right manner, please tell me how can I change the brainstorm code to get the same results in both software and if this changes are harmful?

Thanks,
Talesh

Sorry, I didn’t understand the problem correctly.
EEGLAB and brainstorm display data in a very different way. I don’t think you will be able to get the same figures from the two programs.
Could you post an example of how different the images you get are?

Thanks, now I have no access to my laboratory computer but if you don’t mind I will do it tomorrow.

Hi again dear Francois,

I'm sorry for my delay in posting. I upload one PDF file containing some topography plots and ICA components from EEGLAB and BRAINSTORM.

ICA components and topography plot in EEGLAB and BRAINSTORM.pdf (708.1 KB)

Thanks for your time and reply

Thanks for the screen captures.
Indeed, some components look like they are the same and others different. Wouldn’t they be just in a different order? Or could it be a scaling problem in the display? Or are some components just ignored in the EEGLAB display, while Brainstorm displays them all. Check the total number of components.
For debugging purposes, you could try with less IC (with a PCA before) so that it is easier to check the components order.
I’m sorry, I have no idea how EEGLAB displays them, I can’t help you much with it.

Thank for this fact that you always have provided your best answer for me. Ok, I try ICA bad components rejection in EEGLAB and then I upload the saved EEGLAB data into brainstorm (with EEGLAB.set format).
About your questions, I know you are so busy so I always try to check my problems and then ask about those.

Could it be a scaling problem in the display?
Maybe, but the difference in shape is obvious.

Wouldn’t they be just in a different order?
it’s possible. However, as I said It is reasonable to have ICA components in EEGLAB and BRAINSTORM in the same order.

Are some components just ignored in the EEGLAB display?
Definitely NOT. Total number of components is the same in both software.

At the end of this topic, I am thankful for your try and also your answering mood which is always with you.

With warm regards,
Talesh

Then you could try with fewer components and see if there any re-ordering of the components in EEGLAB.
Other than this, I have no idea… we would need help from someone who is very familiar with EEGLAB.

I don’t know about EEGLAB, but maybe there’s some differences in terms of the mixing and unmixing matrices?
What’s saved in the Channel File in BST, from what I understand, is the unmixing matrix W, that can be used to estimate the ICA time-series W * X where X is the channel data. The topographies that are displayed must be the mixing matrix that’s obtained by inverting as pinv(W) , not sure where in the code (?). If you load from EEGLAB the mixing matrix instead, this would lead to differences in topographies and time-series. Does that make sense?

@peterd:
The code for starting runica, storing the results and producing the linear operator applied to the signals is all in process_ssp2.m:


OK, and I found this here (where the pseudoinverse is taken before plotting the topography):

https://github.com/brainstorm-tools/brainstorm3/blob/master/toolbox/gui/panel_ssp_selection.m#L456

@alirezatalesh Maybe try to see whether EEGLAB expects the mixing matrix when you load the data? You can get it by taking the pseudoinverse of the ICA weights that are saved in BST: pinv()

Btw: Since recently I sort components based on their correlation with ECG/EOG recordings. I extended the ICA process to do that. If that is of interest, here is the commit: https://github.com/pwdonh/brainstorm3/commit/8c8d20b46c46154da5c3c498080ef89d17d91652

I don’t know whether this is something for the main distribution.

Dear peterd and Francois,

I am thanks a lot for your answers and efforts.
For now, I process data in BRAINSTORM and use EEGLAB for ICA bad component rejection.

However, for EEGLAB, I want to say that EEGLAB needs channel information and data (can be mat format). For ICA analysis, users are able to upload weight and sphere matrix of ICA which have been calculated previously. So, I saved the weight and sphere matrices with text format (just after the line 691 of SSP2 code) and then loaded those files in EEGLAB. I am sure that EEGLAB needs unmixing and sphere matrix for ICA analysis. In addition, in uploaded pdf file, I have shown the time series of ICA components in both EEGLAB and BRAINSTORM. As one can see, both software using the same icaweight and icasphere approximately present the same components but with different order. This results prove this idea that EEGLAB needs unmixing matrix to be uploaded not mixing one.

The best,
Talesh

Yes, sure! You're welcome to open a pull request to submit this.
Same for other improvements you have developed for yourself.

In MNE-Python, they do an automatic selection of the components to remove based on the % of correlation with the EOG and the ECG. Have you tried doing this automatically too?