Hi Eric @larsoner can I pick your brain a bit for the following (or otherwise please point me to whomever is more fit to be brainpicked about this). Vladimir @vlitvak reported an issue with reading a MAG4Health OPM fif-file in FieldTrip (which uses the mne-tools/mne-matlab code). Specifically, MNE-python and brainstorm seem to do just fine. The issue is referenced here:
fieldtrip/fieldtrip#2459
I looked into this a bit, and it turns out that the very last tag in the culprit file has a value of '0' in the 'next' field. This causes fiff_open to try and read beyond the end of the fif-file in the corresponding while loop (lines 95-103). The long story short seems to be that (also according to the FIFFV_NEXT_NONE constant, which is defined as -1) the code kind of expects to be able to escape the while loop when tag.next==-1 at the end of a fif-file.
I could confirm that all other fif-files I have lying around close by indeed have a tag.next==-1 at the end of the file.
I could not find online any chatter about the official way in which the end of a fif-file should be formatted, so I was wondering whether the referenced file is fif-invalid in its definition, and whether that should be brought to the attention of the Mag4health folks. Alternatively, I could of course put a small bandaid on the relevant piece of code and then crawl back into my cave to try and forget about the current state of the world.
Hi Eric @larsoner can I pick your brain a bit for the following (or otherwise please point me to whomever is more fit to be brainpicked about this). Vladimir @vlitvak reported an issue with reading a MAG4Health OPM fif-file in FieldTrip (which uses the mne-tools/mne-matlab code). Specifically, MNE-python and brainstorm seem to do just fine. The issue is referenced here:
fieldtrip/fieldtrip#2459
I looked into this a bit, and it turns out that the very last tag in the culprit file has a value of '0' in the 'next' field. This causes fiff_open to try and read beyond the end of the fif-file in the corresponding while loop (lines 95-103). The long story short seems to be that (also according to the FIFFV_NEXT_NONE constant, which is defined as -1) the code kind of expects to be able to escape the while loop when
tag.next==-1at the end of a fif-file.I could confirm that all other fif-files I have lying around close by indeed have a
tag.next==-1at the end of the file.I could not find online any chatter about the official way in which the end of a fif-file should be formatted, so I was wondering whether the referenced file is fif-invalid in its definition, and whether that should be brought to the attention of the Mag4health folks. Alternatively, I could of course put a small bandaid on the relevant piece of code and then crawl back into my cave to try and forget about the current state of the world.