Skip to content

Commit 10549c3

Browse files
committed
RF: Ensure clipping of anatomical template, simplify workflow
1 parent 10bbef8 commit 10549c3

File tree

2 files changed

+14
-43
lines changed

2 files changed

+14
-43
lines changed

nibabies/workflows/anatomical/fit.py

Lines changed: 12 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -567,19 +567,11 @@ def init_infant_anat_fit_wf(
567567

568568
if not t1w_preproc:
569569
LOGGER.info('ANAT Skipping skull-strip, INU-correction only')
570-
t1w_n4_only_wf = init_n4_only_wf(
571-
omp_nthreads=omp_nthreads,
572-
atropos_use_random_seed=not skull_strip_fixed_seed,
573-
bids_suffix='T1w',
574-
name='t1w_n4_only_wf',
575-
)
570+
t1w_n4_wf = init_anat_preproc_wf(name='t1w_n4_wf')
576571
workflow.connect([
577-
(t1w_validate, t1w_n4_only_wf, [('out_file', 'inputnode.in_files')]),
578-
(t1w_n4_only_wf, t1w_buffer, [
579-
(('outputnode.bias_corrected', pop_file), 't1w_preproc'),
580-
]),
581-
(t1w_n4_only_wf, apply_t1w_mask, [
582-
(('outputnode.out_file', pop_file), 'in_file')]),
572+
(t1w_validate, t1w_n4_wf, [('out_file', 'inputnode.in_anat')]),
573+
(t1w_n4_wf, t1w_buffer, [('outputnode.anat_preproc', 't1w_preproc')]),
574+
(t1w_n4_wf, apply_t1w_mask, [('outputnode.anat_preproc', 'in_file')]),
583575
]) # fmt:skip
584576
else:
585577
LOGGER.info('ANAT Skipping T1w masking')
@@ -719,19 +711,11 @@ def init_infant_anat_fit_wf(
719711

720712
if not t2w_preproc:
721713
LOGGER.info('ANAT Skipping skull-strip, INU-correction only')
722-
t2w_n4_only_wf = init_n4_only_wf(
723-
omp_nthreads=omp_nthreads,
724-
atropos_use_random_seed=not skull_strip_fixed_seed,
725-
bids_suffix='T2w',
726-
name='t2w_n4_only_wf',
727-
)
714+
t2w_n4_wf = init_anat_preproc_wf(name='t2w_n4_wf')
728715
workflow.connect([
729-
(t2w_validate, t2w_n4_only_wf, [('out_file', 'inputnode.in_files')]),
730-
(t2w_n4_only_wf, t2w_buffer, [
731-
(('outputnode.bias_corrected', pop_file), 't2w_preproc'),
732-
]),
733-
(t2w_n4_only_wf, apply_t2w_mask, [
734-
(('outputnode.out_file', pop_file), 'in_file')]),
716+
(t2w_validate, t2w_n4_wf, [('out_file', 'inputnode.in_anat')]),
717+
(t2w_n4_wf, t2w_buffer, [('outputnode.anat_preproc', 't2w_preproc')]),
718+
(t2w_n4_wf, apply_t2w_mask, [('outputnode.anat_preproc', 'in_file')]),
735719
]) # fmt:skip
736720
else:
737721
LOGGER.info('ANAT Skipping T2w masking')
@@ -1647,18 +1631,11 @@ def init_infant_single_anat_fit_wf(
16471631

16481632
if not anat_preproc:
16491633
LOGGER.info('ANAT Skipping skull-strip, INU-correction only')
1650-
n4_only_wf = init_n4_only_wf(
1651-
omp_nthreads=omp_nthreads,
1652-
atropos_use_random_seed=not skull_strip_fixed_seed,
1653-
bids_suffix=reference_anat,
1654-
name='n4_only_wf',
1655-
)
1634+
anat_n4_wf = init_anat_preproc_wf(name='anat_n4_wf')
16561635
workflow.connect([
1657-
(anat_validate, n4_only_wf, [('out_file', 'inputnode.in_files')]),
1658-
(n4_only_wf, anat_buffer, [
1659-
(('outputnode.bias_corrected', pop_file), 'anat_preproc'),
1660-
]),
1661-
(n4_only_wf, apply_mask, [(('outputnode.out_file', pop_file), 'in_file')]),
1636+
(anat_validate, anat_n4_wf, [('out_file', 'inputnode.in_anat')]),
1637+
(anat_n4_wf, anat_buffer, [('outputnode.anat_preproc', 'anat_preproc')]),
1638+
(anat_n4_wf, apply_mask, [('outputnode.anat_preproc', 'in_file')]),
16621639
]) # fmt:skip
16631640
else:
16641641
LOGGER.info(f'ANAT Skipping {reference_anat} masking')

nibabies/workflows/anatomical/preproc.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@ def init_anat_preproc_wf(
1212
1313
This workflow accepts T1w/T2w images as inputs (either raw or a merged template) and performs:
1414
- Intensity clipping
15-
- Denoising
1615
- N4 Bias Field Correction
1716
18-
The outputs of this workflow will be used to either create the brainmask,
19-
or reconstruct the cortical surfaces.
17+
The outputs of this workflow will be a structural reference used for subsequent processing.
2018
2119
Inputs
2220
------
@@ -45,7 +43,6 @@ def init_anat_preproc_wf(
4543
# validate image
4644
validate = pe.Node(ValidateImage(), name='anat_validate', run_without_submitting=True)
4745
clip = pe.Node(IntensityClip(p_min=10.0, p_max=99.5), name='clip')
48-
# denoise = pe.Node(DenoiseImage(dimension=3, noise_model="Rician"), name="denoise")
4946
n4_correct = pe.Node(
5047
N4BiasFieldCorrection(
5148
dimension=3,
@@ -61,14 +58,11 @@ def init_anat_preproc_wf(
6158
)
6259
final_clip = pe.Node(IntensityClip(p_min=5.0, p_max=99.5), name='final_clip')
6360

64-
# fmt:off
6561
wf.connect([
6662
(inputnode, validate, [('in_anat', 'in_file')]),
6763
(validate, clip, [('out_file', 'in_file')]),
6864
(clip, n4_correct, [('out_file', 'input_image')]),
69-
# (denoise, n4_correct, [("output_image", "input_image")]),
7065
(n4_correct, final_clip, [('output_image', 'in_file')]),
7166
(final_clip, outputnode, [('out_file', 'anat_preproc')]),
72-
])
73-
# fmt:on
67+
]) # fmt:skip
7468
return wf

0 commit comments

Comments
 (0)