# read\_raw\_eeglab gives ValueError: cannot convert float NaN to integer

**URL:** <https://mne.discourse.group/t/read-raw-eeglab-gives-valueerror-cannot-convert-float-nan-to-integer/8285>\
**Category:** Support & Discussions\
**Tags:** eeglab\
**Created:** [February 6, 2024, 10:11am UTC](https://mne.discourse.group/t/read-raw-eeglab-gives-valueerror-cannot-convert-float-nan-to-integer/8285 "2024-02-06T10:11:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yusuf-S-Aytekin](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/yusuf-s-aytekin/32/3424_2.png) [@Yusuf-S-Aytekin](https://mne.discourse.group/u/Yusuf-S-Aytekin)\
**Post date:** [February 6, 2024, 10:11am UTC](https://mne.discourse.group/t/read-raw-eeglab-gives-valueerror-cannot-convert-float-nan-to-integer/8285/1 "2024-02-06T10:11:23Z")

</div>

- 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](https://openneuro.org/datasets/ds004842/versions/1.0.0)

When I run this code:

```python
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:

```python
{
	"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.

---

<div class="post-metadata">

**Author:** ![cbrnr](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/cbrnr/32/1409_2.png) [@cbrnr](https://mne.discourse.group/u/cbrnr)\
**Post date:** [February 7, 2024, 7:40am UTC](https://mne.discourse.group/t/read-raw-eeglab-gives-valueerror-cannot-convert-float-nan-to-integer/8285/2 "2024-02-07T07:40:03Z")

</div>

This is a bug, I’ve created an issue here: [Annotation-related error reading EEGLAB file · Issue #12425 · mne-tools/mne-python · GitHub](https://github.com/mne-tools/mne-python/issues/12425)

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [February 14, 2024, 7:40am UTC](https://mne.discourse.group/t/read-raw-eeglab-gives-valueerror-cannot-convert-float-nan-to-integer/8285/3 "2024-02-14T07:40:53Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
