-
Notifications
You must be signed in to change notification settings - Fork 294
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
ENH: Enable users to pass JSON filters to select subsets of data #1770
Conversation
Thanks for opening this pull request! We have detected this is the first time for you to contribute to fMRIPrep. Please check out our contributing guidelines.
Of course, if you want to opt-out this time there is no problem at all with adding your name later. You will be always welcome to add it in the future whenever you feel it should be listed. |
I made corresponding changes in niworkflows: https://github.com/bpinsard/niworkflows/tree/enh/bids_filter |
Do you have an example JSON filter? |
For instance, the following add a filter for reconstruction (rec-xxx), and bold is the same filter as default.
( adding this for reference: https://github.com/bids-standard/pybids/blob/master/bids/layout/config/bids.json ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minimal nitpick 👍 . Will check the PR to niworkflows when ready.
Co-Authored-By: Oscar Esteban <code@oscaresteban.es>
Co-Authored-By: Oscar Esteban <code@oscaresteban.es>
Co-Authored-By: Chris Markiewicz <effigies@gmail.com>
I wonder if this work wouldn't make sense to upstream to BIDS Apps more generally ? I'm thinking in particular of the spec @effigies was co-leading. It seems like a general question of how BIDS Apps should handle multiple eligible inputs. @bpinsard and I discussed this in person, and I would have thought the best "BIDS" way to do this for the moment is just to modify a study's |
@emdupre |
I completely understand that 😸 I just mean that this seems like something that we would want to upstream to the BIDS Execution specification, since it strikes me as a very general issue. EDIT: And sorry if this is the wrong place to post this ! There are a few cross-linked issues and PRs, now, so I'm not sure where's the best place to have this discussion.... |
Tests fails due to dependency on niworkflow changes, same for PR on smriprep. |
I think this is in good shape. How do we feel about squeezing it in to 20.0.0? It adds a CLI option but does not change anything when the option is not passed. Need to merge nipreps/smriprep#143 and release niworkflows and smriprep, but we can do that tomorrow if everybody's happy. @bpinsard Have you been actually testing this? I can try it with a multi-session OpenNeuro dataset tomorrow if not. Or we can push a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor suggestion, but overall this looks good. We can definitely get this in for 20.0.0, will target a smriprep / niworkflow release for tomorrow.
fmriprep/cli/run.py
Outdated
@@ -76,6 +77,11 @@ def get_parser(): | |||
# Re-enable when option is actually implemented | |||
# g_bids.add_argument('-r', '--run-id', action='store', default='single_run', | |||
# help='select a specific run to be processed') | |||
g_bids.add_argument( | |||
'--bids-filters', action='store', type=Path, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think making it explicit this is a file will improve clarity and be more in line with the other file cli arguments
'--bids-filters', action='store', type=Path, | |
'--bids-filter-file', action='store', type=Path, |
fmriprep/cli/run.py
Outdated
@@ -499,6 +505,8 @@ def build_workflow(opts, retval): | |||
bids_dir = opts.bids_dir.resolve() | |||
output_dir = opts.output_dir.resolve() | |||
work_dir = opts.work_dir.resolve() | |||
bids_filters = json.loads(opts.bids_filters.read_text()) \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bids_filters = json.loads(opts.bids_filters.read_text()) \ | |
bids_filters = json.loads(opts.bids_filter_file.read_text()) \ |
fmriprep/cli/run.py
Outdated
@@ -499,6 +505,8 @@ def build_workflow(opts, retval): | |||
bids_dir = opts.bids_dir.resolve() | |||
output_dir = opts.output_dir.resolve() | |||
work_dir = opts.work_dir.resolve() | |||
bids_filters = json.loads(opts.bids_filters.read_text()) \ | |||
if opts.bids_filters else None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if opts.bids_filters else None | |
if opts.bids_filter_file else None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool - thanks. I suggested the updated pins, will commit once those are live on pypi and then we can merge this in
Changes proposed in this pull request
reference issue: nipreps/smriprep#104
Adding a
--bids_filters
option to further specify the options to select input files to the pipeline.This points to a json files containing a dict with pybids entities filters, that is to be passed to nipype.interfaces.io.BIDSDataGrabber output_query option.
I created the same branch in smriprep with similar changes in run.py and workflow.base.py
While I was coding that I realized that f/smriprep uses in fact niworkflows.interfaces.bids.BIDSDataGrabber (this is a mistaking name btw).
Is there a specific reason to recode that part, could it be possible to use the original nipype one, or it is missing a feature?
I need you insight there.
Thanks
Documentation that should be reviewed
TODO/WIP