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!
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).
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.
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:
@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!