<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style id="ms-outlook-ios-style" type="text/css">html {
background-color: transparent;
}

body {
color: #333;
line-height: 150%;
font-family: "-apple-system", "HelveticaNeue";
margin: 0;
}

.ms-outlook-ios-reference-expand {
display: block;
color: #999;
padding: 20px 0px;
text-decoration: none;
}

.ms-outlook-ios-availability-container {
max-width: 500px;
margin: auto;
padding: 12px 15px 15px 15px;
border: 1px solid #C7E0F4;
border-radius: 4px;
}

.ms-outlook-ios-availability-container > .ms-outlook-ios-availability-delete-button {
width: 25px;
height: 25px;
right: -12px;
top: -12px;
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEsAAABLCAYAAAA4TnrqAAAAAXNSR0IArs4c6QAACxpJREFUeAHlnFuMXlUVx/fcOzNtp0ynF0U7hWKrEmKLosZEjUZ9MgZIQBNC0uAtJr745oOJIT74xgskJkQbAlQNJmBMfNDEG0YjEC7GIBQZ6IAI005L79O5+/+dfut0f5dzzt7nu8w37UrWt893zt5rr/U/e6+zL+ucHrcGtLq62q9qd4gnxTeKb6kcc267eEI8Kz4mnhFPi58Rv1g5nunp6VnS8ZVHAqdHPCk+KP6zuBWEHORNinvWNWoYIN4q/o74mLidhHzqob71AxzKij8g/p14LYh6qb97QUM58T7x38TdQOiBPt0FmhQaEf9M3I2EXiNr7tOkBK3pVvGCuJsJ/dCzqVbWWxZxVTygso+InxBz3M2Efuj5SEXvUrqWQloV7lRtT4vfX6rWtS30pqr/uMZp78SqEQ2WgPqQKvmnuKWtaWnFuaWVVbciXl51rk+a9fb2uP6EY80qzL+oHB8RYC8V5vQyRIEloD6tsk965UsdAsyZ+WV35uKyOz+/4uZ0YgmEMqhfyA3397rRoV63eUOf2zzUJxAzMsed/owA+2tokWCwmgVKDcadvLDsZs8vutMXV5zkhepYl08GurENvW5idMCNj/Q5Nb5mKBiwoGoqXe/fZTQCkmNnl9x/Ty+4xZzW0yeLB9WC6Hp0QbLSJRd0s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Ov040O3J06LsV3CKzVpBvqgClPUJQfUcEWO8Dgjoi79UDoaYNp9MeOQPohQJHXfBbHD/NTRDRFooKN2IeLiEyxYh1N0e9t6WmE/hFu4DEr54P1B50MGs2z4E9UMMS0gdDE5eYG9YmsdvygF/rZxBm9/Q2Lgjp/r+vp4zYFS00Nc39cUDi9TPi0TUDZ4X1FCnUjoZfFZqAvekfQd60LUiYFqyLgUaXTlePchMgUwqclLMl3WvtvhCZ2E6EPekHoib4RET9/V7FXk8KVnyqwJJBByI/8DHnHbCkRPm2E/+oWwGpjStHT3wIznXPSe/xWRb4qsCoFDyl9qnJcmBBnTvi0EYC9NLN2PgwfRf3oYYR+kfHwYFDnvxs+FDRIPaDMfHQiaJbJc7U2vJvH85UWB98QLNnOqP4+Jd/jOJTW+g0Lhgf21MNHdeQNC8ARWAymcHIf5X8osVZ01b27AzgC7Holz4nH+B9KDAKvqrfCDBgB9hUdPy4O8l9WjpRFtqvmfUMzXIB9U8cP2v+YFOcf8yYr227sTLHCwexgXb3JasAIsB/oOHgMZuUsxXha2hX/jrQZ3CxgJoe1LSLuCCSLfvteczuWuANXOK3KrDT4ZXIEZA4dsqRXuuRPdD3ah2XJ5DwAEs1C16MV0hXpksznWgSMXz0j1vZ+18FqE2A4/YfFUU9JK7/G6Zuqv9QXQxpNdwpt0YDvN8p0szhoZ6hQYOcyHFZVvDSe+5Z9W9RRCxsU3ydeEnczteQrRy0BUSgdEP+jS9Hqju9n+UgLKL6l9XXx0S4BrTu/zFYDWr/AOig+skagdf83/3zAOBZQvOryRTEf+Donbid15GuS0eOsWlBC/gsl9iW/LP6C+PPi68TN0usS8EcxH6z4be2qZrPCG5XvCFi1FQu8SZ1j6YdXYeC9YuLxiZyGicQltpuoRPiEmJVLwqPgZwXOtNKO0v8BzRAPSFNM7HEAAAAASUVORK5CYII=");
background-size: 25px 25px;
background-position: center;
}

#ms-outlook-ios-main-container {
margin: 0 0 0 0;
margin-top: 120;
padding: 8;
}

#ms-outlook-ios-content-container {
padding: 0;
padding-top: 12;
padding-bottom: 20;
}

.ms-outlook-ios-mention {
color: #333;
background-color: #f1f1f1;
border-radius: 4px;
padding: 0 2px 0 2px;
pointer-events: none;
text-decoration: none;
}

.ms-outlook-ios-mention-external {
color: #ba8f0d;
background-color: #fdf7e7;
}

.ms-outlook-ios-mention-external-clear-design {
color: #ba8f0d;
background-color: #f1f1f1;
}</style>
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0">
</head>
<body style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><p><span style="padding: 3px 10px; border-radius: 5px; color: #ffffff; font-weight: bold; display: inline-block; background-color: #ff0000;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;External Email - Use Caution&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></p><p></p>
<div style="direction: ltr;">
<div>Hello,</div>
<div><br>
</div>
<div>I am trying to calculate inter-trial coherence (itc) for a project. Does anyone know of an easy way to calculate the average itc over several channels? It is not clear to me how do this over a 3D array in Python. Any help would be greatly appreciated.</div>
<div><br>
</div>
<div>Thanks,</div>
<div><br>
</div>
<div>Jason</div>
<div><br>
</div>
<div class="ms-outlook-ios-signature">Get <a href="https://aka.ms/o0ukef">Outlook for iOS</a></div>
</div>
<div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="dir=&quot;ltr&quot;"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Geller, Jason &lt;jason-geller@uiowa.edu&gt;<br>
<b>Sent:</b> Saturday, July 6, 2019 11:46 AM<br>
<b>To:</b> mne_analysis@nmr.mgh.harvard.edu<br>
<b>Subject:</b> Re: [External] Mne_analysis Digest, Vol 138, Issue 5
<div>&nbsp;</div>
</font></div>
<meta content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Exchange Server">
<style><!--.EmailQuote        {margin-left:1pt;        padding-left:4pt;        border-left:#800000 2px solid}--></style>
<div>
<div>
<div>
<div>Hello,</div>
<div><br>
</div>
<div style="direction:ltr">I am trying to calculate inter-trial coherence (itc) for a project. Does anyone know of an easy way to calculate the average itc over several channels? It is not clear to me how do this over a 3D array in Python. Any help would be
 greatly appreciated. </div>
<div><br>
</div>
<div style="direction:ltr">Thanks,</div>
<div><br>
</div>
<div style="direction:ltr">Jason </div>
</div>
<div><br>
</div>
<div class="x_ms-outlook-ios-signature">Get <a href="https://aka.ms/o0ukef">Outlook for iOS</a></div>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> mne_analysis-bounces@nmr.mgh.harvard.edu &lt;mne_analysis-bounces@nmr.mgh.harvard.edu&gt; on behalf of mne_analysis-request@nmr.mgh.harvard.edu
 &lt;mne_analysis-request@nmr.mgh.harvard.edu&gt;<br>
<b>Sent:</b> Wednesday, July 3, 2019 4:40:57 PM<br>
<b>To:</b> mne_analysis@nmr.mgh.harvard.edu<br>
<b>Subject:</b> [External] Mne_analysis Digest, Vol 138, Issue 5</font>
<div>&nbsp;</div>
</div>
</div>
<font size="2"><span style="font-size:11pt">
<div class="PlainText">Send Mne_analysis mailing list submissions to<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mne_analysis@nmr.mgh.harvard.edu<br>
<br>
To subscribe or unsubscribe via the World Wide Web, visit<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis">
https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis</a><br>
or, via email, send a message with subject or body 'help' to<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mne_analysis-request@nmr.mgh.harvard.edu<br>
<br>
You can reach the person managing the list at<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mne_analysis-owner@nmr.mgh.harvard.edu<br>
<br>
When replying, please edit your Subject line so it is more specific<br>
than &quot;Re: Contents of Mne_analysis digest...&quot;<br>
<br>
<br>
Today's Topics:<br>
<br>
&nbsp;&nbsp; 1. Re: Applying ICA with No Components Selected out but Signal<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Changes Using Default Parameters (Alexandre Gramfort)<br>
&nbsp;&nbsp; 2. Re: Applying ICA with No Components Selected out but Signal<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Changes Using Default Parameters (Mainak Jas)<br>
<br>
<br>
----------------------------------------------------------------------<br>
<br>
Message: 1<br>
Date: Wed, 3 Jul 2019 22:22:50 &#43;0200<br>
From: Alexandre Gramfort &lt;alexandre.gramfort@inria.fr&gt;<br>
Subject: Re: [Mne_analysis] Applying ICA with No Components Selected<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; out but Signal Changes Using Default Parameters<br>
To: Discussion and support forum for the users of MNE Software<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;mne_analysis@nmr.mgh.harvard.edu&gt;<br>
Message-ID:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;CADeotZpCnNZypyjXfYeoyxvdDMf-Hn9CapPwYvy3zE30T1VKww@mail.gmail.com&gt;<br>
Content-Type: text/plain; charset=&quot;utf-8&quot;<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; External Email - Use Caution&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>
<br>
Hi Alex,<br>
<br>
I could replicate the pb and start to investigate.<br>
<br>
You have a strong transient artifact in your data (stim artifact I suspect)<br>
and this affects the conditioning of the mixing matrix. So when computing<br>
the pinv here: <a href="https://github.com/mne-tools/mne-python/blob/master/mne/preprocessing/ica.py#L677">
https://github.com/mne-tools/mne-python/blob/master/mne/preprocessing/ica.py#L677</a><br>
the mixing is not numerically the inverse of the unmixing matrix.<br>
<br>
I don't know exactly how to fix this but that's a starting point.<br>
He someone can look into this it's great.<br>
<br>
Alex<br>
<br>
On Wed, Jul 3, 2019 at 3:33 PM Rockhill, Alexander P.<br>
&lt;AROCKHILL@mgh.harvard.edu&gt; wrote:<br>
&gt;<br>
&gt; Hi Alex and Mainak,<br>
&gt;<br>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; The n_components argument is given None which yields 57 components and there are 64 channels with 7 bad channels which are not included so no I don't think it's because of the dimensionality reduction. Maybe it's some whitening.<br>
&gt;<br>
&gt; To see something similar to what I'm looking at as far as scaling you can use the script below but I haven't been able to replicate the changes after ICA with sample data. I filedropped you both test epochs to the emails you responded to the thread with that
 does show that.<br>
&gt;<br>
&gt; from time import time<br>
&gt; import matplotlib.pyplot as plt<br>
&gt; import mne<br>
&gt; from mne.preprocessing import ICA<br>
&gt; from mne.datasets import sample<br>
&gt;<br>
&gt; '''data_path = sample.data_path()<br>
&gt; raw_fname = data_path &#43; '/MEG/sample/sample_audvis-raw.fif'<br>
&gt;<br>
&gt; raw = mne.io.Raw(raw_fname, preload=True)<br>
&gt; events = mne.find_events(raw)<br>
&gt; epochs = mne.Epochs(raw, events, preload=True)<br>
&gt;<br>
&gt; '''<br>
&gt; epochs = mne.read_epochs('test-epo.fif', preload=True)<br>
&gt;<br>
&gt; epochs = epochs.pick_types(meg=False, eeg=True)<br>
&gt;<br>
&gt; fig, (ax0, ax1) = plt.subplots(1,2)<br>
&gt; epochs.average().plot(axes=ax0, show=False)<br>
&gt;<br>
&gt; ica = ICA(method='fastica', random_state=0)<br>
&gt; t0 = time()<br>
&gt; ica.fit(epochs)<br>
&gt; fit_time = time() - t0<br>
&gt; epochs = ica.apply(epochs, exclude=ica.exclude)<br>
&gt; epochs.average().plot(axes=ax1, show=False)<br>
&gt; ica.plot_sources(epochs)<br>
&gt;<br>
&gt; Thanks,<br>
&gt;<br>
&gt; Alex<br>
&gt;<br>
&gt; Translational NeuroEngineering Laboratory<br>
&gt; Division of Neurotherapeutics, Department of Psychiatry<br>
&gt; Massachusetts General Hospital, Martinos Center<br>
&gt; 149 13th St Charlestown #2301, Boston, MA 02129<br>
&gt; ________________________________<br>
&gt; From: mne_analysis-bounces@nmr.mgh.harvard.edu &lt;mne_analysis-bounces@nmr.mgh.harvard.edu&gt; on behalf of Alexandre Gramfort &lt;alexandre.gramfort@inria.fr&gt;<br>
&gt; Sent: Wednesday, July 3, 2019 2:30 AM<br>
&gt; To: Discussion and support forum for the users of MNE Software<br>
&gt; Subject: Re: [Mne_analysis] Applying ICA with No Components Selected out but Signal Changes Using Default Parameters<br>
&gt;<br>
&gt;<br>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; External Email - Use Caution<br>
&gt;<br>
&gt; hi,<br>
&gt;<br>
&gt; can you check that the number of components you fit is equal to the number of channels?<br>
&gt; If it's less you have a dimensionality reduction step.<br>
&gt;<br>
&gt; Alex<br>
&gt;<br>
&gt;<br>
&gt; On Tue, Jul 2, 2019 at 11:28 PM Mainak Jas &lt;mainakjas@gmail.com&gt; wrote:<br>
&gt;<br>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; External Email - Use Caution<br>
&gt;<br>
&gt; Hi Alex,<br>
&gt;<br>
&gt; Could you provide us a full script on the MNE sample data that we can run?<br>
&gt;<br>
&gt; Mainak<br>
&gt;<br>
&gt; On Tue, Jul 2, 2019 at 5:14 PM Rockhill, Alexander P. &lt;AROCKHILL@mgh.harvard.edu&gt; wrote:<br>
&gt;<br>
&gt; Also, of note the ica scale is off by quite a lot in the plot_sources plot, it is way too zoomed in.<br>
&gt;<br>
&gt; Alex<br>
&gt;<br>
&gt; Translational NeuroEngineering Laboratory<br>
&gt; Division of Neurotherapeutics, Department of Psychiatry<br>
&gt; Massachusetts General Hospital, Martinos Center<br>
&gt; 149 13th St Charlestown #2301, Boston, MA 02129<br>
&gt; ________________________________<br>
&gt; From: mne_analysis-bounces@nmr.mgh.harvard.edu &lt;mne_analysis-bounces@nmr.mgh.harvard.edu&gt; on behalf of Rockhill, Alexander P. &lt;AROCKHILL@mgh.harvard.edu&gt;<br>
&gt; Sent: Tuesday, July 2, 2019 3:25 PM<br>
&gt; To: mne_analysis@nmr.mgh.harvard.edu<br>
&gt; Subject: [Mne_analysis] Applying ICA with No Components Selected out but Signal Changes Using Default Parameters<br>
&gt;<br>
&gt; Hi,<br>
&gt;<br>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; In an analysis, I am running:<br>
&gt;<br>
&gt; ica = ICA(method='fastica', n_components=n_components,&nbsp; # n_components=None<br>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; random_state=seed)<br>
&gt; ica.fit(inst2)<br>
&gt; ...<br>
&gt; inst2 = ica.apply(inst2, exclude=ica.exclude)<br>
&gt;<br>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; and when I skip all intermediate steps and just fit the ICA and apply it with an empty list for ica.exclude the signal still changes, quite a bit. I thought if no components were selected out and all the max PCA components were used the signal would be
 unchanged or basically unchanged. Is this a bug or something with my implementation?<br>
&gt;<br>
&gt; Thanks,<br>
&gt;<br>
&gt; Alex<br>
&gt;<br>
&gt; Translational NeuroEngineering Laboratory<br>
&gt; Division of Neurotherapeutics, Department of Psychiatry<br>
&gt; Massachusetts General Hospital, Martinos Center<br>
&gt; 149 13th St Charlestown #2301, Boston, MA 02129<br>
&gt; _______________________________________________<br>
&gt; Mne_analysis mailing list<br>
&gt; Mne_analysis@nmr.mgh.harvard.edu<br>
&gt; <a href="https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis">https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis</a><br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; Mne_analysis mailing list<br>
&gt; Mne_analysis@nmr.mgh.harvard.edu<br>
&gt; <a href="https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis">https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis</a><br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; Mne_analysis mailing list<br>
&gt; Mne_analysis@nmr.mgh.harvard.edu<br>
&gt; <a href="https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis">https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis</a><br>
<br>
<br>
<br>
------------------------------<br>
<br>
Message: 2<br>
Date: Wed, 3 Jul 2019 16:40:41 -0400<br>
From: Mainak Jas &lt;mainakjas@gmail.com&gt;<br>
Subject: Re: [Mne_analysis] Applying ICA with No Components Selected<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; out but Signal Changes Using Default Parameters<br>
To: Discussion and support forum for the users of MNE Software<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;mne_analysis@nmr.mgh.harvard.edu&gt;<br>
Message-ID:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;CANzrpG1ubBi7EQdykvAPA_q3=1MGv8MFJmhrpOyx=X8FDBnitg@mail.gmail.com&gt;<br>
Content-Type: text/plain; charset=&quot;utf-8&quot;<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; External Email - Use Caution&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>
<br>
I can confirm what Alex said. Here?s a simpler script to play with:<br>
<br>
import mnefrom mne.preprocessing import ICA<br>
from numpy.testing import assert_array_equal<br>
<br>
epochs = mne.read_epochs('test-epo.fif', preload=True)<br>
<br>
epochs.pick_types(meg=False, eeg=True)<br>
epochs.crop(0.2, None)<br>
<br>
epochs2 = epochs.copy()<br>
<br>
reject = dict(eeg=200e-6)<br>
ica = ICA(method='fastica', random_state=42, max_iter=500, n_components=0.95)<br>
ica.fit(epochs.copy().drop_bad(reject=reject), decim=10)<br>
<br>
ica.apply(epochs2, exclude=[])<br>
<br>
epochs.average().plot()<br>
epochs2.average().plot()<br>
# from mne import combine_evoked# evoked_diff =<br>
combine_evoked([epochs.average(), -epochs2.average()], 'equal')#<br>
evoked_diff.plot()<br>
<br>
assert_array_equal(epochs.get_data(), epochs2.get_data())<br>
<br>
Using n_components=0.95 vs n_components=1.0 actually seems to make a huge<br>
difference, perhaps for the reasons that Alex outlines. Ultimately, what<br>
you reconstruct depends on the quality of your decomposition -- and it's<br>
not perfect.<br>
<br>
Best,<br>
Mainak<br>
<br>
On Wed, Jul 3, 2019 at 4:23 PM Alexandre Gramfort &lt;<br>
alexandre.gramfort@inria.fr&gt; wrote:<br>
<br>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; External Email - Use Caution<br>
&gt;<br>
&gt; Hi Alex,<br>
&gt;<br>
&gt; I could replicate the pb and start to investigate.<br>
&gt;<br>
&gt; You have a strong transient artifact in your data (stim artifact I suspect)<br>
&gt; and this affects the conditioning of the mixing matrix. So when computing<br>
&gt; the pinv here:<br>
&gt; <a href="https://github.com/mne-tools/mne-python/blob/master/mne/preprocessing/ica.py#L677">
https://github.com/mne-tools/mne-python/blob/master/mne/preprocessing/ica.py#L677</a><br>
&gt; the mixing is not numerically the inverse of the unmixing matrix.<br>
&gt;<br>
&gt; I don't know exactly how to fix this but that's a starting point.<br>
&gt; He someone can look into this it's great.<br>
&gt;<br>
&gt; Alex<br>
&gt;<br>
&gt; On Wed, Jul 3, 2019 at 3:33 PM Rockhill, Alexander P.<br>
&gt; &lt;AROCKHILL@mgh.harvard.edu&gt; wrote:<br>
&gt; &gt;<br>
&gt; &gt; Hi Alex and Mainak,<br>
&gt; &gt;<br>
&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; The n_components argument is given None which yields 57 components<br>
&gt; and there are 64 channels with 7 bad channels which are not included so no<br>
&gt; I don't think it's because of the dimensionality reduction. Maybe it's some<br>
&gt; whitening.<br>
&gt; &gt;<br>
&gt; &gt; To see something similar to what I'm looking at as far as scaling you<br>
&gt; can use the script below but I haven't been able to replicate the changes<br>
&gt; after ICA with sample data. I filedropped you both test epochs to the<br>
&gt; emails you responded to the thread with that does show that.<br>
&gt; &gt;<br>
&gt; &gt; from time import time<br>
&gt; &gt; import matplotlib.pyplot as plt<br>
&gt; &gt; import mne<br>
&gt; &gt; from mne.preprocessing import ICA<br>
&gt; &gt; from mne.datasets import sample<br>
&gt; &gt;<br>
&gt; &gt; '''data_path = sample.data_path()<br>
&gt; &gt; raw_fname = data_path &#43; '/MEG/sample/sample_audvis-raw.fif'<br>
&gt; &gt;<br>
&gt; &gt; raw = mne.io.Raw(raw_fname, preload=True)<br>
&gt; &gt; events = mne.find_events(raw)<br>
&gt; &gt; epochs = mne.Epochs(raw, events, preload=True)<br>
&gt; &gt;<br>
&gt; &gt; '''<br>
&gt; &gt; epochs = mne.read_epochs('test-epo.fif', preload=True)<br>
&gt; &gt;<br>
&gt; &gt; epochs = epochs.pick_types(meg=False, eeg=True)<br>
&gt; &gt;<br>
&gt; &gt; fig, (ax0, ax1) = plt.subplots(1,2)<br>
&gt; &gt; epochs.average().plot(axes=ax0, show=False)<br>
&gt; &gt;<br>
&gt; &gt; ica = ICA(method='fastica', random_state=0)<br>
&gt; &gt; t0 = time()<br>
&gt; &gt; ica.fit(epochs)<br>
&gt; &gt; fit_time = time() - t0<br>
&gt; &gt; epochs = ica.apply(epochs, exclude=ica.exclude)<br>
&gt; &gt; epochs.average().plot(axes=ax1, show=False)<br>
&gt; &gt; ica.plot_sources(epochs)<br>
&gt; &gt;<br>
&gt; &gt; Thanks,<br>
&gt; &gt;<br>
&gt; &gt; Alex<br>
&gt; &gt;<br>
&gt; &gt; Translational NeuroEngineering Laboratory<br>
&gt; &gt; Division of Neurotherapeutics, Department of Psychiatry<br>
&gt; &gt; Massachusetts General Hospital, Martinos Center<br>
&gt; &gt; 149 13th St Charlestown #2301, Boston, MA 02129<br>
&gt; &gt; ________________________________<br>
&gt; &gt; From: mne_analysis-bounces@nmr.mgh.harvard.edu &lt;<br>
&gt; mne_analysis-bounces@nmr.mgh.harvard.edu&gt; on behalf of Alexandre Gramfort<br>
&gt; &lt;alexandre.gramfort@inria.fr&gt;<br>
&gt; &gt; Sent: Wednesday, July 3, 2019 2:30 AM<br>
&gt; &gt; To: Discussion and support forum for the users of MNE Software<br>
&gt; &gt; Subject: Re: [Mne_analysis] Applying ICA with No Components Selected out<br>
&gt; but Signal Changes Using Default Parameters<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; External Email - Use Caution<br>
&gt; &gt;<br>
&gt; &gt; hi,<br>
&gt; &gt;<br>
&gt; &gt; can you check that the number of components you fit is equal to the<br>
&gt; number of channels?<br>
&gt; &gt; If it's less you have a dimensionality reduction step.<br>
&gt; &gt;<br>
&gt; &gt; Alex<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; On Tue, Jul 2, 2019 at 11:28 PM Mainak Jas &lt;mainakjas@gmail.com&gt; wrote:<br>
&gt; &gt;<br>
&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; External Email - Use Caution<br>
&gt; &gt;<br>
&gt; &gt; Hi Alex,<br>
&gt; &gt;<br>
&gt; &gt; Could you provide us a full script on the MNE sample data that we can<br>
&gt; run?<br>
&gt; &gt;<br>
&gt; &gt; Mainak<br>
&gt; &gt;<br>
&gt; &gt; On Tue, Jul 2, 2019 at 5:14 PM Rockhill, Alexander P. &lt;<br>
&gt; AROCKHILL@mgh.harvard.edu&gt; wrote:<br>
&gt; &gt;<br>
&gt; &gt; Also, of note the ica scale is off by quite a lot in the plot_sources<br>
&gt; plot, it is way too zoomed in.<br>
&gt; &gt;<br>
&gt; &gt; Alex<br>
&gt; &gt;<br>
&gt; &gt; Translational NeuroEngineering Laboratory<br>
&gt; &gt; Division of Neurotherapeutics, Department of Psychiatry<br>
&gt; &gt; Massachusetts General Hospital, Martinos Center<br>
&gt; &gt; 149 13th St Charlestown #2301, Boston, MA 02129<br>
&gt; &gt; ________________________________<br>
&gt; &gt; From: mne_analysis-bounces@nmr.mgh.harvard.edu &lt;<br>
&gt; mne_analysis-bounces@nmr.mgh.harvard.edu&gt; on behalf of Rockhill,<br>
&gt; Alexander P. &lt;AROCKHILL@mgh.harvard.edu&gt;<br>
&gt; &gt; Sent: Tuesday, July 2, 2019 3:25 PM<br>
&gt; &gt; To: mne_analysis@nmr.mgh.harvard.edu<br>
&gt; &gt; Subject: [Mne_analysis] Applying ICA with No Components Selected out but<br>
&gt; Signal Changes Using Default Parameters<br>
&gt; &gt;<br>
&gt; &gt; Hi,<br>
&gt; &gt;<br>
&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; In an analysis, I am running:<br>
&gt; &gt;<br>
&gt; &gt; ica = ICA(method='fastica', n_components=n_components,&nbsp; #<br>
&gt; n_components=None<br>
&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; random_state=seed)<br>
&gt; &gt; ica.fit(inst2)<br>
&gt; &gt; ...<br>
&gt; &gt; inst2 = ica.apply(inst2, exclude=ica.exclude)<br>
&gt; &gt;<br>
&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; and when I skip all intermediate steps and just fit the ICA and<br>
&gt; apply it with an empty list for ica.exclude the signal still changes, quite<br>
&gt; a bit. I thought if no components were selected out and all the max PCA<br>
&gt; components were used the signal would be unchanged or basically unchanged.<br>
&gt; Is this a bug or something with my implementation?<br>
&gt; &gt;<br>
&gt; &gt; Thanks,<br>
&gt; &gt;<br>
&gt; &gt; Alex<br>
&gt; &gt;<br>
&gt; &gt; Translational NeuroEngineering Laboratory<br>
&gt; &gt; Division of Neurotherapeutics, Department of Psychiatry<br>
&gt; &gt; Massachusetts General Hospital, Martinos Center<br>
&gt; &gt; 149 13th St Charlestown #2301, Boston, MA 02129<br>
&gt; &gt; _______________________________________________<br>
&gt; &gt; Mne_analysis mailing list<br>
&gt; &gt; Mne_analysis@nmr.mgh.harvard.edu<br>
&gt; &gt; <a href="https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis">https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis</a><br>
&gt; &gt;<br>
&gt; &gt; _______________________________________________<br>
&gt; &gt; Mne_analysis mailing list<br>
&gt; &gt; Mne_analysis@nmr.mgh.harvard.edu<br>
&gt; &gt; <a href="https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis">https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis</a><br>
&gt; &gt;<br>
&gt; &gt; _______________________________________________<br>
&gt; &gt; Mne_analysis mailing list<br>
&gt; &gt; Mne_analysis@nmr.mgh.harvard.edu<br>
&gt; &gt; <a href="https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis">https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis</a><br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; Mne_analysis mailing list<br>
&gt; Mne_analysis@nmr.mgh.harvard.edu<br>
&gt; <a href="https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis">https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis</a><br>
&gt;<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <a href="http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20190703/ad2a76b3/attachment.html">
http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20190703/ad2a76b3/attachment.html</a><br>
<br>
------------------------------<br>
<br>
_______________________________________________<br>
Mne_analysis mailing list<br>
Mne_analysis@nmr.mgh.harvard.edu<br>
<a href="https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis">https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis</a><br>
<br>
End of Mne_analysis Digest, Vol 138, Issue 5<br>
********************************************<br>
</div>
</span></font></div>
</body>
</html>