BUG: Split file issue on dashes#8340
Conversation
|
Thanks for looking into this!
Can you modify this test to save and load a split file using a name that fails on https://github.com/mne-tools/mne-python/blob/master/mne/io/fiff/tests/test_raw_fiff.py#L360-L361 It looks like Azure CI style check is unhappy with: |
Well, sort of. I don't think I can properly test it, because the internals of the test fif file seem to be different from the fif file I experienced the error. Specifically, in the test file the next file name seems to be coded in As a very crude approach to bypass this issue, I can force A better way of testing would be to use a different test file, one that doesn't code the next file name as name but as number. As far as I understand this would be coded somewhere in the
Yes, I fixed that. |
c34b0e9 to
57588ee
Compare
larsoner
left a comment
There was a problem hiding this comment.
Specifically, in the test file the next file name seems to be coded in FIFF.FIFF_REF_FILE_NAME, whereas in my file it is coded in FIFF.FIFF_REF_FILE_NUM
I pushed a test in 57588ee that uses monkeypatch to prevent writing the name. This fails on master but passes on this PR, so we should be good to go from that end.
Can you update latest.inc in the BUG section? Then we can merge and backport
… split-files-fix
…into split-files-fix
Done. One more thing, that extra test that you pushed does not test BIDS-formatted filenames (files ending on Should BIDS-formatted files be covered with this function? Or should users just use the mne_bids for reading bids files? If split bids files should also be properly read with this function, the PR needs some fixing. (edit: and the changes to latest.inc to be undone for now) |
Does it pass on I'm not sure how often people will run into this problem / how problematic it actually is, though. MNE-Python (and MNE-BIDS) write the |
No, it also fails on master. So, overall it seems that splitting on numbers neither works if the filename contains dashes (fixed by this PR), nor if the filename is BIDS-formatted (would require a new PR, that would also affect the current PR).
They were written by the MEG machine/acquisition software (Neuromag/Elekta scanner).
Possible. I agree that it probably doesn't affect many users. The only reason I bumped into this problem was that I was aware of BIDS (so I tried to have my files BIDS-formatted), but not of |
We already have tests for BIDS-formatting splits. They work just fine if you save using MNE-Python (master and this PR) when using https://github.com/mne-tools/mne-python/blob/master/mne/io/fiff/tests/test_raw_fiff.py#L370-L381 So the "problem" is really with the Neuromag software, or maybe more so with our expectations for it. If a given piece of software only writes out the If that's the case then I think things with MNE-Python and mne-bids are fine, but people using Elekta acquisition software should not try to use BIDS filenames if they end up with split files because the software cannot write them properly. Or if they do it and end up with non-BIDS filenames, they need to use MNE-Python (with |
Yes, split-files are written with
That makes sense. But ideally this would also be somehow communicated. Otherwise the situation might be a little confusing. |
Can you make an issue for this on mne-bids? Perhaps they should detect the missing file warning and probably turn it into an error. |
|
Thanks @eort ! |
* fix split files issue on dashes * style fix * TST: Add test case * update doc * new author contributions Co-authored-by: examplename <e.ort@vu.nl> Co-authored-by: Eric Larson <larson.eric.d@gmail.com>
Sure, but why on mne-bids? The issue occurs when using |
Let's talk about a concrete example. What use case are you trying to address where you will get this warning? From what I understand, if you:
The motivation behind making changes in mne-bids is that mne-bids is all about conforming to a spec and making sure everything is in the right place. MNE-Python is more flexible and allows you to (and has allowed you to for quite a while) have these split files missing, and you get a warning. I guess we could add a |
|
One more case: But yes, this is a very specific case, that hardly ever will occur. As far as I see, there is only a problem when users try to read files with mne-python that were recorded on neuromag systems and were manually renamed to adhere to BIDS. Now that the PR is merged, split file names won't produce correct file names and an error will be raised. That could already be sufficient, but
No, I get that and I completely agree. I just haven't tested anything with mne-bids. So, I wasn't aware that the same behaviour would be observed when using mne-bids. If the same issue is present in mne-bids, then indeed, split files would just silently be ignored, if they were produced by the niche-case described above.
I guess that would generally be a useful warning, but given that you normally have clear expectations regarding the length of your files perhaps not essential. |
* fix split files issue on dashes * style fix * TST: Add test case * update doc * new author contributions Co-authored-by: examplename <e.ort@vu.nl> Co-authored-by: Eric Larson <larson.eric.d@gmail.com>
Reference issue
Potentially fixes #8339
Additional information
Local tests with a few variations on filenames worked, but I did not extensive testing.
The most likely source for problems in this commit is that I did not understand what the function of former lines 90 and 91 were. For my proposed fix, these lines would not do anything, so I removed them.
Hope that's useful.