From 3877194a47dd1b40ddd84e4e3780c7835807d1c2 Mon Sep 17 00:00:00 2001 From: anroy1 Date: Tue, 29 Oct 2024 14:11:15 +0000 Subject: [PATCH 1/2] update main --- subworkflows/nf-neuro/preproc_t1/main.nf | 40 +++++++++++++++++------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/subworkflows/nf-neuro/preproc_t1/main.nf b/subworkflows/nf-neuro/preproc_t1/main.nf index c2e9d83..ee2f9fb 100644 --- a/subworkflows/nf-neuro/preproc_t1/main.nf +++ b/subworkflows/nf-neuro/preproc_t1/main.nf @@ -25,23 +25,37 @@ workflow PREPROC_T1 { ch_versions = Channel.empty() // ** Denoising ** // - ch_nlmeans = ch_image.join(ch_mask_nlmeans) + ch_nlmeans = ch_image + .join(ch_mask_nlmeans, remainder: true) + .map{ it[0..1] + [it[2] ?: []] } + DENOISING_NLMEANS ( ch_nlmeans ) ch_versions = ch_versions.mix(DENOISING_NLMEANS.out.versions.first()) // ** N4 correction ** // - ch_N4 = DENOISING_NLMEANS.out.image.join(ch_ref_n4) + ch_N4 = DENOISING_NLMEANS.out.image + .join(ch_ref_n4, remainder: true) + .map{ it[0..1] + [it[2] ?: []] } + .join(ch_mask_nlmeans, remainder: true) + .map{ it[0..2] + [it[3] ?: []] } + PREPROC_N4 ( ch_N4 ) ch_versions = ch_versions.mix(PREPROC_N4.out.versions.first()) // ** Resampling ** // - ch_resampling = PREPROC_N4.out.image.join(ch_ref_resample) + ch_resampling = PREPROC_N4.out.image + .join(ch_ref_resample, remainder: true) + .map{ it[0..1] + [it[2] ?: []] } + IMAGE_RESAMPLE ( ch_resampling ) ch_versions = ch_versions.mix(IMAGE_RESAMPLE.out.versions.first()) // ** Brain extraction ** // if ( params.run_synthbet) { - ch_bet = IMAGE_RESAMPLE.out.image.join(ch_weights) + ch_bet = IMAGE_RESAMPLE.out.image + .join(ch_weights, remainder: true) + .map{ it[0..1] + [it[2] ?: []] } + BETCROP_SYNTHBET ( ch_bet ) ch_versions = ch_versions.mix(BETCROP_SYNTHBET.out.versions.first()) @@ -51,9 +65,10 @@ workflow PREPROC_T1 { } else { - ch_template = ch_template.ifEmpty(Channel.error('Template is required for ANTS registration')) - ch_probability_map = ch_probability_map.ifEmpty(Channel.error('Probability map is required for ANTS registration')) - ch_bet = IMAGE_RESAMPLE.out.image.join(ch_template).join(ch_probability_map) + ch_bet = IMAGE_RESAMPLE.out.image + .join(ch_template, remainder: true) + .join(ch_probability_map, remainder: true) + BETCROP_ANTSBET ( ch_bet ) ch_versions = ch_versions.mix(BETCROP_ANTSBET.out.versions.first()) @@ -62,13 +77,16 @@ workflow PREPROC_T1 { mask_bet = BETCROP_ANTSBET.out.mask } - // ** crop image ** // - ch_crop = image_bet.map{it + [[]]} + // ** Crop image ** // + ch_crop = image_bet + .map{ it + [[]] } + BETCROP_CROPVOLUME_T1 ( ch_crop ) ch_versions = ch_versions.mix(BETCROP_CROPVOLUME_T1.out.versions.first()) - // ** crop mask ** // - ch_crop_mask = mask_bet.join(BETCROP_CROPVOLUME_T1.out.bounding_box) + // ** Crop mask ** // + ch_crop_mask = mask_bet + .join(BETCROP_CROPVOLUME_T1.out.bounding_box) BETCROP_CROPVOLUME_MASK ( ch_crop_mask ) ch_versions = ch_versions.mix(BETCROP_CROPVOLUME_MASK.out.versions.first()) From dcd9d29107e36e50dbd7c9cbf79c4d905b76a221 Mon Sep 17 00:00:00 2001 From: anroy1 Date: Fri, 1 Nov 2024 00:52:53 +0000 Subject: [PATCH 2/2] Remove remainder to antsbet inputs --- subworkflows/nf-neuro/preproc_t1/main.nf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/subworkflows/nf-neuro/preproc_t1/main.nf b/subworkflows/nf-neuro/preproc_t1/main.nf index ee2f9fb..29552a7 100644 --- a/subworkflows/nf-neuro/preproc_t1/main.nf +++ b/subworkflows/nf-neuro/preproc_t1/main.nf @@ -66,8 +66,8 @@ workflow PREPROC_T1 { else { ch_bet = IMAGE_RESAMPLE.out.image - .join(ch_template, remainder: true) - .join(ch_probability_map, remainder: true) + .join(ch_template) + .join(ch_probability_map) BETCROP_ANTSBET ( ch_bet ) ch_versions = ch_versions.mix(BETCROP_ANTSBET.out.versions.first())