Replies: 2 comments 8 replies
-
I'm not sure I understand the motivation of point 1. The point of the method is to reconstitute the paths forming a component, or to expand over a new template. It actually does depend on the component's path template: it's used as the template if no new template is provided. Is there any practical benefit to getting the isolated expand function? Note that in the snakemake context, you of course already get the |
Beta Was this translation helpful? Give feedback.
-
For point 2, I think you may be thinking of 2.2, 2.3, and 2.4 seem a bit strange to me, to be honest. It's certainly possible with python operator overloading, but it's generally not advisable to do mathematical operations between two different types (e.g. a |
Beta Was this translation helpful? Give feedback.
-
The problem
I'm following the snakebids tutorial and issue #209. The current way of passing arguments to bids() and expand() seem to be to use entities/wildcards found in the current BidsDataset as a base dict, and manually add a few components if needed. For example, from the tutorial
There are two possible issues:
input['bold']
which may have other attributes not needed (e.g. dataset root path), suggesting separating expand() function out of BidsComponentRow/BidsPartialComponent class as an independent function bids_expand(). With this in mind, we can change the above rule all to the following:Interfaces like BidsDataset.drop() or BidsDataset.with_entities() may be equivalent to doing some more intuitive and simpler dictionary operations over entities or wildcards.
Assume we define a subclass MyDict of Python dict that supports the following operations:
d1 | d2
d - k # remove key k from dict d
d - [k1, k2…, kn] # subtracting an iterable of keys; i.e. remove n keys at once
d & k
d & [k1, k2…, kn]
d = {'subject': '{subject}'} becomes d = dict(subject='{subject}')
To make code analysis easier, above operations 2-3 should be implemented as pure functions (with no side effects and solely depends on its input parameters), instead of modifying the dictionary caller.
This would allow reuse of variables, for example if A and B are two BIDS datasets on paths 'path/to/a' and 'path/to/b', we can define
Similarly, if we want to form wildcard paths for both input and output, we may write
Proposed Enhancement
I would like to propose a different way to pass parameters to bids() and expand() functions, as described above.
To do so, we need to move expand() out of BidsComponentRow/BidsPartialComponent class, and add a dict subclass to support parameter concatenation, overwrite, keyset removal and subsetting.
Environment
snakebids
is the main branch as of todayBeta Was this translation helpful? Give feedback.
All reactions