When reading a raw egi
file, the compiler return an error
xml.etree.ElementTree.ParseError: not well-formed (invalid token): line 1, column 0
Surprisingly, this only happen on certain file. But, the same file can open using Matlab eeglab
.
My machine setup:
- MNE version: 1.3.1
- operating system: Windows 11
The code to reproduce the above runtime error
import mne
fname = 'P.mff'
raw = mne.io.read_raw_egi(fname, preload=True)
The file .mff
is accessable via the following link
https://drive.google.com/drive/folders/1-18gaDSoPzVH2tKncCEIyvg6_QN6KK3-?usp=sharing
The full traceback is as below:
Traceback (most recent call last):
File "C:\Users\userx\IdeaProjects\dproject\issue_mne.py", line 5, in <module>
raw = mne.io.read_raw_egi(fname, preload=True)
File "<decorator-gen-260>", line 12, in read_raw_egi
File "C:\Users\userx\anaconda3\envs\dproject\lib\site-packages\mne\io\egi\egi.py", line 156, in read_raw_egi
return _read_raw_egi_mff(input_fname, eog, misc, include,
File "<decorator-gen-257>", line 12, in _read_raw_egi_mff
File "C:\Users\userx\anaconda3\envs\dproject\lib\site-packages\mne\io\egi\egimff.py", line 389, in _read_raw_egi_mff
return RawMff(input_fname, eog, misc, include, exclude,
File "<decorator-gen-258>", line 12, in __init__
File "C:\Users\userx\anaconda3\envs\dproject\lib\site-packages\mne\io\egi\egimff.py", line 412, in __init__
egi_events, egi_info = _read_events(input_fname, egi_info)
File "C:\Users\userx\anaconda3\envs\dproject\lib\site-packages\mne\io\egi\events.py", line 26, in _read_events
mff_events, event_codes = _read_mff_events(input_fname, info['sfreq'])
File "C:\Users\userx\anaconda3\envs\dproject\lib\site-packages\mne\io\egi\events.py", line 49, in _read_mff_events
orig[xml_type] = _parse_xml(xml_file)
File "C:\Users\userx\anaconda3\envs\dproject\lib\site-packages\mne\io\egi\events.py", line 81, in _parse_xml
xml = parse(xml_file)
File "C:\Users\userx\anaconda3\envs\dproject\lib\xml\etree\ElementTree.py", line 1222, in parse
tree.parse(source, parser)
File "C:\Users\userx\anaconda3\envs\dproject\lib\xml\etree\ElementTree.py", line 580, in parse
self._root = parser._parse_whole(source)
xml.etree.ElementTree.ParseError: not well-formed (invalid token): line 1, column 0
This issue seem related to Unable to load MFF files : ParseError: not well-formed(invalid token) - #7 by ometett as highlighted by @drammock . But, I do not find any suspicious xml
reside under the .mff
.
Appreciate for any help