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

Makoto Miyakoshi mmiyakoshi at ucsd.edu
Tue Feb 26 10:26:54 PST 2013

```Dear Maarten,

Sorry I was hasty. Let me get back here.

>>First of all, if I understand correctly, it is not the 2 different
sphering matrices that I need to compare (filt vs. continuous) but it is
the sphering*weights vs. the weights matrix of 1 dataset? And then check
which ones are closest to each other?

What you should actually do is of course to compare the following 1 vs 2
1. weights_a * sphering_a * data_a
2. weights_a * sphering_b * data_a

Sorry if I have confused you and make you perform a wrong comparison. Could
you check your calculation and result?

Makoto

2013/2/26 Maarten De Schuymer <maartendeschuymer at gmail.com>

> Dear Makoto,
>
> Indeed, I completely forgot that it should be weights*sphere, not the
> other way around.
> Ok, now it seems to add up, but it still doesn't really solve the problem
> I suppose. Here is the output for both continuous and epochized data:
>
> >> [sphereMIR_cont icaMIR_cont]
>>
> ans =
>
>    40.2787   40.1626
>
> >> [sphereMIR_epoch icaMIR_epoch]
>> ans =
>>    27.4830   29.7269
>
>
> So based on this, I would say that taking recomputing the sphering matrix
> gives better results. However, does it matter that the values of the
> continuous data are larger (40) than those of the epoched data?
>
>
> 2013/2/26 Makoto Miyakoshi <mmiyakoshi at ucsd.edu>
>
>> Dear Maarten,
>>
>> >First of all, if I understand correctly, it is not the 2 different
>> sphering matrices that I need to compare (filt vs. continuous) but it is
>> the sphering*weights vs. the weights matrix of 1 dataset? And then check
>> which ones are closest to each other?
>>
>> Right. Just an example how it should work and what you should expect to
>> see.
>>
>> >My code is actually completely the same as yours.
>>
>> No, watch carefully. It should be icaweights*icasphere, not the other way
>> around. This order is kind of counterintuitive, isn't it? Try it again with
>> the correct order and tell me what you  get.
>>
>> Makoto
>>
>> 2013/2/26 Maarten De Schuymer <maartendeschuymer at gmail.com>
>>
>>> Hi again,
>>>
>>> First of all, if I understand correctly, it is not the 2 different
>>> sphering matrices that I need to compare (filt vs. continuous) but it is
>>> the sphering*weights vs. the weights matrix of 1 dataset? And then check
>>> which ones are closest to each other?
>>>
>>> My code is actually completely the same as yours.
>>>
>>>>
>>>> sphereMIR = getMIR(EEG.icasphere, EEG.data(:,:))
>>>> sphereMIR =
>>>>    27.4830
>>>> >> icaMIR = getMIR(EEG.icasphere*EEG.icaweights, EEG.data(:,:))
>>>> icaMIR =
>>>>   -19.3297
>>>
>>>
>>> This is the result I get when using the sphering matrix of the filtered
>>> epoched data (so the real sphering matrix automatically computed by the ICA
>>> algorithm).
>>>
>>> If I would have made a mistake in preprocessing, what should this be
>>> then? My preprocessing was quite straight forward: filter, epochation and
>>> then running ICA. I don't see how a mistake could have happened there :).
>>>
>>> I did not however reran the ICA with amica, but just used the regular
>>> ICA weights and spheres that I had by using the runica, might this explain
>>> this difference?
>>>
>>>
>>> 2013/2/26 Makoto Miyakoshi <mmiyakoshi at ucsd.edu>
>>>
>>>> Dear Maarten,
>>>>
>>>> Hmm strange.
>>>> Here are my results. You must be seeing something like this.
>>>>
>>>> %%%%%%%%%%%%%%%
>>>> sphareMIR = getMIR(EEG.icasphere, EEG.data(:,:))
>>>> icaMIR    = getMIR(EEG.icaweights*EEG.icasphere, EEG.data(:,:))
>>>> dummyMIR  = getMIR(rand(68), EEG.data(:,:))
>>>>
>>>> sphareMIR =
>>>>
>>>>    88.0146
>>>>
>>>>
>>>> icaMIR =
>>>>
>>>>    90.7252
>>>>
>>>>
>>>> dummyMIR =
>>>>
>>>>  -197.7197
>>>> %%%%%%%%%%%%%%%%
>>>>
>>>> This tells you that the difference between sphering and ICA is very
>>>> little and distinguished from random matrix (which gives you mutual info
>>>> increase actually).
>>>>
>>>> Why don't you give me the whole code you used. If I don't find anything
>>>> wrong there you must have made a mistake in preprocessing.
>>>>
>>>> Make sure you use same data (EITHER epoched or continuous) for
>>>> comparison.
>>>>
>>>> Makoto
>>>>
>>>> 2013/2/26 Maarten De Schuymer <maartendeschuymer at gmail.com>
>>>>
>>>>> Dear Makoto,
>>>>>
>>>>> I do have some problems interpreting the output that is given by the
>>>>> getMIR.
>>>>> In what way should this output be interpreted?
>>>>>
>>>>> In the following my results based on the epoched filtered data (so the
>>>>> sphering matrix obtained with the ICA dataset) and the newly computed
>>>>> sphering matrix (continuous). The inputs were in both case the same
>>>>> (EEG.data) and the W was either W_epoch = EEG.icaweights*sphere_epoch or
>>>>> W_cont = EEG.icaweights*sphere_continuous.
>>>>>
>>>>> Obtained outputs:
>>>>>> mir_epoch: -19.3297
>>>>>> v_epoch: 0.000046
>>>>>>
>>>>>
>>>>>
>>>>>> mir_cont: -30.7652
>>>>>> v_cont: 0.000045
>>>>>
>>>>>
>>>>> How come these values are negative? In what way should these be
>>>>> interpreted?
>>>>>
>>>>> Thanks for the help; when everything is clear, I will send the results
>>>>> to the list.
>>>>>  Maarten
>>>>>
>>>>>
>>>>> 2013/2/26 Makoto Miyakoshi <mmiyakoshi at ucsd.edu>
>>>>>
>>>>>> Dear Maarten,
>>>>>>
>>>>>> Yes. If you find any problem let me know.
>>>>>>
>>>>>> Makoto
>>>>>>
>>>>>>
>>>>>> 2013/2/26 Maarten De Schuymer <maartendeschuymer at gmail.com>
>>>>>>
>>>>>>> Hi Makoto,
>>>>>>>
>>>>>>> thank you for the file. I will check how long it takes and in the
>>>>>>> worst case scenario I can also run it via a central server.
>>>>>>> So after running amica I can use the function getMIR() to check
>>>>>>> which W works better, right?
>>>>>>>
>>>>>>> Thanks for all the help.
>>>>>>>
>>>>>>> Maarten
>>>>>>>
>>>>>>>
>>>>>>> 2013/2/26 Makoto Miyakoshi <mmiyakoshi at ucsd.edu>
>>>>>>>
>>>>>>>> Dear Maarten,
>>>>>>>>
>>>>>>>> Here is the file. Good luck.
>>>>>>>> I CCed to Jason so that he can check the repository.
>>>>>>>>
>>>>>>>> I'm not sure if it's a good idea to use AMICA in 4-8 core CPUs. We
>>>>>>>> usually use 32-64 (which is a dedicated server for parallel computation).
>>>>>>>> You can try it anyway to see how long it takes. The default iteration is
>>>>>>>> 2000 which may be too many in that case. Some of us uses 750 for your
>>>>>>>> information.
>>>>>>>>
>>>>>>>> Makoto
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> 2013/2/25 Maarten De Schuymer <maartendeschuymer at gmail.com>
>>>>>>>>
>>>>>>>>> Dear Makoto,
>>>>>>>>>
>>>>>>>>> I am having some troubles installing the amica toolbox. I followed
>>>>>>>>> the steps on the site, but after running the command in terminal  (I have a
>>>>>>>>> mac, 64 bit), it didn't find the runamica12.m file anywhere. Subsequentely,
>>>>>>>>> I searched for this file and found it on Jason Palmer's site. However, I'm
>>>>>>>>> still not able to execute runamica because I don't find AMDIR in that file
>>>>>>>>> (I suppose it has been renamed for another version), which -according to
>>>>>>>>> the wiki- needs me to specify the path . Moreover, I don't find any info on
>>>>>>>>> the getMIR() function online.
>>>>>>>>> Any help on this would be highly appreciated.
>>>>>>>>>
>>>>>>>>> Best,
>>>>>>>>> Maarten
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> 2013/2/22 Makoto Miyakoshi <mmiyakoshi at ucsd.edu>
>>>>>>>>>
>>>>>>>>>> Dear Maarten,
>>>>>>>>>>
>>>>>>>>>> I asked it to Nima offline at SCCN B177E. He said categorically
>>>>>>>>>> no because ICA weight matrix is very dependent of the sphering matrix.
>>>>>>>>>>
>>>>>>>>>> By the way you can download a function getMIR() which is included
>>>>>>>>>> This function would eventually tells you which W works better in
>>>>>>>>>> terms of mutual information reduction (this unmixing matrix W should be a
>>>>>>>>>> product of sphering matrix x ica weight matrix). Let us know if you find
>>>>>>>>>> something interesting.
>>>>>>>>>>
>>>>>>>>>> Makoto
>>>>>>>>>>
>>>>>>>>>> 2013/2/22 Maarten De Schuymer <maartendeschuymer at gmail.com>
>>>>>>>>>>
>>>>>>>>>>> Dear list,
>>>>>>>>>>>
>>>>>>>>>>> I am still trying to figure out which is the correct sphering
>>>>>>>>>>> matrix when applying ICA weights to another version of the same dataset.
>>>>>>>>>>> Is there an expert who can weight in on this issue?
>>>>>>>>>>>
>>>>>>>>>>> Thanks a lot,
>>>>>>>>>>> Maarten De Schuymer
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> ---------- Forwarded message ----------
>>>>>>>>>>> From: Maarten De Schuymer <maartendeschuymer at gmail.com>
>>>>>>>>>>> Date: 2013/2/14
>>>>>>>>>>> Subject: Applying ICA weight matrix on another dataset
>>>>>>>>>>> To: eeglablist at sccn.ucsd.edu
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> Dear list,
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> I have a question concerning the role of the sphering matrix
>>>>>>>>>>> (which decorrelates the channels) in the rather common scenario where I
>>>>>>>>>>> compute an ICA on one version of a dataset, but then apply the ICA results
>>>>>>>>>>> to another version of the same data (e.g. epoched vs. continuous, filtered
>>>>>>>>>>> vs. unfiltered).
>>>>>>>>>>>
>>>>>>>>>>> To remove artifacts in my study, I compute the ICA on high-pass
>>>>>>>>>>> filtered (e.g. 1 Hz) data, because this results in much better ICA
>>>>>>>>>>> decompositions. However, I would like to apply the results of this ICA to
>>>>>>>>>>> my original, unfiltered version of the same dataset, because would like to
>>>>>>>>>>> keep slow potentials (< 1 Hz) in the data. After running ICA on the
>>>>>>>>>>> filtered data, I save both EEG.icaweights and EEG.icasphere.
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> When I now apply the ICA weight matrix to the original data it
>>>>>>>>>>> is unclear to me which sphering matrix needs to be used.
>>>>>>>>>>>
>>>>>>>>>>> Should I (A) also import the ICA sphering matrix from the
>>>>>>>>>>> filtered data or (B) recompute the sphering matrix (cmd: sphere(EEG.data))
>>>>>>>>>>> for the original unfiltered data and consequently use that one. Both
>>>>>>>>>>> possibilities result in different outcomes since sphering matrices are
>>>>>>>>>>> different for both versions of the datasets. Which of these possibilities
>>>>>>>>>>> are recommended and more importantly, why exactly?
>>>>>>>>>>>
>>>>>>>>>>> A related question concerns the exporting-importing of the
>>>>>>>>>>> weight matrix in the GUI of EEGLAB. When exporting weights, a single
>>>>>>>>>>> exported file contains the combined weight*sphering matrix. However, when
>>>>>>>>>>> importing, two different files need to be imported, i.e. both weight matrix
>>>>>>>>>>> and sphere matrix separately. This does not seem practical. Or is there a
>>>>>>>>>>> rationale behind this distinction between import and export?
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> Thanks for any input on this,
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> Best
>>>>>>>>>>> Maarten De Schuymer
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> _______________________________________________
>>>>>>>>>>> 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
>>>>>>>>>> JSPS Postdoctral Fellow for Research Abroad
>>>>>>>>>> Swartz Center for Computational Neuroscience
>>>>>>>>>> Institute for Neural Computation, University of California San
>>>>>>>>>> Diego
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> Makoto Miyakoshi
>>>>>>>> JSPS Postdoctral Fellow for Research Abroad
>>>>>>>> Swartz Center for Computational Neuroscience
>>>>>>>> Institute for Neural Computation, University of California San Diego
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Makoto Miyakoshi
>>>>>> JSPS Postdoctral Fellow for Research Abroad
>>>>>> Swartz Center for Computational Neuroscience
>>>>>> Institute for Neural Computation, University of California San Diego
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> Makoto Miyakoshi
>>>> JSPS Postdoctral Fellow for Research Abroad
>>>> Swartz Center for Computational Neuroscience
>>>> Institute for Neural Computation, University of California San Diego
>>>>
>>>
>>>
>>
>>
>> --
>> Makoto Miyakoshi
>> JSPS Postdoctral Fellow for Research Abroad
>> Swartz Center for Computational Neuroscience
>> Institute for Neural Computation, University of California San Diego
>>
>
>

--
Makoto Miyakoshi
JSPS Postdoctral Fellow for Research Abroad
Swartz Center for Computational Neuroscience
Institute for Neural Computation, University of California San Diego
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://sccn.ucsd.edu/pipermail/eeglablist/attachments/20130226/082b555c/attachment-0001.html
```