Skip to content

Commit

Permalink
Merge pull request #344 from mgxd/mnt/debug-sloppy
Browse files Browse the repository at this point in the history
MNT: Add `sloppy` argument to workflows, distinguish from `debug`
  • Loading branch information
effigies authored Jun 2, 2023
2 parents 0cd77e3 + 60f0266 commit c2158aa
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
3 changes: 2 additions & 1 deletion smriprep/cli/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,8 @@ def build_workflow(opts, retval):

# Build main workflow
retval["workflow"] = init_smriprep_wf(
debug=opts.sloppy,
sloppy=opts.sloppy,
debug=False,
fast_track=opts.fast_track,
freesurfer=opts.run_reconall,
fs_subjects_dir=opts.fs_subjects_dir,
Expand Down
7 changes: 5 additions & 2 deletions smriprep/workflows/anatomical.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def init_anat_preproc_wf(
spaces,
cifti_output=False,
debug=False,
sloppy=False,
existing_derivatives=None,
name="anat_preproc_wf",
skull_strip_fixed_seed=False,
Expand Down Expand Up @@ -142,6 +143,8 @@ def init_anat_preproc_wf(
Object containing standard and nonstandard space specifications.
debug : :obj:`bool`
Enable debugging outputs
sloppy: :obj:`bool`
Quick, impercise operations. Used to decrease workflow duration.
name : :obj:`str`, optional
Workflow name (default: anat_preproc_wf)
skull_strip_mode : :obj:`str`
Expand Down Expand Up @@ -393,12 +396,12 @@ def _check_img(img):
template_spec=skull_strip_template.spec,
atropos_use_random_seed=not skull_strip_fixed_seed,
omp_nthreads=omp_nthreads,
normalization_quality="precise" if not debug else "testing",
normalization_quality="precise" if not sloppy else "testing",
)

# 4. Spatial normalization
anat_norm_wf = init_anat_norm_wf(
debug=debug,
sloppy=sloppy,
omp_nthreads=omp_nthreads,
templates=spaces.get_spaces(nonstandard=False, dim=(3,)),
)
Expand Down
10 changes: 10 additions & 0 deletions smriprep/workflows/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

def init_smriprep_wf(
*,
sloppy,
debug,
fast_track,
freesurfer,
Expand Down Expand Up @@ -80,6 +81,7 @@ def init_smriprep_wf(
from smriprep.workflows.base import init_smriprep_wf
from niworkflows.utils.spaces import SpatialReferences, Reference
wf = init_smriprep_wf(
sloppy=False,
debug=False,
fast_track=False,
freesurfer=True,
Expand All @@ -102,6 +104,8 @@ def init_smriprep_wf(
Parameters
----------
sloppy: :obj:`bool`
Quick, impercise operations. Used to decrease workflow duration.
debug : :obj:`bool`
Enable debugging outputs
fast_track : :obj:`bool`
Expand Down Expand Up @@ -164,6 +168,7 @@ def init_smriprep_wf(

for subject_id in subject_list:
single_subject_wf = init_single_subject_wf(
sloppy=sloppy,
debug=debug,
freesurfer=freesurfer,
fast_track=fast_track,
Expand Down Expand Up @@ -199,6 +204,7 @@ def init_smriprep_wf(

def init_single_subject_wf(
*,
sloppy,
debug,
fast_track,
freesurfer,
Expand Down Expand Up @@ -238,6 +244,7 @@ def init_single_subject_wf(
from smriprep.workflows.base import init_single_subject_wf
BIDSLayout = namedtuple('BIDSLayout', ['root'])
wf = init_single_subject_wf(
sloppy=False,
debug=False,
freesurfer=True,
fast_track=False,
Expand All @@ -258,6 +265,8 @@ def init_single_subject_wf(
Parameters
----------
sloppy: :obj:`bool`
Quick, impercise operations. Used to decrease workflow duration.
debug : :obj:`bool`
Enable debugging outputs
fast_track : :obj:`bool`
Expand Down Expand Up @@ -400,6 +409,7 @@ def init_single_subject_wf(
# Preprocessing of T1w (includes registration to MNI)
anat_preproc_wf = init_anat_preproc_wf(
bids_root=layout.root,
sloppy=sloppy,
debug=debug,
existing_derivatives=deriv_cache,
freesurfer=freesurfer,
Expand Down
10 changes: 5 additions & 5 deletions smriprep/workflows/norm.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

def init_anat_norm_wf(
*,
debug,
sloppy,
omp_nthreads,
templates,
name="anat_norm_wf",
Expand All @@ -53,7 +53,7 @@ def init_anat_norm_wf(
from smriprep.workflows.norm import init_anat_norm_wf
wf = init_anat_norm_wf(
debug=False,
sloppy=False,
omp_nthreads=1,
templates=['MNI152NLin2009cAsym', 'MNI152NLin6Asym'],
)
Expand All @@ -70,7 +70,7 @@ def init_anat_norm_wf(
Parameters
----------
debug : :obj:`bool`
sloppy : :obj:`bool`
Apply sloppy arguments to speed up processing. Use with caution,
registration processes will be very inaccurate.
omp_nthreads : :obj:`int`
Expand Down Expand Up @@ -194,7 +194,7 @@ def init_anat_norm_wf(
split_desc = pe.Node(TemplateDesc(), run_without_submitting=True, name="split_desc")

tf_select = pe.Node(
TemplateFlowSelect(resolution=1 + debug),
TemplateFlowSelect(resolution=1 + sloppy),
name="tf_select",
run_without_submitting=True,
)
Expand All @@ -208,7 +208,7 @@ def init_anat_norm_wf(
registration = pe.Node(
SpatialNormalization(
float=True,
flavor=["precise", "testing"][debug],
flavor=["precise", "testing"][sloppy],
),
name="registration",
n_procs=omp_nthreads,
Expand Down

0 comments on commit c2158aa

Please sign in to comment.