Unable to load MFF files : ParseError: not well-formed(invalid token)

Hi all,
I am running MNE on my macOS device in Spyder IDE and I have been having difficulty in loading MFF files and it gives me this weird error:
Reading events …
File “”, line unknown
ParseError: not well-formed (invalid token): line 1, column 0

I used to not get this error when I was running my code on Windows and now only successfully load a single MFF file, none of the other MFF files work and give the same error above. I did some research on it found that it’s related to utf-8 XML problem. I tried to use the solutions provided in StackOverflow but they didn’t help. Is there any guidance you can give me on how to fix this error? Thank you very much!

we cannot easily help you without a file and a python script to replicate the problem

A

I can send you my script if that’s okay?

best practice is to put a link to the file here (dropbox, google drive, etc) and paste in your code here, so that anyone (not just Alex) can help when they have time. The pasted code should get formatted by putting a line of three backticks (`) above and below the first and last lines of code. It should also be minimal code (i.e., if the error comes when you load a file, then remove everything except the couple of lines needed to import the library and load the file).

@drammock I found where it occurs and it’s simply at one line which is when loading raw EGI.

MEG= mne.io.read_raw_fif(‘CC_EP009_PN_LD1_RD1_RUN01.fif’,preload=True, allow_maxshield = True, verbose=‘info’)
EEG= mne.io.read_raw_egi(‘CC_EP009_PN_LandR_ Thumb_Run01_20200730_165416.mff’, preload=True, verbose=‘info’)
print(EEG.info)

I was able to load EGI files with ease when I was using MNE in windows but ever since I started using macOS this has been the issue. This mne.io.read_raw_egi works with one recording I have and it also works with the mff file from the mne testing data but it does not work with any other recordings. Here I attach the screenshot of the error.

Sometimes we can guess the problem from seeing the error traceback, but if we could do that in this case, we would have done so after your initial copy/paste of the error message (adding a screenshot of the ParseError doesn’t give us much more to work with).

I understand. Here I attached a google drive with a very simple python script that causes an error with these specific recordings. It’s reading the fif file well but .mff file causes ParseError. If you can help me, I will be very grateful. I can’t upload and work on mff recordings.

https://drive.google.com/drive/folders/1WR1r7w3qLEdtLHWcwheAph1ExrCs3mOi?usp=sharing

First point: your script does not reproduce the error. Your test script has the wrong filename for the EEG mff file; it yields a FileNotFound error rather than a ParseError. I worked around this by changing the EEG filename to CC_EP009_PN_LandR_ Thumb_Run01_20200730_165416.mff (the folder that is actually present in your example data). Next time please verify that your test script actually reproduces the correct error.

Second point: The parse error occurs when trying to read _Events_8 DINs.xml That file is a binary file, not a valid XML file, and I don’t know why it is there. There is another (valid) XML file with the same name except without the leading _ so I suspect the failing one was possibly created by macOS search indexer. Regardless of how it got there, renaming the binary file to _Events_8 DINs.xml.bak (or deleting it) was enough to get it to work. Here is the resulting EEG.info:

<Info | 7 non-empty values
 bads: []
 ch_names: E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11, E12, E13, E14, ...
 chs: 257 EEG, 3 STIM
 custom_ref_applied: False
 highpass: 0.0 Hz
 lowpass: 500.0 Hz
 meas_date: 2020-07-29 14:06:28 UTC
 nchan: 260
 projs: []
 sfreq: 1000.0 Hz
>

@drammock I apologize. I forgot to update the code with the correct filename, I was testing different mff files to detect the cause of the problem. The ParseError has been solved by deleting the extra .xml file and everything works just fine now. Thank you so much!