# Unexpected behaviour in find\_bads\_eog

**URL:** <https://mne.discourse.group/t/unexpected-behaviour-in-find-bads-eog/3474>\
**Category:** Support & Discussions\
**Tags:** eeg, ica, autoreject\
**Created:** [July 30, 2021, 9:06am UTC](https://mne.discourse.group/t/unexpected-behaviour-in-find-bads-eog/3474 "2021-07-30T09:06:03Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![eduardo](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/eduardo/32/1157_2.png) [@eduardo](https://mne.discourse.group/u/eduardo)\
**Post date:** [July 30, 2021, 9:06am UTC](https://mne.discourse.group/t/unexpected-behaviour-in-find-bads-eog/3474/1 "2021-07-30T09:06:03Z")

</div>

I have applied the following workflow for automated artifact rejection (based on [this example](https://872-59485140-gh.circle-artifacts.com/0/html/auto_examples/plot_autoreject_workflow.html#sphx-glr-auto-examples-plot-autoreject-workflow-py)).

```python
# Autoreject (local) to clean epochs before ICA
ar_pre_ica = AutoReject(random_state = seed).fit(epochs[:20])
_, reject_log = ar_pre_ica.transform(epochs, return_log = True)

# Fit ICA on non-artifactual epochs 
ica = mne.preprocessing.ICA(random_state = seed)
ica.fit(epochs[~reject_log.bad_epochs])

# Exclude blink artifact components (use Fp1 as EOG proxy)
epochs_eog = mne.preprocessing.create_eog_epochs(raw = raw, ch_name = 'Fp1') 
eog_idx, eog_scores = ica.find_bads_eog(epochs_eog, ch_name = 'Fp1', verbose = 2)
ica.exclude = eog_idx
            
# Apply ICA
epochs_clean = ica.apply(epochs.copy())
            
# Autoreject (local) on blink-artifact-free epochs
ar_post_ica = AutoReject(random_state = seed).fit(epochs_clean[:20])
epochs_clean = ar_post_ica.transform(epochs_clean)

```

The thing is, `find_bads_eog` does not seem to catch the blink artifact components despite they are quite evident. Actually, the `eog_scores` of the two first ICA components are `0.81` and `-0.77`, however I get `eog_idx = []`

Below is the plot of the ICA components.

 ![ica1.PNG](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/5a5bdac625d559b8beb075fc1801a5922303041b.jpeg)

I have also tried using `n_components = 0.99` to reduce the number of components. In this case, the two blink components are combined into a single component with an `eog_score = 0.97`, however, `find_bads_eog` still does not catch this component as `eog_idx = []`.

 ![ica2](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/1207efd07f8c3d460f09456617ddf49244bb9a2f.png)

Does anyone know why this happens? Thanks.

---

<div class="post-metadata">

**Author:** ![agramfort](https://avatars.discourse-cdn.com/v4/letter/a/7c8e57/32.png) [@agramfort](https://mne.discourse.group/u/agramfort)\
**Post date:** [July 30, 2021, 8:23pm UTC](https://mne.discourse.group/t/unexpected-behaviour-in-find-bads-eog/3474/2 "2021-07-30T20:23:42Z")

</div>

can you share the data file with a script to replicate what you report?

Alex

---

<div class="post-metadata">

**Author:** ![eduardo](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/eduardo/32/1157_2.png) [@eduardo](https://mne.discourse.group/u/eduardo)\
**Post date:** [July 31, 2021, 11:20am UTC](https://mne.discourse.group/t/unexpected-behaviour-in-find-bads-eog/3474/3 "2021-07-31T11:20:14Z")

</div>

Hi Alexandre.

I’ve created a folder with the necessary data. You just need to download the folder [here](https://www.dropbox.com/sh/twrfsvs1aje222z/AAAQtB3jbIn8wm8w3lpHH0mya?dl=0) and run the script inside.

Thank you.  
Eduardo

---

<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:** [July 31, 2021, 4:42pm UTC](https://mne.discourse.group/t/unexpected-behaviour-in-find-bads-eog/3474/4 "2021-07-31T16:42:10Z")

</div>

Hello @eduardo,

simply lowering the detection threshold seems to do the trick for me.

```python
eog_idx, eog_scores = ica.find_bads_eog(
    epochs_eog,
    ch_name='Fp1',
    threshold=2 # default is 3
)
ica.plot_scores(scores=eog_scores, exclude=eog_idx)

```

 ![Screen Shot 2021-07-31 at 18.39.26](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/6111b84a4ec039a14d7ff131bf78395c03b74331.png)

Btw there’s an undocumented feature of `find_bads_eog`: the paramter `ch_name` can actually also be a list of channels, so you could do:

```python
eog_idx, eog_scores = ica.find_bads_eog(
    epochs_eog,
    ch_name=['Fp1', 'Fp2'],
    threshold=2
)
ica.plot_scores(scores=eog_scores, exclude=eog_idx)

```

and MNE would do the scoring based on those two channels:

 ![Screen Shot 2021-07-31 at 18.41.00](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/40da21d3cd36c26e8b4598a094ae8b4e872a92b5.png)

… better don’t rely on this as, like I said, it’s undocumented; but in some situations it might come in handy. (In this specific example, though, both channels yield roughly the same scores, so there’s not much to gain by using both…)

PS:  
You’re using `ica.plot_components()` in your example script. If you pass a `Raw` or `Epochs` instance, you can make the figure interactive: `ica.plot_components(inst=epochs[~reject_log.bad_epochs])` Clicking on the topomaps will then open the properties plot of the respective component.

---

<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:** [July 31, 2021, 4:55pm UTC](https://mne.discourse.group/t/unexpected-behaviour-in-find-bads-eog/3474/5 "2021-07-31T16:55:55Z")

</div>

Oh, and another thing I’ve noticed: the ICA doesn’t converge on my computer with the default `max_iter` setting (1000 for `fastica`). So I had to increase the value to reach convergence:

```python
ica = mne.preprocessing.ICA(random_state=seed, max_iter=5000)

```

You may wish to consider using [Picard](https://pierreablin.github.io/picard/), which typically converges much faster than `fastica`. To use it, pass `method='picard'` to `ICA()`.

---

<div class="post-metadata">

**Author:** ![eduardo](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/eduardo/32/1157_2.png) [@eduardo](https://mne.discourse.group/u/eduardo)\
**Post date:** [August 2, 2021, 8:22am UTC](https://mne.discourse.group/t/unexpected-behaviour-in-find-bads-eog/3474/6 "2021-08-02T08:22:56Z")

</div>

HI @richard, when I lower the threshold, I don’t seem to get the same components you get for exclusion. I modified the ICA subsection following your recommendations:

```python
# Fit ICA on non-artifactual epochs 
ica = mne.preprocessing.ICA(method = 'picard', random_state = seed)
ica.fit(epochs[~reject_log.bad_epochs])

# Exclude blink artifact components (use Fp1 as EOG proxy)
epochs_eog = mne.preprocessing.create_eog_epochs(raw = raw, ch_name = 'Fp1') 
eog_idx, eog_scores = ica.find_bads_eog(epochs_eog, ch_name = 'Fp1', threshold = 2)
ica.exclude = eog_idx
ica.plot_scores(eog_scores)

```

Now ICA converges, but `find_bads_eog` excludes three components.

![exclusion](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/70d5029821dd5966a360f2af03b173b59d6bfdbf.png)
