[Eeglablist] injecting ICA weights from one dataset to another

Tarik S Bel-Bahar tarikbelbahar at gmail.com
Thu May 25 11:06:21 PDT 2017

Hi Jose,

Thanks for providing good/clear details about your issue, this is good form.

I'm not sure, but based on your notes, I think your issue is that you're
dropping ICs before applying them to the full dataset. It also looks like
you may be re-referencing twice, which may be messing up something. See
basic steps/ recommendations listed below.

I've also seen some weirdness after dropping ICs in some datasets in the
past, but not usually. You may benefit from sending the list some images
and examples using a few different files.

For debugging, I recommend all via GUI first, and reviewing eegh output,
and building/refining script from there. I recommend mimicking the eegh
output even more, as there are some of the normal updated commands that
seem to be missing in the code lines you shared. FOr debugging I also
recommend saving out a new file at each step.

Overall, I would recommend the following, if you have not already tried it,
only via GUI first, and closely reviewing/copying/using eegh output after
each step.
Just go back to doing it simply and slowly first, looking closely at each

1. Compute ICA without replacing/interpolating bad channels before ICA. DO
NOT remove any ICs at this step.

2. Go to continuous original EEG data with exactly the same channels as the
file that went into ICA. Alternatively, drop the channels so there is a
full match.

3. Then apply the ICA solution to this original continuous EEG data.

4. Then confirm/disconfirm that nothing happens to your continuous data
just from applying the ICA solution. (nothing should happen, as you're just
loading the ICA info,m which should give you ICA activations for your whole
continuous data set, which should not be impacting the main EEG data in any

5. then drop the ICs in question, and confirm/disconfirm whether the
problem you're having remains or not. REdo with another subject for further

ps, also review Makoto's general processing pipeline and other pages, which
contain many hints that may be useful to you.

pps: I googled eeglablist and your topic here some other posts to review,
though there were others.

[Eeglablist] Applying ICA weights from 1Hz filtered data to 0.1Hz ...


[Eeglablist] Calculate ICA on short 'cleaned' epoch, then apply to ...


[Eeglablist] Fwd: Applying ICA weight matrix on another dataset

On Thu, May 25, 2017 at 9:22 AM, José Luis <joseluisulloafulgeri at gmail.com>

> dear community,
> I'm performing analysis of EEG data, which I want to explore for ERP and
> TF analysis. I aimed at performing two separated analyses, one with
> filtered data (for ERPs) and another with unfiltered data (for TF, also
> because I want to see high frequency oscillations),
> I applied ICA to the filtered data to get ride of ocular and other
> artifacts. Next, I wanted to inject the weights of the ICA into the
> unfiltered data. Unfortunately I didn't find too much documentation about
> this, so I hope this will be useful for other users that want to do this
> (if there is any documentation please let me know).
> What I did was the following:
> 1) In a first step I eliminated the bad components of my filtered data so
> I get an ICA-pruned dataset,
> 2) Next, I save the ICA variables from my ICA-pruned data set,
>     icachansind = EEG.icachansind;
>     icasphere = EEG.icasphere;
>     icaweights = EEG.icaweights;
> 3) Next, I load my unfiltered data. I make sure any bad channel that need
> to be removed was removed, and that the data was re-referenced to the
> average reference. I'm not certain that the average reference is very
> important, but regarding the bad channels I know that if I inject ICA
> weights from another dataset they need to have the same number of channels,
> so if I remove one channel when I perform ICA on the filtered data I need
> to remove one channel in the unfiltered data to apply the ICA weights.
> Next, I load the mat files that I save in step 2, and I edit the unfiltered
> dataset with:
>     EEG = pop_editset(EEG, 'icachansind', 'icachansind', 'icaweights',
> 'icaweights', 'icasphere', 'icasphere');
>     EEG = eeg_checkset(EEG);
> to integrate the ICA information in the unfiltered dataset. Next, I sort
> of apply the ICA decomposition with:
>     EEG = pop_subcomp(EEG, [ ], 0);
>     EEG = eeg_checkset(EEG);
> and this certainly eliminate the ocular movements of my unfiletered
> dataset,
> 4) Next, I interpolated if this is necessary with;
>     EEG = pop_interp(EEG, orichannels, 'spherical');
>     EEG = eeg_checkset(EEG);
> the orichannels correspond to the orginal arrangement of the EEG channels,
> and this works well to interpolate when there is a missing channel in the
> dataset,
> 5) Next, I re-reference to the average reference
>     EEG = pop_reref(EEG, [ ],'exclude', [65 66]);
>     EEG = eeg_checkset(EEG);
> While all looks like it was working good, I noted that my unfiltered
> dataset was drastically changed. For some channels the amplitude of the
> signal was really diminished and looked like it was flat, but actually was
> just really diminished.
> I went to back to my pipeline.
> When I did ICA I set the rank to: all channels minus 3 (-1 due to the
> average reference and -2 due to both EOG channels)
>     EEG = pop_runica(EEG, 'icatype', 'runica', 'extended', 1,'interupt',
> 'on','chanind', [1:EEG.nbchan-3]);
> So, for a given subject the dimensions for the icachansind, icasphere, and
> icaweights variables were *1x63, 63x63 and 43x63* (so 66 [64 EEG channels
> + 2 EOG channels] -3). However, for this same subject the number of
> channels for the unfiltered dataset is *66*. I think this is
> inconsistency is screwing up my data, however I don't know how this should
> be done to overcome my problem,
> I find a message in the eeglab list about this but the procedure is not
> clear to me https://sccn.ucsd.edu/pipermail/eeglablist/2013/006294.html
> I hope the description is good enough to show what my problem is,
> Any directions about this will be really appreciated,
> Jose
> _______________________________________________
> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://sccn.ucsd.edu/pipermail/eeglablist/attachments/20170525/f3d3673f/attachment.html>

More information about the eeglablist mailing list