If you have a question or issue with MNE-Python, please include the following info:
-
MNE version: 1.8
-
operating system: e.g. macOS 12 / Windows 10 / Ubuntu 18.04
Hi, all epochs are dropped when I use the mne.epoch function. I want to know if it is because of my .bdf file or because I set the baseline correction range incorrectly. Here is my source code and the problemfor idx, sub in enumerate(sub_info):
sub_path = os.path.join(data_dir,sub) print("Current processing subject:", sub) trigger, onset, duration, rawdata, [unit, impedance, experiments] = read_data(sub_path) # read_the_remark_data remark_data = hdf5storage.loadmat(os.path.join(sub_path, 'After_remarks.mat'))['After_remark'] vids = np.squeeze(remark_data['vid']) frequency = rawdata.info['sfreq'] events = np.transpose(np.vstack((np.vstack((onset, duration)), trigger))) # The first batch and the second batch have different unit (uV and V) original_raw = rawdata.copy() # Epochs cutting cut_seconds = -30; event_id = 102; epochs = mne.Epochs(original_raw, events, event_id=event_id, tmin=cut_seconds, tmax=0, preload=True)
def read_data(folderPath):
Read the data
rawdata = mne.io.read_raw_bdf(os.path.join(folderPath, 'data.bdf'), preload=True)
rawdata,unit = unit_check(rawdata)
fs = rawdata.info['sfreq']
# Read the event
## read events
try:
events = mne.read_annotations(os.path.join(folderPath, 'evt.bdf'))
onset = np.array([int(x * fs) for x in events.onset] )
duration = np.array([int(x) for x in events.duration])
trigger = np.array([i for i in events.description])
print("Original trigger events:", trigger)
# Impedance checking
trigger,onset,duration,impedance = inter_impedance_inspect(trigger,onset,duration)
trigger = np.array([int(x) for x in trigger])
# Check wheter there is ERP data
trigger,onset, duration, experiment = trigger_check(trigger,onset, duration)
return trigger, onset, duration, rawdata, [unit, impedance, experiment]
except:
raise RuntimeError("No event was found")
My problem:
Extracting EDF parameters from /home/zyy/mycode/AIEEG-main-faced/data/sub000/data.bdfβ¦
BDF file detected
/home/zyy/mycode/AIEEG-main-faced/Preprocessing/Preprocessing.py:146: RuntimeWarning: Number of records from the header does not match the file size (perhaps the recording was not stopped before exiting). Inferring from the file size.
rawdata = mne.io.read_raw_bdf(os.path.join(folderPath, βdata.bdfβ), preload=True)
Setting channel info structureβ¦
Creating raw.info structureβ¦
Reading 0 β¦ 18999 = 0.000 β¦ 18.999 secsβ¦
Unit change : 0.01649761137060406
Original trigger events: [β100β β100β β100β β100β β100β β11β β101β β102β β8β β101β β102β β2β β101β
β102β β5β β101β β102β β6β β101β β102β β9β β101β β102β β3β β101β β102β
β12β β101β β102β β20β β101β β102β β17β β101β β102β β26β β101β β102β β23β
β101β β102β β13β β101β β102β β15β β101β β102β β14β β101β β102β β16β β101β
β102β β10β β101β β102β β1β β101β β102β β4β β101β β102β β7β β101β β102β
β28β β101β β102β β25β β101β β102β β22β β101β β102β β19β β101β β102β β18β
β101β β102β β21β β101β β102β β27β β101β β102β β24β β101β β102β
βStart Impedanceβ βStop Impedanceβ]
There is an Impedance in the dataset but at the end
Not setting metadata
28 matching events found
Setting baseline interval to [-30.0, 0.0] s
Applying baseline correction (mode: mean)
0 projection items activated
Using data from preloaded Raw for 28 events and 30001 original time points β¦
28 bad epochs dropped
/home/zyy/mycode/AIEEG-main-faced/Preprocessing/main.py:62: RuntimeWarning: All epochs were dropped!
You might need to alter reject/flat-criteria or drop bad channels to avoid this. You can use Epochs.plot_drop_log() to see which channels are responsible for the dropping of epochs.