-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
MRG: Warn if NIRX directory structure has been modified from original format #7898
Conversation
5fcdad0
to
c544ded
Compare
mne/io/nirx/tests/test_nirx.py
Outdated
with pytest.raises(RuntimeWarning, match='A single dat'): | ||
read_raw_nirx(fname, preload=True) | ||
os.rename(fname_nirx_15_2_short + "/NIRS-2019-08-23_001.tmp", | ||
fname_nirx_15_2_short + "/NIRS-2019-08-23_001.dat") |
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.
this is for me dangerous as if the lines above fail you will never revert the renaming.
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.
Agreed. Could I not have a test for this? It will drop the code coverage :(
Or is there another way you would suggest?
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.
@rob-luke the way we usually solve this is with the pattern:
def test_whatever(tmpdir): # pytest builtin tmpdir fixture
shutuil.copytree(orig_dir, str(tmpdir))
# mess with files in tmpdir
...
read_raw_nirx(tmpdir.join('whatever.ext'))
pytest takes care of creating and destroying the tmpdir
directory
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.
beautiful. Thanks
maybe a try finally construct?
… |
@larsoner @agramfort could you please review, this failure seems due to the Mac CI exceeding its time limit. |
a 16 second turn around. Surely that's a record, thanks @agramfort |
:)
… |
os.rename(str(tmpdir) + "/data" + "/NIRS-2019-08-23_001.dat", | ||
str(tmpdir) + "/data" + "/NIRS-2019-08-23_001.tmp") | ||
fname = str(tmpdir) + "/data" + "/NIRS-2019-08-23_001.hdr" | ||
with pytest.raises(RuntimeWarning, match='A single dat'): |
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.
usually we use pytest.warns
, but I suppose this works, too
Thanks @rob-luke |
* upstream/master: MRG, FIX: Speed up I/O tests, mark some slow (mne-tools#7904) Proper attribution for Blender tutorial (mne-tools#7900) MAINT: Check usage [ci skip] (mne-tools#7902) Allow find_bad_channels_maxwell() to return scores (mne-tools#7845) Warn if NIRx directory structure has been modified from original format (mne-tools#7898)
* upstream/master: (24 commits) WIP: Fix Travis (mne-tools#7906) WIP: Prototype of notebook viz (screencast) (mne-tools#7758) MRG, FIX: Speed up I/O tests, mark some slow (mne-tools#7904) Proper attribution for Blender tutorial (mne-tools#7900) MAINT: Check usage [ci skip] (mne-tools#7902) Allow find_bad_channels_maxwell() to return scores (mne-tools#7845) Warn if NIRx directory structure has been modified from original format (mne-tools#7898) Pin pvyista to 0.24.3 (mne-tools#7899) MRG: Add support for reading and writing sufaces to .obj (mne-tools#7824) Fix _auto_topomap_coords docstring. (mne-tools#7895) MRG, FIX: Ensure Info H5-writeable (mne-tools#7887) Website contents (mne-tools#7889) MRG, ENH: Add mri_resolution="sparse" (mne-tools#7888) MRG, ENH: Allow disabling FXAA (mne-tools#7877) remove "and and" [ci skip] (mne-tools#7882) fix evoked nave → inverse guidance (mne-tools#7881) ENH: Better error messages (mne-tools#7879) FIX : EDF+ Annotation Timestamps missing sub-second accuracy (mne-tools#7875) FIX: Fix get_channel_types (mne-tools#7878) MRG, BUG: Fix combine evokeds (mne-tools#7869) ...
* upstream/master: (23 commits) MAINT: Add mne.surface to docstring tests (mne-tools#7930) MRG: Add smoothing controller to TimeViewer for the notebook backend (mne-tools#7928) MRG: TimeViewer matplotlib figure color (mne-tools#7925) fix typos (mne-tools#7924) MRG, ENH: Add method to project onto max power ori (mne-tools#7883) WIP: Warn if untested NIRX device (mne-tools#7905) MRG, BUG: Fix bug with volume morph and subject_to!="fsaverage" (mne-tools#7896) MRG, MAINT: Clean up use of bool, float, int (mne-tools#7917) ENH: Better error message for incompatible Evoked objects (mne-tools#7910) try to fix nullcontext (mne-tools#7908) WIP: Fix Travis (mne-tools#7906) WIP: Prototype of notebook viz (screencast) (mne-tools#7758) MRG, FIX: Speed up I/O tests, mark some slow (mne-tools#7904) Proper attribution for Blender tutorial (mne-tools#7900) MAINT: Check usage [ci skip] (mne-tools#7902) Allow find_bad_channels_maxwell() to return scores (mne-tools#7845) Warn if NIRx directory structure has been modified from original format (mne-tools#7898) Pin pvyista to 0.24.3 (mne-tools#7899) MRG: Add support for reading and writing sufaces to .obj (mne-tools#7824) Fix _auto_topomap_coords docstring. (mne-tools#7895) ...
Reference issue
Fixes #7894. @swy7ch noted that the NIRX file reader checks for a dat file, but it is not used.
What does this implement/fix?
Instead of failing if the
.dat
is missing this now throws a warning to the user that the file structure has been modified from what the measurement machine saved.Additional information
We have had some discussion about what the correct behaviour is. See the above linked issue for discussion.