# ica.apply() doesn't seem to change the data at all

**URL:** <https://mne.discourse.group/t/ica-apply-doesnt-seem-to-change-the-data-at-all/9344>\
**Category:** Support & Discussions\
**Tags:** preprocessing, eeg, ica\
**Created:** [September 22, 2024, 3:02am UTC](https://mne.discourse.group/t/ica-apply-doesnt-seem-to-change-the-data-at-all/9344 "2024-09-22T03:02:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![eegsignirob](https://avatars.discourse-cdn.com/v4/letter/e/bb73d2/32.png) [@eegsignirob](https://mne.discourse.group/u/eegsignirob)\
**Post date:** [September 22, 2024, 3:02am UTC](https://mne.discourse.group/t/ica-apply-doesnt-seem-to-change-the-data-at-all/9344/1 "2024-09-22T03:02:39Z")

</div>

It seems like zeroing out ICA components has no effect on the data. I plot the sources and components and click on the sources I want to zero out before exiting the window, I then use .apply(raw) which tells me it is zeroing out the number of components that I selected, but then when I plot both raw and raw\_corrected they are identical.

Before applying ica I also use

```python
ica.plot_overlay(raw, exclude=[9,10], picks="eeg")

```

to see what the effect will be and there is definitely a difference shown there. The difference in the “average across EEG channels” plot is very noticeable.

MNE version: e.g. 0.24.0  
operating system: macOS 12

```python
raw = mne.io.read_raw(before_ICA_path, preload = True)
raw.interpolate_bads()

ica_chans = raw.info['ch_names'].copy()

# create ica instance with defined parameters
ica = ICA(.95,           
          max_iter= 1000, # max iterations allowed for the algorithm
          random_state= 42, 
          method = 'infomax', 
          fit_params=dict(extended = True) 
         )                              

# fit ica with the parameters above to the data
ica.fit(raw,
        picks = ica_chans, # channels to use
        reject = dict(eeg = 300e-5) # threshold to ignore parts of the signal
       )

# plot topology and select components in sources plot.
ica.plot_sources(raw)
ica.plot_components()

raw_corrected = ica.apply(raw)

raw.plot(start = 14, scalings="auto")
raw_corrected.plot(start = 14, scalings="auto")

```

Is there any reason why this would be happening? There was a [github issue](https://github.com/mne-tools/mne-python/issues/5053) opened on this topic, where I think the people responding basically were saying that the difference will be small enough to not see a change between plots but they didn’t go into any more detail. That just doesn’t really make sense to me either, especially since there is such a noticeable difference when I use plot\_overlay.

---

<div class="post-metadata">

**Author:** ![eegsignirob](https://avatars.discourse-cdn.com/v4/letter/e/bb73d2/32.png) [@eegsignirob](https://mne.discourse.group/u/eegsignirob)\
**Post date:** [September 22, 2024, 3:22am UTC](https://mne.discourse.group/t/ica-apply-doesnt-seem-to-change-the-data-at-all/9344/2 "2024-09-22T03:22:12Z")

</div>

For anyone having this same issue, the problem was that I did not know that ica.apply() modifies the data in place so I needed to copy the raw data when using it in .apply so I changed this:

```python
raw_corrected = ica.apply(raw)

raw.plot(start = 14, scalings="auto")
raw_corrected.plot(start = 14, scalings="auto")

```

to this:

```python
raw_corrected = ica.apply(raw.copy())

raw.plot(start = 14, scalings="auto")
raw_corrected.plot(start = 14, scalings="auto")

```

Or else it literally was plotting the exact same thing.

---

<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:** [September 29, 2024, 3:23am UTC](https://mne.discourse.group/t/ica-apply-doesnt-seem-to-change-the-data-at-all/9344/3 "2024-09-29T03:23:09Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
