-
Notifications
You must be signed in to change notification settings - Fork 285
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
[WIP] ENH: Add --func-only option to skip anatomical processing #808
Closed
Closed
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
a778b21
ENH: Add --dismiss-t1w option to skip anatomical processing
b78a50d
Merge remote-tracking branch 'upstream/master' into madeleine-snyder-…
oesteban 16c367a
[skip ci] Add Maddie to zenodo
oesteban cb3c6fc
Merge pull request #2 from oesteban/madeleine-snyder-dismiss-t1-patch
madeleinesnyder 9fcb693
fix erroneously removed medial_surface_nan
oesteban db088e7
fix erroneous initialization of anatomical workflow
oesteban 86c010e
Merge branch 'master' into func-only
oesteban 453e91f
convert indentation to spaces
oesteban 940340b
Connected onlyfunc workflow in workflows/base.py
d9b66f6
remove fmriprep/workflows/.base.py.swo
9b377ea
Added raise exception if user tries func_only and anat_only simultane…
d3decf9
Connected other workflows in workflows/bold/base.py onlyfunc
4878aae
Added mututally exclusive argument for func and anat in run.py
fc7fd68
remove .swo file, update .gitignore
oesteban 7403a97
Merge remote-tracking branch 'upstream/master' into func-only
oesteban 5c6fb3d
fix zenodo ordering
oesteban 1aab4c6
Merge remote-tracking branch 'upstream/master' into func-only
oesteban File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
# Editors | ||
.*.py.swo | ||
|
||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,11 +27,11 @@ | |
from ..info import __version__ | ||
|
||
from .anatomical import init_anat_preproc_wf | ||
from .bold import init_func_preproc_wf | ||
from .bold import init_func_preproc_wf, init_onlyfunc_preproc_wf | ||
|
||
|
||
def init_fmriprep_wf(subject_list, task_id, run_uuid, | ||
ignore, debug, low_mem, anat_only, longitudinal, omp_nthreads, | ||
ignore, debug, low_mem, anat_only, func_only, longitudinal, omp_nthreads, | ||
skull_strip_template, work_dir, output_dir, bids_dir, | ||
freesurfer, output_spaces, template, medial_surface_nan, hires, | ||
use_bbr, bold2t1w_dof, fmap_bspline, fmap_demean, use_syn, force_syn, | ||
|
@@ -55,6 +55,7 @@ def init_fmriprep_wf(subject_list, task_id, run_uuid, | |
debug=False, | ||
low_mem=False, | ||
anat_only=False, | ||
func_only=False, | ||
longitudinal=False, | ||
omp_nthreads=1, | ||
skull_strip_template='OASIS', | ||
|
@@ -94,6 +95,8 @@ def init_fmriprep_wf(subject_list, task_id, run_uuid, | |
Write uncompressed .nii files in some cases to reduce memory usage | ||
anat_only : bool | ||
Disable functional workflows | ||
func_only : bool | ||
Disable anatomical workflows | ||
longitudinal : bool | ||
Treat multiple sessions as longitudinal (may increase runtime) | ||
See sub-workflows for specific differences | ||
|
@@ -167,6 +170,7 @@ def init_fmriprep_wf(subject_list, task_id, run_uuid, | |
debug=debug, | ||
low_mem=low_mem, | ||
anat_only=anat_only, | ||
func_only=func_only, | ||
longitudinal=longitudinal, | ||
omp_nthreads=omp_nthreads, | ||
skull_strip_template=skull_strip_template, | ||
|
@@ -203,8 +207,8 @@ def init_fmriprep_wf(subject_list, task_id, run_uuid, | |
|
||
|
||
def init_single_subject_wf(subject_id, task_id, name, | ||
ignore, debug, low_mem, anat_only, longitudinal, omp_nthreads, | ||
skull_strip_template, reportlets_dir, output_dir, | ||
ignore, debug, low_mem, anat_only, func_only, longitudinal, | ||
omp_nthreads, skull_strip_template, reportlets_dir, output_dir, | ||
bids_dir, freesurfer, output_spaces, template, medial_surface_nan, | ||
hires, use_bbr, bold2t1w_dof, fmap_bspline, fmap_demean, use_syn, | ||
force_syn, output_grid_ref, use_aroma, ignore_aroma_err): | ||
|
@@ -241,6 +245,7 @@ def init_single_subject_wf(subject_id, task_id, name, | |
debug=False, | ||
low_mem=False, | ||
anat_only=False, | ||
func_only=False, | ||
hires=True, | ||
use_bbr=True, | ||
bold2t1w_dof=9, | ||
|
@@ -268,6 +273,8 @@ def init_single_subject_wf(subject_id, task_id, name, | |
Write uncompressed .nii files in some cases to reduce memory usage | ||
anat_only : bool | ||
Disable functional workflows | ||
func_only : bool | ||
Disable anatomical workflows | ||
longitudinal : bool | ||
Treat multiple sessions as longitudinal (may increase runtime) | ||
See sub-workflows for specific differences | ||
|
@@ -342,7 +349,7 @@ def init_single_subject_wf(subject_id, task_id, name, | |
"All workflows require BOLD images.".format( | ||
subject_id, task_id if task_id else '<all>')) | ||
|
||
if not subject_data['t1w']: | ||
if not func_only or not subject_data['t1w']: | ||
raise Exception("No T1w images found for participant {}. " | ||
"All workflows require T1w images.".format(subject_id)) | ||
|
||
|
@@ -351,7 +358,8 @@ def init_single_subject_wf(subject_id, task_id, name, | |
inputnode = pe.Node(niu.IdentityInterface(fields=['subjects_dir']), | ||
name='inputnode') | ||
|
||
bidssrc = pe.Node(BIDSDataGrabber(subject_data=subject_data, anat_only=anat_only), | ||
bidssrc = pe.Node(BIDSDataGrabber(subject_data=subject_data, anat_only=anat_only, | ||
func_only=func_only), | ||
name='bidssrc') | ||
|
||
bids_info = pe.Node(BIDSInfo(), name='bids_info', run_without_submitting=True) | ||
|
@@ -373,79 +381,117 @@ def init_single_subject_wf(subject_id, task_id, name, | |
suffix='about'), | ||
name='ds_about_report', run_without_submitting=True) | ||
|
||
# Preprocessing of T1w (includes registration to MNI) | ||
anat_preproc_wf = init_anat_preproc_wf(name="anat_preproc_wf", | ||
skull_strip_template=skull_strip_template, | ||
output_spaces=output_spaces, | ||
template=template, | ||
debug=debug, | ||
longitudinal=longitudinal, | ||
omp_nthreads=omp_nthreads, | ||
freesurfer=freesurfer, | ||
hires=hires, | ||
reportlets_dir=reportlets_dir, | ||
output_dir=output_dir, | ||
num_t1w=len(subject_data['t1w'])) | ||
|
||
workflow.connect([ | ||
(inputnode, anat_preproc_wf, [('subjects_dir', 'inputnode.subjects_dir')]), | ||
(bidssrc, bids_info, [(('t1w', fix_multi_T1w_source_name), 'in_file')]), | ||
(inputnode, summary, [('subjects_dir', 'subjects_dir')]), | ||
(bidssrc, summary, [('t1w', 't1w'), | ||
('t2w', 't2w'), | ||
('bold', 'bold')]), | ||
(bids_info, summary, [('subject_id', 'subject_id')]), | ||
(bidssrc, anat_preproc_wf, [('t1w', 'inputnode.t1w'), | ||
('t2w', 'inputnode.t2w')]), | ||
(summary, anat_preproc_wf, [('subject_id', 'inputnode.subject_id')]), | ||
(bidssrc, ds_summary_report, [(('t1w', fix_multi_T1w_source_name), 'source_file')]), | ||
(summary, ds_summary_report, [('out_report', 'in_file')]), | ||
(bidssrc, ds_about_report, [(('t1w', fix_multi_T1w_source_name), 'source_file')]), | ||
(about, ds_about_report, [('out_report', 'in_file')]), | ||
]) | ||
|
||
if anat_only: | ||
return workflow | ||
|
||
for bold_file in subject_data['bold']: | ||
func_preproc_wf = init_func_preproc_wf(bold_file=bold_file, | ||
layout=layout, | ||
ignore=ignore, | ||
freesurfer=freesurfer, | ||
use_bbr=use_bbr, | ||
bold2t1w_dof=bold2t1w_dof, | ||
reportlets_dir=reportlets_dir, | ||
if not func_only: | ||
# Preprocessing of T1w (includes registration to MNI) | ||
anat_preproc_wf = init_anat_preproc_wf(name="anat_preproc_wf", | ||
skull_strip_template=skull_strip_template, | ||
output_spaces=output_spaces, | ||
template=template, | ||
medial_surface_nan=medial_surface_nan, | ||
output_dir=output_dir, | ||
omp_nthreads=omp_nthreads, | ||
low_mem=low_mem, | ||
fmap_bspline=fmap_bspline, | ||
fmap_demean=fmap_demean, | ||
use_syn=use_syn, | ||
force_syn=force_syn, | ||
debug=debug, | ||
output_grid_ref=output_grid_ref, | ||
use_aroma=use_aroma, | ||
ignore_aroma_err=ignore_aroma_err) | ||
longitudinal=longitudinal, | ||
omp_nthreads=omp_nthreads, | ||
freesurfer=freesurfer, | ||
hires=hires, | ||
reportlets_dir=reportlets_dir, | ||
output_dir=output_dir, | ||
num_t1w=len(subject_data['t1w'])) | ||
|
||
workflow.connect([ | ||
(anat_preproc_wf, func_preproc_wf, | ||
[('outputnode.t1_preproc', 'inputnode.t1_preproc'), | ||
('outputnode.t1_brain', 'inputnode.t1_brain'), | ||
('outputnode.t1_mask', 'inputnode.t1_mask'), | ||
('outputnode.t1_seg', 'inputnode.t1_seg'), | ||
('outputnode.t1_tpms', 'inputnode.t1_tpms'), | ||
('outputnode.t1_2_mni_forward_transform', 'inputnode.t1_2_mni_forward_transform'), | ||
('outputnode.t1_2_mni_reverse_transform', 'inputnode.t1_2_mni_reverse_transform'), | ||
# Undefined if --no-freesurfer, but this is safe | ||
('outputnode.subjects_dir', 'inputnode.subjects_dir'), | ||
('outputnode.subject_id', 'inputnode.subject_id'), | ||
('outputnode.t1_2_fsnative_forward_transform', | ||
'inputnode.t1_2_fsnative_forward_transform'), | ||
('outputnode.t1_2_fsnative_reverse_transform', | ||
'inputnode.t1_2_fsnative_reverse_transform')]), | ||
(inputnode, anat_preproc_wf, [('subjects_dir', 'inputnode.subjects_dir')]), | ||
(bidssrc, bids_info, [(('t1w', fix_multi_T1w_source_name), 'in_file')]), | ||
(inputnode, summary, [('subjects_dir', 'subjects_dir')]), | ||
(bidssrc, summary, [('t1w', 't1w'), | ||
('t2w', 't2w'), | ||
('bold', 'bold')]), | ||
(bids_info, summary, [('subject_id', 'subject_id')]), | ||
(bidssrc, anat_preproc_wf, [('t1w', 'inputnode.t1w'), | ||
('t2w', 'inputnode.t2w')]), | ||
(summary, anat_preproc_wf, [('subject_id', 'inputnode.subject_id')]), | ||
(bidssrc, ds_summary_report, [(('t1w', fix_multi_T1w_source_name), 'source_file')]), | ||
(summary, ds_summary_report, [('out_report', 'in_file')]), | ||
(bidssrc, ds_about_report, [(('t1w', fix_multi_T1w_source_name), 'source_file')]), | ||
(about, ds_about_report, [('out_report', 'in_file')]), | ||
]) | ||
|
||
if anat_only: | ||
return workflow | ||
|
||
for bold_file in subject_data['bold']: | ||
if not func_only: # Connect anatomical only if possible | ||
func_preproc_wf = init_func_preproc_wf( | ||
bold_file=bold_file, | ||
layout=layout, | ||
ignore=ignore, | ||
freesurfer=freesurfer, | ||
use_bbr=use_bbr, | ||
bold2t1w_dof=bold2t1w_dof, | ||
reportlets_dir=reportlets_dir, | ||
output_spaces=output_spaces, | ||
template=template, | ||
medial_surface_nan=medial_surface_nan, | ||
output_dir=output_dir, | ||
omp_nthreads=omp_nthreads, | ||
low_mem=low_mem, | ||
fmap_bspline=fmap_bspline, | ||
fmap_demean=fmap_demean, | ||
use_syn=use_syn, | ||
force_syn=force_syn, | ||
debug=debug, | ||
output_grid_ref=output_grid_ref, | ||
use_aroma=use_aroma, | ||
ignore_aroma_err=ignore_aroma_err, | ||
) | ||
workflow.connect([ | ||
(anat_preproc_wf, func_preproc_wf, | ||
[('outputnode.t1_preproc', 'inputnode.t1_preproc'), | ||
('outputnode.t1_brain', 'inputnode.t1_brain'), | ||
('outputnode.t1_mask', 'inputnode.t1_mask'), | ||
('outputnode.t1_seg', 'inputnode.t1_seg'), | ||
('outputnode.t1_tpms', 'inputnode.t1_tpms'), | ||
('outputnode.t1_2_mni_forward_transform', | ||
'inputnode.t1_2_mni_forward_transform'), | ||
('outputnode.t1_2_mni_reverse_transform', | ||
'inputnode.t1_2_mni_reverse_transform'), | ||
# Undefined if --no-freesurfer, but this is safe | ||
('outputnode.subjects_dir', 'inputnode.subjects_dir'), | ||
('outputnode.subject_id', 'inputnode.subject_id'), | ||
('outputnode.t1_2_fsnative_forward_transform', | ||
'inputnode.t1_2_fsnative_forward_transform'), | ||
('outputnode.t1_2_fsnative_reverse_transform', | ||
'inputnode.t1_2_fsnative_reverse_transform')]), | ||
]) | ||
|
||
else: | ||
func_preproc_wf = init_onlyfunc_preproc_wf( | ||
bold_file=bold_file, | ||
layout=layout, | ||
ignore=ignore, | ||
reportlets_dir=reportlets_dir, | ||
output_dir=output_dir, | ||
omp_nthreads=omp_nthreads, | ||
low_mem=low_mem, | ||
fmap_bspline=fmap_bspline, | ||
fmap_demean=fmap_demean, | ||
debug=debug, | ||
use_aroma=use_aroma, | ||
ignore_aroma_err=ignore_aroma_err, | ||
) | ||
|
||
workflow.connect([ | ||
(inputnode, func_preproc_wf, [('subjects_dir', 'inputnode.subjects_dir')]), | ||
(bidssrc, bids_info, [ | ||
(('bold', fix_multi_bold_source_name), 'in_file')]), | ||
(inputnode, summary, [('subjects_dir', 'subjects_dir')]), | ||
(bidssrc, summary, [('bold', 'bold')]), | ||
(bids_info, summary, [('subject_id', 'subject_id')]), | ||
(bidssrc, func_preproc_wf, [('bold', 'inputnode.bold')]), | ||
(summary, func_preproc_wf, [('subject_id', 'inputnode.subject_id')]), | ||
(bidssrc, ds_summary_report, [ | ||
(('bold', fix_multi_bold_source_name), 'source_file')]), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
(summary, ds_summary_report, [('out_report', 'in_file')]), | ||
(bidssrc, ds_about_report, [ | ||
(('bold', fix_multi_bold_source_name), 'source_file')]), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
(about, ds_about_report, [('out_report', 'in_file')]), | ||
]) | ||
|
||
return workflow |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
fix_multi_bold_source_name
is undefinedThere 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 assumed there was an analog to fic_multi_t1w_source_name, which pops up in the anat_only workflow.