From acda670126ecc3b88f77e59a7056d8c4e1118e9e Mon Sep 17 00:00:00 2001 From: anroy1 Date: Wed, 11 Sep 2024 02:07:56 +0000 Subject: [PATCH] main dev, add test and meta --- subworkflows/nf-scil/registration/main.nf | 21 +++++++++++++++++-- subworkflows/nf-scil/registration/meta.yml | 16 ++++++++++++++ .../nf-scil/registration/tests/main.nf.test | 1 + .../tests/nextflow_surgery.config | 1 + 4 files changed, 37 insertions(+), 2 deletions(-) diff --git a/subworkflows/nf-scil/registration/main.nf b/subworkflows/nf-scil/registration/main.nf index 431d7914..18cd0313 100644 --- a/subworkflows/nf-scil/registration/main.nf +++ b/subworkflows/nf-scil/registration/main.nf @@ -34,14 +34,17 @@ workflow REGISTRATION { // ** Setting outputs ** // image_warped = REGISTRATION_ANATTODWI.out.t1_warped + ref_warped = Channel.empty() transfo_image = REGISTRATION_ANATTODWI.out.transfo_image transfo_trk = REGISTRATION_ANATTODWI.out.transfo_trk + ref_segmentation = Channel.empty() + image_segmentation = Channel.empty() } else if ( params.run_surgery ) { // ** Set up input channel ** // ch_register = ch_ref.combine(ch_image, by: 0) - .combine(ch_ref_segmentation) - .combine(ch_flo_segmentation) + .combine(ch_ref_segmentation, by: 0) + .combine(ch_flo_segmentation, by: 0) // ** Registration using Easyreg ** // REGISTRATION_EASYREG ( ch_register ) @@ -50,7 +53,15 @@ workflow REGISTRATION { // ** Setting outputs ** // image_warped = REGISTRATION_EASYREG.out.flo_reg transfo_image = REGISTRATION_EASYREG.out.fwd_field + .map{ it + [[]] } transfo_trk = REGISTRATION_EASYREG.out.bak_field + .map{ [[]] + it } + ref_warped - REGISTRATON_EASYREG.out.ref_reg + + // ** Setting optional outputs. If segmentations are not provided as inputs, ** // + // ** easyreg will outputs synthseg segmentations ** // + ref_segmentation = ch_ref_segmentation ? REGISTRATION_EASYREG.out.ref_seg : Channel.empty() + flo_segmentation = ch_ref_segmentation ? REGISTRATION_EASYREG.out.flo_seg : Channel.empty() } else { @@ -72,14 +83,20 @@ workflow REGISTRATION { // ** Setting outputs ** // image_warped = REGISTRATION_ANTS.out.image + ref_warped = Channel.empty() transfo_image = REGISTRATION_ANTS.out.transfo_image transfo_trk = REGISTRATION_ANTS.out.transfo_trk + ref_segmentation = Channel.empty() + flo_segmentation = Channel.empty() } emit: image_warped = image_warped // channel: [ val(meta), [ image ] ] + ref_warped = ref_warped // channel: [ val(meta), [ ref ] ] transfo_image = transfo_image // channel: [ val(meta), [ warp, affine ] ] transfo_trk = transfo_trk // channel: [ val(meta), [ inverseAffine, inverseWarp ] ] + ref_segmentation = ref_segmentation // channel: [ val(meta), [ ref_seg ] ] + flo_segmentation = flo_segmentation // channel: [ val(meta), [ flo_seg ] ] versions = ch_versions // channel: [ versions.yml ] } diff --git a/subworkflows/nf-scil/registration/meta.yml b/subworkflows/nf-scil/registration/meta.yml index fc8dbac6..3ac849dd 100644 --- a/subworkflows/nf-scil/registration/meta.yml +++ b/subworkflows/nf-scil/registration/meta.yml @@ -75,6 +75,12 @@ output: Channel containing warped moving images. Typically, this would be the warped T1 in DWI space. Structure: [ val(meta), path(image) ] pattern: "*.{nii,nii.gz}" + - ref_warped: + type: file + description: | + Channel containing warped reference images. Typically, this would be the warped T1 in DWI space. + Structure: [ val(meta), path(image) ] + pattern: "*.{nii,nii.gz}" - transfo_image: type: file description: | @@ -91,6 +97,16 @@ output: be used to register tractograms or bundle in the subject's anatomical space. Structure: [ val(meta), [ path(inverseAffine), path(inverseWarp) ] pattern: "*.{nii,nii.gz,mat}" + - ref_segmentation: + type: file + description: | + Channel containing the file with the SynthSeg v2 (non-robust) segmentation + parcellation of the reference image. + pattern: "*.{nii,nii.gz}" + - flo_segmentation: + type: file + description: | + Channel containing the file with the SynthSeg v2 (non-robust) segmentation + parcellation of the floating image. + pattern: "*.{nii,nii.gz}" - versions: type: file description: | diff --git a/subworkflows/nf-scil/registration/tests/main.nf.test b/subworkflows/nf-scil/registration/tests/main.nf.test index 30fce84a..887d6e9e 100644 --- a/subworkflows/nf-scil/registration/tests/main.nf.test +++ b/subworkflows/nf-scil/registration/tests/main.nf.test @@ -12,6 +12,7 @@ nextflow_workflow { tag "registration/anattodwi" tag "registration" tag "registration/ants" + tag "registration/easyreg" tag "load_test_data" diff --git a/subworkflows/nf-scil/registration/tests/nextflow_surgery.config b/subworkflows/nf-scil/registration/tests/nextflow_surgery.config index 2b62445f..dffb4b8c 100644 --- a/subworkflows/nf-scil/registration/tests/nextflow_surgery.config +++ b/subworkflows/nf-scil/registration/tests/nextflow_surgery.config @@ -1,6 +1,7 @@ process { withName: "REGISTRATION_EASYREG" { publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } + ext.field = true } }