# How to set up and fit the ICA?

**URL:** <https://mne.discourse.group/t/how-to-set-up-and-fit-the-ica/5678>\
**Category:** Support & Discussions\
**Tags:** ica\
**Created:** [October 5, 2022, 8:48am UTC](https://mne.discourse.group/t/how-to-set-up-and-fit-the-ica/5678 "2022-10-05T08:48:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![irene](https://avatars.discourse-cdn.com/v4/letter/i/c89c15/32.png) [@irene](https://mne.discourse.group/u/irene)\
**Post date:** [October 5, 2022, 8:48am UTC](https://mne.discourse.group/t/how-to-set-up-and-fit-the-ica/5678/1 "2022-10-05T08:48:57Z")

</div>

Hi, I’m an absolute newbie, so apologies for the dumb question.

I am trying out this tutorial: [Overview of MEG/EEG analysis with MNE-Python — MNE 1.1.1 documentation](https://mne.tools/stable/auto_tutorials/intro/10_overview.html#sphx-glr-auto-tutorials-intro-10-overview-py)

- MNE version: 1.1.1
- operating system: e.g. macOS Monterey 12.3

In the preprocessing section, the tutorial says:

```python
# set up and fit the ICA
ica = mne.preprocessing.ICA(n_components=20, random_state=97, max_iter=800)
ica.fit(raw)
ica.exclude = [1, 2] # details on how we picked these are omitted here
ica.plot_properties(raw, picks=ica.exclude)

```

However, my output is:

`/usr/local/bin/python3 "/Users/irene/Python Trial/riproviamo.py"`

Instead of the results of the ICA.  
Also, the last output line before that is:  
`/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/mne/viz/evoked.py:116: MatplotlibDeprecationWarning: The resize_event function was deprecated in Matplotlib 3.6 and will be removed two minor releases later. Use callbacks.process('resize_event', ResizeEvent(...)) instead.`

I don’t know what any of this means, any help is immensely appreciated.

Thank you so so much!!

---

<div class="post-metadata">

**Author:** ![richard](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/richard/32/15_2.png) [@richard](https://mne.discourse.group/u/richard)\
**Post date:** [October 5, 2022, 9:39am UTC](https://mne.discourse.group/t/how-to-set-up-and-fit-the-ica/5678/2 "2022-10-05T09:39:49Z")

</div>

Hello @irene and welcome to the forum!

> [@irene](#):
>
> However, my output is:
> 
> `/usr/local/bin/python3 "/Users/irene/Python Trial/riproviamo.py"`
> 
> Instead of the results of the ICA.

It appears you’re running your code from a non-interactive Python session (via `python3 ...`), hence the figure will close immediately once the end of your script is reached. You can prevent this from happening by running Python with the `-i` switch (`python3 -i ...`), or by running the code in an interactive session, e.g. in IPython or Jupyter.

> [@irene](#):
>
> Also, the last output line before that is:  
> `/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/mne/viz/evoked.py:116: MatplotlibDeprecationWarning: The resize_event function was deprecated in Matplotlib 3.6 and will be removed two minor releases later. Use callbacks.process('resize_event', ResizeEvent(...)) instead.`

This is a warning that you can ignore. The MNE-Python developers will have to take care of this in a future release, but for now, it shouldn’t affect your work.

Best wishes,  
Richard

---

<div class="post-metadata">

**Author:** ![irene](https://avatars.discourse-cdn.com/v4/letter/i/c89c15/32.png) [@irene](https://mne.discourse.group/u/irene)\
**Post date:** [October 5, 2022, 1:39pm UTC](https://mne.discourse.group/t/how-to-set-up-and-fit-the-ica/5678/3 "2022-10-05T13:39:14Z")

</div>

Hello Richard, took me quite some time but it did work in the end, so thank you so much! I’ll probably work solely in an interactive session from now on 🙂  
Best!
