Hi, Iām writing code to apply ICA for EEG data , but i got this error ( RuntimeError: No clean segment found. Please consider updating your rejection thresholds.)
this is my code
import numpy as np
import pandas as pd
import mne
from mne.preprocessing import (ICA, create_eog_epochs, create_ecg_epochs,
corrmap)
import scipy
from mne.preprocessing.ica import corrmap
path = 'C:/Users/Sar/Desktop/Unicorn config/UnicornHybridBlack-master/UnicornHybridBlack-master/Python Collect/Gentask/Engine/'
data = pd.read_csv(path + 'test2.csv',
skiprows=0, usecols=[*range(0, 8)])*1e-6
ch_names = ['EEG1','EEG2','EEG3','EEG4','EEG5','EEG6','EEG7','EEG8']
sfreq = 250
info = mne.create_info(ch_names = ch_names, sfreq = sfreq,ch_types='eeg')
raw = mne.io.RawArray(data.transpose() , info)
method = 'fastica'
n_components = 7
reject = dict(eeg=40e-6, grad=5000e-13)
start, stop = [0, raw.times[-1]]
intervals = np.linspace(start, stop, 4, dtype=np.float)
icas_from_other_data = list()
raw.pick_types(meg=False, eeg=True) # take only MEG channels
for ii, start in enumerate(intervals):
if ii + 1 < len(intervals):
stop = intervals[ii + 1]
print('fitting ICA from {0} to {1} seconds'.format(start, stop))
this_ica = ICA(n_components=n_components, method=method).fit(
raw, start=start, stop=stop, reject=reject)
icas_from_other_data.append(this_ica)
Can any one help and tell me what is the right threshold for EEG?
thank you.