Hello
since I accidently set an eeg electrode, my mastoid reference, as āeogā, and now fixed it and set it to āeegā, I get an error when I want to interpolate the data. When I drop bad channels and then reload the data to save the interpolated data, I get āValueError: array must not contain infs or NaNsā. What also changed since I set the electrode to āeegā, is that the plot.psd is now black instead of coloured. The following code itself doesnt produce any error:
raw.set_channel_types(mapping={'hore 28': 'eog', 'vou 17': 'eog', 'holi 32': 'eog', 'mast2':'eeg'})
#Display file information
print(raw)
print(raw.info)
# Load the montage (1020)
ten_twenty_montage = mne.channels.make_standard_montage('standard_1020')
raw_1020 = raw.copy().set_montage(ten_twenty_montage, on_missing='ignore')
print(raw_1020.info['projs'])
# Sanity check visualizations
raw_1020.plot_psd(fmax=80)
raw.plot(duration=4, n_channels=5, show_scalebars=(True))
return raw_1020
bids_root ='C:\\Users\\Admin\\Desktop\\Projekt_Franziska\\Studie 3\\Analyse\\EEG\\BIDS_EOG_EEG'
subject = 'sub-09'
session = 'ses-Expo'
raw_1020=flux_eegImport(bids_root, subject, session)
# Save referenced data with marked bad channels
raw_1020.info['bads'] = ['T7','T8']
But when I want to interpolate the data afterwards with the following code, I get the āValueError: array must not contain infs or NaNsā error. This only appears when I marked electrodes as bad beforehead, in this case T7 and T8.
def flux_eegInterpolateBads (mne_data_folder, subject, session):
raw_bads=mne.io.read_raw_fif(mne_data_folder + subject + '_ses-' + session + '_run01_' + 'data_ref.fif', verbose=False)
raw_bads.load_data()
print(raw_bads.info['bads'])
eeg_data = raw_bads.copy().pick_types(eog=True, eeg=True, exclude=[])
eeg_data_interp = eeg_data.copy().interpolate_bads(reset_bads=False)
for title, data in zip(['orig.', 'interp.'], [eeg_data, eeg_data_interp]):
fig = data.plot(butterfly=True, color='#00000022', bad_color='r')
fig.subplots_adjust(top=0.9)
fig.suptitle(title, size='xx-large', weight='bold')
eeg_data_interp = eeg_data.copy().interpolate_bads(reset_bads=True)
return eeg_data_interp
# Save referenced data with marked bad channels
#Subjects Included: 4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,24,25
# 26,27,28,30,31,33,34,35
subject = 'sub-09'
session = 'ses-Expo'
bids_root ='C:\\Users\\Admin\\Desktop\\Projekt_Franziska\Studie 3\\Analyse\\EEG\\BIDS_EOG_EEG'
mne_data_folder=bids_root + '/' + subject + '/' + session + '/' + 'eeg/'
raw_interpolated=flux_eegInterpolateBads (mne_data_folder, subject, session)
raw_interpolated.save(mne_data_folder + subject + '_' + session + '_run01_' + 'data_interpolated.fif', overwrite=True)
I wondered if this is the case since my added eeg electrode is not included in the 1020 system and I would have to manually add it. I found the suggestion with on_missing=āignoreā, but it didnt do the trick. When I set it to on_missing=āwarningā, I get There are 1 channel position not present in the DigMontage. The required channels are: [āmast2ā].
Any suggestions?
Thank you
Franzi