Skip to content

Commit 737e62c

Browse files
authored
Merge pull request #271 from madisoth/enh/t2-vol-out
ENH: Add preprocessed T2w volume to outputs
2 parents 5b20166 + 0e2861f commit 737e62c

File tree

4 files changed

+73
-31
lines changed

4 files changed

+73
-31
lines changed

.circleci/bcp_anat_outputs.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,4 @@ sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-MNIInfant_cohort-1_dseg.nii.gz
4747
sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-MNIInfant_cohort-1_label-CSF_probseg.nii.gz
4848
sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-MNIInfant_cohort-1_label-GM_probseg.nii.gz
4949
sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-MNIInfant_cohort-1_label-WM_probseg.nii.gz
50+
sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-T1w_desc-preproc_T2w.nii.gz

.circleci/bcp_full_outputs.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-MNIInfant_cohort-1_dseg.nii.gz
4747
sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-MNIInfant_cohort-1_label-CSF_probseg.nii.gz
4848
sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-MNIInfant_cohort-1_label-GM_probseg.nii.gz
4949
sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-MNIInfant_cohort-1_label-WM_probseg.nii.gz
50+
sub-01/ses-1mo/anat/sub-01_ses-1mo_run-001_space-T1w_desc-preproc_T2w.nii.gz
5051
sub-01/ses-1mo/fmap
5152
sub-01/ses-1mo/fmap/sub-01_ses-1mo_run-001_fmapid-auto00000_desc-coeff_fieldmap.nii.gz
5253
sub-01/ses-1mo/fmap/sub-01_ses-1mo_run-001_fmapid-auto00000_desc-epi_fieldmap.nii.gz

nibabies/workflows/anatomical/base.py

Lines changed: 55 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ def init_infant_anat_wf(
7777
"""
7878
from nipype.interfaces.ants.base import Info as ANTsInfo
7979
from niworkflows.engine.workflows import LiterateWorkflow as Workflow
80+
from sdcflows.workflows.ancillary import (
81+
init_brainextraction_wf as init_sdc_brain_extraction_wf,
82+
)
8083

8184
from ...utils.misc import fix_multi_source_name
8285
from .brain_extraction import (
@@ -214,25 +217,26 @@ def init_infant_anat_wf(
214217
if precomp_mask:
215218
precomp_mask_wf = init_precomputed_mask_wf(omp_nthreads=omp_nthreads)
216219
precomp_mask_wf.inputs.inputnode.t1w_mask = precomp_mask
217-
218-
else:
219-
brain_extraction_wf = init_infant_brain_extraction_wf(
220-
age_months=age_months,
221-
ants_affine_init=ants_affine_init,
222-
skull_strip_template=skull_strip_template.space,
223-
template_specs=skull_strip_template.spec,
224-
omp_nthreads=omp_nthreads,
225-
sloppy=sloppy,
226-
debug="registration" in config.execution.debug,
227-
)
228-
coregistration_wf = init_coregistration_wf(
229-
omp_nthreads=omp_nthreads,
230-
sloppy=sloppy,
231-
debug="registration" in config.execution.debug,
232-
)
233-
coreg_report_wf = init_coreg_report_wf(
234-
output_dir=output_dir,
220+
sdc_brain_extraction_wf = init_sdc_brain_extraction_wf(
221+
name="sdc_brain_extraction_wf",
235222
)
223+
brain_extraction_wf = init_infant_brain_extraction_wf(
224+
age_months=age_months,
225+
ants_affine_init=ants_affine_init,
226+
skull_strip_template=skull_strip_template.space,
227+
template_specs=skull_strip_template.spec,
228+
omp_nthreads=omp_nthreads,
229+
sloppy=sloppy,
230+
debug="registration" in config.execution.debug,
231+
)
232+
coregistration_wf = init_coregistration_wf(
233+
omp_nthreads=omp_nthreads,
234+
sloppy=sloppy,
235+
debug="registration" in config.execution.debug,
236+
)
237+
coreg_report_wf = init_coreg_report_wf(
238+
output_dir=output_dir,
239+
)
236240
t1w_preproc_wf = precomp_mask_wf if precomp_mask else coregistration_wf
237241

238242
# Segmentation - initial implementation should be simple: JLF
@@ -285,6 +289,9 @@ def init_infant_anat_wf(
285289
("outputnode.t1w_mask", "inputnode.t1w_mask"),
286290
("outputnode.t1w_preproc", "inputnode.t1w_preproc"),
287291
]),
292+
(coregistration_wf, anat_derivatives_wf, [
293+
("outputnode.t2w_preproc", "inputnode.t2w_preproc")
294+
]),
288295
(t1w_preproc_wf, outputnode, [
289296
("outputnode.t1w_preproc", "anat_preproc"),
290297
("outputnode.t1w_brain", "anat_brain"),
@@ -296,36 +303,50 @@ def init_infant_anat_wf(
296303
wf.connect([
297304
(t1w_preproc_wf, anat_seg_wf, [("outputnode.t1w_brain", "inputnode.anat_brain")]),
298305
])
299-
306+
wf.connect([
307+
(inputnode, t2w_template_wf, [("t2w", "inputnode.in_files")]),
308+
])
300309
if precomp_mask:
301310
wf.connect([
302311
(t1w_template_wf, precomp_mask_wf, [
303312
("outputnode.out_file", "inputnode.t1w"),
304313
]),
314+
(t2w_template_wf, sdc_brain_extraction_wf, [
315+
("outputnode.out_file", "inputnode.in_file"),
316+
]),
317+
(sdc_brain_extraction_wf, coregistration_wf, [
318+
("outputnode.out_file", "inputnode.in_t2w_preproc"),
319+
("outputnode.out_mask", "inputnode.in_mask"),
320+
("outputnode.out_probseg", "inputnode.in_probmap"),
321+
]),
305322
])
306323
else:
307324
wf.connect([
308-
(inputnode, t2w_template_wf, [("t2w", "inputnode.in_files")]),
309325
(t2w_template_wf, brain_extraction_wf, [
310326
("outputnode.out_file", "inputnode.in_t2w"),
311327
]),
312-
(t1w_template_wf, coregistration_wf, [
313-
("outputnode.out_file", "inputnode.in_t1w"),
314-
]),
315328
(brain_extraction_wf, coregistration_wf, [
316329
("outputnode.t2w_preproc", "inputnode.in_t2w_preproc"),
317330
("outputnode.out_mask", "inputnode.in_mask"),
318331
("outputnode.out_probmap", "inputnode.in_probmap"),
319332
]),
320-
(inputnode, coreg_report_wf, [
321-
("t1w", "inputnode.source_file"),
322-
]),
323-
(t1w_preproc_wf, coreg_report_wf, [
324-
("outputnode.t1w_preproc", "inputnode.t1w_preproc"),
325-
("outputnode.t2w_preproc", "inputnode.t2w_preproc"),
326-
("outputnode.t1w_mask", "inputnode.in_mask"),
327-
]),
328333
])
334+
wf.connect([
335+
(t1w_template_wf, coregistration_wf, [
336+
("outputnode.out_file", "inputnode.in_t1w"),
337+
]),
338+
339+
(inputnode, coreg_report_wf, [
340+
("t1w", "inputnode.source_file"),
341+
]),
342+
(t1w_preproc_wf, coreg_report_wf, [
343+
("outputnode.t1w_preproc", "inputnode.t1w_preproc"),
344+
("outputnode.t1w_mask", "inputnode.in_mask"),
345+
]),
346+
(coregistration_wf, coreg_report_wf, [
347+
("outputnode.t2w_preproc", "inputnode.t2w_preproc")
348+
]),
349+
])
329350

330351
wf.connect([
331352
# reports
@@ -350,6 +371,9 @@ def init_infant_anat_wf(
350371
("outputnode.valid_list", "inputnode.source_files"),
351372
("outputnode.realign_xfms", "inputnode.t1w_ref_xfms"),
352373
]),
374+
(t2w_template_wf, anat_derivatives_wf, [
375+
("outputnode.valid_list", "inputnode.t2w_source_files"),
376+
]),
353377
(anat_norm_wf, anat_derivatives_wf, [
354378
("outputnode.template", "inputnode.template"),
355379
("outputnode.anat2std_xfm", "inputnode.anat2std_xfm"),

nibabies/workflows/anatomical/outputs.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,10 @@ def init_anat_derivatives_wf(
310310
FreeSurfer's aseg segmentation, in native T1w space
311311
t1w_fs_aparc
312312
FreeSurfer's aparc+aseg segmentation, in native T1w space
313+
t2w_source_files
314+
List of input T2w images
315+
t2w_preproc
316+
The T2w image in T1w space.
313317
"""
314318
from niworkflows.interfaces.nibabel import ApplyMask
315319
from niworkflows.interfaces.utility import KeySelect
@@ -341,6 +345,8 @@ def init_anat_derivatives_wf(
341345
"morphometrics",
342346
"t1w_fs_aseg",
343347
"t1w_fs_aparc",
348+
"t2w_source_files",
349+
"t2w_preproc",
344350
]
345351
),
346352
name="inputnode",
@@ -369,6 +375,14 @@ def init_anat_derivatives_wf(
369375
run_without_submitting=True,
370376
)
371377

378+
ds_t2w_preproc = pe.Node(
379+
DerivativesDataSink(
380+
data_dtype="i2", base_directory=output_dir, space="T1w", desc="preproc", compress=True
381+
),
382+
name="ds_t2w_preproc",
383+
run_without_submitting=True,
384+
)
385+
372386
ds_t1w_tpms = pe.Node(
373387
DerivativesDataSink(base_directory=output_dir, suffix="probseg", compress=True),
374388
name="ds_t1w_tpms",
@@ -381,6 +395,8 @@ def init_anat_derivatives_wf(
381395
(inputnode, raw_sources, [('source_files', 'in_files')]),
382396
(inputnode, ds_t1w_preproc, [('t1w_preproc', 'in_file'),
383397
('source_files', 'source_file')]),
398+
(inputnode, ds_t2w_preproc, [('t2w_preproc', 'in_file'),
399+
('t2w_source_files', 'source_file')]),
384400
(inputnode, ds_t1w_mask, [('t1w_mask', 'in_file'),
385401
('source_files', 'source_file')]),
386402
(inputnode, ds_t1w_tpms, [('t1w_tpms', 'in_file'),

0 commit comments

Comments
 (0)