-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
FIX:7067 - None meas_date roundtrip #7071
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report
@@ Coverage Diff @@
## master #7071 +/- ##
==========================================
- Coverage 89.74% 89.74% -0.01%
==========================================
Files 442 442
Lines 77786 77790 +4
Branches 12621 12620 -1
==========================================
- Hits 69812 69810 -2
- Misses 5163 5170 +7
+ Partials 2811 2810 -1 |
mne/io/tests/test_meas_info.py
Outdated
| m2 = m2.hexdigest() | ||
| assert m1 == m2 | ||
|
|
||
| # check for bug 7067 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| # check for bug 7067 | |
| # check for bug #7067 |
jasmainak
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix looks straightforward and the test seems to check that. LGTM
mne/io/meas_info.py
Outdated
| if info.get('meas_date') is not None: | ||
| write_int(fid, FIFF.FIFF_MEAS_DATE, info['meas_date']) | ||
| else: | ||
| write_int(fid, FIFF.FIFF_MEAS_DATE, DATE_NONE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bloyl can you help me understand why the writer should be fixed? It seems normal not to write anything if meas_date is None. Is it the reader that does not set the date to None when it's not present in the file on disk?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
over my morning coffee, I agree the writer shouldn't be fixed. It seemed like the most straightforward at the time.
The current fix will have non mne-python readers showing strange dates. or faulting trying to convert DATA_NONE to a timestamp.
|
You have something to try then ?
|
|
Posted this to the issue by mistack... Potential Fixes
Finally, I think that only case 1 would preserve round trip IO of both ;---- mne-python/mne/io/meas_info.py Lines 1229 to 1230 in ef7d7c1
pass IO tests. So whatever it's original need was it isn't explicitly tested for :) |
|
arfff so the bug is more that setting meas_date to None is not enough to
remove recording date ... yet another example of duplication of
information. What @larsoner suggested last week with a inst.set_meas_date()
is necessary and one should document not to set meas_date manually.
thoughts @jasmainak @larsoner?
basically having meas_date != meas_id should not happen.
… |
|
I think the issue is that you can erase |
|
@larsoner <https://github.com/larsoner> what's your call on this?
… |
|
My preference would be to (in rough PR order):
|
|
great plan !
… |
|
@bloyl okay for you? |
|
I'm +1 on steps 2, 3 and 4. I'm -1 on step 1. I don't see the purpose in reengineering #5255. to support the ability of setting I'd suggest just doing steps 2, 3 and 4 as somewhat of a priority and closing this PR without merging anything. |
|
Your opposition to 1 sounds like it's related to BIDS anonymization. I don't see the relationship between BIDS anonymization and None/special date writing. BIDS anon will never use it, so what problems will it cause there? Basically people in my proposal people can continue to use the old None style of anonymization (and work with files they've already processed this way!), or use the new date shift method. Steps 2/3/4 to me would allow datetime or None as options, sorry for not listing that. |
|
anonymize code would just call raw.set_meas_date(None) if no days back is
provided. For BIDS
mne-bids would force the daysback
|
|
Agreed @agramfort. The question for @bloyl is why no (1) in the proposal above? I think we want 1/this PR if and only if we allow |
|
There seems to be some confusion. I am fine with supporting That is all great. The original issue (#7067) We all agree (I think) that following steps 2/3/4 this situation shouldn't occur, because My issue with step 1 is what is meant by
What is the backward compatible thing to do in the out of sync case? Assuming its pre #5255 behaviour, then that would be that after reading back from disk you'd get To do that I think you'd have to do either option 2 or 3 from my comment above.
I guess I'm willing to give option 3 (the Hacky one) a shot and if it works then great. But I don't have time to redo PR #5255, particularly to support an edge case that will be eliminated before the next release. |
|
Does following 2/3/4 actually guarantee |
|
info['meas_date'] = None should be an alias for DATE_NONE and as meas_id
must stay meas_id will be set to DATE_NONE if and only if info['meas_date']
= None. So readers will set info['meas_date'] = None when they see that
meas_id == DATE_NONE
… |
|
But |
|
Okay I think I have a bit better handle on the problem. From 9 years ago Alex did in This is reasonable if, e.g., some old files don't have a But then on write we do: So we only write if not None. I propose a variant of (1) we change it so that this is always written, like: This will not be totally backward compatible, as those old files were not written this way. But it is at least forward compatible with allowing |
|
The reason not to write |
|
so you want to prevent the ability to remove any date?
… |
|
Looking back at 0.17, what we used to do is not write So we could continue not writing So maybe move point (4) up, add the
Regarding this point, I'm not sure what these other readers do when they encountered missing |
|
Is there any information on the FIFF file format? Specifically as to what |
|
if we aren't concerned about other packages/platforms supporting DATE_NONE as a date, then I'm fine with the proposed fix currently sitting on #7090 |
As for the motivations, I can only infer them from these files. But it does look like |
|
Okay now all #7090 does is ensure that doing this works: It round-trips properly. Basically what we did before with So I think we should merge #7090, then proceed with steps 2-4 above. @bloyl this sounds like it's compatible with what you're thinking (right?) and I think it stays true to what @agramfort and I talked about regarding |
|
This seems fine to me although I'm pretty sure that
Already works. its even tested: mne-python/mne/io/tests/test_meas_info.py Lines 520 to 535 in 6861595
That being said the additional test in this PR seems fine. My only suggestion would be to change the api of That way user code would look like this.
which I think is cleaner and less prone to error (ie only doing the |
Let's get #7090 in, and then do steps 2-4, then see if it's necessary. I don't think it will be since people will be able to do the following if they really want |
Fixes #7067
always writing meas_date seems like the most straight forward fix. Hopefully it doesn't break anything.
As a fix it does have the downside that if a fiff file exists on disk without a
meas_datetag and ameas_idthat isn't equal toDATE_NONEthen on reading in the file themeas_datewill be guessed.