Skip to content
This repository has been archived by the owner on Aug 8, 2024. It is now read-only.

FIXES: invalid filters, mark all xfails, etc.. #40

Merged
merged 16 commits into from
Mar 8, 2023

Conversation

adelavega
Copy link
Collaborator

@adelavega adelavega commented Feb 27, 2023

Various fixes:

  • Implement invalid filters Invalid filters are ignored / not parameterizable  #12
  • Added relative paths to BIDSFile and respect absolute_paths BIDSLayout parameter
  • Fix various tests with minor failures
  • Implemented Query ENUM
  • Mark all xfails (i.e. things that are known to not be yet implemented)

I looked at all the tests and here's the summary:

Only 2 "unexpected" failures since they are ancpbids bugs:

  • "datatype" entity missing Datatype entity is missed #11
  • ancpbids fails to match meta-data for a file where an entity is missing
    • file doesn't have run id, and should match to sidecar w/o run id, but it doesn't

the rest are xfails:

derivatives features not implemented:

  • derivative as root / out of tree derivatives Derivative loading differences #10
  • also: selecting which derivatives to index (e.g,. only add this specific deriv, but not others)
  • scope argument to .get
  • adding derivatives after instantiating BIDSLayout

won't be implemented / not critical:

  • 'config' not implemented (and wont be)
  • Entity enum not implemented
  • handling wrong dtype in query

So all in all, I think the main work is in supporting derivatives, and fixing the two issues w/ ancpbids and I think we'll be 80% of the way there

@adelavega adelavega marked this pull request as ready for review February 27, 2023 23:36
Comment on lines +317 to +318
# but it was not. Session does not exist in dataset, yet since Query
# Enum is set to optional the query passes even with 'ignore_filters'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Session is a legitimate entity, so we should be able to search for files where session may be any value or absent. The idea is to be able to write queries that will work regardless of dataset. If we can't query for legit entities that are absent, that's a problem.

Copy link
Collaborator Author

@adelavega adelavega Feb 28, 2023

Choose a reason for hiding this comment

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

Right, but shouldn't that behavior depend on ignore_filters? Seems kinda weird to me to say ignore_filters=error and then not error on session.

I guess we could say all core entities are valid queries

Copy link
Collaborator

Choose a reason for hiding this comment

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

Well an invalid filter is one that doesn't match any files. session=OPTIONAL matches all files.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Allright, fair enough, I don't feel strongly -- but is this in the actual BIDS spec or just a pyBIDS thing?

Copy link
Collaborator

Choose a reason for hiding this comment

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

It is just a pybids thing, but we definitely use it when writing queries. It's useful to say "present but any" (REQUIRED), "absent" (NONE) or "either" (OPTIONAL), and not have to put in a bunch of dataset-dependent logic before constructing your query, or implement your own OPTIONAL and remove it from kwargs.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

And it's not sufficient to just say ignore_filters='ignore' for those types of queries? Is that too "unsafe"?

Copy link
Collaborator

Choose a reason for hiding this comment

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

How would you implement it with invalid_filters='ignore'? Wouldn't that silently return no files?

Copy link
Collaborator

Choose a reason for hiding this comment

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

The way we implement it right now is that we just remove OPTIONAL filters from the list. We could check whether the entity is valid and do the same. I think it would also be reasonable for session=NONE to return True for all files in a dataset without sessions.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, it would, but isn't that obvious when writing the query?

I would be in favor of not throwing errors for all BIDS valid core entities by default. Either way, I think this is all open for revision in the new API

@@ -479,22 +493,24 @@ def test_get_with_regex_search_bad_dtype(layout_7t_trt):
# Two runs (1 per session) for each of subjects '10' and '01'
assert len(results) == 4


# AD: Changed this test to use a entity found in ds005
# 'session' was not in dataset, therefore not suggested
Copy link
Collaborator

Choose a reason for hiding this comment

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

Isn't the point that session=True is invalid?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Maybe, depends on how the above is resolved, but I thought it was just a simple test of using the wrong name for an entity (i.e. "ses" instead of "session")

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh, that was probably it.

Copy link
Collaborator

@effigies effigies left a comment

Choose a reason for hiding this comment

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

Overall looks reasonable, but left a couple comments.

bids/layout/layout.py Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Mar 7, 2023

Codecov Report

Patch coverage: 69.56% and project coverage change: -6.99 ⚠️

Comparison is base (b94864d) 53.33% compared to head (7f85f8e) 46.35%.

Additional details and impacted files
@@                Coverage Diff                 @@
##           rf/ancp-layout      #40      +/-   ##
==================================================
- Coverage           53.33%   46.35%   -6.99%     
==================================================
  Files                  34       34              
  Lines                3549     3596      +47     
  Branches              857      876      +19     
==================================================
- Hits                 1893     1667     -226     
- Misses               1489     1787     +298     
+ Partials              167      142      -25     
Impacted Files Coverage Δ
bids/layout/models.py 47.01% <60.00%> (-12.53%) ⬇️
bids/layout/layout.py 62.46% <70.31%> (-14.47%) ⬇️
bids/variables/entities.py 23.07% <0.00%> (-59.62%) ⬇️
bids/variables/io.py 16.81% <0.00%> (-27.28%) ⬇️
bids/reports/parameters.py 43.33% <0.00%> (-24.01%) ⬇️
bids/utils.py 46.31% <0.00%> (-15.79%) ⬇️
bids/reports/parsing.py 21.09% <0.00%> (-14.07%) ⬇️
bids/reports/report.py 44.77% <0.00%> (-4.48%) ⬇️
... and 3 more

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

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@effigies effigies merged commit 1211497 into rf/ancp-layout Mar 8, 2023
@effigies effigies deleted the invalid_filters branch March 8, 2023 14:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants