- MNE version: 1.6.1
- operating system: Windows 11
Hi everyone
I am having trouble reading EEGLAB files with MNE. The dataset is from OpenNeuro
When I run this code:
import matplotlib
matplotlib.use("QtAgg")
%matplotlib widget
import mne
raw=mne.io.read_raw_eeglab("C:\xxxxx\sub-006_ses-C1C_task-DriveOnMission_run-2_eeg.set", preload=True)
fig = raw.plot()
It returns this error:
{
"name": "ValueError",
"message": "cannot convert float NaN to integer",
"stack": "---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[11], line 6
3 get_ipython().run_line_magic('matplotlib', 'widget')
5 import mne # \"C:\\Users\\yusuf\\Downloads\\TX15\\sub-006\\ses-C1C\\eeg\\sub-006_ses-C1C_task-DriveOnMission_run-2_eeg.set\"
----> 6 raw=mne.io.read_raw_eeglab(r\"C:\\Users\\yusuf\\Downloads\\TX15\\sub-006\\ses-C1C\\eeg\\sub-006_ses-C1C_task-DriveOnMission_run-2_eeg.set\", preload=True)
7 #raw = mne.io.read_raw_fif(r\"C:\\Users\\yusuf\\Downloads\\sub-1448.fif\", preload=True, allow_maxshield=True)
8 raw
File ~\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python311\\site-packages\\mne\\io\\eeglab\\eeglab.py:332, in read_raw_eeglab(input_fname, eog, preload, uint16_codec, montage_units, verbose)
288 @fill_doc
289 def read_raw_eeglab(
290 input_fname,
(...)
295 verbose=None,
296 ):
297 r\"\"\"Read an EEGLAB .set file.
298
299 Parameters
(...)
330 .. versionadded:: 0.11.0
331 \"\"\"
--> 332 return RawEEGLAB(
333 input_fname=input_fname,
334 preload=preload,
335 eog=eog,
336 uint16_codec=uint16_codec,
337 montage_units=montage_units,
338 verbose=verbose,
339 )
File <decorator-gen-237>:12, in __init__(self, input_fname, eog, preload, uint16_codec, montage_units, verbose)
File ~\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python311\\site-packages\\mne\\io\\eeglab\\eeglab.py:505, in RawEEGLAB.__init__(self, input_fname, eog, preload, uint16_codec, montage_units, verbose)
503 # create event_ch from annotations
504 annot = read_annotations(input_fname, uint16_codec=uint16_codec)
--> 505 self.set_annotations(annot)
506 _check_boundary(annot, None)
508 _set_dig_montage_in_init(self, eeg_montage)
File <decorator-gen-224>:12, in set_annotations(self, annotations, emit_warning, on_missing, verbose)
File ~\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python311\\site-packages\\mne\\io\\base.py:737, in BaseRaw.set_annotations(self, annotations, emit_warning, on_missing, verbose)
735 new_annotations._prune_ch_names(self.info, on_missing)
736 if annotations.orig_time is None:
--> 737 new_annotations.crop(
738 0, self.times[-1] + delta, emit_warning=emit_warning
739 )
740 new_annotations.onset += self._first_time
741 else:
File <decorator-gen-35>:12, in crop(self, tmin, tmax, emit_warning, use_orig_time, verbose)
File ~\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python311\\site-packages\\mne\\annotations.py:629, in Annotations.crop(***failed resolving arguments***)
627 duration = 0.0
628 # convert to absolute times
--> 629 absolute_onset = timedelta(seconds=onset) + offset
630 absolute_offset = absolute_onset + timedelta(seconds=duration)
631 out_of_bounds.append(
632 absolute_onset > absolute_tmax or absolute_offset < absolute_tmin
633 )
ValueError: cannot convert float NaN to integer"
}
All the Google search results were about Pandas value errors, and I couldn’t find anything about this on the MNE forum. I have no idea how to solve this problem with MNE, as I can’t even read the file.
I would really appreciate it if someone could help me with this issue.