-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Convert old Spectrum and TFR birthday info format on read
#13526
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
Something like and in true TDD form, I'd write this test while on |
|
Writing the https://github.com/h5io/h5io/blob/80126abda226da8226d1163555b5db1c702c3b0b/h5io/_h5io.py#L244 I think the easiest way around this would be to do a |
|
@larsoner I just noticed this in the TFR tests: mne-python/mne/time_frequency/tests/test_tfr.py Lines 657 to 662 in 653130a
Could modifying the unlocked info before saving also be a valid approach here without messing with h5io? |
|
It might validate before saving or something which would be a problem but if that works out seems like a nice solution! |
|
@larsoner You were right, things were still being validated in that simpler solution. |
|
Apparently the TFR files saved from |
mne/time_frequency/tests/test_tfr.py
Outdated
| from itertools import product | ||
| from pathlib import Path | ||
|
|
||
| import h5py |
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.
By putting this at the top, you are implicitly making h5py a required dependency for running MNE-Python tests. So instead, this should be lower with
h5py = pytest.importorskip("h5py")
probably nested in whatever test actually needs it so that non-HDF5 tests can still run
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.
Ah sorry! Have fixed here and in test_spectrum.py.
|
Thanks @tsbinns ! |
Reference issue (if any)
Fixes #13483
What does this implement/fix?
Converts deprecated
info["subject_info"]["birthday"]tuples to datetimes, allowing reading of spectrum/tfr objects saved before v1.8.The issue and original forum post mentions this affecting TFRs, but spectrum objects are also affected.
Not sure if
mne/utils/spectrum.pyis the best place for this conversion function, but I felt it could fit since that file also contains the helper_get_instance_type_stringwhich is being called for both spectrum & TFRs.Have confirmed the fix works for objects created using the following code in v1.7:
Unsure what the recommended approach for a unit test would be that requires an object created with an older MNE version.