bids-standard/pybids

Unable to use `Query.*` on extension

Closed this issue · 2 comments

On the following dataset:

sub-0
  sub-0
  sub-0_suff.0

I am unable to use any of the bids.layout.Query items to filter extension with the BIDSLayout.get(). All such attempts return empty lists. eg:

layout.get(extension=Query.NONE) === []
layout.get(extension=Query.ANY) === []
layout.get(extension=Query.OPTIONAL) === []

The function behaves as expected for subject and suffix.

The code likely responsible is a bunch of SQL queries, and I have very little experience in such things, so I'm afraid I have no start to a solution.

Admittedly, such filtering over extension probably has little use in the real world... the above example was discovered while input fuzzing (as in #991). So if this issue will be resolve anyway in Pybids 1.0, it may not be worth spending time addressing, in which case feel free to close.

Extensions should not be treated differently than other path components, so I'm not sure why this is happening. A quick glance at the code that normalizes the initial dot doesn't seem like it should have this effect. I agree, though, that this is a pretty niche case. If someone figures it out, or it goes away with the 1.0 change, then cool. We can leave this open until then.

Figured out what was going on here when researching #993. In bids.layout.BIDSLayout.get(), the function does some validation of extension to ensure all entries start with a leading '.'. This ends up turning the filter into a list of values, even if only one value (Query.NONE) is passed. The function then fails for the same reason as in #993. So resolving #993 will also resolve this issue