khanlab / snakebids

Snakemake + BIDS
https://snakebids.readthedocs.io
MIT License
17 stars 13 forks source link

Cannot use `--participant-label` and `--exclude-participant-label` simultaneously #343

Closed pvandyken closed 6 months ago

pvandyken commented 1 year ago

Snakebids currently prohibits the scenario in the title with a ValueError. As far as I can tell, this prohibition is arbitrary, and it has caused inconveniences for me. In some of my workflows, I have the CLI call coded in a .sh script file, and I have --exclude-participant-label written in the file to exclude some subjects I know will fail. But if I'm testing the workflow and I want to use --participant-label, I have to first remove the --exclude-participant-label to get the workflow to work.

I propose allowing both with the following order of priority:

  1. First apply --participant-label
  2. Then apply --exclude-participant-label
  3. If the two lists have any overlap, raise a warning indicating the overlapping subjects

The above scheme tilts us toward "inactivity" rather than "activity": i.e. if a subject is included and excluded, we won't run on the subject. The warning will make it clear what happened. In practice, the two lists should rarely overlap and the warning will hardly be seen.

kaitj commented 9 months ago

Sorry, I must have missed this when you first posted an issue about it. I think this warrants a discussion as I am having trouble envisioning what happens to the participants that are not listed.

AFAIK, --participant-label currently runs the workflow for only the provided subject ids, while --exclude-participant-label will run on all subjects except the provided subject ids. I can definitely see how this is an issue in the scenario you provided.

In your proposal, I'm not sure participants listed by --participant-label would be processed when both flags are provided unless the mechanisms behind these flags change? As it currently works, it would still be the same as running only --exclude-participant-label (e.g. running on all the subjects not listed)?

pvandyken commented 9 months ago

In fact, it would be the reverse, running only on the subjects listed by --participant-label.

The somewhat self-motivated purpose is because I typically put the (rather long) calls to my bidsapps in a run.sh file. If I have exclusions, I encode them directly in the file. Something like:

my_app input output participant --exclude-participant-label XXX YYY "$@"

Sometimes when running the app, however, I'll want to run on just one participant:

./run.sh --participant-label ZZZ

Currently, I can't compose like this because I can't provide both arguments simultaneously.

The set logic is like this:

POPULATION ∩ INCLUDE - EXCLUDE

The inclusion intersection and exclusion subtraction are commutable, so there's no ambiguity.

kaitj commented 8 months ago

Ahh yeah okay, this makes sense to me and is definitely a nice thing to have working (i.e. being able to pass both filters).