[Eeglablist] ICA component variance explained

Bruzadin Nunes, Ugo ugob at siu.edu
Tue Sep 24 11:15:40 PDT 2019


Hi Makoto,

Thank you so much for your quick response as always, and I apologize for this late response. The question was posed by a user wanting to extract the variance explained by each component that is plotted by ICAlabel. I rewrote those lines in an independent fashion to take that data into an external variable. This pvaftopo plugin indeed looks like exactly the same thing, albeit much smaller and faster! We're testing it out to see which one fits best the pipeline, but it's really good to know that there are other plugins out there, they might make our lives easy.

Cheers,

Ugo Bruzadin Nunes, M.A. & Doctoral Candidate
PSYC 222 Instructor - Effects of Recreational Drugs
Brain and Cognitive Sciences Ph.D Program ||
School of Psychological and Behavioral Sciences
Southern Illinois University - Carbondale

________________________________
From: Makoto Miyakoshi <mmiyakoshi at ucsd.edu>
Sent: Friday, September 20, 2019 9:20 PM
To: eeglablist at sccn.ucsd.edu <eeglablist at sccn.ucsd.edu>
Subject: Re: [Eeglablist] ICA component variance explained

Dear Ugo,

Sorry I don't know what the original question was, but the script seems to
be related to the plugin pvaftopo(). I advised Luca to include this measure
when he designed the plots. Because I worked on envtopo() functions a lot,
I was used to relate IC sources-channel variance.
If you are interested in, please also try/read pvaftopo() plugin. The main
function has only three lines (by the way the first line does not seem
necessary... should be made into two lines) See below.

% compute pvaftopo
outTopo  = zeros(EEG.nbchan,length(IC));
backProj =
EEG.icawinv(:,IC)*eeg_getdatact(EEG,'component',IC,'reshape','2d');
outTopo  = 100-100*var(EEG.data(:,:)-backProj,0,2)./var(EEG.data(:,:),0,2);

Makoto



On Tue, Sep 17, 2019 at 11:55 PM Bruzadin Nunes, Ugo <ugob at siu.edu> wrote:

> Hi,
>
> I was looking for the answer to your question on EEGLAB listserv from
> March 2019 and found out that the answer was a little more complicated that
> find "just a variable". I don't know how to respond to an old list-serv
> email, so I'm sorry if this is the wrong way.
>
> In any case, I wrote/modified the code from pop_prop_extended() from
> viewprop. You can copy and paste this snip within a code of your own in a
> pipeline or in a separate script  and run it once the data is loaded via
> EEGLAB. This code basically calculates the percentage of explained variable
> as it is done in IClabel and makes into a variable called finalList in
> order of component number. You can call that variable from a separate code
> then, instead of having to modify the original script (which was the thing
> was going to do).
>
> I also don't know the proper etiquette for modifying people's codes, so
> this is my best attempt. Hope it helps!!!
>
> %%% This code was adapted from pop_prop_extended() originally from Luca
> %%% Pion-Tonachini (2017) from the EEGLAB plugin ViewProps
> %%% It was snipped and modified by Ugo Bruzadin Nunes, M.A., with
> collaboration with Matthew Gunn at
> %%% the INL lab at SIU - C to fit our pipeline purposes
> % This is a GNU copyrighted content for free distribution only
>
> temporaryList = {}
> finalList = []
> EEG.icaact = (EEG.icaweights*EEG.icasphere)*EEG.data(EEG.icachansind,:);
>
>     chanorcomp = size(EEG.icaweights,1);
>     for i=1:chanorcomp
>
>         icaacttmp = EEG.icaact(i, :, :);
>         maxsamp = 1e6;
>         n_samp = min(maxsamp, EEG.pnts*EEG.trials);
>         try
>             samp_ind = randperm(EEG.pnts*EEG.trials, n_samp);
>         catch
>             samp_ind = randperm(EEG.pnts*EEG.trials);
>             samp_ind = samp_ind(1:n_samp);
>         end
>         if ~isempty(EEG.icachansind)
>             icachansind = EEG.icachansind;
>         else
>             icachansind = 1:EEG.nbchan;
>         end
>         datavar = mean(var(EEG.data(icachansind, samp_ind), [], 2));
>         projvar = mean(var(EEG.data(icachansind, samp_ind) - ...
>         EEG.icawinv(:, i) * icaacttmp(1, samp_ind), [], 2))
>         pvafval = 100 *(1 - projvar/ datavar);
>         pvaf = num2str(pvafval, '%3.1f')
>         temporaryList = {pvaf};
>         finalList = cat(1, finalList, temporaryList);
>     end
> Best wishes,
>
> Ugo Bruzadin Nunes, M.A. & Doctoral Candidate
> PSYC 222 Instructor - Effects of Recreational Drugs
> Brain and Cognitive Sciences Ph.D Program ||
> School of Psychological and Behavioral Sciences
> Southern Illinois University - Carbondale
> _______________________________________________
> 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
>


--
Makoto Miyakoshi
Assistant Project Scientist, Swartz Center for Computational Neuroscience
Institute for Neural Computation, University of California San Diego




More information about the eeglablist mailing list