Skip to content
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

Merged
merged 1 commit into from
Jun 15, 2020

Conversation

rob-luke
Copy link
Member

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.

@rob-luke rob-luke force-pushed the nirsdatwarn branch 2 times, most recently from 5fcdad0 to c544ded Compare June 14, 2020 01:57
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")
Copy link
Member

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.

Copy link
Member Author

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?

Copy link
Member

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

beautiful. Thanks

@agramfort
Copy link
Member

agramfort commented Jun 14, 2020 via email

@rob-luke
Copy link
Member Author

@larsoner @agramfort could you please review, this failure seems due to the Mac CI exceeding its time limit.

@rob-luke rob-luke changed the title WIP: Warn if NIRX directory structure has been modified from original format MRG: Warn if NIRX directory structure has been modified from original format Jun 15, 2020
@rob-luke
Copy link
Member Author

a 16 second turn around. Surely that's a record, thanks @agramfort

@agramfort
Copy link
Member

agramfort commented Jun 15, 2020 via email

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'):
Copy link
Member

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

@larsoner larsoner merged commit 6a7636a into mne-tools:master Jun 15, 2020
@larsoner
Copy link
Member

Thanks @rob-luke

larsoner added a commit to GuillaumeFavelier/mne-python that referenced this pull request Jun 16, 2020
* 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)
larsoner added a commit to larsoner/mne-python that referenced this pull request Jun 17, 2020
* 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)
  ...
larsoner added a commit to larsoner/mne-python that referenced this pull request Jun 25, 2020
* 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)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Question][fNIRS] The use of .dat file
3 participants