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

BUG: Fix API for candidates #1093

Merged
merged 3 commits into from
Nov 2, 2022
Merged

BUG: Fix API for candidates #1093

merged 3 commits into from
Nov 2, 2022

Conversation

larsoner
Copy link
Member

@larsoner larsoner commented Nov 1, 2022

PR Description

So in #1083 I added return_candidates=True, but this doesn't really solve the use case. The "list all candidates" step needs to be separate from the "traverse and read all candidates", and it's not currently. This PR splits them. Now instead of doing:

fname, candidates = bids_path.find_empty_room(return_candidates=True)

you do

candidates = bids_path.get_empty_room_candidates()
fname = bids_path.find_empty_room()

And the get_empty_room_candidates does not read any files, just lists/globs filenames so should be very fast (and negligible I/O overhead).

Merge checklist

Maintainer, please confirm the following before merging.
If applicable:

  • All comments are resolved
  • This is not your own PR
  • All CIs are happy
  • PR title starts with [MRG]
  • whats_new.rst is updated
  • New contributors have been added to CITATION.cff
  • PR description includes phrase "closes <#issue-number>"

@larsoner
Copy link
Member Author

larsoner commented Nov 1, 2022

... can I make _find_matching_sidecar public as bids_path.find_matching_sidecar()? Then we could actually get the sidecar paths for stuff like this, which is nice.

@codecov
Copy link

codecov bot commented Nov 1, 2022

Codecov Report

Merging #1093 (08992a3) into main (be17f5b) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main    #1093   +/-   ##
=======================================
  Coverage   95.20%   95.21%           
=======================================
  Files          24       24           
  Lines        3861     3867    +6     
=======================================
+ Hits         3676     3682    +6     
  Misses        185      185           
Impacted Files Coverage Δ
mne_bids/path.py 97.61% <100.00%> (+0.01%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@larsoner
Copy link
Member Author

larsoner commented Nov 1, 2022

Okay I pushed a bids_path.find_matching_sidecar as this is something else we've wanted for mne-bids-pipeline. If these sidecar files are updated, we need to rerun steps, so it's good to be able to find the same files that mne-bids will use / look at...

@@ -19,7 +19,7 @@
BIDSPath, write_raw_bids, read_raw_bids,
write_meg_calibration, write_meg_crosstalk)
from mne_bids.path import (_parse_ext, get_entities_from_fname,
_find_best_candidates, _find_matching_sidecar,
_find_best_candidates,
Copy link
Member Author

Choose a reason for hiding this comment

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

I changed the private _find_matching_sidecar calls in this file to use the public interface. There are other places the private function is used like test_write.py but it doesn't seem necessary to change them all here (code churn / blame obfuscation with little benefit)

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.

seems sensible from a top level view, and code changes look clean as well.

@agramfort agramfort merged commit 9ef1e38 into mne-tools:main Nov 2, 2022
@agramfort
Copy link
Member

thx @larsoner

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.

None yet

3 participants