EOG artifac correction with ICA

Dear mne experts,

Could someone please help me with two questions related to the EOG artifact
removal from raw MEG data with ICA?

I have created my script following this example:
https://martinos.org/mne/stable/auto_tutorials/plot_artifacts_correction_ica.html?highlight=ica

I tested the script with one EOG channel and got the following result:

Question 1: Why are components 5 and 12 marked with red even if there are
other components with stronger (although negative) correlation (e.g. 13 and
16)?

Thereafter, I tested the script with two EOG channels and got:

Question 2: Why are the correlation values with EOG61 now different
compared to the case when I only used EOG61 and not EOG62?

I am using mne 0.14.1.

Many thanks already in advance if you can help!

Best,

Maria

Here is yet the code that I am using (I have used low threshold value for
testing purposes, but will use higher threshold, e.g. 3, in the final
analysis):

import matplotlib

matplotlib.use('Agg')

import matplotlib.pyplot as plt

import numpy as np

import mne

from mne.preprocessing import ICA

from mne.preprocessing import create_eog_epochs

subject = 'ak'

session = 'sentences16b'

data_path = '/m/nbe/scratch/braindata/mhhakone/intell/TaskIII/MEG-data/' +
subject + '/'

raw_fname = data_path + subject + '_' + session + '_raw_tsss.fif'

raw = mne.io.read_raw_fif(raw_fname, preload=True)

raw.filter(1, 40, n_jobs=2)

picks_meg = mne.pick_types(raw.info, meg=True, eeg=False, eog=False,

                           stim=False, exclude='bads')

n_components = 25 # if float, select n_components by explained variance of
PCA

method = 'fastica' # for comparison with EEGLAB try "extended-infomax" here

decim = 3 # we need sufficient statistics, not all time points -> saves
time

# we will also set state of the random number generator - ICA is a

# non-deterministic algorithm, but we want to have the same decomposition

# and the same order of components each time this tutorial is run

random_state = 23

ica = ICA(n_components=n_components, method=method,
random_state=random_state)

print(ica)

reject = dict(mag=5e-12, grad=4000e-13)

ica.fit(raw, picks=picks_meg, decim=decim, reject=reject)

#ica.save('my-ica.fif')

eog_average = create_eog_epochs(raw,ch_name='EOG 061',
reject=dict(mag=5e-12, grad=4000e-13),

                                picks=picks_meg).average()

eog_epochs = create_eog_epochs(raw,ch_name='EOG 061',reject=reject) # get
single EOG trials

eog_inds, scores = ica.find_bads_eog(eog_epochs,ch_name='EOG
061',threshold=1.2) # find via correlation

ica.plot_scores(scores, exclude=eog_inds) # look at r scores of components

file_end='_scores.png'

filename = subject+'_'+session+file_end

plt.savefig(data_path+filename)

plt.close()

ica.plot_sources(eog_average, exclude=eog_inds) # look at source time
course

file_end='_sources.png'

filename = subject+'_'+session+file_end

plt.savefig(data_path+filename)

plt.close()

fig_list = ica.plot_properties(eog_epochs, picks=eog_inds,
psd_args={'fmax': 35.},

                    image_args={'sigma': 1.})

for i in range(len(fig_list)):

    file_end='_properties_component'+str(i)+'.png'

    filename = subject+'_'+session+file_end

    fig_list[i].savefig(data_path+filename)

plt.close()

ica.plot_overlay(eog_average, exclude=eog_inds, show=False)

file_end='_overlay.png'

filename = subject+'_'+session+file_end

plt.savefig(data_path+filename)

plt.close()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20170805/a2c675dc/attachment-0001.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ak_sentences16b_scores.png
Type: image/png
Size: 22051 bytes
Desc: not available
Url : http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20170805/a2c675dc/attachment-0002.png
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ak_sentences16b_scores2.png
Type: image/png
Size: 33927 bytes
Desc: not available
Url : http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20170805/a2c675dc/attachment-0003.png

Hi Maria,

I'm currently traveling. I'll get back to you later.

Denis

Dear mne experts,

Could someone please help me with two questions related to the EOG
artifact removal from raw MEG data with ICA?

I have created my script following this example:
https://martinos.org/mne/stable/auto_tutorials/plot_artifacts_correction_ica.html?highlight=ica

I tested the script with one EOG channel and got the following result:

[image: ak_sentences16b_scores.png]

Question 1: Why are components 5 and 12 marked with red even if there are
other components with stronger (although negative) correlation (e.g. 13 and
16)?

Thereafter, I tested the script with two EOG channels and got:

[image: ak_sentences16b_scores2.png]

Question 2: Why are the correlation values with EOG61 now different
compared to the case when I only used EOG61 and not EOG62?

I am using mne 0.14.1.

Many thanks already in advance if you can help!

Best,

Maria

Here is yet the code that I am using (I have used low threshold value for
testing purposes, but will use higher threshold, e.g. 3, in the final
analysis):

import matplotlib

matplotlib.use('Agg')

import matplotlib.pyplot as plt

import numpy as np

import mne

from mne.preprocessing import ICA

from mne.preprocessing import create_eog_epochs

subject = 'ak'

session = 'sentences16b'

data_path = '/m/nbe/scratch/braindata/mhhakone/intell/TaskIII/MEG-data/' +
subject + '/'

raw_fname = data_path + subject + '_' + session + '_raw_tsss.fif'

raw = mne.io.read_raw_fif(raw_fname, preload=True)

raw.filter(1, 40, n_jobs=2)

picks_meg = mne.pick_types(raw.info, meg=True, eeg=False, eog=False,

                           stim=False, exclude='bads')

n_components = 25 # if float, select n_components by explained variance
of PCA

method = 'fastica' # for comparison with EEGLAB try "extended-infomax"
here

decim = 3 # we need sufficient statistics, not all time points -> saves
time

# we will also set state of the random number generator - ICA is a

# non-deterministic algorithm, but we want to have the same decomposition

# and the same order of components each time this tutorial is run

random_state = 23

ica = ICA(n_components=n_components, method=method,
random_state=random_state)

print(ica)

reject = dict(mag=5e-12, grad=4000e-13)

ica.fit(raw, picks=picks_meg, decim=decim, reject=reject)

ica.save('my-ica.fif')

eog_average = create_eog_epochs(raw,ch_name='EOG 061',
reject=dict(mag=5e-12, grad=4000e-13),

                                picks=picks_meg).average()

eog_epochs = create_eog_epochs(raw,ch_name='EOG 061',reject=reject) # get
single EOG trials

eog_inds, scores = ica.find_bads_eog(eog_epochs,ch_name='EOG
061',threshold=1.2) # find via correlation

ica.plot_scores(scores, exclude=eog_inds) # look at r scores of components

file_end='_scores.png'

filename = subject+'_'+session+file_end

plt.savefig(data_path+filename)

plt.close()

ica.plot_sources(eog_average, exclude=eog_inds) # look at source time
course

file_end='_sources.png'

filename = subject+'_'+session+file_end

plt.savefig(data_path+filename)

plt.close()

fig_list = ica.plot_properties(eog_epochs, picks=eog_inds,
psd_args={'fmax': 35.},

                    image_args={'sigma': 1.})

for i in range(len(fig_list)):

    file_end='_properties_component'+str(i)+'.png'

    filename = subject+'_'+session+file_end

    fig_list[i].savefig(data_path+filename)

plt.close()

ica.plot_overlay(eog_average, exclude=eog_inds, show=False)

file_end='_overlay.png'

filename = subject+'_'+session+file_end

plt.savefig(data_path+filename)

plt.close()
_______________________________________________
Mne_analysis mailing list
Mne_analysis at nmr.mgh.harvard.edu
https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis

The information in this e-mail is intended only for the person to whom it
is
addressed. If you believe this e-mail was sent to you in error and the
e-mail
contains patient information, please contact the Partners Compliance
HelpLine at
http://www.partners.org/complianceline . If the e-mail was sent to you in
error
but does not contain patient information, please contact the sender and
properly
dispose of the e-mail.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20170808/492733c9/attachment-0001.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ak_sentences16b_scores.png
Type: image/png
Size: 22051 bytes
Desc: not available
Url : http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20170808/492733c9/attachment-0002.png
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ak_sentences16b_scores2.png
Type: image/png
Size: 33927 bytes
Desc: not available
Url : http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20170808/492733c9/attachment-0003.png

Hi Maria,

The many correlated components indicate that the ICA solution might be of
poor quality.
Is there a reason why you use 25 components?
I'd recommend to use as many components as the number of orthogonal
dimensions in your data, e.g. 64, depending on your SSS / maxfilter
settings.
Also the score is quite low at 1.2. It will make you include many
uninteresting components.
Maybe you want to give it a try and we have another look?

Denis

Hi Maria,

I'm currently traveling. I'll get back to you later.

Denis

Dear mne experts,

Could someone please help me with two questions related to the EOG
artifact removal from raw MEG data with ICA?

I have created my script following this example:
https://martinos.org/mne/stable/auto_tutorials/plot_artifacts_correction_ica.html?highlight=ica

I tested the script with one EOG channel and got the following result:

[image: ak_sentences16b_scores.png]

Question 1: Why are components 5 and 12 marked with red even if there are
other components with stronger (although negative) correlation (e.g. 13 and
16)?

Thereafter, I tested the script with two EOG channels and got:

[image: ak_sentences16b_scores2.png]

Question 2: Why are the correlation values with EOG61 now different
compared to the case when I only used EOG61 and not EOG62?

I am using mne 0.14.1.

Many thanks already in advance if you can help!

Best,

Maria

Here is yet the code that I am using (I have used low threshold value for
testing purposes, but will use higher threshold, e.g. 3, in the final
analysis):

import matplotlib

matplotlib.use('Agg')

import matplotlib.pyplot as plt

import numpy as np

import mne

from mne.preprocessing import ICA

from mne.preprocessing import create_eog_epochs

subject = 'ak'

session = 'sentences16b'

data_path = '/m/nbe/scratch/braindata/mhhakone/intell/TaskIII/MEG-data/'
+ subject + '/'

raw_fname = data_path + subject + '_' + session + '_raw_tsss.fif'

raw = mne.io.read_raw_fif(raw_fname, preload=True)

raw.filter(1, 40, n_jobs=2)

picks_meg = mne.pick_types(raw.info, meg=True, eeg=False, eog=False,

                           stim=False, exclude='bads')

n_components = 25 # if float, select n_components by explained variance
of PCA

method = 'fastica' # for comparison with EEGLAB try "extended-infomax"
here

decim = 3 # we need sufficient statistics, not all time points -> saves
time

# we will also set state of the random number generator - ICA is a

# non-deterministic algorithm, but we want to have the same decomposition

# and the same order of components each time this tutorial is run

random_state = 23

ica = ICA(n_components=n_components, method=method,
random_state=random_state)

print(ica)

reject = dict(mag=5e-12, grad=4000e-13)

ica.fit(raw, picks=picks_meg, decim=decim, reject=reject)

ica.save('my-ica.fif')

eog_average = create_eog_epochs(raw,ch_name='EOG 061',
reject=dict(mag=5e-12, grad=4000e-13),

                                picks=picks_meg).average()

eog_epochs = create_eog_epochs(raw,ch_name='EOG 061',reject=reject) #
get single EOG trials

eog_inds, scores = ica.find_bads_eog(eog_epochs,ch_name='EOG
061',threshold=1.2) # find via correlation

ica.plot_scores(scores, exclude=eog_inds) # look at r scores of
components

file_end='_scores.png'

filename = subject+'_'+session+file_end

plt.savefig(data_path+filename)

plt.close()

ica.plot_sources(eog_average, exclude=eog_inds) # look at source time
course

file_end='_sources.png'

filename = subject+'_'+session+file_end

plt.savefig(data_path+filename)

plt.close()

fig_list = ica.plot_properties(eog_epochs, picks=eog_inds,
psd_args={'fmax': 35.},

                    image_args={'sigma': 1.})

for i in range(len(fig_list)):

    file_end='_properties_component'+str(i)+'.png'

    filename = subject+'_'+session+file_end

    fig_list[i].savefig(data_path+filename)

plt.close()

ica.plot_overlay(eog_average, exclude=eog_inds, show=False)

file_end='_overlay.png'

filename = subject+'_'+session+file_end

plt.savefig(data_path+filename)

plt.close()
_______________________________________________
Mne_analysis mailing list
Mne_analysis at nmr.mgh.harvard.edu
Mne_analysis Info Page

The information in this e-mail is intended only for the person to whom it
is
addressed. If you believe this e-mail was sent to you in error and the
e-mail
contains patient information, please contact the Partners Compliance
HelpLine at
MyComplianceReport.com: Compliance and Ethics Reporting . If the e-mail was sent to you
in error
but does not contain patient information, please contact the sender and
properly
dispose of the e-mail.

_______________________________________________
Mne_analysis mailing list
Mne_analysis at nmr.mgh.harvard.edu
Mne_analysis Info Page

The information in this e-mail is intended only for the person to whom it
is
addressed. If you believe this e-mail was sent to you in error and the
e-mail
contains patient information, please contact the Partners Compliance
HelpLine at
MyComplianceReport.com: Compliance and Ethics Reporting . If the e-mail was sent to you in
error
but does not contain patient information, please contact the sender and
properly
dispose of the e-mail.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20170808/e17620fc/attachment-0001.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ak_sentences16b_scores.png
Type: image/png
Size: 22051 bytes
Desc: not available
Url : http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20170808/e17620fc/attachment-0002.png
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ak_sentences16b_scores2.png
Type: image/png
Size: 33927 bytes
Desc: not available
Url : http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20170808/e17620fc/attachment-0003.png

Hi Denis,

Thank you for your advice!

The script seems to reject the components which have the highest correlation values when I increased the number of components to 64. I also increased the threshold, and now ICA seems to identify EOG related components correctly. I just first tested the script with low threshold since I wanted to see whether the script can identify more that one component (in the example they determined only the component with the highest correlation value but sometimes there may also be more than one EOG-related components).

Best,
Maria

1 Like

Hi Maria,

The important thing to do to achieve mental peace, in this context, is to
inspect average artifacts. Does my EOG induce strong amplitude changes? If
yes I can hope to extract the artifact with ICA. If not then I can't but
probably don't need to as the artifact is small anyways. If I have managed
to get ICA components that are related to artifacts, then I want to see how
they reduce the average artifact. If 2 components do most of the job, which
they typically do, I am happy. The artifact average amplitude should now be
below or on the same order of magnitude as an evoked field / potential and
not 10-20 times bigger as before.
If you look in our tutorials they roughly follow this logic.
Hope that helps a bit.

Denis