# ICA - Getting the mixing matrix from ica objet.

**URL:** <https://mne.discourse.group/t/ica-getting-the-mixing-matrix-from-ica-objet/1747>\
**Category:** Mailing List Archive (read-only)\
**Tags:** list-archive\
**Created:** [February 21, 2019, 2:46pm UTC](https://mne.discourse.group/t/ica-getting-the-mixing-matrix-from-ica-objet/1747 "2019-02-21T14:46:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [February 21, 2019, 2:46pm UTC](https://mne.discourse.group/t/ica-getting-the-mixing-matrix-from-ica-objet/1747/1 "2019-02-21T14:46:19Z")

</div>

External Email - Use Caution

Dear MNE team and users,

I currently working on testing MNE ICA algorithms for different case ( noise level, sample length)  
I would like to extract the mixing matrix M used by ica.apply to go back from ica source space to recording space such as

Recordings = M \* Sources

I ended with this formula :  
M = pre\_whitener\_ \* (pca\_components\_) -1 \* mixing [1]

And implemented it with python using:

pre\_whitener\_ = getattr(ica, "pre\_whitener\_" )  
whitenning\_matrix = np.eye(len(pre\_whitener\_))\*pre\_whitener\_  
mixing = getattr(ica, "mixing\_matrix\_" )  
pca\_components\_ = getattr(ica, "pca\_components\_" )

M = np.dot (whitenning\_matrix, np.dot(np.linalg.inv(pca\_components\_), mixing ) )

But I weren?t able to successfully reconstruct the signal by using the following line:

Records\_from\_ica = np.dot(M, ica.get\_sources(Raw).get\_data())

It?s probably a problem in the formula [1] , but I can?t find any solution

Do you have any idea on how to get the mixing matrix used by the ica.apply function ? I looked up the code, but it didn?t completely understand it

Thanks for your help,  
Victor

-------------- next part --------------  
An HTML attachment was scrubbed...  
URL: [http://mail.nmr.mgh.harvard.edu/pipermail/mne\_analysis/attachments/20190221/b803ff3b/attachment-0001.html](http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20190221/b803ff3b/attachment-0001.html)

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [February 21, 2019, 8:25pm UTC](https://mne.discourse.group/t/ica-getting-the-mixing-matrix-from-ica-objet/1747/2 "2019-02-21T20:25:12Z")

</div>

External Email - Use Caution

see for example

[https://github.com/mne-tools/mne-python/blob/master/mne/preprocessing/ica.py#L684](https://github.com/mne-tools/mne-python/blob/master/mne/preprocessing/ica.py#L684)

do you take into account the PCA centering?

Alex
