Hi, I have issue while concatenating the EEG using the following code.
I first realized that there was wierd EEG signals inserted before the EEG recording.
I found that there was a issue in down sampling the EEG data from a edf file (since the original file had a sf of 2000).
Followings are the code that I am using for the concatenation of EEG files.
for filei in range(len(s_filtered_file_names)):
currentEdf=s_filtered_file_names[filei]
edfpath=os.path.join(path, currentEdf)
raw= mne.io.read_raw_edf(edfpath)
# Assuming edfIdx and currentEdfName are defined earlier in your code
# if filei == 1:
# record_start=raw.info['meas_date']
time_list.append(raw.info['meas_date'])
raw.drop_channels(['POL E', 'POL PG1', 'POL PG2', 'POL TI', 'POL T2', 'POL EOGR', 'POL EKG1', 'POL EKG2', 'POL RESP','POL RESP1', 'POL RESP2', 'POL EOGL', 'POL A32', 'POL DC01', 'POL DC02', 'POL DC03', 'POL DC04', 'POL $A1', 'POL $A2', 'POL A47'], on_missing='warn')
print(raw.ch_names)
new_names = {ch: ch.replace('POL', '').replace(' ', '').replace('EEG', '').replace('$', '').replace('-Ref', '').replace('T7','T3').replace('T8','T4').replace('P7','T5').replace('P8','T6').replace('FZ','Fz').replace('CZ','Cz').replace('PZ','Pz') for ch in raw.ch_names}
raw.rename_channels(new_names)
#down sample all the data
sf=raw.info['sfreq']
if sf>200:
raw.resample(200)
sf=raw.info['sfreq']
#sort the channels in order.
targetChannelList =['Fp1', 'Fp2', 'F3', 'F4', 'C3', 'C4', 'P3', 'P4', 'O1', 'O2', 'F7', 'F8', 'T3', 'T4', 'T5', 'T6', 'Fz', 'Cz', 'Pz', 'A1', 'A2']
sort_raw=raw.pick_channels(targetChannelList)
EEG_list.append(sort_raw)
EEG_data = [data.get_data() for data in EEG_list]
concat_data = np.concatenate(EEG_data, axis=1)
concat_raw=mne.concatenate_raws(EEG_list)
if concat_raw.get_data().shape[1]>35460000:
print(βfiles are cropped to 48hβ)
concat_raw = concat_raw.crop(tmin=0, tmax=172800)
for i in range(len(time_list)):
print(fβ{s_filtered_file_names[i]}:{time_list[i]}')
filename=os.path.join(group,filename+β.edfβ)
concat_raw.export(filename, fmt=βedfβ,overwrite=True)
This scaling error happened even when I downsampled the single EEG data.
Would you kindly tell me why this is happening?
Thank you very much for your help.
mneversion: 1.6.0
opereating system WIndows 10
down sampled file
original file
Atsuro