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] BIDSPath to allow users to turn off entity check, and replace all make_bids_basename with BIDSPath #511

Merged
merged 36 commits into from Aug 25, 2020

Conversation

adam2392
Copy link
Member

@adam2392 adam2392 commented Aug 21, 2020

PR Description

Closes #510

  • Removes make_bids_basename completely per discussion below in favor of BIDSPath.
  • Added the check kwarg to BIDSPath.__init__() and BIDSPath.update() functions.
  • created a private _convert_str_to_BIDSPath() function to handle the necessary converting from strings to BIDSPath objects.

The next PR

  • Change kind -> suffix and add modality in favor of kind.
  • Implement fpath functionality to replace get_bids_fname

Merge checklist

Maintainer, please confirm the following before merging:

  • All comments resolved
  • This is not your own PR
  • All CIs are happy
  • PR title starts with [MRG]
  • whats_new.rst is updated
  • PR description includes phrase "closes <#issue-number>"
  • Commit history does not contain any merge commits

@codecov-commenter
Copy link

codecov-commenter commented Aug 21, 2020

Codecov Report

Merging #511 into master will increase coverage by 0.07%.
The diff coverage is 88.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #511      +/-   ##
==========================================
+ Coverage   92.74%   92.82%   +0.07%     
==========================================
  Files          14       14              
  Lines        2026     2020       -6     
==========================================
- Hits         1879     1875       -4     
+ Misses        147      145       -2     
Impacted Files Coverage Δ
mne_bids/read.py 96.01% <57.14%> (+0.49%) ⬆️
mne_bids/utils.py 94.60% <71.42%> (+0.02%) ⬆️
mne_bids/path.py 95.87% <95.83%> (+0.12%) ⬆️
mne_bids/commands/mne_bids_raw_to_bids.py 94.11% <100.00%> (ø)
mne_bids/copyfiles.py 96.96% <100.00%> (ø)
mne_bids/dig.py 90.71% <100.00%> (ø)
mne_bids/write.py 96.73% <100.00%> (-0.01%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a6891bf...4ac2fbc. Read the comment docs.

@agramfort
Copy link
Member

what we do in mne-study-template is that we do it via update that does not check. If you go this route with a check param/attribute it's probably more explicit.

@hoechenberger wdyt?

@hoechenberger
Copy link
Member

hoechenberger commented Aug 22, 2020

I think it's good to have the check option (so one can turn it off); however I also think we should add it to the BIDSPath.update() method – and default to check=True.

@hoechenberger
Copy link
Member

hoechenberger commented Aug 22, 2020

Also this makes me wonder, maybe we can drop make_bids_basename() altogether if we add check to BIDSPath.__init__()? The check was the only reason to have make_bids_basename() alongside with BIDSPath, right?

@agramfort
Copy link
Member

agramfort commented Aug 22, 2020 via email

@adam2392
Copy link
Member Author

it's true that if we have this check param then there is no difference between BIDSPath init and the make_bids_basename function that can go...

Do we want a deprecation cycle, or just axe it now?

@hoechenberger
Copy link
Member

Do we want a deprecation cycle, or just axe it now?

I believe we're breaking so much in the next release already that we don't need to care about deprecation cycles 😁

But we could also follow a slightly different approach: make BIDSPath private, and rename make_bids_basename to make_bids_path, which for now would only instantiate a BIDSPath but could be extended in the future to do more work… not sure if that makes sense?

@jasmainak
Copy link
Member

I like @hoechenberger 's idea

@hoechenberger
Copy link
Member

hoechenberger commented Aug 23, 2020

Just to outline the idea in more detail:

  1. add check=True kwarg to make_bids_basename(), BIDSPath.__init__(), and BIDSPath.update()
  2. rename make_bids_basename() to make_bids_path()
  3. do one of the following
    • either make BIDSPath private -> _BIDSPath – this, however, would potentially make things a little odd when users try to look up the documentation, e.g. for .update()?
    • or add an info box to the BIDSPath documentation, stating that it should be instantiated via make_bids_path() – I'm thinking something similar to mne.Covariance. I would prefer this.

This will allow us to be more flexible and potentially change internals in the future without breaking backward-compatibility.

@jasmainak
Copy link
Member

on second thoughts whether you rename to BIDSPath or make_bids_path you're breaking backwards compatibility, so not sure if this more complicated approach would help ...

@agramfort
Copy link
Member

agramfort commented Aug 23, 2020 via email

@hoechenberger
Copy link
Member

hoechenberger commented Aug 23, 2020

Ok so then I'd like to revise my proposal and I'd say let's drop make_bids_basename and add check=True to BIDSPath :)

@adam2392 adam2392 changed the title [MRG] Fixing make_bids_basename to allow users to turn off entity check [WIP] Fixing make_bids_basename to allow users to turn off entity check Aug 24, 2020
@adam2392 adam2392 changed the title [WIP] Fixing make_bids_basename to allow users to turn off entity check [MRG] BIDSPath to allow users to turn off entity check, and replace all make_bids_basename with BIDSPath Aug 24, 2020
@adam2392
Copy link
Member Author

So this is pretty much good to go once CI is green. It is the first installment of the 3-tiered PR, proposed in: #492 (comment)

mne_bids/path.py Outdated Show resolved Hide resolved
doc/whats_new.rst Outdated Show resolved Hide resolved
doc/whats_new.rst Outdated Show resolved Hide resolved
doc/whats_new.rst Outdated Show resolved Hide resolved
mne_bids/path.py Outdated Show resolved Hide resolved
adam2392 and others added 5 commits August 24, 2020 10:52
Co-authored-by: Richard Höchenberger <richard.hoechenberger@gmail.com>
Co-authored-by: Richard Höchenberger <richard.hoechenberger@gmail.com>
Co-authored-by: Richard Höchenberger <richard.hoechenberger@gmail.com>
mne_bids/tests/test_read.py Outdated Show resolved Hide resolved
Copy link
Member

@agramfort agramfort left a comment

Choose a reason for hiding this comment

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

mne_bids/tests/test_read.py Outdated Show resolved Hide resolved
mne_bids/tests/test_read.py Outdated Show resolved Hide resolved
mne_bids/tests/test_read.py Outdated Show resolved Hide resolved
@agramfort
Copy link
Member

agramfort commented Aug 25, 2020 via email

@hoechenberger
Copy link
Member

fetch the branch and try to remove it to see if necessary

You mean … WORK MYSELF? Daaamn… ok, will do :)

@agramfort
Copy link
Member

agramfort commented Aug 25, 2020 via email

test_get_matched_emptyroom_no_meas_date() fails with check=False, need
to figure out why.
@hoechenberger
Copy link
Member

hoechenberger commented Aug 25, 2020

e7e25c8 makes it such that we don't fall back to an empty-room's info['meas_date'] if the file naming scheme violates BIDS. Instead, we now raise an error and advice users to fix their BIDS dataset. This simplifies get_matched_emptyroom() quite a bit.

I'm starting to like not trying to be clever.

@hoechenberger
Copy link
Member

Good to go from my end.

@agramfort
Copy link
Member

@sappelhoff @jasmainak do you want to have a look?

Copy link
Member

@sappelhoff sappelhoff left a comment

Choose a reason for hiding this comment

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

LGTM :)

mne_bids/path.py Show resolved Hide resolved
mne_bids/path.py Outdated Show resolved Hide resolved
@agramfort agramfort merged commit d7fcde9 into mne-tools:master Aug 25, 2020
@hoechenberger
Copy link
Member

Awesome work, @adam2392!

hoechenberger added a commit to hoechenberger/mne-bids that referenced this pull request Aug 25, 2020
As pointed out by @sappelhoff in mne-tools#511 (comment),
the presence of the attribute could lead to unexpected behavior.

My solution is to just drop it and expect users to
pass it to `BIDSPath.update()` if they want to disable checking during
an update.
hoechenberger added a commit to hoechenberger/mne-bids that referenced this pull request Aug 26, 2020
Turns out, empty-room recording sessions SHOULD be the recording date,
but not MUST.

This reverts e7e25c8 of mne-toolsGH-511
@hoechenberger hoechenberger mentioned this pull request Aug 26, 2020
7 tasks
hoechenberger added a commit to hoechenberger/mne-bids that referenced this pull request Aug 26, 2020
Turns out, empty-room recording sessions SHOULD be the recording date,
but not MUST.

This reverts e7e25c8 of mne-toolsGH-511
agramfort pushed a commit that referenced this pull request Aug 26, 2020
* Revert assuming ER naming scheme

Turns out, empty-room recording sessions SHOULD be the recording date,
but not MUST.

This reverts e7e25c8 of GH-511

* Remove on_invalid_er_session check
@jasmainak
Copy link
Member

Sorry for my silence, I trust that the PR was in good hands ;)

@adam2392 adam2392 deleted the check branch August 27, 2020 19:13
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.

Allow user to specify if they don't want to do "deep check" when running make_bids_basename
6 participants