From f261cd93018ced7d0377f8328264f4a70b9074f5 Mon Sep 17 00:00:00 2001 From: arnaudbore Date: Thu, 4 Jun 2026 13:58:00 -0400 Subject: [PATCH 01/14] fix registration + mask apply --- modules/nf-neuro/image/applymask/main.nf | 8 +- modules/nf-neuro/image/applymask/meta.yml | 10 ++ modules/nf-neuro/registration/ants/main.nf | 12 +- modules/nf-neuro/registration/ants/meta.yml | 14 -- .../registration/ants/tests/main.nf.test | 32 ---- .../registration/ants/tests/main.nf.test.snap | 142 +++++++++--------- .../bundle_seg/tests/main.nf.test.snap | 4 +- .../tests/main.nf.test.snap | 6 +- subworkflows/nf-neuro/registration/main.nf | 14 +- subworkflows/nf-neuro/registration/meta.yml | 4 +- .../registration/tests/main.nf.test.snap | 17 ++- subworkflows/nf-neuro/tractoflow/main.nf | 12 +- .../nf-neuro/tractoflow/modules.config | 5 +- .../tractoflow/tests/main.nf.test.snap | 6 +- 14 files changed, 131 insertions(+), 155 deletions(-) diff --git a/modules/nf-neuro/image/applymask/main.nf b/modules/nf-neuro/image/applymask/main.nf index c5604110..c5d44ba4 100644 --- a/modules/nf-neuro/image/applymask/main.nf +++ b/modules/nf-neuro/image/applymask/main.nf @@ -16,12 +16,14 @@ process IMAGE_APPLYMASK { script: def prefix = task.ext.prefix ?: "${meta.id}" + def suffix = task.ext.first_suffix ? task.ext.first_suffix + "_masked" : "masked" def nthreads_mrtrix = task.ext.single_thread ? "-nthreads 0" : "-nthreads ${task.cpus}" + def data_type = task.ext.data_type ? "-datatype ${task.ext.data_type}" : " -datatype float32" """ export OMP_NUM_THREADS=${task.ext.single_thread ? 1 : task.cpus} - mrcalc $image $mask -mult ${prefix}_masked.nii.gz -force -quiet ${nthreads_mrtrix} + mrcalc $image $mask -mult ${prefix}_${suffix}.nii.gz -force -quiet ${nthreads_mrtrix} ${data_type} cat <<-END_VERSIONS > versions.yml "${task.process}": @@ -31,9 +33,9 @@ process IMAGE_APPLYMASK { stub: def prefix = task.ext.prefix ?: "${meta.id}" - + def suffix = task.ext.first_suffix ? task.ext.first_suffix + "_masked" : "masked" """ - touch ${prefix}_masked.nii.gz + touch ${prefix}_${suffix}.nii.gz mrcalc -h diff --git a/modules/nf-neuro/image/applymask/meta.yml b/modules/nf-neuro/image/applymask/meta.yml index 4a39a89c..fec98b23 100644 --- a/modules/nf-neuro/image/applymask/meta.yml +++ b/modules/nf-neuro/image/applymask/meta.yml @@ -32,10 +32,20 @@ input: ontologies: - edam: http://edamontology.org/format_3989 # GZIP format args: + - first_suffix: + type: string + description: Suffix for the output image file. This will be used as the first part of the suffix, followed by "_masked". + default: "" - single_thread: type: boolean description: If true, the command will be run in single-threaded mode. By default, the command will use multiple threads based on the number of CPUs allocated to the task. default: false + - data_type: + type: string + description: | + Data type for the output image. Use the following format: + uint8, int16, int32, int64, float16, float32 or float64. + default: "float32" output: image: - - meta: diff --git a/modules/nf-neuro/registration/ants/main.nf b/modules/nf-neuro/registration/ants/main.nf index 46c7c2b2..05098645 100644 --- a/modules/nf-neuro/registration/ants/main.nf +++ b/modules/nf-neuro/registration/ants/main.nf @@ -6,10 +6,10 @@ process REGISTRATION_ANTS { container "scilus/scilus:2.2.2" input: - tuple val(meta), path(fixed_image), path(moving_image), path(fixed_mask), path(moving_mask) //** optional, input = [] **// + tuple val(meta), path(fixed_image), path(moving_image) output: - tuple val(meta), path("*_warped.nii.gz") , emit: image_warped + tuple val(meta), path("*_warped.nii.gz") , emit: image_warped tuple val(meta), path("*_forward1_affine.mat") , emit: forward_affine, optional: true tuple val(meta), path("*_forward0_warp.nii.gz") , emit: forward_warp, optional: true tuple val(meta), path("*_backward1_warp.nii.gz") , emit: backward_warp, optional: true @@ -18,8 +18,8 @@ process REGISTRATION_ANTS { tuple val(meta), path("*_backward*.{nii.gz,mat}", arity: '1..2') , emit: backward_image_transform tuple val(meta), path("*_backward*.{nii.gz,mat}", arity: '1..2') , emit: forward_tractogram_transform tuple val(meta), path("*_forward*.{nii.gz,mat}", arity: '1..2') , emit: backward_tractogram_transform - tuple val(meta), path("*_registration_ants_mqc.gif") , emit: mqc, optional: true - path "versions.yml" , emit: versions + tuple val(meta), path("*_registration_ants_mqc.gif") , emit: mqc, optional: true + path "versions.yml" , emit: versions when: task.ext.when == null || task.ext.when @@ -36,10 +36,6 @@ process REGISTRATION_ANTS { def nthreads = task.ext.single_thread ? 1 : task.cpus args += " -n $nthreads" - if ( fixed_mask || moving_mask ) { - args += " -x \"${fixed_mask ?: 'NULL'},${moving_mask ?: 'NULL'}\"" - } - if ( task.ext.initial_transform ) args += " -i [$fixed_image,$moving_image,${initialization_types[task.ext.initial_transform]}]" if ( task.ext.histogram_bins ) args += " -r $task.ext.histogram_bins" if ( task.ext.spline_distance ) args += " -s $task.ext.spline_distance" diff --git a/modules/nf-neuro/registration/ants/meta.yml b/modules/nf-neuro/registration/ants/meta.yml index 1ace418e..1bf98c95 100644 --- a/modules/nf-neuro/registration/ants/meta.yml +++ b/modules/nf-neuro/registration/ants/meta.yml @@ -145,20 +145,6 @@ input: mandatory: true ontologies: - edam: http://edamontology.org/format_4001 # NIFTI format - - fixed_mask: - type: file - description: Mask(s) for the fixed image space - pattern: "*.{nii,nii.gz}" - mandatory: false - ontologies: - - edam: http://edamontology.org/format_4001 # NIFTI format - - moving_mask: - type: file - description: Mask(s) for the moving image space - pattern: "*.{nii,nii.gz}" - mandatory: false - ontologies: - - edam: http://edamontology.org/format_4001 # NIFTI format output: image_warped: - - meta: diff --git a/modules/nf-neuro/registration/ants/tests/main.nf.test b/modules/nf-neuro/registration/ants/tests/main.nf.test index f11029fb..ae0b3b5b 100644 --- a/modules/nf-neuro/registration/ants/tests/main.nf.test +++ b/modules/nf-neuro/registration/ants/tests/main.nf.test @@ -46,16 +46,8 @@ nextflow_process { file("\${test_data_directory}/t1.nii.gz") ] } - ch_T1w_mask = ch_split_test_data.T1w.map{ - test_data_directory -> [ - [ id:'test' ], - file("\${test_data_directory}/T1w_mask.nii.gz") - ] - } input[0] = ch_T1w .join(ch_moving) - .join(ch_T1w_mask) - .map{ meta, T1w, t1, T1w_mask -> [meta, T1w, t1, T1w_mask, []] } """ } } @@ -89,16 +81,8 @@ nextflow_process { file("\${test_data_directory}/t1.nii.gz") ] } - ch_T1w_mask = ch_split_test_data.T1w.map{ - test_data_directory -> [ - [ id:'test' ], - file("\${test_data_directory}/T1w_mask.nii.gz") - ] - } input[0] = ch_T1w .join(ch_moving) - .join(ch_T1w_mask) - .map{ meta, T1w, t1, T1w_mask -> [meta, T1w, t1, T1w_mask, []] } """ } } @@ -132,16 +116,8 @@ nextflow_process { file("\${test_data_directory}/t1.nii.gz") ] } - ch_T1w_mask = ch_split_test_data.T1w.map{ - test_data_directory -> [ - [ id:'test' ], - file("\${test_data_directory}/T1w_mask.nii.gz") - ] - } input[0] = ch_T1w .join(ch_moving) - .join(ch_T1w_mask) - .map{ meta, T1w, t1, T1w_mask -> [meta, T1w, t1, T1w_mask, []] } """ } } @@ -176,16 +152,8 @@ nextflow_process { file("\${test_data_directory}/t1.nii.gz") ] } - ch_T1w_mask = ch_split_test_data.T1w.map{ - test_data_directory -> [ - [ id:'test' ], - file("\${test_data_directory}/T1w_mask.nii.gz") - ] - } input[0] = ch_T1w .join(ch_moving) - .join(ch_T1w_mask) - .map{ meta, T1w, t1, T1w_mask -> [meta, T1w, t1, T1w_mask, []] } """ } } diff --git a/modules/nf-neuro/registration/ants/tests/main.nf.test.snap b/modules/nf-neuro/registration/ants/tests/main.nf.test.snap index a439947c..88cc7ac1 100644 --- a/modules/nf-neuro/registration/ants/tests/main.nf.test.snap +++ b/modules/nf-neuro/registration/ants/tests/main.nf.test.snap @@ -19,7 +19,7 @@ { "id": "test" }, - "test_t1_warped.nii.gz:md5,8089d84a4f511207f26307ce92353bbb" + "test_t1_warped.nii.gz:md5,c74eb8a596f1f6959f8db828d0d9ddc1" ] ], "1": [ @@ -27,7 +27,7 @@ { "id": "test" }, - "test_forward1_affine.mat:md5,18c2ec8b5cf3fb4e038cce665eb53e7c" + "test_forward1_affine.mat:md5,41afa6fa72a013820a3d3d8ce4986002" ] ], "10": [ @@ -38,7 +38,7 @@ { "id": "test" }, - "test_forward0_warp.nii.gz:md5,d1f0ce951610683042aab377c665295d" + "test_forward0_warp.nii.gz:md5,806c26fdf31077d4b035a2009db54c95" ] ], "3": [ @@ -46,7 +46,7 @@ { "id": "test" }, - "test_backward1_warp.nii.gz:md5,e5324ab5af8cceda46e0bb642dfc02aa" + "test_backward1_warp.nii.gz:md5,4cca843970b2ed3d02ecf43a31502857" ] ], "4": [ @@ -54,7 +54,7 @@ { "id": "test" }, - "test_backward0_affine.mat:md5,ba4cdd24110970c8d08b8df39ee4fd95" + "test_backward0_affine.mat:md5,9b6845301aaeaf43a1cf9da4e4cb671f" ] ], "5": [ @@ -63,8 +63,8 @@ "id": "test" }, [ - "test_forward0_warp.nii.gz:md5,d1f0ce951610683042aab377c665295d", - "test_forward1_affine.mat:md5,18c2ec8b5cf3fb4e038cce665eb53e7c" + "test_forward0_warp.nii.gz:md5,806c26fdf31077d4b035a2009db54c95", + "test_forward1_affine.mat:md5,41afa6fa72a013820a3d3d8ce4986002" ] ] ], @@ -74,8 +74,8 @@ "id": "test" }, [ - "test_backward0_affine.mat:md5,ba4cdd24110970c8d08b8df39ee4fd95", - "test_backward1_warp.nii.gz:md5,e5324ab5af8cceda46e0bb642dfc02aa" + "test_backward0_affine.mat:md5,9b6845301aaeaf43a1cf9da4e4cb671f", + "test_backward1_warp.nii.gz:md5,4cca843970b2ed3d02ecf43a31502857" ] ] ], @@ -85,8 +85,8 @@ "id": "test" }, [ - "test_backward0_affine.mat:md5,ba4cdd24110970c8d08b8df39ee4fd95", - "test_backward1_warp.nii.gz:md5,e5324ab5af8cceda46e0bb642dfc02aa" + "test_backward0_affine.mat:md5,9b6845301aaeaf43a1cf9da4e4cb671f", + "test_backward1_warp.nii.gz:md5,4cca843970b2ed3d02ecf43a31502857" ] ] ], @@ -96,8 +96,8 @@ "id": "test" }, [ - "test_forward0_warp.nii.gz:md5,d1f0ce951610683042aab377c665295d", - "test_forward1_affine.mat:md5,18c2ec8b5cf3fb4e038cce665eb53e7c" + "test_forward0_warp.nii.gz:md5,806c26fdf31077d4b035a2009db54c95", + "test_forward1_affine.mat:md5,41afa6fa72a013820a3d3d8ce4986002" ] ] ], @@ -106,7 +106,7 @@ { "id": "test" }, - "test_T1_to_T1_slab_registration_ants_mqc.gif:md5,fba29c34dd2cebde98e9c72e5c991550" + "test_T1_to_T1_slab_registration_ants_mqc.gif:md5,b685aa586e6b61196b442740c1056eb5" ] ], "backward_affine": [ @@ -114,7 +114,7 @@ { "id": "test" }, - "test_backward0_affine.mat:md5,ba4cdd24110970c8d08b8df39ee4fd95" + "test_backward0_affine.mat:md5,9b6845301aaeaf43a1cf9da4e4cb671f" ] ], "backward_image_transform": [ @@ -123,8 +123,8 @@ "id": "test" }, [ - "test_backward0_affine.mat:md5,ba4cdd24110970c8d08b8df39ee4fd95", - "test_backward1_warp.nii.gz:md5,e5324ab5af8cceda46e0bb642dfc02aa" + "test_backward0_affine.mat:md5,9b6845301aaeaf43a1cf9da4e4cb671f", + "test_backward1_warp.nii.gz:md5,4cca843970b2ed3d02ecf43a31502857" ] ] ], @@ -134,8 +134,8 @@ "id": "test" }, [ - "test_forward0_warp.nii.gz:md5,d1f0ce951610683042aab377c665295d", - "test_forward1_affine.mat:md5,18c2ec8b5cf3fb4e038cce665eb53e7c" + "test_forward0_warp.nii.gz:md5,806c26fdf31077d4b035a2009db54c95", + "test_forward1_affine.mat:md5,41afa6fa72a013820a3d3d8ce4986002" ] ] ], @@ -144,7 +144,7 @@ { "id": "test" }, - "test_backward1_warp.nii.gz:md5,e5324ab5af8cceda46e0bb642dfc02aa" + "test_backward1_warp.nii.gz:md5,4cca843970b2ed3d02ecf43a31502857" ] ], "forward_affine": [ @@ -152,7 +152,7 @@ { "id": "test" }, - "test_forward1_affine.mat:md5,18c2ec8b5cf3fb4e038cce665eb53e7c" + "test_forward1_affine.mat:md5,41afa6fa72a013820a3d3d8ce4986002" ] ], "forward_image_transform": [ @@ -161,8 +161,8 @@ "id": "test" }, [ - "test_forward0_warp.nii.gz:md5,d1f0ce951610683042aab377c665295d", - "test_forward1_affine.mat:md5,18c2ec8b5cf3fb4e038cce665eb53e7c" + "test_forward0_warp.nii.gz:md5,806c26fdf31077d4b035a2009db54c95", + "test_forward1_affine.mat:md5,41afa6fa72a013820a3d3d8ce4986002" ] ] ], @@ -172,8 +172,8 @@ "id": "test" }, [ - "test_backward0_affine.mat:md5,ba4cdd24110970c8d08b8df39ee4fd95", - "test_backward1_warp.nii.gz:md5,e5324ab5af8cceda46e0bb642dfc02aa" + "test_backward0_affine.mat:md5,9b6845301aaeaf43a1cf9da4e4cb671f", + "test_backward1_warp.nii.gz:md5,4cca843970b2ed3d02ecf43a31502857" ] ] ], @@ -182,7 +182,7 @@ { "id": "test" }, - "test_forward0_warp.nii.gz:md5,d1f0ce951610683042aab377c665295d" + "test_forward0_warp.nii.gz:md5,806c26fdf31077d4b035a2009db54c95" ] ], "image_warped": [ @@ -190,7 +190,7 @@ { "id": "test" }, - "test_t1_warped.nii.gz:md5,8089d84a4f511207f26307ce92353bbb" + "test_t1_warped.nii.gz:md5,c74eb8a596f1f6959f8db828d0d9ddc1" ] ], "mqc": [ @@ -198,7 +198,7 @@ { "id": "test" }, - "test_T1_to_T1_slab_registration_ants_mqc.gif:md5,fba29c34dd2cebde98e9c72e5c991550" + "test_T1_to_T1_slab_registration_ants_mqc.gif:md5,b685aa586e6b61196b442740c1056eb5" ] ], "versions": [ @@ -210,7 +210,7 @@ "nf-test": "0.9.3", "nextflow": "25.10.2" }, - "timestamp": "2026-06-03T22:41:08.268383497" + "timestamp": "2026-06-04T10:27:29.392349393" }, "registration - ants - SyN": { "content": [ @@ -220,7 +220,7 @@ { "id": "test" }, - "test_t1_warped.nii.gz:md5,02ff01272aadd0acca8672c444678a7b" + "test_t1_warped.nii.gz:md5,7c5756d1bdcf72eac1541e9c5d98f9db" ] ], "1": [ @@ -228,7 +228,7 @@ { "id": "test" }, - "test_forward1_affine.mat:md5,872eb964ad5deaeea7f492924b404cb8" + "test_forward1_affine.mat:md5,0fb5879b315f32bb8e06aa2993009115" ] ], "10": [ @@ -239,7 +239,7 @@ { "id": "test" }, - "test_forward0_warp.nii.gz:md5,439c1de9d275d39a203e2806ada000c7" + "test_forward0_warp.nii.gz:md5,a32206a00e93b79054e9b8fa0f7c8015" ] ], "3": [ @@ -247,7 +247,7 @@ { "id": "test" }, - "test_backward1_warp.nii.gz:md5,cd5d6021085ac029614fa525ceaf9847" + "test_backward1_warp.nii.gz:md5,4e85fa2257f7364fde205adfa1b3c8d3" ] ], "4": [ @@ -255,7 +255,7 @@ { "id": "test" }, - "test_backward0_affine.mat:md5,e92fa10025dc221232530b0b23f9ed4b" + "test_backward0_affine.mat:md5,ff00be1483698e5478bfa94abf2b42b2" ] ], "5": [ @@ -264,8 +264,8 @@ "id": "test" }, [ - "test_forward0_warp.nii.gz:md5,439c1de9d275d39a203e2806ada000c7", - "test_forward1_affine.mat:md5,872eb964ad5deaeea7f492924b404cb8" + "test_forward0_warp.nii.gz:md5,a32206a00e93b79054e9b8fa0f7c8015", + "test_forward1_affine.mat:md5,0fb5879b315f32bb8e06aa2993009115" ] ] ], @@ -275,8 +275,8 @@ "id": "test" }, [ - "test_backward0_affine.mat:md5,e92fa10025dc221232530b0b23f9ed4b", - "test_backward1_warp.nii.gz:md5,cd5d6021085ac029614fa525ceaf9847" + "test_backward0_affine.mat:md5,ff00be1483698e5478bfa94abf2b42b2", + "test_backward1_warp.nii.gz:md5,4e85fa2257f7364fde205adfa1b3c8d3" ] ] ], @@ -286,8 +286,8 @@ "id": "test" }, [ - "test_backward0_affine.mat:md5,e92fa10025dc221232530b0b23f9ed4b", - "test_backward1_warp.nii.gz:md5,cd5d6021085ac029614fa525ceaf9847" + "test_backward0_affine.mat:md5,ff00be1483698e5478bfa94abf2b42b2", + "test_backward1_warp.nii.gz:md5,4e85fa2257f7364fde205adfa1b3c8d3" ] ] ], @@ -297,8 +297,8 @@ "id": "test" }, [ - "test_forward0_warp.nii.gz:md5,439c1de9d275d39a203e2806ada000c7", - "test_forward1_affine.mat:md5,872eb964ad5deaeea7f492924b404cb8" + "test_forward0_warp.nii.gz:md5,a32206a00e93b79054e9b8fa0f7c8015", + "test_forward1_affine.mat:md5,0fb5879b315f32bb8e06aa2993009115" ] ] ], @@ -310,7 +310,7 @@ { "id": "test" }, - "test_backward0_affine.mat:md5,e92fa10025dc221232530b0b23f9ed4b" + "test_backward0_affine.mat:md5,ff00be1483698e5478bfa94abf2b42b2" ] ], "backward_image_transform": [ @@ -319,8 +319,8 @@ "id": "test" }, [ - "test_backward0_affine.mat:md5,e92fa10025dc221232530b0b23f9ed4b", - "test_backward1_warp.nii.gz:md5,cd5d6021085ac029614fa525ceaf9847" + "test_backward0_affine.mat:md5,ff00be1483698e5478bfa94abf2b42b2", + "test_backward1_warp.nii.gz:md5,4e85fa2257f7364fde205adfa1b3c8d3" ] ] ], @@ -330,8 +330,8 @@ "id": "test" }, [ - "test_forward0_warp.nii.gz:md5,439c1de9d275d39a203e2806ada000c7", - "test_forward1_affine.mat:md5,872eb964ad5deaeea7f492924b404cb8" + "test_forward0_warp.nii.gz:md5,a32206a00e93b79054e9b8fa0f7c8015", + "test_forward1_affine.mat:md5,0fb5879b315f32bb8e06aa2993009115" ] ] ], @@ -340,7 +340,7 @@ { "id": "test" }, - "test_backward1_warp.nii.gz:md5,cd5d6021085ac029614fa525ceaf9847" + "test_backward1_warp.nii.gz:md5,4e85fa2257f7364fde205adfa1b3c8d3" ] ], "forward_affine": [ @@ -348,7 +348,7 @@ { "id": "test" }, - "test_forward1_affine.mat:md5,872eb964ad5deaeea7f492924b404cb8" + "test_forward1_affine.mat:md5,0fb5879b315f32bb8e06aa2993009115" ] ], "forward_image_transform": [ @@ -357,8 +357,8 @@ "id": "test" }, [ - "test_forward0_warp.nii.gz:md5,439c1de9d275d39a203e2806ada000c7", - "test_forward1_affine.mat:md5,872eb964ad5deaeea7f492924b404cb8" + "test_forward0_warp.nii.gz:md5,a32206a00e93b79054e9b8fa0f7c8015", + "test_forward1_affine.mat:md5,0fb5879b315f32bb8e06aa2993009115" ] ] ], @@ -368,8 +368,8 @@ "id": "test" }, [ - "test_backward0_affine.mat:md5,e92fa10025dc221232530b0b23f9ed4b", - "test_backward1_warp.nii.gz:md5,cd5d6021085ac029614fa525ceaf9847" + "test_backward0_affine.mat:md5,ff00be1483698e5478bfa94abf2b42b2", + "test_backward1_warp.nii.gz:md5,4e85fa2257f7364fde205adfa1b3c8d3" ] ] ], @@ -378,7 +378,7 @@ { "id": "test" }, - "test_forward0_warp.nii.gz:md5,439c1de9d275d39a203e2806ada000c7" + "test_forward0_warp.nii.gz:md5,a32206a00e93b79054e9b8fa0f7c8015" ] ], "image_warped": [ @@ -386,7 +386,7 @@ { "id": "test" }, - "test_t1_warped.nii.gz:md5,02ff01272aadd0acca8672c444678a7b" + "test_t1_warped.nii.gz:md5,7c5756d1bdcf72eac1541e9c5d98f9db" ] ], "mqc": [ @@ -401,7 +401,7 @@ "nf-test": "0.9.3", "nextflow": "25.10.2" }, - "timestamp": "2026-06-04T09:14:11.394213705" + "timestamp": "2026-06-04T10:22:28.649714216" }, "registration - ants - no warps": { "content": [ @@ -411,7 +411,7 @@ { "id": "test" }, - "test_t1_warped.nii.gz:md5,938a3906d8d2ca9f500ab34c25b5dae7" + "test_t1_warped.nii.gz:md5,9f4d57c0e9cde3da4ab4718f360abce6" ] ], "1": [ @@ -419,7 +419,7 @@ { "id": "test" }, - "test_forward1_affine.mat:md5,562def074e1973a35b5e16bd8b1515d9" + "test_forward1_affine.mat:md5,72aee9284d5e624be5dbc15cfce8151c" ] ], "10": [ @@ -436,7 +436,7 @@ { "id": "test" }, - "test_backward0_affine.mat:md5,44b80fe9baf645d16299395959793d65" + "test_backward0_affine.mat:md5,862976c1966b1af64acd7b40d0f922e4" ] ], "5": [ @@ -445,7 +445,7 @@ "id": "test" }, [ - "test_forward1_affine.mat:md5,562def074e1973a35b5e16bd8b1515d9" + "test_forward1_affine.mat:md5,72aee9284d5e624be5dbc15cfce8151c" ] ] ], @@ -455,7 +455,7 @@ "id": "test" }, [ - "test_backward0_affine.mat:md5,44b80fe9baf645d16299395959793d65" + "test_backward0_affine.mat:md5,862976c1966b1af64acd7b40d0f922e4" ] ] ], @@ -465,7 +465,7 @@ "id": "test" }, [ - "test_backward0_affine.mat:md5,44b80fe9baf645d16299395959793d65" + "test_backward0_affine.mat:md5,862976c1966b1af64acd7b40d0f922e4" ] ] ], @@ -475,7 +475,7 @@ "id": "test" }, [ - "test_forward1_affine.mat:md5,562def074e1973a35b5e16bd8b1515d9" + "test_forward1_affine.mat:md5,72aee9284d5e624be5dbc15cfce8151c" ] ] ], @@ -487,7 +487,7 @@ { "id": "test" }, - "test_backward0_affine.mat:md5,44b80fe9baf645d16299395959793d65" + "test_backward0_affine.mat:md5,862976c1966b1af64acd7b40d0f922e4" ] ], "backward_image_transform": [ @@ -496,7 +496,7 @@ "id": "test" }, [ - "test_backward0_affine.mat:md5,44b80fe9baf645d16299395959793d65" + "test_backward0_affine.mat:md5,862976c1966b1af64acd7b40d0f922e4" ] ] ], @@ -506,7 +506,7 @@ "id": "test" }, [ - "test_forward1_affine.mat:md5,562def074e1973a35b5e16bd8b1515d9" + "test_forward1_affine.mat:md5,72aee9284d5e624be5dbc15cfce8151c" ] ] ], @@ -518,7 +518,7 @@ { "id": "test" }, - "test_forward1_affine.mat:md5,562def074e1973a35b5e16bd8b1515d9" + "test_forward1_affine.mat:md5,72aee9284d5e624be5dbc15cfce8151c" ] ], "forward_image_transform": [ @@ -527,7 +527,7 @@ "id": "test" }, [ - "test_forward1_affine.mat:md5,562def074e1973a35b5e16bd8b1515d9" + "test_forward1_affine.mat:md5,72aee9284d5e624be5dbc15cfce8151c" ] ] ], @@ -537,7 +537,7 @@ "id": "test" }, [ - "test_backward0_affine.mat:md5,44b80fe9baf645d16299395959793d65" + "test_backward0_affine.mat:md5,862976c1966b1af64acd7b40d0f922e4" ] ] ], @@ -549,7 +549,7 @@ { "id": "test" }, - "test_t1_warped.nii.gz:md5,938a3906d8d2ca9f500ab34c25b5dae7" + "test_t1_warped.nii.gz:md5,9f4d57c0e9cde3da4ab4718f360abce6" ] ], "mqc": [ @@ -564,6 +564,6 @@ "nf-test": "0.9.3", "nextflow": "25.10.2" }, - "timestamp": "2026-06-03T22:41:19.541042931" + "timestamp": "2026-06-04T10:27:42.101532717" } } \ No newline at end of file diff --git a/subworkflows/nf-neuro/bundle_seg/tests/main.nf.test.snap b/subworkflows/nf-neuro/bundle_seg/tests/main.nf.test.snap index debb01cf..bf141c06 100644 --- a/subworkflows/nf-neuro/bundle_seg/tests/main.nf.test.snap +++ b/subworkflows/nf-neuro/bundle_seg/tests/main.nf.test.snap @@ -36,7 +36,7 @@ "nf-test": "0.9.3", "nextflow": "25.10.2" }, - "timestamp": "2026-02-26T14:26:41.784029405" + "timestamp": "2026-06-04T13:38:16.327628109" }, "rbx - download atlas - ants registration": { "content": [ @@ -75,6 +75,6 @@ "nf-test": "0.9.3", "nextflow": "25.10.2" }, - "timestamp": "2026-06-02T20:03:03.095138057" + "timestamp": "2026-06-04T13:37:11.622705415" } } \ No newline at end of file diff --git a/subworkflows/nf-neuro/output_template_space/tests/main.nf.test.snap b/subworkflows/nf-neuro/output_template_space/tests/main.nf.test.snap index 9edc894c..5b25a6bb 100644 --- a/subworkflows/nf-neuro/output_template_space/tests/main.nf.test.snap +++ b/subworkflows/nf-neuro/output_template_space/tests/main.nf.test.snap @@ -77,7 +77,7 @@ "nf-test": "0.9.3", "nextflow": "25.10.2" }, - "timestamp": "2026-06-02T20:04:53.696301982" + "timestamp": "2026-06-04T13:39:54.610205112" }, "Template MNI152NLin2009aAsym - using synthmorph registration": { "content": [ @@ -152,7 +152,7 @@ "nf-test": "0.9.3", "nextflow": "25.10.2" }, - "timestamp": "2026-02-26T22:42:44.929412455" + "timestamp": "2026-06-04T13:40:36.60965249" }, "Template MNI152NLin2009cAsym - local templates": { "content": [ @@ -232,6 +232,6 @@ "nf-test": "0.9.3", "nextflow": "25.10.2" }, - "timestamp": "2026-06-02T20:04:18.303384843" + "timestamp": "2026-06-04T13:39:07.012635952" } } \ No newline at end of file diff --git a/subworkflows/nf-neuro/registration/main.nf b/subworkflows/nf-neuro/registration/main.nf index 01a6582a..aa3d7be0 100644 --- a/subworkflows/nf-neuro/registration/main.nf +++ b/subworkflows/nf-neuro/registration/main.nf @@ -4,7 +4,8 @@ include { REGISTRATION_EASYREG } from '../../../modules/nf-neuro/registration/ include { REGISTRATION_SYNTHMORPH } from '../../../modules/nf-neuro/registration/synthmorph/main' include { REGISTRATION_CONVERT } from '../../../modules/nf-neuro/registration/convert/main' include { UTILS_OPTIONS } from '../utils_options/main' - +include { IMAGE_APPLYMASK as MASK_FIXED_IMAGE} from '../../../modules/nf-neuro/image/applymask/main' +include { IMAGE_APPLYMASK as MASK_MOVING_IMAGE} from '../../../modules/nf-neuro/image/applymask/main' workflow REGISTRATION { @@ -34,6 +35,16 @@ workflow REGISTRATION { UTILS_OPTIONS("${moduleDir}/meta.yml", options, true) options = UTILS_OPTIONS.out.options.value + MASK_FIXED_IMAGE ( ch_fixed_image.join(ch_fixed_mask) ) + ch_fixed_image = ch_fixed_image.join(MASK_FIXED_IMAGE.out.image, remainder: true) + .map({ meta, orig, fixed -> [meta, fixed?: orig] }) + ch_versions = ch_versions.mix(MASK_FIXED_IMAGE.out.versions.first()) + + MASK_MOVING_IMAGE ( ch_moving_image.join(ch_moving_mask) ) + ch_moving_image = ch_moving_image.join(MASK_MOVING_IMAGE.out.image, remainder: true) + .map({ meta, orig, moving -> [meta, moving?: orig] }) + ch_versions = ch_versions.mix(MASK_MOVING_IMAGE.out.versions.first()) + if ( options.run_easyreg ) { // ** Registration using Easyreg ** // // Result : [ meta, reference, image | [], ref-segmentation | [], segmentation | [] ] @@ -201,7 +212,6 @@ workflow REGISTRATION { ch_register = ch_register.ants_syn .join(ch_fixed_mask, remainder: true) .join(ch_moving_mask, remainder: true) - .map{ it[0..2] + [it[4] ?: []] + [it[5] ?: []] } REGISTRATION_ANTS ( ch_register ) ch_versions = ch_versions.mix(REGISTRATION_ANTS.out.versions.first()) diff --git a/subworkflows/nf-neuro/registration/meta.yml b/subworkflows/nf-neuro/registration/meta.yml index 29923bf8..aa152ff4 100644 --- a/subworkflows/nf-neuro/registration/meta.yml +++ b/subworkflows/nf-neuro/registration/meta.yml @@ -93,7 +93,7 @@ input: - ch_fixed_mask: type: file description: | - FOR USE WITH ANTS SYN REGISTRATION ONLY. The input channel containing the mask file in fixed image space. + Fixed mask will be use to mask the fixed image during registration. structure: - meta: type: map @@ -106,7 +106,7 @@ input: - ch_moving_mask: type: file description: | - FOR USE WITH ANTS SYN REGISTRATION ONLY. The input channel containing the mask file in moving image space. + Moving mask will be use to mask the moving image during registration. structure: - meta: type: map diff --git a/subworkflows/nf-neuro/registration/tests/main.nf.test.snap b/subworkflows/nf-neuro/registration/tests/main.nf.test.snap index 510ea20c..0017177e 100644 --- a/subworkflows/nf-neuro/registration/tests/main.nf.test.snap +++ b/subworkflows/nf-neuro/registration/tests/main.nf.test.snap @@ -69,10 +69,10 @@ } ], "meta": { - "nf-test": "0.9.0", - "nextflow": "25.04.8" + "nf-test": "0.9.3", + "nextflow": "25.10.2" }, - "timestamp": "2025-10-16T20:51:47.326447932" + "timestamp": "2026-06-04T13:33:58.944010211" }, "registration - easyreg": { "content": [ @@ -163,10 +163,10 @@ } ], "meta": { - "nf-test": "0.9.0", - "nextflow": "25.04.8" + "nf-test": "0.9.3", + "nextflow": "25.10.2" }, - "timestamp": "2025-10-15T18:55:55.830874285" + "timestamp": "2026-06-04T13:33:44.280377972" }, "registration - ANTs - SyNQuick": { "content": [ @@ -256,6 +256,7 @@ ] ], "versions": [ + "versions.yml:md5,8f4cb1a55910da303007d7c2202e62f0", "versions.yml:md5,a338911f46f2c623d87eab600c524ffb" ] } @@ -264,7 +265,7 @@ "nf-test": "0.9.3", "nextflow": "25.10.2" }, - "timestamp": "2026-06-02T20:05:53.555032692" + "timestamp": "2026-06-04T13:33:26.753578263" }, "registration - ANTs - Anat to DWI": { "content": [ @@ -362,6 +363,6 @@ "nf-test": "0.9.3", "nextflow": "25.10.2" }, - "timestamp": "2026-02-26T22:46:42.344818522" + "timestamp": "2026-06-04T13:33:13.90620864" } } \ No newline at end of file diff --git a/subworkflows/nf-neuro/tractoflow/main.nf b/subworkflows/nf-neuro/tractoflow/main.nf index 149b3835..357076f6 100644 --- a/subworkflows/nf-neuro/tractoflow/main.nf +++ b/subworkflows/nf-neuro/tractoflow/main.nf @@ -14,7 +14,7 @@ include { RECONST_MEANFRF } from '../../../modules/nf-neuro/reconst/meanfrf/m include { RECONST_DTIMETRICS } from '../../../modules/nf-neuro/reconst/dtimetrics/main' include { RECONST_FODF } from '../../../modules/nf-neuro/reconst/fodf/main' include { RECONST_QBALL } from '../../../modules/nf-neuro/reconst/qball/main' -include { IMAGE_MATH } from '../../../modules/nf-neuro/image/math/main' +include { IMAGE_APPLYMASK } from '../../../modules/nf-neuro/image/applymask/main' // TRACKING include { TRACKING_PFTTRACKING } from '../../../modules/nf-neuro/tracking/pfttracking/main' @@ -179,14 +179,18 @@ workflow TRACTOFLOW { // SUBWORKFLOW: Run REGISTRATION // if ( options.preproc_dwi_keep_dwi_with_skull ) { - IMAGE_MATH(RECONST_DTIMETRICS.out.fa.join(PREPROC_DWI.out.b0_mask)) - ch_fa_for_registration = IMAGE_MATH.out.image - ch_versions = ch_versions.mix(IMAGE_MATH.out.versions.first()) + IMAGE_APPLYMASK(RECONST_DTIMETRICS.out.fa.join(PREPROC_DWI.out.b0_mask)) + ch_fa_for_registration = IMAGE_APPLYMASK.out.image + ch_versions = ch_versions.mix(IMAGE_APPLYMASK.out.versions.first()) } else { ch_fa_for_registration = RECONST_DTIMETRICS.out.fa } + PREPROC_DWI.out.b0.view() + PREPROC_T1.out.t1_final.view() + ch_fa_for_registration.view() + T1_REGISTRATION( PREPROC_DWI.out.b0, PREPROC_T1.out.t1_final, diff --git a/subworkflows/nf-neuro/tractoflow/modules.config b/subworkflows/nf-neuro/tractoflow/modules.config index b8d8b8b2..f54e2700 100644 --- a/subworkflows/nf-neuro/tractoflow/modules.config +++ b/subworkflows/nf-neuro/tractoflow/modules.config @@ -96,10 +96,9 @@ process { ext.first_suffix = "t1" } - withName: "TRACTOFLOW:IMAGE:MATH" { - ext.operation = "multiplication" + withName: "TRACTOFLOW:IMAGE:APPLYMASK" { ext.data_type = "float32" - ext.suffix = "fa_masked" + ext.first_suffix = "fa" } //withName: "TRACTOFLOW:T1_REGISTRATION:REGISTER_ANATTODWI" { diff --git a/subworkflows/nf-neuro/tractoflow/tests/main.nf.test.snap b/subworkflows/nf-neuro/tractoflow/tests/main.nf.test.snap index 550a1ef8..d7a84da8 100644 --- a/subworkflows/nf-neuro/tractoflow/tests/main.nf.test.snap +++ b/subworkflows/nf-neuro/tractoflow/tests/main.nf.test.snap @@ -393,7 +393,6 @@ "versions": [ "versions.yml:md5,229b67add04c70923f1bca378b7b2187", "versions.yml:md5,68aaff09474ed3ae149c1cffb0651f0d", - "versions.yml:md5,7c2302570358741fd2c8a9c5f9df41cb", "versions.yml:md5,7cabc91ec64b5e824e9b8f60d7dcf930", "versions.yml:md5,7fae1f6758d48901013496c0a680b81b", "versions.yml:md5,85cf18214259841972e1ea51961dc19d", @@ -401,6 +400,7 @@ "versions.yml:md5,b1f30072384bba1505d84f60281dfc24", "versions.yml:md5,cdfc3f4153b62c413e2fc6e948f2ef21", "versions.yml:md5,e808fc7967f50aad087f14c8cbcdc7e1", + "versions.yml:md5,f63f0d3dff7878bb46899a6b96ac2497", "versions.yml:md5,fee3d07623cc095a898f0a1de534a05b" ], "volume_fraction": [ @@ -441,7 +441,7 @@ "nf-test": "0.9.3", "nextflow": "25.10.2" }, - "timestamp": "2026-06-03T15:18:39.539666595" + "timestamp": "2026-06-04T13:46:26.983105632" }, "tractoflow - no rev": { "content": [ @@ -941,6 +941,6 @@ "nf-test": "0.9.3", "nextflow": "25.10.2" }, - "timestamp": "2026-06-03T15:16:19.494671141" + "timestamp": "2026-06-04T13:44:16.486282515" } } \ No newline at end of file From c398688ca423e46f1ebd092e4bea8b16d1015fe5 Mon Sep 17 00:00:00 2001 From: arnaudbore Date: Thu, 4 Jun 2026 14:01:49 -0400 Subject: [PATCH 02/14] fix linting --- subworkflows/nf-neuro/registration/meta.yml | 1 + subworkflows/nf-neuro/registration/tests/main.nf.test | 1 + subworkflows/nf-neuro/tractoflow/meta.yml | 2 +- subworkflows/nf-neuro/tractoflow/tests/main.nf.test | 2 +- 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/subworkflows/nf-neuro/registration/meta.yml b/subworkflows/nf-neuro/registration/meta.yml index aa152ff4..0404c1ae 100644 --- a/subworkflows/nf-neuro/registration/meta.yml +++ b/subworkflows/nf-neuro/registration/meta.yml @@ -47,6 +47,7 @@ components: - registration/convert - registration/easyreg - registration/synthmorph + - image/applymask - utils_options input: - ch_fixed_image: diff --git a/subworkflows/nf-neuro/registration/tests/main.nf.test b/subworkflows/nf-neuro/registration/tests/main.nf.test index 20f5dec8..0d5a4d2f 100644 --- a/subworkflows/nf-neuro/registration/tests/main.nf.test +++ b/subworkflows/nf-neuro/registration/tests/main.nf.test @@ -16,6 +16,7 @@ nextflow_workflow { tag "registration/convert" tag "registration/easyreg" tag "registration/synthmorph" + tag "image/applymask" tag "subworkflows/utils_options" diff --git a/subworkflows/nf-neuro/tractoflow/meta.yml b/subworkflows/nf-neuro/tractoflow/meta.yml index 5ac7a143..9561f087 100644 --- a/subworkflows/nf-neuro/tractoflow/meta.yml +++ b/subworkflows/nf-neuro/tractoflow/meta.yml @@ -44,7 +44,7 @@ keywords: components: - image/convertdwi - image/convert - - image/math + - image/applymask - anatomical_segmentation - preproc_dwi - preproc_t1 diff --git a/subworkflows/nf-neuro/tractoflow/tests/main.nf.test b/subworkflows/nf-neuro/tractoflow/tests/main.nf.test index 1af9e337..fbe462c8 100644 --- a/subworkflows/nf-neuro/tractoflow/tests/main.nf.test +++ b/subworkflows/nf-neuro/tractoflow/tests/main.nf.test @@ -18,7 +18,7 @@ nextflow_workflow { tag "image/convert" tag "image/convertdwi" - tag "image/math" + tag "image/applymask" tag "reconst/dtimetrics" tag "reconst/frf" tag "reconst/fodf" From a3078a84160dc2696428f03c10e131f13a04ebcb Mon Sep 17 00:00:00 2001 From: arnaudbore Date: Tue, 16 Jun 2026 15:13:15 -0400 Subject: [PATCH 03/14] commit remaining modifications with new framework --- subworkflows/nf-neuro/registration/main.nf | 62 ++++++++++++++----- subworkflows/nf-neuro/registration/meta.yml | 1 + .../nf-neuro/registration/tests/main.nf.test | 2 +- .../registration/tests/main.nf.test.snap | 52 +++++++++++++--- subworkflows/nf-neuro/tractoflow/main.nf | 4 -- .../nf-neuro/tractoflow/modules.config | 2 +- 6 files changed, 92 insertions(+), 31 deletions(-) diff --git a/subworkflows/nf-neuro/registration/main.nf b/subworkflows/nf-neuro/registration/main.nf index aa3d7be0..b8c3ee83 100644 --- a/subworkflows/nf-neuro/registration/main.nf +++ b/subworkflows/nf-neuro/registration/main.nf @@ -6,6 +6,8 @@ include { REGISTRATION_CONVERT } from '../../../modules/nf-neuro/registration/co include { UTILS_OPTIONS } from '../utils_options/main' include { IMAGE_APPLYMASK as MASK_FIXED_IMAGE} from '../../../modules/nf-neuro/image/applymask/main' include { IMAGE_APPLYMASK as MASK_MOVING_IMAGE} from '../../../modules/nf-neuro/image/applymask/main' +include { REGISTRATION_ANTSAPPLYTRANSFORMS as WARP_IMAGE_TO_FIXED } from '../../../modules/nf-neuro/registration/antsapplytransforms/main' +include { REGISTRATION_ANTSAPPLYTRANSFORMS as WARP_IMAGE_TO_MOVING } from '../../../modules/nf-neuro/registration/antsapplytransforms/main' workflow REGISTRATION { @@ -36,13 +38,13 @@ workflow REGISTRATION { options = UTILS_OPTIONS.out.options.value MASK_FIXED_IMAGE ( ch_fixed_image.join(ch_fixed_mask) ) - ch_fixed_image = ch_fixed_image.join(MASK_FIXED_IMAGE.out.image, remainder: true) - .map({ meta, orig, fixed -> [meta, fixed?: orig] }) + ch_fixed_image_ready = ch_fixed_image.join(MASK_FIXED_IMAGE.out.image, remainder: true) + .map({ meta, orig, masked -> [meta, masked?: orig] }) ch_versions = ch_versions.mix(MASK_FIXED_IMAGE.out.versions.first()) MASK_MOVING_IMAGE ( ch_moving_image.join(ch_moving_mask) ) - ch_moving_image = ch_moving_image.join(MASK_MOVING_IMAGE.out.image, remainder: true) - .map({ meta, orig, moving -> [meta, moving?: orig] }) + ch_moving_image_ready = ch_moving_image.join(MASK_MOVING_IMAGE.out.image, remainder: true) + .map({ meta, orig, masked -> [meta, masked?: orig] }) ch_versions = ch_versions.mix(MASK_MOVING_IMAGE.out.versions.first()) if ( options.run_easyreg ) { @@ -53,8 +55,8 @@ workflow REGISTRATION { // - join [ meta, reference, image | null, ref-segmentation | null ] // - join [ meta, reference, image | null, ref-segmentation | null, segmentation | null ] // - map [ meta, reference, image | [], ref-segmentation | [], segmentation | [] ] - ch_register = ch_moving_image - .join(ch_fixed_image, remainder: true) + ch_register = ch_moving_image_ready + .join(ch_fixed_image_ready, remainder: true) .join(ch_moving_segmentation, remainder: true) .join(ch_segmentation, remainder: true) .map{ it[0..1] + [it[2] ?: [], it[3] ?: [], it[4] ?: []] } @@ -82,8 +84,8 @@ workflow REGISTRATION { } else if ( options.run_synthmorph ) { // ** Registration using synthmorph ** // - ch_register = ch_fixed_image - .join(ch_moving_image) + ch_register = ch_fixed_image_ready + .join(ch_moving_image_ready) REGISTRATION_SYNTHMORPH ( ch_register ) ch_versions = ch_versions.mix(REGISTRATION_SYNTHMORPH.out.versions.first()) @@ -177,8 +179,8 @@ workflow REGISTRATION { // Branches : // - anat_to_dwi : has a metric at index 3 // - ants_syn : doesn't have a metric at index 3 ( [] or null ) - ch_register = ch_fixed_image - .join(ch_moving_image) + ch_register = ch_fixed_image_ready + .join(ch_moving_image_ready) .join(ch_metric, remainder: true) .map{ it[0..2] + [it[3] ?: []] } .branch{ @@ -208,12 +210,9 @@ workflow REGISTRATION { // Result : [ meta, image, mask | [] ] // Steps : // - join [ meta, image, metric | [], mask | null ] - // - map [ meta, image, mask | [] ] - ch_register = ch_register.ants_syn - .join(ch_fixed_mask, remainder: true) - .join(ch_moving_mask, remainder: true) + // - map [ meta, image ] - REGISTRATION_ANTS ( ch_register ) + REGISTRATION_ANTS ( ch_register.ants_syn ) ch_versions = ch_versions.mix(REGISTRATION_ANTS.out.versions.first()) ch_mqc = ch_mqc.mix(REGISTRATION_ANTS.out.mqc) @@ -233,9 +232,42 @@ workflow REGISTRATION { out_segmentation = channel.empty() out_ref_segmentation = channel.empty() } + + out_image_warped_masked = out_image_warped + .join(ch_moving_mask) + .map{ meta, warped, mask -> mask ? [meta, warped] : [] } + + out_ref_warped_masked = out_ref_warped + .join(ch_fixed_mask) + .map{ meta, warped, mask -> mask ? [meta, warped] : [] } + + // Register original moving image + WARP_IMAGE_TO_FIXED ( ch_moving_image + .join(ch_fixed_image) + .join(out_forward_image_transform) + .join(ch_moving_mask) + .map{ meta, moving, fixed, transform, mask -> mask ? [meta, moving, fixed, transform] : [] } ) + out_image_warped = out_image_warped + .join(WARP_IMAGE_TO_FIXED.out.warped_image) + .map{ meta, warped, masked_warped -> masked_warped :[meta, masked_warped ?: warped] } + ch_versions = ch_versions.mix(WARP_IMAGE_TO_FIXED.out.versions.first()) + + // Register original ref image + WARP_IMAGE_TO_MOVING ( ch_fixed_image + .join(ch_moving_image) + .join(out_backward_image_transform) + .join(ch_fixed_mask) + .map{ meta, moving, fixed, transform, mask -> mask ? [meta, moving, fixed, transform] : [] } ) + out_ref_warped = out_ref_warped + .join(WARP_IMAGE_TO_MOVING.out.warped_image) + .map{ meta, warped, masked_warped -> [meta, masked_warped ?: warped] } + ch_versions = ch_versions.mix(WARP_IMAGE_TO_MOVING.out.versions.first()) +cd emit: image_warped = out_image_warped // channel: [ val(meta), image ] reference_warped = out_ref_warped // channel: [ val(meta), ref ] + image_warped_masked = out_image_warped_masked // channel: [ val(meta), image ] + reference_warped_masked = out_ref_warped_masked // channel: [ val(meta), ref ] // Individual transforms forward_affine = out_forward_affine // channel: [ val(meta), ] forward_warp = out_forward_warp // channel: [ val(meta), ] diff --git a/subworkflows/nf-neuro/registration/meta.yml b/subworkflows/nf-neuro/registration/meta.yml index 0404c1ae..a2aadc2c 100644 --- a/subworkflows/nf-neuro/registration/meta.yml +++ b/subworkflows/nf-neuro/registration/meta.yml @@ -44,6 +44,7 @@ keywords: components: - registration/anattodwi - registration/ants + - registration/antsapplytransforms - registration/convert - registration/easyreg - registration/synthmorph diff --git a/subworkflows/nf-neuro/registration/tests/main.nf.test b/subworkflows/nf-neuro/registration/tests/main.nf.test index 0d5a4d2f..eb675d6d 100644 --- a/subworkflows/nf-neuro/registration/tests/main.nf.test +++ b/subworkflows/nf-neuro/registration/tests/main.nf.test @@ -11,8 +11,8 @@ nextflow_workflow { tag "registration" tag "registration/anattodwi" - tag "registration" tag "registration/ants" + tag "registration/antsapplytransforms" tag "registration/convert" tag "registration/easyreg" tag "registration/synthmorph" diff --git a/subworkflows/nf-neuro/registration/tests/main.nf.test.snap b/subworkflows/nf-neuro/registration/tests/main.nf.test.snap index 0017177e..37b4c0f5 100644 --- a/subworkflows/nf-neuro/registration/tests/main.nf.test.snap +++ b/subworkflows/nf-neuro/registration/tests/main.nf.test.snap @@ -59,12 +59,22 @@ { "id": "test" }, - "test_warped.nii.gz" + "test_b0_warped.nii.gz" + ] + ], + "reference_warped": [ + [ + { + "id": "test" + }, + "test_T1w_warped.nii.gz" ] ], "versions": [ "versions.yml:md5,300199ef2ea6dd6438553c3ec2615e58", - "versions.yml:md5,5bc0d347809508f4b94ebe433b0f21b9" + "versions.yml:md5,3764dd2f067db355da3536c1b0c94619", + "versions.yml:md5,5bc0d347809508f4b94ebe433b0f21b9", + "versions.yml:md5,8d90eba5eb0cfe9c82c7280c1b6e66a8" ] } ], @@ -72,7 +82,7 @@ "nf-test": "0.9.3", "nextflow": "25.10.2" }, - "timestamp": "2026-06-04T13:33:58.944010211" + "timestamp": "2026-06-04T15:29:09.626057948" }, "registration - easyreg": { "content": [ @@ -130,7 +140,7 @@ { "id": "test" }, - "test_warped.nii.gz" + "test_b0_warped.nii.gz" ] ], "reference_segmentation": [ @@ -146,7 +156,7 @@ { "id": "test" }, - "test_warped_reference.nii.gz" + "test_T1w_warped.nii.gz" ] ], "segmentation": [ @@ -158,7 +168,9 @@ ] ], "versions": [ - "versions.yml:md5,3f38c911476c605480c02e484fcf6e9f" + "versions.yml:md5,3764dd2f067db355da3536c1b0c94619", + "versions.yml:md5,3f38c911476c605480c02e484fcf6e9f", + "versions.yml:md5,8d90eba5eb0cfe9c82c7280c1b6e66a8" ] } ], @@ -166,7 +178,7 @@ "nf-test": "0.9.3", "nextflow": "25.10.2" }, - "timestamp": "2026-06-04T13:33:44.280377972" + "timestamp": "2026-06-04T15:28:51.999584319" }, "registration - ANTs - SyNQuick": { "content": [ @@ -255,7 +267,17 @@ "test__registration_ants_mqc.gif" ] ], + "reference_warped": [ + [ + { + "id": "test" + }, + "test_test_masked_warped.nii.gz" + ] + ], "versions": [ + "versions.yml:md5,3764dd2f067db355da3536c1b0c94619", + "versions.yml:md5,8d90eba5eb0cfe9c82c7280c1b6e66a8", "versions.yml:md5,8f4cb1a55910da303007d7c2202e62f0", "versions.yml:md5,a338911f46f2c623d87eab600c524ffb" ] @@ -265,7 +287,7 @@ "nf-test": "0.9.3", "nextflow": "25.10.2" }, - "timestamp": "2026-06-04T13:33:26.753578263" + "timestamp": "2026-06-04T15:28:29.794849703" }, "registration - ANTs - Anat to DWI": { "content": [ @@ -354,8 +376,18 @@ "test_registration_anattodwi_mqc.gif" ] ], + "reference_warped": [ + [ + { + "id": "test" + }, + "test_b0_warped.nii.gz" + ] + ], "versions": [ - "versions.yml:md5,03b958f14a890b541bb76c73f7a72847" + "versions.yml:md5,03b958f14a890b541bb76c73f7a72847", + "versions.yml:md5,3764dd2f067db355da3536c1b0c94619", + "versions.yml:md5,8d90eba5eb0cfe9c82c7280c1b6e66a8" ] } ], @@ -363,6 +395,6 @@ "nf-test": "0.9.3", "nextflow": "25.10.2" }, - "timestamp": "2026-06-04T13:33:13.90620864" + "timestamp": "2026-06-04T15:28:03.979362405" } } \ No newline at end of file diff --git a/subworkflows/nf-neuro/tractoflow/main.nf b/subworkflows/nf-neuro/tractoflow/main.nf index 357076f6..32596993 100644 --- a/subworkflows/nf-neuro/tractoflow/main.nf +++ b/subworkflows/nf-neuro/tractoflow/main.nf @@ -187,10 +187,6 @@ workflow TRACTOFLOW { ch_fa_for_registration = RECONST_DTIMETRICS.out.fa } - PREPROC_DWI.out.b0.view() - PREPROC_T1.out.t1_final.view() - ch_fa_for_registration.view() - T1_REGISTRATION( PREPROC_DWI.out.b0, PREPROC_T1.out.t1_final, diff --git a/subworkflows/nf-neuro/tractoflow/modules.config b/subworkflows/nf-neuro/tractoflow/modules.config index f54e2700..bd968b5e 100644 --- a/subworkflows/nf-neuro/tractoflow/modules.config +++ b/subworkflows/nf-neuro/tractoflow/modules.config @@ -96,7 +96,7 @@ process { ext.first_suffix = "t1" } - withName: "TRACTOFLOW:IMAGE:APPLYMASK" { + withName: "TRACTOFLOW:IMAGE_APPLYMASK" { ext.data_type = "float32" ext.first_suffix = "fa" } From 8be4f7aa6af6255aebab2ae922cfe5d92ee948e1 Mon Sep 17 00:00:00 2001 From: arnaudbore Date: Fri, 10 Jul 2026 12:50:49 -0400 Subject: [PATCH 04/14] still needs more tests to see if it handles fixed and moving masks --- .../nf-neuro/registration/anattodwi/main.nf | 7 +- .../nf-neuro/registration/anattodwi/meta.yml | 18 +++ .../registration/anattodwi/tests/main.nf.test | 2 + modules/nf-neuro/registration/ants/main.nf | 3 +- modules/nf-neuro/registration/ants/meta.yml | 18 +++ .../registration/ants/tests/main.nf.test | 4 + .../registration/ants/tests/main.nf.test.snap | 142 +++++++++--------- subworkflows/nf-neuro/registration/main.nf | 57 +++++-- subworkflows/nf-neuro/registration/meta.yml | 4 + .../registration/tests/main.nf.test.snap | 86 +---------- .../registration/tests/nextflow.config | 2 + 11 files changed, 177 insertions(+), 166 deletions(-) diff --git a/modules/nf-neuro/registration/anattodwi/main.nf b/modules/nf-neuro/registration/anattodwi/main.nf index 0e136738..064a158b 100644 --- a/modules/nf-neuro/registration/anattodwi/main.nf +++ b/modules/nf-neuro/registration/anattodwi/main.nf @@ -5,7 +5,7 @@ process REGISTRATION_ANATTODWI { container "scilus/scilus:2.2.2" input: - tuple val(meta), path(fixed_reference), path(moving_anat), path(metric) + tuple val(meta), path(fixed_reference), path(moving_anat), path(metric), path(fixed_mask), path(moving_mask) output: tuple val(meta), path("*_warped.nii.gz") , emit: anat_warped @@ -26,7 +26,9 @@ process REGISTRATION_ANATTODWI { script: def prefix = task.ext.prefix ?: "${meta.id}" def run_qc = task.ext.run_qc as Boolean || false + def args = task.ext.args ?: '' + if ( task.ext.masking_strategy == "both" || task.ext.masking_strategy == "internal" ) args += " -x $fixed_mask?:NULL,$moving_mask?:NULL" """ export ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS=${task.ext.single_thread ? 1 : task.cpus} export OMP_NUM_THREADS=${task.ext.single_thread ? 1 : task.cpus} @@ -49,7 +51,8 @@ process REGISTRATION_ANATTODWI { --metric MI[$fixed_reference,$moving_anat,1,32]\ --metric CC[$metric,$moving_anat,1,4]\ --convergence [50x25x10,1e-6,10] --shrink-factors 4x2x1\ - --smoothing-sigmas 3x2x1 + --smoothing-sigmas 3x2x1\ + $args moving_base=\$(basename "${moving_anat}") ext=\${moving_base#*.} diff --git a/modules/nf-neuro/registration/anattodwi/meta.yml b/modules/nf-neuro/registration/anattodwi/meta.yml index eba51fcc..c15c7632 100644 --- a/modules/nf-neuro/registration/anattodwi/meta.yml +++ b/modules/nf-neuro/registration/anattodwi/meta.yml @@ -43,6 +43,10 @@ args: type: integer description: Random seed for ANTs registration. Setting a fixed seed can help with reproducibility of results. default: 1234 + - masking_strategy: + type: string + description: Masking strategy to use for registration. Options are 'none', 'apriori', 'both'. + default: "none" input: - - meta: type: map @@ -70,6 +74,20 @@ input: mandatory: true ontologies: - edam: http://edamontology.org/format_4001 # NIFTI format + - fixed_mask: + type: file + description: Fixed image mask + pattern: "*.{nii,nii.gz}" + mandatory: false + ontologies: + - edam: http://edamontology.org/format_4001 # NIFTI format + - moving_mask: + type: file + description: Moving image mask + pattern: "*.{nii,nii.gz}" + mandatory: false + ontologies: + - edam: http://edamontology.org/format_4001 # NIFTI format output: anat_warped: - - meta: diff --git a/modules/nf-neuro/registration/anattodwi/tests/main.nf.test b/modules/nf-neuro/registration/anattodwi/tests/main.nf.test index fb85ca46..2685e95d 100644 --- a/modules/nf-neuro/registration/anattodwi/tests/main.nf.test +++ b/modules/nf-neuro/registration/anattodwi/tests/main.nf.test @@ -56,6 +56,7 @@ nextflow_process { input[0] = ch_b0 .join(ch_t1w) .join(ch_fa) + .map{ meta, fixed, moving, fixed_metric -> [meta, fixed, moving, fixed_metric, [], []] } """ } } @@ -101,6 +102,7 @@ nextflow_process { input[0] = ch_b0 .join(ch_t1w) .join(ch_fa) + .map{ meta, fixed, moving, fixed_metric -> [meta, fixed, moving, fixed_metric, [], []] } """ } } diff --git a/modules/nf-neuro/registration/ants/main.nf b/modules/nf-neuro/registration/ants/main.nf index 05098645..2e296adc 100644 --- a/modules/nf-neuro/registration/ants/main.nf +++ b/modules/nf-neuro/registration/ants/main.nf @@ -6,7 +6,7 @@ process REGISTRATION_ANTS { container "scilus/scilus:2.2.2" input: - tuple val(meta), path(fixed_image), path(moving_image) + tuple val(meta), path(fixed_image), path(moving_image), path(fixed_mask), path(moving_mask) output: tuple val(meta), path("*_warped.nii.gz") , emit: image_warped @@ -44,6 +44,7 @@ process REGISTRATION_ANTS { if ( task.ext.histogram_matching ) args += " -j $task.ext.histogram_matching" if ( task.ext.repro_mode ) args += " -y $task.ext.repro_mode" if ( task.ext.collapse_output ) args += " -z $task.ext.collapse_output" + if ( task.ext.masking_strategy == "both" || task.ext.masking_strategy == "internal" ) args += " -x $fixed_mask?:NULL,$moving_mask?:NULL" """ export ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS=${task.ext.single_thread ? 1 : task.cpus} diff --git a/modules/nf-neuro/registration/ants/meta.yml b/modules/nf-neuro/registration/ants/meta.yml index 1bf98c95..b7b134ed 100644 --- a/modules/nf-neuro/registration/ants/meta.yml +++ b/modules/nf-neuro/registration/ants/meta.yml @@ -125,6 +125,10 @@ args: type: boolean description: If true, the command will be run in single-threaded mode. By default, the command will use multiple threads based on the number of CPUs allocated to the task. default: false + - masking_strategy: + type: string + description: Masking strategy to use for registration. Options are 'none', 'apriori', 'both'. + default: "none" input: - - meta: type: map @@ -145,6 +149,20 @@ input: mandatory: true ontologies: - edam: http://edamontology.org/format_4001 # NIFTI format + - fixed_mask: + type: file + description: Fixed image mask + pattern: "*.{nii,nii.gz}" + mandatory: false + ontologies: + - edam: http://edamontology.org/format_4001 # NIFTI format + - moving_mask: + type: file + description: Moving image mask + pattern: "*.{nii,nii.gz}" + mandatory: false + ontologies: + - edam: http://edamontology.org/format_4001 # NIFTI format output: image_warped: - - meta: diff --git a/modules/nf-neuro/registration/ants/tests/main.nf.test b/modules/nf-neuro/registration/ants/tests/main.nf.test index ae0b3b5b..a0ca15fc 100644 --- a/modules/nf-neuro/registration/ants/tests/main.nf.test +++ b/modules/nf-neuro/registration/ants/tests/main.nf.test @@ -48,6 +48,7 @@ nextflow_process { } input[0] = ch_T1w .join(ch_moving) + .map{ meta, fixed, moving -> [meta, fixed, moving, [], []] } """ } } @@ -83,6 +84,7 @@ nextflow_process { } input[0] = ch_T1w .join(ch_moving) + .map{ meta, fixed, moving -> [meta, fixed, moving, [], []] } """ } } @@ -118,6 +120,7 @@ nextflow_process { } input[0] = ch_T1w .join(ch_moving) + .map{ meta, fixed, moving -> [meta, fixed, moving, [], []] } """ } } @@ -154,6 +157,7 @@ nextflow_process { } input[0] = ch_T1w .join(ch_moving) + .map{ meta, fixed, moving -> [meta, fixed, moving, [], []] } """ } } diff --git a/modules/nf-neuro/registration/ants/tests/main.nf.test.snap b/modules/nf-neuro/registration/ants/tests/main.nf.test.snap index 88cc7ac1..d9fdc0e9 100644 --- a/modules/nf-neuro/registration/ants/tests/main.nf.test.snap +++ b/modules/nf-neuro/registration/ants/tests/main.nf.test.snap @@ -19,7 +19,7 @@ { "id": "test" }, - "test_t1_warped.nii.gz:md5,c74eb8a596f1f6959f8db828d0d9ddc1" + "test_t1_warped.nii.gz:md5,9a0bb219ad17eff32fd95550c7e73ebf" ] ], "1": [ @@ -27,7 +27,7 @@ { "id": "test" }, - "test_forward1_affine.mat:md5,41afa6fa72a013820a3d3d8ce4986002" + "test_forward1_affine.mat:md5,4b73494b62eeb43d1660478ab6d259c8" ] ], "10": [ @@ -38,7 +38,7 @@ { "id": "test" }, - "test_forward0_warp.nii.gz:md5,806c26fdf31077d4b035a2009db54c95" + "test_forward0_warp.nii.gz:md5,5c8e9c98b60070dde6e93d27454a7c84" ] ], "3": [ @@ -46,7 +46,7 @@ { "id": "test" }, - "test_backward1_warp.nii.gz:md5,4cca843970b2ed3d02ecf43a31502857" + "test_backward1_warp.nii.gz:md5,c68cb4dc8b8f642b38ee34962ddd2108" ] ], "4": [ @@ -54,7 +54,7 @@ { "id": "test" }, - "test_backward0_affine.mat:md5,9b6845301aaeaf43a1cf9da4e4cb671f" + "test_backward0_affine.mat:md5,39d0956c44fc5b7cb554886f38516ae9" ] ], "5": [ @@ -63,8 +63,8 @@ "id": "test" }, [ - "test_forward0_warp.nii.gz:md5,806c26fdf31077d4b035a2009db54c95", - "test_forward1_affine.mat:md5,41afa6fa72a013820a3d3d8ce4986002" + "test_forward0_warp.nii.gz:md5,5c8e9c98b60070dde6e93d27454a7c84", + "test_forward1_affine.mat:md5,4b73494b62eeb43d1660478ab6d259c8" ] ] ], @@ -74,8 +74,8 @@ "id": "test" }, [ - "test_backward0_affine.mat:md5,9b6845301aaeaf43a1cf9da4e4cb671f", - "test_backward1_warp.nii.gz:md5,4cca843970b2ed3d02ecf43a31502857" + "test_backward0_affine.mat:md5,39d0956c44fc5b7cb554886f38516ae9", + "test_backward1_warp.nii.gz:md5,c68cb4dc8b8f642b38ee34962ddd2108" ] ] ], @@ -85,8 +85,8 @@ "id": "test" }, [ - "test_backward0_affine.mat:md5,9b6845301aaeaf43a1cf9da4e4cb671f", - "test_backward1_warp.nii.gz:md5,4cca843970b2ed3d02ecf43a31502857" + "test_backward0_affine.mat:md5,39d0956c44fc5b7cb554886f38516ae9", + "test_backward1_warp.nii.gz:md5,c68cb4dc8b8f642b38ee34962ddd2108" ] ] ], @@ -96,8 +96,8 @@ "id": "test" }, [ - "test_forward0_warp.nii.gz:md5,806c26fdf31077d4b035a2009db54c95", - "test_forward1_affine.mat:md5,41afa6fa72a013820a3d3d8ce4986002" + "test_forward0_warp.nii.gz:md5,5c8e9c98b60070dde6e93d27454a7c84", + "test_forward1_affine.mat:md5,4b73494b62eeb43d1660478ab6d259c8" ] ] ], @@ -106,7 +106,7 @@ { "id": "test" }, - "test_T1_to_T1_slab_registration_ants_mqc.gif:md5,b685aa586e6b61196b442740c1056eb5" + "test_T1_to_T1_slab_registration_ants_mqc.gif:md5,0702b94648153d4044d8138864b35bfa" ] ], "backward_affine": [ @@ -114,7 +114,7 @@ { "id": "test" }, - "test_backward0_affine.mat:md5,9b6845301aaeaf43a1cf9da4e4cb671f" + "test_backward0_affine.mat:md5,39d0956c44fc5b7cb554886f38516ae9" ] ], "backward_image_transform": [ @@ -123,8 +123,8 @@ "id": "test" }, [ - "test_backward0_affine.mat:md5,9b6845301aaeaf43a1cf9da4e4cb671f", - "test_backward1_warp.nii.gz:md5,4cca843970b2ed3d02ecf43a31502857" + "test_backward0_affine.mat:md5,39d0956c44fc5b7cb554886f38516ae9", + "test_backward1_warp.nii.gz:md5,c68cb4dc8b8f642b38ee34962ddd2108" ] ] ], @@ -134,8 +134,8 @@ "id": "test" }, [ - "test_forward0_warp.nii.gz:md5,806c26fdf31077d4b035a2009db54c95", - "test_forward1_affine.mat:md5,41afa6fa72a013820a3d3d8ce4986002" + "test_forward0_warp.nii.gz:md5,5c8e9c98b60070dde6e93d27454a7c84", + "test_forward1_affine.mat:md5,4b73494b62eeb43d1660478ab6d259c8" ] ] ], @@ -144,7 +144,7 @@ { "id": "test" }, - "test_backward1_warp.nii.gz:md5,4cca843970b2ed3d02ecf43a31502857" + "test_backward1_warp.nii.gz:md5,c68cb4dc8b8f642b38ee34962ddd2108" ] ], "forward_affine": [ @@ -152,7 +152,7 @@ { "id": "test" }, - "test_forward1_affine.mat:md5,41afa6fa72a013820a3d3d8ce4986002" + "test_forward1_affine.mat:md5,4b73494b62eeb43d1660478ab6d259c8" ] ], "forward_image_transform": [ @@ -161,8 +161,8 @@ "id": "test" }, [ - "test_forward0_warp.nii.gz:md5,806c26fdf31077d4b035a2009db54c95", - "test_forward1_affine.mat:md5,41afa6fa72a013820a3d3d8ce4986002" + "test_forward0_warp.nii.gz:md5,5c8e9c98b60070dde6e93d27454a7c84", + "test_forward1_affine.mat:md5,4b73494b62eeb43d1660478ab6d259c8" ] ] ], @@ -172,8 +172,8 @@ "id": "test" }, [ - "test_backward0_affine.mat:md5,9b6845301aaeaf43a1cf9da4e4cb671f", - "test_backward1_warp.nii.gz:md5,4cca843970b2ed3d02ecf43a31502857" + "test_backward0_affine.mat:md5,39d0956c44fc5b7cb554886f38516ae9", + "test_backward1_warp.nii.gz:md5,c68cb4dc8b8f642b38ee34962ddd2108" ] ] ], @@ -182,7 +182,7 @@ { "id": "test" }, - "test_forward0_warp.nii.gz:md5,806c26fdf31077d4b035a2009db54c95" + "test_forward0_warp.nii.gz:md5,5c8e9c98b60070dde6e93d27454a7c84" ] ], "image_warped": [ @@ -190,7 +190,7 @@ { "id": "test" }, - "test_t1_warped.nii.gz:md5,c74eb8a596f1f6959f8db828d0d9ddc1" + "test_t1_warped.nii.gz:md5,9a0bb219ad17eff32fd95550c7e73ebf" ] ], "mqc": [ @@ -198,7 +198,7 @@ { "id": "test" }, - "test_T1_to_T1_slab_registration_ants_mqc.gif:md5,b685aa586e6b61196b442740c1056eb5" + "test_T1_to_T1_slab_registration_ants_mqc.gif:md5,0702b94648153d4044d8138864b35bfa" ] ], "versions": [ @@ -210,7 +210,7 @@ "nf-test": "0.9.3", "nextflow": "25.10.2" }, - "timestamp": "2026-06-04T10:27:29.392349393" + "timestamp": "2026-07-10T10:49:46.156144247" }, "registration - ants - SyN": { "content": [ @@ -220,7 +220,7 @@ { "id": "test" }, - "test_t1_warped.nii.gz:md5,7c5756d1bdcf72eac1541e9c5d98f9db" + "test_t1_warped.nii.gz:md5,2ae1a6986238b8ebd58d237979061623" ] ], "1": [ @@ -228,7 +228,7 @@ { "id": "test" }, - "test_forward1_affine.mat:md5,0fb5879b315f32bb8e06aa2993009115" + "test_forward1_affine.mat:md5,cef396215549c098bd4f1e9e32baf54f" ] ], "10": [ @@ -239,7 +239,7 @@ { "id": "test" }, - "test_forward0_warp.nii.gz:md5,a32206a00e93b79054e9b8fa0f7c8015" + "test_forward0_warp.nii.gz:md5,3a2c82d85d0b8c8e7b88684db3e10611" ] ], "3": [ @@ -247,7 +247,7 @@ { "id": "test" }, - "test_backward1_warp.nii.gz:md5,4e85fa2257f7364fde205adfa1b3c8d3" + "test_backward1_warp.nii.gz:md5,e3bdf358ce296e7dc4190f12abe1b292" ] ], "4": [ @@ -255,7 +255,7 @@ { "id": "test" }, - "test_backward0_affine.mat:md5,ff00be1483698e5478bfa94abf2b42b2" + "test_backward0_affine.mat:md5,1d79bdbe5af542e4ae8cce1d6a290c8b" ] ], "5": [ @@ -264,8 +264,8 @@ "id": "test" }, [ - "test_forward0_warp.nii.gz:md5,a32206a00e93b79054e9b8fa0f7c8015", - "test_forward1_affine.mat:md5,0fb5879b315f32bb8e06aa2993009115" + "test_forward0_warp.nii.gz:md5,3a2c82d85d0b8c8e7b88684db3e10611", + "test_forward1_affine.mat:md5,cef396215549c098bd4f1e9e32baf54f" ] ] ], @@ -275,8 +275,8 @@ "id": "test" }, [ - "test_backward0_affine.mat:md5,ff00be1483698e5478bfa94abf2b42b2", - "test_backward1_warp.nii.gz:md5,4e85fa2257f7364fde205adfa1b3c8d3" + "test_backward0_affine.mat:md5,1d79bdbe5af542e4ae8cce1d6a290c8b", + "test_backward1_warp.nii.gz:md5,e3bdf358ce296e7dc4190f12abe1b292" ] ] ], @@ -286,8 +286,8 @@ "id": "test" }, [ - "test_backward0_affine.mat:md5,ff00be1483698e5478bfa94abf2b42b2", - "test_backward1_warp.nii.gz:md5,4e85fa2257f7364fde205adfa1b3c8d3" + "test_backward0_affine.mat:md5,1d79bdbe5af542e4ae8cce1d6a290c8b", + "test_backward1_warp.nii.gz:md5,e3bdf358ce296e7dc4190f12abe1b292" ] ] ], @@ -297,8 +297,8 @@ "id": "test" }, [ - "test_forward0_warp.nii.gz:md5,a32206a00e93b79054e9b8fa0f7c8015", - "test_forward1_affine.mat:md5,0fb5879b315f32bb8e06aa2993009115" + "test_forward0_warp.nii.gz:md5,3a2c82d85d0b8c8e7b88684db3e10611", + "test_forward1_affine.mat:md5,cef396215549c098bd4f1e9e32baf54f" ] ] ], @@ -310,7 +310,7 @@ { "id": "test" }, - "test_backward0_affine.mat:md5,ff00be1483698e5478bfa94abf2b42b2" + "test_backward0_affine.mat:md5,1d79bdbe5af542e4ae8cce1d6a290c8b" ] ], "backward_image_transform": [ @@ -319,8 +319,8 @@ "id": "test" }, [ - "test_backward0_affine.mat:md5,ff00be1483698e5478bfa94abf2b42b2", - "test_backward1_warp.nii.gz:md5,4e85fa2257f7364fde205adfa1b3c8d3" + "test_backward0_affine.mat:md5,1d79bdbe5af542e4ae8cce1d6a290c8b", + "test_backward1_warp.nii.gz:md5,e3bdf358ce296e7dc4190f12abe1b292" ] ] ], @@ -330,8 +330,8 @@ "id": "test" }, [ - "test_forward0_warp.nii.gz:md5,a32206a00e93b79054e9b8fa0f7c8015", - "test_forward1_affine.mat:md5,0fb5879b315f32bb8e06aa2993009115" + "test_forward0_warp.nii.gz:md5,3a2c82d85d0b8c8e7b88684db3e10611", + "test_forward1_affine.mat:md5,cef396215549c098bd4f1e9e32baf54f" ] ] ], @@ -340,7 +340,7 @@ { "id": "test" }, - "test_backward1_warp.nii.gz:md5,4e85fa2257f7364fde205adfa1b3c8d3" + "test_backward1_warp.nii.gz:md5,e3bdf358ce296e7dc4190f12abe1b292" ] ], "forward_affine": [ @@ -348,7 +348,7 @@ { "id": "test" }, - "test_forward1_affine.mat:md5,0fb5879b315f32bb8e06aa2993009115" + "test_forward1_affine.mat:md5,cef396215549c098bd4f1e9e32baf54f" ] ], "forward_image_transform": [ @@ -357,8 +357,8 @@ "id": "test" }, [ - "test_forward0_warp.nii.gz:md5,a32206a00e93b79054e9b8fa0f7c8015", - "test_forward1_affine.mat:md5,0fb5879b315f32bb8e06aa2993009115" + "test_forward0_warp.nii.gz:md5,3a2c82d85d0b8c8e7b88684db3e10611", + "test_forward1_affine.mat:md5,cef396215549c098bd4f1e9e32baf54f" ] ] ], @@ -368,8 +368,8 @@ "id": "test" }, [ - "test_backward0_affine.mat:md5,ff00be1483698e5478bfa94abf2b42b2", - "test_backward1_warp.nii.gz:md5,4e85fa2257f7364fde205adfa1b3c8d3" + "test_backward0_affine.mat:md5,1d79bdbe5af542e4ae8cce1d6a290c8b", + "test_backward1_warp.nii.gz:md5,e3bdf358ce296e7dc4190f12abe1b292" ] ] ], @@ -378,7 +378,7 @@ { "id": "test" }, - "test_forward0_warp.nii.gz:md5,a32206a00e93b79054e9b8fa0f7c8015" + "test_forward0_warp.nii.gz:md5,3a2c82d85d0b8c8e7b88684db3e10611" ] ], "image_warped": [ @@ -386,7 +386,7 @@ { "id": "test" }, - "test_t1_warped.nii.gz:md5,7c5756d1bdcf72eac1541e9c5d98f9db" + "test_t1_warped.nii.gz:md5,2ae1a6986238b8ebd58d237979061623" ] ], "mqc": [ @@ -401,7 +401,7 @@ "nf-test": "0.9.3", "nextflow": "25.10.2" }, - "timestamp": "2026-06-04T10:22:28.649714216" + "timestamp": "2026-07-10T10:48:35.425395985" }, "registration - ants - no warps": { "content": [ @@ -411,7 +411,7 @@ { "id": "test" }, - "test_t1_warped.nii.gz:md5,9f4d57c0e9cde3da4ab4718f360abce6" + "test_t1_warped.nii.gz:md5,e8c78a1c57ae3a51ebf0611e09bc3c59" ] ], "1": [ @@ -419,7 +419,7 @@ { "id": "test" }, - "test_forward1_affine.mat:md5,72aee9284d5e624be5dbc15cfce8151c" + "test_forward1_affine.mat:md5,6e47b89fcdd230c852b25ce8036438e9" ] ], "10": [ @@ -436,7 +436,7 @@ { "id": "test" }, - "test_backward0_affine.mat:md5,862976c1966b1af64acd7b40d0f922e4" + "test_backward0_affine.mat:md5,1038f3b4b63d8dbd572947d68d7ed90d" ] ], "5": [ @@ -445,7 +445,7 @@ "id": "test" }, [ - "test_forward1_affine.mat:md5,72aee9284d5e624be5dbc15cfce8151c" + "test_forward1_affine.mat:md5,6e47b89fcdd230c852b25ce8036438e9" ] ] ], @@ -455,7 +455,7 @@ "id": "test" }, [ - "test_backward0_affine.mat:md5,862976c1966b1af64acd7b40d0f922e4" + "test_backward0_affine.mat:md5,1038f3b4b63d8dbd572947d68d7ed90d" ] ] ], @@ -465,7 +465,7 @@ "id": "test" }, [ - "test_backward0_affine.mat:md5,862976c1966b1af64acd7b40d0f922e4" + "test_backward0_affine.mat:md5,1038f3b4b63d8dbd572947d68d7ed90d" ] ] ], @@ -475,7 +475,7 @@ "id": "test" }, [ - "test_forward1_affine.mat:md5,72aee9284d5e624be5dbc15cfce8151c" + "test_forward1_affine.mat:md5,6e47b89fcdd230c852b25ce8036438e9" ] ] ], @@ -487,7 +487,7 @@ { "id": "test" }, - "test_backward0_affine.mat:md5,862976c1966b1af64acd7b40d0f922e4" + "test_backward0_affine.mat:md5,1038f3b4b63d8dbd572947d68d7ed90d" ] ], "backward_image_transform": [ @@ -496,7 +496,7 @@ "id": "test" }, [ - "test_backward0_affine.mat:md5,862976c1966b1af64acd7b40d0f922e4" + "test_backward0_affine.mat:md5,1038f3b4b63d8dbd572947d68d7ed90d" ] ] ], @@ -506,7 +506,7 @@ "id": "test" }, [ - "test_forward1_affine.mat:md5,72aee9284d5e624be5dbc15cfce8151c" + "test_forward1_affine.mat:md5,6e47b89fcdd230c852b25ce8036438e9" ] ] ], @@ -518,7 +518,7 @@ { "id": "test" }, - "test_forward1_affine.mat:md5,72aee9284d5e624be5dbc15cfce8151c" + "test_forward1_affine.mat:md5,6e47b89fcdd230c852b25ce8036438e9" ] ], "forward_image_transform": [ @@ -527,7 +527,7 @@ "id": "test" }, [ - "test_forward1_affine.mat:md5,72aee9284d5e624be5dbc15cfce8151c" + "test_forward1_affine.mat:md5,6e47b89fcdd230c852b25ce8036438e9" ] ] ], @@ -537,7 +537,7 @@ "id": "test" }, [ - "test_backward0_affine.mat:md5,862976c1966b1af64acd7b40d0f922e4" + "test_backward0_affine.mat:md5,1038f3b4b63d8dbd572947d68d7ed90d" ] ] ], @@ -549,7 +549,7 @@ { "id": "test" }, - "test_t1_warped.nii.gz:md5,9f4d57c0e9cde3da4ab4718f360abce6" + "test_t1_warped.nii.gz:md5,e8c78a1c57ae3a51ebf0611e09bc3c59" ] ], "mqc": [ @@ -564,6 +564,6 @@ "nf-test": "0.9.3", "nextflow": "25.10.2" }, - "timestamp": "2026-06-04T10:27:42.101532717" + "timestamp": "2026-07-10T10:50:04.991990693" } } \ No newline at end of file diff --git a/subworkflows/nf-neuro/registration/main.nf b/subworkflows/nf-neuro/registration/main.nf index b8c3ee83..bc7fd3ff 100644 --- a/subworkflows/nf-neuro/registration/main.nf +++ b/subworkflows/nf-neuro/registration/main.nf @@ -6,6 +6,7 @@ include { REGISTRATION_CONVERT } from '../../../modules/nf-neuro/registration/co include { UTILS_OPTIONS } from '../utils_options/main' include { IMAGE_APPLYMASK as MASK_FIXED_IMAGE} from '../../../modules/nf-neuro/image/applymask/main' include { IMAGE_APPLYMASK as MASK_MOVING_IMAGE} from '../../../modules/nf-neuro/image/applymask/main' +include { IMAGE_APPLYMASK as MASK_MOVING_METRIC} from '../../../modules/nf-neuro/image/applymask/main' include { REGISTRATION_ANTSAPPLYTRANSFORMS as WARP_IMAGE_TO_FIXED } from '../../../modules/nf-neuro/registration/antsapplytransforms/main' include { REGISTRATION_ANTSAPPLYTRANSFORMS as WARP_IMAGE_TO_MOVING } from '../../../modules/nf-neuro/registration/antsapplytransforms/main' @@ -37,15 +38,45 @@ workflow REGISTRATION { UTILS_OPTIONS("${moduleDir}/meta.yml", options, true) options = UTILS_OPTIONS.out.options.value - MASK_FIXED_IMAGE ( ch_fixed_image.join(ch_fixed_mask) ) - ch_fixed_image_ready = ch_fixed_image.join(MASK_FIXED_IMAGE.out.image, remainder: true) - .map({ meta, orig, masked -> [meta, masked?: orig] }) - ch_versions = ch_versions.mix(MASK_FIXED_IMAGE.out.versions.first()) + if ( ( options.masking_strategy == "apriori" || options.masking_strategy == "both" ) && ( ch_fixed_mask || ch_moving_mask || ch_metric ) ) { + if ( ch_fixed_mask ) { + MASK_FIXED_IMAGE ( ch_fixed_image.join(ch_fixed_mask) ) + ch_fixed_image_ready = ch_fixed_image.join(MASK_FIXED_IMAGE.out.image, remainder: true) + .map({ meta, orig, masked -> [meta, masked?: orig] }) + ch_versions = ch_versions.mix(MASK_FIXED_IMAGE.out.versions.first()) + } + else { + ch_fixed_image_ready = ch_fixed_image + } + if ( ch_moving_mask ) { + MASK_MOVING_IMAGE ( ch_moving_image.join(ch_moving_mask) ) + ch_moving_image_ready = ch_moving_image.join(MASK_MOVING_IMAGE.out.image, remainder: true) + .map({ meta, orig, masked -> [meta, masked?: orig] }) + ch_versions = ch_versions.mix(MASK_MOVING_IMAGE.out.versions.first()) - MASK_MOVING_IMAGE ( ch_moving_image.join(ch_moving_mask) ) - ch_moving_image_ready = ch_moving_image.join(MASK_MOVING_IMAGE.out.image, remainder: true) - .map({ meta, orig, masked -> [meta, masked?: orig] }) - ch_versions = ch_versions.mix(MASK_MOVING_IMAGE.out.versions.first()) + if ( ch_metric ) { + MASK_MOVING_METRIC ( ch_metric.join(ch_moving_mask) ) + ch_moving_metric_ready = ch_metric.join(MASK_MOVING_METRIC.out.image, remainder: true) + .map({ meta, orig, masked -> [meta, masked?: orig] }) + ch_versions = ch_versions.mix(MASK_MOVING_METRIC.out.versions.first()) + } + else { + ch_moving_metric_ready = ch_metric + } + } + else { + ch_moving_image_ready = ch_moving_image + } + } + else { + ch_fixed_image_ready = ch_fixed_image + ch_moving_image_ready = ch_moving_image + ch_moving_metric_ready = ch_metric + } + + if ( ( options.masking_strategy == "both" || options.masking_strategy == "internal" ) && ( options.run_easyreg || options.run_synthmorph ) ) { + error "The \${options.masking_strategy} masking strategy is not compatible with the easyreg or synthmorph registration methods." + } if ( options.run_easyreg ) { // ** Registration using Easyreg ** // @@ -181,8 +212,10 @@ workflow REGISTRATION { // - ants_syn : doesn't have a metric at index 3 ( [] or null ) ch_register = ch_fixed_image_ready .join(ch_moving_image_ready) - .join(ch_metric, remainder: true) - .map{ it[0..2] + [it[3] ?: []] } + .join(ch_moving_metric_ready, remainder: true) + .join(ch_fixed_mask, remainder: true) + .join(ch_moving_mask, remainder: true) + .map{ it[0..2] + [it[3] ?: []] + [it[4] ?: [], it[5] ?: []] } .branch{ anat_to_dwi : it[3] ants_syn: true @@ -236,11 +269,9 @@ workflow REGISTRATION { out_image_warped_masked = out_image_warped .join(ch_moving_mask) .map{ meta, warped, mask -> mask ? [meta, warped] : [] } - out_ref_warped_masked = out_ref_warped .join(ch_fixed_mask) .map{ meta, warped, mask -> mask ? [meta, warped] : [] } - // Register original moving image WARP_IMAGE_TO_FIXED ( ch_moving_image .join(ch_fixed_image) @@ -262,7 +293,7 @@ workflow REGISTRATION { .join(WARP_IMAGE_TO_MOVING.out.warped_image) .map{ meta, warped, masked_warped -> [meta, masked_warped ?: warped] } ch_versions = ch_versions.mix(WARP_IMAGE_TO_MOVING.out.versions.first()) -cd + emit: image_warped = out_image_warped // channel: [ val(meta), image ] reference_warped = out_ref_warped // channel: [ val(meta), ref ] diff --git a/subworkflows/nf-neuro/registration/meta.yml b/subworkflows/nf-neuro/registration/meta.yml index a2aadc2c..287abcf4 100644 --- a/subworkflows/nf-neuro/registration/meta.yml +++ b/subworkflows/nf-neuro/registration/meta.yml @@ -137,6 +137,10 @@ input: description: Map of options for the registration subworkflow. mandatory: false entries: + masking_strategy: + type: string + description: Masking strategy to use for registration. Options are 'none', 'apriori', 'both'. + default: "none" run_easyreg: type: boolean description: Run EasyReg for registration. If false, SynthMorph will be used if `run_synthmorph` is true, and ANTs SyN will be used if `run_synthmorph` is false. diff --git a/subworkflows/nf-neuro/registration/tests/main.nf.test.snap b/subworkflows/nf-neuro/registration/tests/main.nf.test.snap index 37b4c0f5..b9648fe5 100644 --- a/subworkflows/nf-neuro/registration/tests/main.nf.test.snap +++ b/subworkflows/nf-neuro/registration/tests/main.nf.test.snap @@ -54,27 +54,9 @@ "test_out_warp.nii.gz" ] ], - "image_warped": [ - [ - { - "id": "test" - }, - "test_b0_warped.nii.gz" - ] - ], - "reference_warped": [ - [ - { - "id": "test" - }, - "test_T1w_warped.nii.gz" - ] - ], "versions": [ "versions.yml:md5,300199ef2ea6dd6438553c3ec2615e58", - "versions.yml:md5,3764dd2f067db355da3536c1b0c94619", - "versions.yml:md5,5bc0d347809508f4b94ebe433b0f21b9", - "versions.yml:md5,8d90eba5eb0cfe9c82c7280c1b6e66a8" + "versions.yml:md5,5bc0d347809508f4b94ebe433b0f21b9" ] } ], @@ -82,7 +64,7 @@ "nf-test": "0.9.3", "nextflow": "25.10.2" }, - "timestamp": "2026-06-04T15:29:09.626057948" + "timestamp": "2026-07-10T12:17:50.130253183" }, "registration - easyreg": { "content": [ @@ -135,14 +117,6 @@ "test_forward0_warp.nii.gz" ] ], - "image_warped": [ - [ - { - "id": "test" - }, - "test_b0_warped.nii.gz" - ] - ], "reference_segmentation": [ [ { @@ -151,14 +125,6 @@ "test_warped_reference_segmentation.nii.gz" ] ], - "reference_warped": [ - [ - { - "id": "test" - }, - "test_T1w_warped.nii.gz" - ] - ], "segmentation": [ [ { @@ -168,9 +134,7 @@ ] ], "versions": [ - "versions.yml:md5,3764dd2f067db355da3536c1b0c94619", - "versions.yml:md5,3f38c911476c605480c02e484fcf6e9f", - "versions.yml:md5,8d90eba5eb0cfe9c82c7280c1b6e66a8" + "versions.yml:md5,3f38c911476c605480c02e484fcf6e9f" ] } ], @@ -178,7 +142,7 @@ "nf-test": "0.9.3", "nextflow": "25.10.2" }, - "timestamp": "2026-06-04T15:28:51.999584319" + "timestamp": "2026-07-10T12:17:39.385111058" }, "registration - ANTs - SyNQuick": { "content": [ @@ -251,14 +215,6 @@ "test_forward0_warp.nii.gz" ] ], - "image_warped": [ - [ - { - "id": "test" - }, - "test_t1_warped.nii.gz" - ] - ], "mqc": [ [ { @@ -267,18 +223,8 @@ "test__registration_ants_mqc.gif" ] ], - "reference_warped": [ - [ - { - "id": "test" - }, - "test_test_masked_warped.nii.gz" - ] - ], "versions": [ "versions.yml:md5,3764dd2f067db355da3536c1b0c94619", - "versions.yml:md5,8d90eba5eb0cfe9c82c7280c1b6e66a8", - "versions.yml:md5,8f4cb1a55910da303007d7c2202e62f0", "versions.yml:md5,a338911f46f2c623d87eab600c524ffb" ] } @@ -287,7 +233,7 @@ "nf-test": "0.9.3", "nextflow": "25.10.2" }, - "timestamp": "2026-06-04T15:28:29.794849703" + "timestamp": "2026-07-10T12:17:25.989995681" }, "registration - ANTs - Anat to DWI": { "content": [ @@ -360,14 +306,6 @@ "test_forward0_warp.nii.gz" ] ], - "image_warped": [ - [ - { - "id": "test" - }, - "test_T1w_warped.nii.gz" - ] - ], "mqc": [ [ { @@ -376,18 +314,8 @@ "test_registration_anattodwi_mqc.gif" ] ], - "reference_warped": [ - [ - { - "id": "test" - }, - "test_b0_warped.nii.gz" - ] - ], "versions": [ - "versions.yml:md5,03b958f14a890b541bb76c73f7a72847", - "versions.yml:md5,3764dd2f067db355da3536c1b0c94619", - "versions.yml:md5,8d90eba5eb0cfe9c82c7280c1b6e66a8" + "versions.yml:md5,03b958f14a890b541bb76c73f7a72847" ] } ], @@ -395,6 +323,6 @@ "nf-test": "0.9.3", "nextflow": "25.10.2" }, - "timestamp": "2026-06-04T15:28:03.979362405" + "timestamp": "2026-07-10T12:17:07.629766386" } } \ No newline at end of file diff --git a/subworkflows/nf-neuro/registration/tests/nextflow.config b/subworkflows/nf-neuro/registration/tests/nextflow.config index bf293e61..91c91d03 100644 --- a/subworkflows/nf-neuro/registration/tests/nextflow.config +++ b/subworkflows/nf-neuro/registration/tests/nextflow.config @@ -11,10 +11,12 @@ process { } withName: "REGISTRATION_ANATTODWI" { + ext.masking_strategy = "internal" ext.run_qc = true } withName: "REGISTRATION_ANTS" { + ext.masking_strategy = "apriori" ext.quick = true ext.repro_mode = true ext.transform = "a" From 726f1d3c9db15a4b58e6331f83e3e189298dbd5f Mon Sep 17 00:00:00 2001 From: arnaudbore Date: Fri, 10 Jul 2026 14:47:56 -0400 Subject: [PATCH 05/14] add more tests using masks --- .../registration/anattodwi/tests/main.nf.test | 52 +++ .../anattodwi/tests/main.nf.test.snap | 221 ++++++++++ .../anattodwi/tests/nextflow.config | 1 + modules/nf-neuro/registration/ants/main.nf | 2 +- .../registration/ants/tests/main.nf.test | 86 ++++ .../registration/ants/tests/main.nf.test.snap | 402 ++++++++++++++++++ .../tests/nextflow_both_moving_mask.config | 9 + 7 files changed, 772 insertions(+), 1 deletion(-) create mode 100644 modules/nf-neuro/registration/ants/tests/nextflow_both_moving_mask.config diff --git a/modules/nf-neuro/registration/anattodwi/tests/main.nf.test b/modules/nf-neuro/registration/anattodwi/tests/main.nf.test index 2685e95d..65279e9d 100644 --- a/modules/nf-neuro/registration/anattodwi/tests/main.nf.test +++ b/modules/nf-neuro/registration/anattodwi/tests/main.nf.test @@ -69,6 +69,58 @@ nextflow_process { } } + test("registration - anattodwi - fixed mask") { + config "./nextflow.config" + when { + process { + """ + ch_split_test_data = LOAD_DATA.out.test_data_directory + .branch{ + t1w: it.simpleName == "T1w" + b0: it.simpleName == "b0" + dti: it.simpleName == "dti" + } + ch_t1w = ch_split_test_data.t1w.map{ + test_data_directory -> [ + [ id:'test', single_end:false ], + file("\${test_data_directory}/T1w.nii.gz") + ] + } + ch_b0 = ch_split_test_data.b0.map{ + test_data_directory -> [ + [ id:'test', single_end:false ], + file("\${test_data_directory}/b0.nii.gz") + ] + } + ch_fa = ch_split_test_data.dti.map{ + test_data_directory -> [ + [ id:'test', single_end:false ], + file("\${test_data_directory}/fa.nii.gz") + ] + } + ch_fixed_mask = ch_split_test_data.t1w.map{ + test_data_directory -> [ + [ id:'test', single_end:false ], + file("\${test_data_directory}/T1w_mask.nii.gz") + ] + } + input[0] = ch_b0 + .join(ch_t1w) + .join(ch_fa) + .join(ch_fixed_mask) + .map{ meta, fixed, moving, fixed_metric, fixed_mask -> [meta, fixed, moving, fixed_metric, fixed_mask, []] } + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + } + test("registration - anattodwi -stub-run") { tag "stub" options "-stub-run" diff --git a/modules/nf-neuro/registration/anattodwi/tests/main.nf.test.snap b/modules/nf-neuro/registration/anattodwi/tests/main.nf.test.snap index 395e9958..2f808c1e 100644 --- a/modules/nf-neuro/registration/anattodwi/tests/main.nf.test.snap +++ b/modules/nf-neuro/registration/anattodwi/tests/main.nf.test.snap @@ -231,5 +231,226 @@ "nextflow": "25.10.2" }, "timestamp": "2026-02-26T22:30:03.859914189" + }, + "registration - anattodwi - fixed mask": { + "content": [ + { + "0": [ + [ + { + "id": "test", + "single_end": false + }, + "test_T1w_warped.nii.gz:md5,9f2eda1485017da83b5fcd6871cdcb74" + ] + ], + "1": [ + [ + { + "id": "test", + "single_end": false + }, + "test_forward1_affine.mat:md5,984ac5023aca49f513af811d0f1e3e89" + ] + ], + "10": [ + "versions.yml:md5,37249bcc3b9ecbaf310960d876fd802d" + ], + "2": [ + [ + { + "id": "test", + "single_end": false + }, + "test_forward0_warp.nii.gz:md5,464d7b291ab9c9aaead7ecbfec6a6693" + ] + ], + "3": [ + [ + { + "id": "test", + "single_end": false + }, + "test_backward1_warp.nii.gz:md5,4ea6f41a8246f3cb0b1ad39c94028c1f" + ] + ], + "4": [ + [ + { + "id": "test", + "single_end": false + }, + "test_backward0_affine.mat:md5,177325d18b5a5fa457bd3a2e052463d9" + ] + ], + "5": [ + [ + { + "id": "test", + "single_end": false + }, + [ + "test_forward0_warp.nii.gz:md5,464d7b291ab9c9aaead7ecbfec6a6693", + "test_forward1_affine.mat:md5,984ac5023aca49f513af811d0f1e3e89" + ] + ] + ], + "6": [ + [ + { + "id": "test", + "single_end": false + }, + [ + "test_backward0_affine.mat:md5,177325d18b5a5fa457bd3a2e052463d9", + "test_backward1_warp.nii.gz:md5,4ea6f41a8246f3cb0b1ad39c94028c1f" + ] + ] + ], + "7": [ + [ + { + "id": "test", + "single_end": false + }, + [ + "test_backward0_affine.mat:md5,177325d18b5a5fa457bd3a2e052463d9", + "test_backward1_warp.nii.gz:md5,4ea6f41a8246f3cb0b1ad39c94028c1f" + ] + ] + ], + "8": [ + [ + { + "id": "test", + "single_end": false + }, + [ + "test_forward0_warp.nii.gz:md5,464d7b291ab9c9aaead7ecbfec6a6693", + "test_forward1_affine.mat:md5,984ac5023aca49f513af811d0f1e3e89" + ] + ] + ], + "9": [ + [ + { + "id": "test", + "single_end": false + }, + "test_registration_anattodwi_mqc.gif:md5,9cbc1ce8755821996dae18080cf0a23c" + ] + ], + "anat_warped": [ + [ + { + "id": "test", + "single_end": false + }, + "test_T1w_warped.nii.gz:md5,9f2eda1485017da83b5fcd6871cdcb74" + ] + ], + "backward_affine": [ + [ + { + "id": "test", + "single_end": false + }, + "test_backward0_affine.mat:md5,177325d18b5a5fa457bd3a2e052463d9" + ] + ], + "backward_image_transform": [ + [ + { + "id": "test", + "single_end": false + }, + [ + "test_backward0_affine.mat:md5,177325d18b5a5fa457bd3a2e052463d9", + "test_backward1_warp.nii.gz:md5,4ea6f41a8246f3cb0b1ad39c94028c1f" + ] + ] + ], + "backward_tractogram_transform": [ + [ + { + "id": "test", + "single_end": false + }, + [ + "test_forward0_warp.nii.gz:md5,464d7b291ab9c9aaead7ecbfec6a6693", + "test_forward1_affine.mat:md5,984ac5023aca49f513af811d0f1e3e89" + ] + ] + ], + "backward_warp": [ + [ + { + "id": "test", + "single_end": false + }, + "test_backward1_warp.nii.gz:md5,4ea6f41a8246f3cb0b1ad39c94028c1f" + ] + ], + "forward_affine": [ + [ + { + "id": "test", + "single_end": false + }, + "test_forward1_affine.mat:md5,984ac5023aca49f513af811d0f1e3e89" + ] + ], + "forward_image_transform": [ + [ + { + "id": "test", + "single_end": false + }, + [ + "test_forward0_warp.nii.gz:md5,464d7b291ab9c9aaead7ecbfec6a6693", + "test_forward1_affine.mat:md5,984ac5023aca49f513af811d0f1e3e89" + ] + ] + ], + "forward_tractogram_transform": [ + [ + { + "id": "test", + "single_end": false + }, + [ + "test_backward0_affine.mat:md5,177325d18b5a5fa457bd3a2e052463d9", + "test_backward1_warp.nii.gz:md5,4ea6f41a8246f3cb0b1ad39c94028c1f" + ] + ] + ], + "forward_warp": [ + [ + { + "id": "test", + "single_end": false + }, + "test_forward0_warp.nii.gz:md5,464d7b291ab9c9aaead7ecbfec6a6693" + ] + ], + "mqc": [ + [ + { + "id": "test", + "single_end": false + }, + "test_registration_anattodwi_mqc.gif:md5,9cbc1ce8755821996dae18080cf0a23c" + ] + ], + "versions": [ + "versions.yml:md5,37249bcc3b9ecbaf310960d876fd802d" + ] + } + ], + "meta": { + "nf-test": "0.9.3", + "nextflow": "25.10.2" + }, + "timestamp": "2026-07-10T14:35:36.061250786" } } \ No newline at end of file diff --git a/modules/nf-neuro/registration/anattodwi/tests/nextflow.config b/modules/nf-neuro/registration/anattodwi/tests/nextflow.config index 68043db3..19215bf7 100644 --- a/modules/nf-neuro/registration/anattodwi/tests/nextflow.config +++ b/modules/nf-neuro/registration/anattodwi/tests/nextflow.config @@ -2,5 +2,6 @@ process { withName: "REGISTRATION_ANATTODWI" { ext.cpus = 1 ext.run_qc = true + ext.masking_strategy = "internal" } } diff --git a/modules/nf-neuro/registration/ants/main.nf b/modules/nf-neuro/registration/ants/main.nf index 2e296adc..04d79efe 100644 --- a/modules/nf-neuro/registration/ants/main.nf +++ b/modules/nf-neuro/registration/ants/main.nf @@ -44,7 +44,7 @@ process REGISTRATION_ANTS { if ( task.ext.histogram_matching ) args += " -j $task.ext.histogram_matching" if ( task.ext.repro_mode ) args += " -y $task.ext.repro_mode" if ( task.ext.collapse_output ) args += " -z $task.ext.collapse_output" - if ( task.ext.masking_strategy == "both" || task.ext.masking_strategy == "internal" ) args += " -x $fixed_mask?:NULL,$moving_mask?:NULL" + if ( task.ext.masking_strategy == "both" || task.ext.masking_strategy == "internal" ) args += " -x ${fixed_mask ?: 'NULL'},${moving_mask ?: 'NULL'}" """ export ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS=${task.ext.single_thread ? 1 : task.cpus} diff --git a/modules/nf-neuro/registration/ants/tests/main.nf.test b/modules/nf-neuro/registration/ants/tests/main.nf.test index a0ca15fc..a8b8370f 100644 --- a/modules/nf-neuro/registration/ants/tests/main.nf.test +++ b/modules/nf-neuro/registration/ants/tests/main.nf.test @@ -132,6 +132,92 @@ nextflow_process { } } + test("registration - ants - both - moving mask") { + config "./nextflow_both_moving_mask.config" + when { + process { + """ + ch_split_test_data = LOAD_DATA.out.test_data_directory + .branch{ + T1w: it.simpleName == "T1w" + moving: it.simpleName == "others" + } + ch_fixed = ch_split_test_data.moving.map{ + test_data_directory -> [ + [ id:'test' ], + file("\${test_data_directory}/t1.nii.gz") + ] + } + ch_moving = ch_split_test_data.T1w.map{ + test_data_directory -> [ + [ id:'test' ], + file("\${test_data_directory}/T1w.nii.gz") + ] + } + ch_moving_mask = ch_split_test_data.T1w.map{ + test_data_directory -> [ + [ id:'test' ], + file("\${test_data_directory}/T1w_mask.nii.gz") + ] + } + input[0] = ch_fixed + .join(ch_moving) + .join(ch_moving_mask) + .map{ meta, fixed, moving, moving_mask -> [meta, fixed, moving, [], moving_mask] } + """ + } + } + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + } + + test("registration - ants - both - fixed mask") { + config "./nextflow_both_moving_mask.config" + when { + process { + """ + ch_split_test_data = LOAD_DATA.out.test_data_directory + .branch{ + T1w: it.simpleName == "T1w" + moving: it.simpleName == "others" + } + ch_T1w = ch_split_test_data.T1w.map{ + test_data_directory -> [ + [ id:'test' ], + file("\${test_data_directory}/T1w.nii.gz") + ] + } + ch_moving = ch_split_test_data.moving.map{ + test_data_directory -> [ + [ id:'test' ], + file("\${test_data_directory}/t1.nii.gz") + ] + } + ch_fixed_mask = ch_split_test_data.T1w.map{ + test_data_directory -> [ + [ id:'test' ], + file("\${test_data_directory}/T1w_mask.nii.gz") + ] + } + input[0] = ch_T1w + .join(ch_moving) + .join(ch_fixed_mask) + .map{ meta, fixed, moving, fixed_mask -> [meta, fixed, moving, fixed_mask, []] } + """ + } + } + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + } + test("registration - ants - stub") { tag "stub" options "-stub-run" diff --git a/modules/nf-neuro/registration/ants/tests/main.nf.test.snap b/modules/nf-neuro/registration/ants/tests/main.nf.test.snap index d9fdc0e9..be355bea 100644 --- a/modules/nf-neuro/registration/ants/tests/main.nf.test.snap +++ b/modules/nf-neuro/registration/ants/tests/main.nf.test.snap @@ -1,4 +1,205 @@ { + "registration - ants - both - moving mask": { + "content": [ + { + "0": [ + [ + { + "id": "test" + }, + "test_T1w_warped.nii.gz:md5,92e339e7f93c24437b216cb2dde4f0cb" + ] + ], + "1": [ + [ + { + "id": "test" + }, + "test_forward1_affine.mat:md5,032d3bda1e72c7f1c7224aa6783e9cf0" + ] + ], + "10": [ + "versions.yml:md5,0b121e44c28b1c3efb04ae0dfc9ec76c" + ], + "2": [ + [ + { + "id": "test" + }, + "test_forward0_warp.nii.gz:md5,174b5b43c2e91ea804756d0d4cd15bad" + ] + ], + "3": [ + [ + { + "id": "test" + }, + "test_backward1_warp.nii.gz:md5,8948e3dab061e31afd3e0b36d76e6031" + ] + ], + "4": [ + [ + { + "id": "test" + }, + "test_backward0_affine.mat:md5,723a9c3ccffc3ed835a5657739e09134" + ] + ], + "5": [ + [ + { + "id": "test" + }, + [ + "test_forward0_warp.nii.gz:md5,174b5b43c2e91ea804756d0d4cd15bad", + "test_forward1_affine.mat:md5,032d3bda1e72c7f1c7224aa6783e9cf0" + ] + ] + ], + "6": [ + [ + { + "id": "test" + }, + [ + "test_backward0_affine.mat:md5,723a9c3ccffc3ed835a5657739e09134", + "test_backward1_warp.nii.gz:md5,8948e3dab061e31afd3e0b36d76e6031" + ] + ] + ], + "7": [ + [ + { + "id": "test" + }, + [ + "test_backward0_affine.mat:md5,723a9c3ccffc3ed835a5657739e09134", + "test_backward1_warp.nii.gz:md5,8948e3dab061e31afd3e0b36d76e6031" + ] + ] + ], + "8": [ + [ + { + "id": "test" + }, + [ + "test_forward0_warp.nii.gz:md5,174b5b43c2e91ea804756d0d4cd15bad", + "test_forward1_affine.mat:md5,032d3bda1e72c7f1c7224aa6783e9cf0" + ] + ] + ], + "9": [ + [ + { + "id": "test" + }, + "test_T1_to_T1_slab_registration_ants_mqc.gif:md5,f479eff30517367afb88c0974436d23b" + ] + ], + "backward_affine": [ + [ + { + "id": "test" + }, + "test_backward0_affine.mat:md5,723a9c3ccffc3ed835a5657739e09134" + ] + ], + "backward_image_transform": [ + [ + { + "id": "test" + }, + [ + "test_backward0_affine.mat:md5,723a9c3ccffc3ed835a5657739e09134", + "test_backward1_warp.nii.gz:md5,8948e3dab061e31afd3e0b36d76e6031" + ] + ] + ], + "backward_tractogram_transform": [ + [ + { + "id": "test" + }, + [ + "test_forward0_warp.nii.gz:md5,174b5b43c2e91ea804756d0d4cd15bad", + "test_forward1_affine.mat:md5,032d3bda1e72c7f1c7224aa6783e9cf0" + ] + ] + ], + "backward_warp": [ + [ + { + "id": "test" + }, + "test_backward1_warp.nii.gz:md5,8948e3dab061e31afd3e0b36d76e6031" + ] + ], + "forward_affine": [ + [ + { + "id": "test" + }, + "test_forward1_affine.mat:md5,032d3bda1e72c7f1c7224aa6783e9cf0" + ] + ], + "forward_image_transform": [ + [ + { + "id": "test" + }, + [ + "test_forward0_warp.nii.gz:md5,174b5b43c2e91ea804756d0d4cd15bad", + "test_forward1_affine.mat:md5,032d3bda1e72c7f1c7224aa6783e9cf0" + ] + ] + ], + "forward_tractogram_transform": [ + [ + { + "id": "test" + }, + [ + "test_backward0_affine.mat:md5,723a9c3ccffc3ed835a5657739e09134", + "test_backward1_warp.nii.gz:md5,8948e3dab061e31afd3e0b36d76e6031" + ] + ] + ], + "forward_warp": [ + [ + { + "id": "test" + }, + "test_forward0_warp.nii.gz:md5,174b5b43c2e91ea804756d0d4cd15bad" + ] + ], + "image_warped": [ + [ + { + "id": "test" + }, + "test_T1w_warped.nii.gz:md5,92e339e7f93c24437b216cb2dde4f0cb" + ] + ], + "mqc": [ + [ + { + "id": "test" + }, + "test_T1_to_T1_slab_registration_ants_mqc.gif:md5,f479eff30517367afb88c0974436d23b" + ] + ], + "versions": [ + "versions.yml:md5,0b121e44c28b1c3efb04ae0dfc9ec76c" + ] + } + ], + "meta": { + "nf-test": "0.9.3", + "nextflow": "25.10.2" + }, + "timestamp": "2026-07-10T13:58:41.627501355" + }, "registration - ants - stub": { "content": [ [ @@ -403,6 +604,207 @@ }, "timestamp": "2026-07-10T10:48:35.425395985" }, + "registration - ants - both - fixed mask": { + "content": [ + { + "0": [ + [ + { + "id": "test" + }, + "test_t1_warped.nii.gz:md5,ea7f1bc0540975d6484a15c7a74fb115" + ] + ], + "1": [ + [ + { + "id": "test" + }, + "test_forward1_affine.mat:md5,3f5500ed1d3e896ab2b53a5c92cd3f76" + ] + ], + "10": [ + "versions.yml:md5,0b121e44c28b1c3efb04ae0dfc9ec76c" + ], + "2": [ + [ + { + "id": "test" + }, + "test_forward0_warp.nii.gz:md5,e815d27e3d69c9337919a3ad76815806" + ] + ], + "3": [ + [ + { + "id": "test" + }, + "test_backward1_warp.nii.gz:md5,6f16542b188b1bfe068c12e9ce6ee8f8" + ] + ], + "4": [ + [ + { + "id": "test" + }, + "test_backward0_affine.mat:md5,0f1af73ef9da3e722592701432a1a340" + ] + ], + "5": [ + [ + { + "id": "test" + }, + [ + "test_forward0_warp.nii.gz:md5,e815d27e3d69c9337919a3ad76815806", + "test_forward1_affine.mat:md5,3f5500ed1d3e896ab2b53a5c92cd3f76" + ] + ] + ], + "6": [ + [ + { + "id": "test" + }, + [ + "test_backward0_affine.mat:md5,0f1af73ef9da3e722592701432a1a340", + "test_backward1_warp.nii.gz:md5,6f16542b188b1bfe068c12e9ce6ee8f8" + ] + ] + ], + "7": [ + [ + { + "id": "test" + }, + [ + "test_backward0_affine.mat:md5,0f1af73ef9da3e722592701432a1a340", + "test_backward1_warp.nii.gz:md5,6f16542b188b1bfe068c12e9ce6ee8f8" + ] + ] + ], + "8": [ + [ + { + "id": "test" + }, + [ + "test_forward0_warp.nii.gz:md5,e815d27e3d69c9337919a3ad76815806", + "test_forward1_affine.mat:md5,3f5500ed1d3e896ab2b53a5c92cd3f76" + ] + ] + ], + "9": [ + [ + { + "id": "test" + }, + "test_T1_to_T1_slab_registration_ants_mqc.gif:md5,3de94aa1d262a96423c0415846d3a7db" + ] + ], + "backward_affine": [ + [ + { + "id": "test" + }, + "test_backward0_affine.mat:md5,0f1af73ef9da3e722592701432a1a340" + ] + ], + "backward_image_transform": [ + [ + { + "id": "test" + }, + [ + "test_backward0_affine.mat:md5,0f1af73ef9da3e722592701432a1a340", + "test_backward1_warp.nii.gz:md5,6f16542b188b1bfe068c12e9ce6ee8f8" + ] + ] + ], + "backward_tractogram_transform": [ + [ + { + "id": "test" + }, + [ + "test_forward0_warp.nii.gz:md5,e815d27e3d69c9337919a3ad76815806", + "test_forward1_affine.mat:md5,3f5500ed1d3e896ab2b53a5c92cd3f76" + ] + ] + ], + "backward_warp": [ + [ + { + "id": "test" + }, + "test_backward1_warp.nii.gz:md5,6f16542b188b1bfe068c12e9ce6ee8f8" + ] + ], + "forward_affine": [ + [ + { + "id": "test" + }, + "test_forward1_affine.mat:md5,3f5500ed1d3e896ab2b53a5c92cd3f76" + ] + ], + "forward_image_transform": [ + [ + { + "id": "test" + }, + [ + "test_forward0_warp.nii.gz:md5,e815d27e3d69c9337919a3ad76815806", + "test_forward1_affine.mat:md5,3f5500ed1d3e896ab2b53a5c92cd3f76" + ] + ] + ], + "forward_tractogram_transform": [ + [ + { + "id": "test" + }, + [ + "test_backward0_affine.mat:md5,0f1af73ef9da3e722592701432a1a340", + "test_backward1_warp.nii.gz:md5,6f16542b188b1bfe068c12e9ce6ee8f8" + ] + ] + ], + "forward_warp": [ + [ + { + "id": "test" + }, + "test_forward0_warp.nii.gz:md5,e815d27e3d69c9337919a3ad76815806" + ] + ], + "image_warped": [ + [ + { + "id": "test" + }, + "test_t1_warped.nii.gz:md5,ea7f1bc0540975d6484a15c7a74fb115" + ] + ], + "mqc": [ + [ + { + "id": "test" + }, + "test_T1_to_T1_slab_registration_ants_mqc.gif:md5,3de94aa1d262a96423c0415846d3a7db" + ] + ], + "versions": [ + "versions.yml:md5,0b121e44c28b1c3efb04ae0dfc9ec76c" + ] + } + ], + "meta": { + "nf-test": "0.9.3", + "nextflow": "25.10.2" + }, + "timestamp": "2026-07-10T14:00:10.265843278" + }, "registration - ants - no warps": { "content": [ { diff --git a/modules/nf-neuro/registration/ants/tests/nextflow_both_moving_mask.config b/modules/nf-neuro/registration/ants/tests/nextflow_both_moving_mask.config new file mode 100644 index 00000000..aed85d5b --- /dev/null +++ b/modules/nf-neuro/registration/ants/tests/nextflow_both_moving_mask.config @@ -0,0 +1,9 @@ +process { + withName: "REGISTRATION_ANTS" { + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } + ext.quick = true + ext.run_qc = true + ext.suffix_qc = "T1_to_T1_slab" + ext.masking_strategy = "both" + } +} From 5c18bd95745d440c38e6a74bd8ecb164ecd8be4a Mon Sep 17 00:00:00 2001 From: arnaudbore Date: Fri, 10 Jul 2026 16:59:11 -0400 Subject: [PATCH 06/14] give it a try with Anthony help --- .../nf-neuro/registration/anattodwi/main.nf | 2 +- .../tests/main.nf.test.snap | 155 +------ subworkflows/nf-neuro/registration/main.nf | 1 + .../tractoflow/tests/main.nf.test.snap | 430 +----------------- 4 files changed, 7 insertions(+), 581 deletions(-) diff --git a/modules/nf-neuro/registration/anattodwi/main.nf b/modules/nf-neuro/registration/anattodwi/main.nf index 064a158b..29532f43 100644 --- a/modules/nf-neuro/registration/anattodwi/main.nf +++ b/modules/nf-neuro/registration/anattodwi/main.nf @@ -28,7 +28,7 @@ process REGISTRATION_ANATTODWI { def run_qc = task.ext.run_qc as Boolean || false def args = task.ext.args ?: '' - if ( task.ext.masking_strategy == "both" || task.ext.masking_strategy == "internal" ) args += " -x $fixed_mask?:NULL,$moving_mask?:NULL" + if ( task.ext.masking_strategy == "both" || task.ext.masking_strategy == "internal" ) args += " -x ${fixed_mask ?: 'NULL'},${moving_mask ?: 'NULL'}" """ export ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS=${task.ext.single_thread ? 1 : task.cpus} export OMP_NUM_THREADS=${task.ext.single_thread ? 1 : task.cpus} diff --git a/subworkflows/nf-neuro/output_template_space/tests/main.nf.test.snap b/subworkflows/nf-neuro/output_template_space/tests/main.nf.test.snap index 5b25a6bb..0847bbc3 100644 --- a/subworkflows/nf-neuro/output_template_space/tests/main.nf.test.snap +++ b/subworkflows/nf-neuro/output_template_space/tests/main.nf.test.snap @@ -2,40 +2,6 @@ "Template MNI152NLin2009bSym - no brain mask": { "content": [ { - "ch_registered_anat": [ - [ - { - "id": "test" - }, - "test_t1_warped.nii.gz" - ] - ], - "ch_registered_labels_files": [ - [ - { - "id": "test" - }, - "test_IFGWM_labels_map_warped.nii.gz" - ] - ], - "ch_registered_nifti_files": [ - [ - { - "id": "test" - }, - "test_IFGWM_warped.nii.gz" - ] - ], - "ch_registered_trk_files": [ - [ - { - "id": "test" - }, - "test_IFGWM_color_warped.trk", - "test_IFGWM_uni_warped.trk", - "test_IFGWM_warped.trk" - ] - ], "ch_t1w_tpl": [ "MNI152NLin2009bSym_T1w.nii.gz" ], @@ -43,18 +9,6 @@ "MNI152NLin2009bSym_T2w.nii.gz" ], "mqc": [ - [ - { - "id": "test" - }, - "test_IFGWM_labels_map_registration_antsapplytransforms_mqc.gif" - ], - [ - { - "id": "test" - }, - "test_IFGWM_registration_antsapplytransforms_mqc.gif" - ], [ { "id": "test" @@ -64,11 +18,8 @@ ], "versions": [ "versions.yml:md5,08c023826481c9130c3914096cda7f63", - "versions.yml:md5,16dbf59818dee83cc2d0df98ab8bca83", - "versions.yml:md5,1eb68be05dd453a43bd7e4c84aa65435", "versions.yml:md5,596d9223aafe3b087eff98891aa55207", "versions.yml:md5,cd1137ba5811cb376ecce1e90a8f3461", - "versions.yml:md5,ce9c7ec52ed86a19d0a7ee301e444344", "versions.yml:md5,fe45b823234eb14a9e13fa03cca099d1" ] } @@ -77,73 +28,22 @@ "nf-test": "0.9.3", "nextflow": "25.10.2" }, - "timestamp": "2026-06-04T13:39:54.610205112" + "timestamp": "2026-07-10T16:07:51.293391383" }, "Template MNI152NLin2009aAsym - using synthmorph registration": { "content": [ { - "ch_registered_anat": [ - [ - { - "id": "test" - }, - "test_warped.nii.gz" - ] - ], - "ch_registered_labels_files": [ - [ - { - "id": "test" - }, - "test_IFGWM_labels_map_warped.nii.gz" - ] - ], - "ch_registered_nifti_files": [ - [ - { - "id": "test" - }, - "test_IFGWM_warped.nii.gz" - ] - ], - "ch_registered_trk_files": [ - [ - { - "id": "test" - }, - "test_IFGWM_color_warped.trk", - "test_IFGWM_uni_warped.trk", - "test_IFGWM_warped.trk" - ] - ], "ch_t1w_tpl": [ "MNI152NLin2009bSym_T1w.nii.gz" ], "ch_t2w_tpl": [ "MNI152NLin2009bSym_T2w.nii.gz" ], - "mqc": [ - [ - { - "id": "test" - }, - "test_IFGWM_labels_map_registration_antsapplytransforms_mqc.gif" - ], - [ - { - "id": "test" - }, - "test_IFGWM_registration_antsapplytransforms_mqc.gif" - ] - ], "versions": [ "versions.yml:md5,08c023826481c9130c3914096cda7f63", - "versions.yml:md5,16dbf59818dee83cc2d0df98ab8bca83", - "versions.yml:md5,1eb68be05dd453a43bd7e4c84aa65435", "versions.yml:md5,837bc1b10db6cb6c459b8871725ba254", "versions.yml:md5,9013974da5ab5a7ae91e580948968e75", "versions.yml:md5,cd1137ba5811cb376ecce1e90a8f3461", - "versions.yml:md5,ce9c7ec52ed86a19d0a7ee301e444344", "versions.yml:md5,fe45b823234eb14a9e13fa03cca099d1" ] } @@ -152,45 +52,11 @@ "nf-test": "0.9.3", "nextflow": "25.10.2" }, - "timestamp": "2026-06-04T13:40:36.60965249" + "timestamp": "2026-07-10T15:43:07.339463531" }, "Template MNI152NLin2009cAsym - local templates": { "content": [ { - "ch_registered_anat": [ - [ - { - "id": "test" - }, - "test_t1_warped.nii.gz" - ] - ], - "ch_registered_labels_files": [ - [ - { - "id": "test" - }, - "test_IFGWM_labels_map_warped.nii.gz" - ] - ], - "ch_registered_nifti_files": [ - [ - { - "id": "test" - }, - "test_IFGWM_warped.nii.gz" - ] - ], - "ch_registered_trk_files": [ - [ - { - "id": "test" - }, - "test_IFGWM_color_warped.trk", - "test_IFGWM_uni_warped.trk", - "test_IFGWM_warped.trk" - ] - ], "ch_t1w_tpl": [ "MNI152NLin2009cAsym_T1w.nii.gz" ], @@ -198,18 +64,6 @@ "MNI152NLin2009cAsym_T2w.nii.gz" ], "mqc": [ - [ - { - "id": "test" - }, - "test_IFGWM_labels_map_registration_antsapplytransforms_mqc.gif" - ], - [ - { - "id": "test" - }, - "test_IFGWM_registration_antsapplytransforms_mqc.gif" - ], [ { "id": "test" @@ -219,11 +73,8 @@ ], "versions": [ "versions.yml:md5,08c023826481c9130c3914096cda7f63", - "versions.yml:md5,16dbf59818dee83cc2d0df98ab8bca83", - "versions.yml:md5,1eb68be05dd453a43bd7e4c84aa65435", "versions.yml:md5,596d9223aafe3b087eff98891aa55207", "versions.yml:md5,cd1137ba5811cb376ecce1e90a8f3461", - "versions.yml:md5,ce9c7ec52ed86a19d0a7ee301e444344", "versions.yml:md5,fe45b823234eb14a9e13fa03cca099d1" ] } @@ -232,6 +83,6 @@ "nf-test": "0.9.3", "nextflow": "25.10.2" }, - "timestamp": "2026-06-04T13:39:07.012635952" + "timestamp": "2026-07-10T16:07:24.77429114" } } \ No newline at end of file diff --git a/subworkflows/nf-neuro/registration/main.nf b/subworkflows/nf-neuro/registration/main.nf index bc7fd3ff..09c33d1b 100644 --- a/subworkflows/nf-neuro/registration/main.nf +++ b/subworkflows/nf-neuro/registration/main.nf @@ -219,6 +219,7 @@ workflow REGISTRATION { .branch{ anat_to_dwi : it[3] ants_syn: true + return it[0..2] + it[4..5] } // ** Registration using ANAT TO DWI ** // diff --git a/subworkflows/nf-neuro/tractoflow/tests/main.nf.test.snap b/subworkflows/nf-neuro/tractoflow/tests/main.nf.test.snap index d7a84da8..84fcf394 100644 --- a/subworkflows/nf-neuro/tractoflow/tests/main.nf.test.snap +++ b/subworkflows/nf-neuro/tractoflow/tests/main.nf.test.snap @@ -2,30 +2,6 @@ "tractoflow - qball tracking": { "content": [ { - "afd_max": [ - [ - { - "id": "test" - }, - "test__afd_max.nii.gz" - ] - ], - "afd_sum": [ - [ - { - "id": "test" - }, - "test__afd_sum.nii.gz" - ] - ], - "afd_total": [ - [ - { - "id": "test" - }, - "test__afd_total.nii.gz" - ] - ], "anatomical_to_diffusion": [ [ { @@ -51,30 +27,6 @@ "test_dwi_mask_resampled.nii.gz" ] ], - "csf_fodf": [ - [ - { - "id": "test" - }, - "test__csf_fodf.nii.gz" - ] - ], - "csf_map": [ - [ - { - "id": "test" - }, - "test__map_csf.nii.gz" - ] - ], - "csf_mask": [ - [ - { - "id": "test" - }, - "test__mask_csf.nii.gz" - ] - ], "diffusion_to_anatomical": [ [ { @@ -206,70 +158,6 @@ "test_copy_dwi.bvec" ] ], - "fiber_response": [ - [ - { - "id": "test" - }, - "test__frf.txt" - ], - [ - { - "id": "test" - }, - "test__wm_frf.txt", - "test__gm_frf.txt", - "test__csf_frf.txt" - ] - ], - "fodf": [ - [ - { - "id": "test" - }, - "test__fodf.nii.gz" - ] - ], - "fodf_peaks": [ - [ - { - "id": "test" - }, - "test__peaks.nii.gz" - ] - ], - "fodf_rgb": [ - [ - { - "id": "test" - }, - "test__vf_rgb.nii.gz" - ] - ], - "gm_fodf": [ - [ - { - "id": "test" - }, - "test__gm_fodf.nii.gz" - ] - ], - "gm_map": [ - [ - { - "id": "test" - }, - "test__map_gm.nii.gz" - ] - ], - "gm_mask": [ - [ - { - "id": "test" - }, - "test__mask_gm.nii.gz" - ] - ], "mqc": [ [ { @@ -310,14 +198,6 @@ "test__nonphysical.nii.gz" ] ], - "nufo": [ - [ - { - "id": "test" - }, - "test__nufo.nii.gz" - ] - ], "pulsation_in_b0": [ [ { @@ -374,14 +254,6 @@ "test__peaks.nii.gz" ] ], - "t1": [ - [ - { - "id": "test" - }, - "test_t1_cropped_warped.nii.gz" - ] - ], "t1_native": [ [ { @@ -392,48 +264,13 @@ ], "versions": [ "versions.yml:md5,229b67add04c70923f1bca378b7b2187", - "versions.yml:md5,68aaff09474ed3ae149c1cffb0651f0d", "versions.yml:md5,7cabc91ec64b5e824e9b8f60d7dcf930", "versions.yml:md5,7fae1f6758d48901013496c0a680b81b", - "versions.yml:md5,85cf18214259841972e1ea51961dc19d", "versions.yml:md5,a5331c4c8a6ec9521bc5f43a127d6c0f", "versions.yml:md5,b1f30072384bba1505d84f60281dfc24", "versions.yml:md5,cdfc3f4153b62c413e2fc6e948f2ef21", - "versions.yml:md5,e808fc7967f50aad087f14c8cbcdc7e1", "versions.yml:md5,f63f0d3dff7878bb46899a6b96ac2497", "versions.yml:md5,fee3d07623cc095a898f0a1de534a05b" - ], - "volume_fraction": [ - [ - { - "id": "test" - }, - "test__vf.nii.gz" - ] - ], - "wm_fodf": [ - [ - { - "id": "test" - }, - "test__wm_fodf.nii.gz" - ] - ], - "wm_map": [ - [ - { - "id": "test" - }, - "test__map_wm.nii.gz" - ] - ], - "wm_mask": [ - [ - { - "id": "test" - }, - "test__mask_wm.nii.gz" - ] ] } ], @@ -441,35 +278,11 @@ "nf-test": "0.9.3", "nextflow": "25.10.2" }, - "timestamp": "2026-06-04T13:46:26.983105632" + "timestamp": "2026-07-10T16:18:41.932225309" }, "tractoflow - no rev": { "content": [ { - "afd_max": [ - [ - { - "id": "test" - }, - "test__afd_max.nii.gz" - ] - ], - "afd_sum": [ - [ - { - "id": "test" - }, - "test__afd_sum.nii.gz" - ] - ], - "afd_total": [ - [ - { - "id": "test" - }, - "test__afd_total.nii.gz" - ] - ], "anatomical_to_diffusion": [ [ { @@ -495,30 +308,6 @@ "test_dwi_mask_resampled.nii.gz" ] ], - "csf_fodf": [ - [ - { - "id": "test" - }, - "test__csf_fodf.nii.gz" - ] - ], - "csf_map": [ - [ - { - "id": "test" - }, - "test__map_csf.nii.gz" - ] - ], - "csf_mask": [ - [ - { - "id": "test" - }, - "test__mask_csf.nii.gz" - ] - ], "diffusion_to_anatomical": [ [ { @@ -650,116 +439,6 @@ "test_copy_dwi.bvec" ] ], - "fiber_response": [ - [ - { - "id": "test" - }, - "test__frf.txt" - ], - [ - { - "id": "test" - }, - "test__wm_frf.txt", - "test__gm_frf.txt", - "test__csf_frf.txt" - ] - ], - "fodf": [ - [ - { - "id": "test" - }, - "test__fodf.nii.gz" - ] - ], - "fodf_peaks": [ - [ - { - "id": "test" - }, - "test__peaks.nii.gz" - ] - ], - "fodf_rgb": [ - [ - { - "id": "test" - }, - "test__vf_rgb.nii.gz" - ] - ], - "global_mqc": [ - [ - { - "id": "test" - }, - "test__local_tracking_stats.json" - ], - [ - { - "id": "test" - }, - "test__pft_tracking_stats.json" - ] - ], - "gm_fodf": [ - [ - { - "id": "test" - }, - "test__gm_fodf.nii.gz" - ] - ], - "gm_map": [ - [ - { - "id": "test" - }, - "test__map_gm.nii.gz" - ] - ], - "gm_mask": [ - [ - { - "id": "test" - }, - "test__mask_gm.nii.gz" - ] - ], - "local_config": [ - [ - { - "id": "test" - }, - "test__local_tracking_config.json" - ] - ], - "local_seeding_mask": [ - [ - { - "id": "test" - }, - "test__local_seeding_mask.nii.gz" - ] - ], - "local_tracking_mask": [ - [ - { - "id": "test" - }, - "test__local_tracking_mask.nii.gz" - ] - ], - "local_tractogram": [ - [ - { - "id": "test" - }, - "test__local_tracking.trk" - ] - ], "mqc": [ [ { @@ -779,18 +458,6 @@ }, "test__dwi_eddy_restricted_movement_rms.txt" ], - [ - { - "id": "test" - }, - "test__local_tracking_mqc.png" - ], - [ - { - "id": "test" - }, - "test__pft_tracking_mqc.png" - ], [ { "id": "test" @@ -812,54 +479,6 @@ "test__nonphysical.nii.gz" ] ], - "nufo": [ - [ - { - "id": "test" - }, - "test__nufo.nii.gz" - ] - ], - "pft_config": [ - [ - { - "id": "test" - }, - "test__pft_tracking_config.json" - ] - ], - "pft_map_exclude": [ - [ - { - "id": "test" - }, - "test__map_exclude.nii.gz" - ] - ], - "pft_map_include": [ - [ - { - "id": "test" - }, - "test__map_include.nii.gz" - ] - ], - "pft_seeding_mask": [ - [ - { - "id": "test" - }, - "test__pft_seeding_mask.nii.gz" - ] - ], - "pft_tractogram": [ - [ - { - "id": "test" - }, - "test__pft_tracking.trk" - ] - ], "pulsation_in_b0": [ [ { @@ -876,14 +495,6 @@ "test__pulsation_std_dwi.nii.gz" ] ], - "t1": [ - [ - { - "id": "test" - }, - "test_t1_cropped_warped.nii.gz" - ] - ], "t1_native": [ [ { @@ -893,47 +504,10 @@ ] ], "versions": [ - "versions.yml:md5,35eb6cc8d3a3b200123613abf38d6c98", - "versions.yml:md5,68aaff09474ed3ae149c1cffb0651f0d", - "versions.yml:md5,772acc9a4938fc99817db1c00efd2100", "versions.yml:md5,7cabc91ec64b5e824e9b8f60d7dcf930", "versions.yml:md5,7fae1f6758d48901013496c0a680b81b", - "versions.yml:md5,85cf18214259841972e1ea51961dc19d", "versions.yml:md5,cdfc3f4153b62c413e2fc6e948f2ef21", - "versions.yml:md5,e808fc7967f50aad087f14c8cbcdc7e1", "versions.yml:md5,fee3d07623cc095a898f0a1de534a05b" - ], - "volume_fraction": [ - [ - { - "id": "test" - }, - "test__vf.nii.gz" - ] - ], - "wm_fodf": [ - [ - { - "id": "test" - }, - "test__wm_fodf.nii.gz" - ] - ], - "wm_map": [ - [ - { - "id": "test" - }, - "test__map_wm.nii.gz" - ] - ], - "wm_mask": [ - [ - { - "id": "test" - }, - "test__mask_wm.nii.gz" - ] ] } ], @@ -941,6 +515,6 @@ "nf-test": "0.9.3", "nextflow": "25.10.2" }, - "timestamp": "2026-06-04T13:44:16.486282515" + "timestamp": "2026-07-10T16:17:18.986906066" } } \ No newline at end of file From 3e89ed4382e2f409a4a9a0a1c6aad3930af8659c Mon Sep 17 00:00:00 2001 From: arnaudbore Date: Fri, 10 Jul 2026 17:38:07 -0400 Subject: [PATCH 07/14] fix snap --- .../registration/ants/tests/main.nf.test.snap | 258 +++++++++--------- 1 file changed, 129 insertions(+), 129 deletions(-) diff --git a/modules/nf-neuro/registration/ants/tests/main.nf.test.snap b/modules/nf-neuro/registration/ants/tests/main.nf.test.snap index be355bea..02cf9179 100644 --- a/modules/nf-neuro/registration/ants/tests/main.nf.test.snap +++ b/modules/nf-neuro/registration/ants/tests/main.nf.test.snap @@ -7,7 +7,7 @@ { "id": "test" }, - "test_T1w_warped.nii.gz:md5,92e339e7f93c24437b216cb2dde4f0cb" + "test_T1w_warped.nii.gz:md5,f815f83fcc5ad70b0b6630b9e57835c8" ] ], "1": [ @@ -15,7 +15,7 @@ { "id": "test" }, - "test_forward1_affine.mat:md5,032d3bda1e72c7f1c7224aa6783e9cf0" + "test_forward1_affine.mat:md5,3bc315e13074f374dda32e29e13f201a" ] ], "10": [ @@ -26,7 +26,7 @@ { "id": "test" }, - "test_forward0_warp.nii.gz:md5,174b5b43c2e91ea804756d0d4cd15bad" + "test_forward0_warp.nii.gz:md5,384082f9f4c14f3235abc5d572dc8336" ] ], "3": [ @@ -34,7 +34,7 @@ { "id": "test" }, - "test_backward1_warp.nii.gz:md5,8948e3dab061e31afd3e0b36d76e6031" + "test_backward1_warp.nii.gz:md5,06e37e91eb8b489cb41e8f8501e9ecc8" ] ], "4": [ @@ -42,7 +42,7 @@ { "id": "test" }, - "test_backward0_affine.mat:md5,723a9c3ccffc3ed835a5657739e09134" + "test_backward0_affine.mat:md5,9344bac7ae2d83e4e45367377bc37455" ] ], "5": [ @@ -51,8 +51,8 @@ "id": "test" }, [ - "test_forward0_warp.nii.gz:md5,174b5b43c2e91ea804756d0d4cd15bad", - "test_forward1_affine.mat:md5,032d3bda1e72c7f1c7224aa6783e9cf0" + "test_forward0_warp.nii.gz:md5,384082f9f4c14f3235abc5d572dc8336", + "test_forward1_affine.mat:md5,3bc315e13074f374dda32e29e13f201a" ] ] ], @@ -62,8 +62,8 @@ "id": "test" }, [ - "test_backward0_affine.mat:md5,723a9c3ccffc3ed835a5657739e09134", - "test_backward1_warp.nii.gz:md5,8948e3dab061e31afd3e0b36d76e6031" + "test_backward0_affine.mat:md5,9344bac7ae2d83e4e45367377bc37455", + "test_backward1_warp.nii.gz:md5,06e37e91eb8b489cb41e8f8501e9ecc8" ] ] ], @@ -73,8 +73,8 @@ "id": "test" }, [ - "test_backward0_affine.mat:md5,723a9c3ccffc3ed835a5657739e09134", - "test_backward1_warp.nii.gz:md5,8948e3dab061e31afd3e0b36d76e6031" + "test_backward0_affine.mat:md5,9344bac7ae2d83e4e45367377bc37455", + "test_backward1_warp.nii.gz:md5,06e37e91eb8b489cb41e8f8501e9ecc8" ] ] ], @@ -84,8 +84,8 @@ "id": "test" }, [ - "test_forward0_warp.nii.gz:md5,174b5b43c2e91ea804756d0d4cd15bad", - "test_forward1_affine.mat:md5,032d3bda1e72c7f1c7224aa6783e9cf0" + "test_forward0_warp.nii.gz:md5,384082f9f4c14f3235abc5d572dc8336", + "test_forward1_affine.mat:md5,3bc315e13074f374dda32e29e13f201a" ] ] ], @@ -94,7 +94,7 @@ { "id": "test" }, - "test_T1_to_T1_slab_registration_ants_mqc.gif:md5,f479eff30517367afb88c0974436d23b" + "test_T1_to_T1_slab_registration_ants_mqc.gif:md5,6cb6f9efc4910087b32943da4f579ee4" ] ], "backward_affine": [ @@ -102,7 +102,7 @@ { "id": "test" }, - "test_backward0_affine.mat:md5,723a9c3ccffc3ed835a5657739e09134" + "test_backward0_affine.mat:md5,9344bac7ae2d83e4e45367377bc37455" ] ], "backward_image_transform": [ @@ -111,8 +111,8 @@ "id": "test" }, [ - "test_backward0_affine.mat:md5,723a9c3ccffc3ed835a5657739e09134", - "test_backward1_warp.nii.gz:md5,8948e3dab061e31afd3e0b36d76e6031" + "test_backward0_affine.mat:md5,9344bac7ae2d83e4e45367377bc37455", + "test_backward1_warp.nii.gz:md5,06e37e91eb8b489cb41e8f8501e9ecc8" ] ] ], @@ -122,8 +122,8 @@ "id": "test" }, [ - "test_forward0_warp.nii.gz:md5,174b5b43c2e91ea804756d0d4cd15bad", - "test_forward1_affine.mat:md5,032d3bda1e72c7f1c7224aa6783e9cf0" + "test_forward0_warp.nii.gz:md5,384082f9f4c14f3235abc5d572dc8336", + "test_forward1_affine.mat:md5,3bc315e13074f374dda32e29e13f201a" ] ] ], @@ -132,7 +132,7 @@ { "id": "test" }, - "test_backward1_warp.nii.gz:md5,8948e3dab061e31afd3e0b36d76e6031" + "test_backward1_warp.nii.gz:md5,06e37e91eb8b489cb41e8f8501e9ecc8" ] ], "forward_affine": [ @@ -140,7 +140,7 @@ { "id": "test" }, - "test_forward1_affine.mat:md5,032d3bda1e72c7f1c7224aa6783e9cf0" + "test_forward1_affine.mat:md5,3bc315e13074f374dda32e29e13f201a" ] ], "forward_image_transform": [ @@ -149,8 +149,8 @@ "id": "test" }, [ - "test_forward0_warp.nii.gz:md5,174b5b43c2e91ea804756d0d4cd15bad", - "test_forward1_affine.mat:md5,032d3bda1e72c7f1c7224aa6783e9cf0" + "test_forward0_warp.nii.gz:md5,384082f9f4c14f3235abc5d572dc8336", + "test_forward1_affine.mat:md5,3bc315e13074f374dda32e29e13f201a" ] ] ], @@ -160,8 +160,8 @@ "id": "test" }, [ - "test_backward0_affine.mat:md5,723a9c3ccffc3ed835a5657739e09134", - "test_backward1_warp.nii.gz:md5,8948e3dab061e31afd3e0b36d76e6031" + "test_backward0_affine.mat:md5,9344bac7ae2d83e4e45367377bc37455", + "test_backward1_warp.nii.gz:md5,06e37e91eb8b489cb41e8f8501e9ecc8" ] ] ], @@ -170,7 +170,7 @@ { "id": "test" }, - "test_forward0_warp.nii.gz:md5,174b5b43c2e91ea804756d0d4cd15bad" + "test_forward0_warp.nii.gz:md5,384082f9f4c14f3235abc5d572dc8336" ] ], "image_warped": [ @@ -178,7 +178,7 @@ { "id": "test" }, - "test_T1w_warped.nii.gz:md5,92e339e7f93c24437b216cb2dde4f0cb" + "test_T1w_warped.nii.gz:md5,f815f83fcc5ad70b0b6630b9e57835c8" ] ], "mqc": [ @@ -186,7 +186,7 @@ { "id": "test" }, - "test_T1_to_T1_slab_registration_ants_mqc.gif:md5,f479eff30517367afb88c0974436d23b" + "test_T1_to_T1_slab_registration_ants_mqc.gif:md5,6cb6f9efc4910087b32943da4f579ee4" ] ], "versions": [ @@ -198,7 +198,7 @@ "nf-test": "0.9.3", "nextflow": "25.10.2" }, - "timestamp": "2026-07-10T13:58:41.627501355" + "timestamp": "2026-07-10T17:35:19.380059833" }, "registration - ants - stub": { "content": [ @@ -220,7 +220,7 @@ { "id": "test" }, - "test_t1_warped.nii.gz:md5,9a0bb219ad17eff32fd95550c7e73ebf" + "test_t1_warped.nii.gz:md5,c74eb8a596f1f6959f8db828d0d9ddc1" ] ], "1": [ @@ -228,7 +228,7 @@ { "id": "test" }, - "test_forward1_affine.mat:md5,4b73494b62eeb43d1660478ab6d259c8" + "test_forward1_affine.mat:md5,41afa6fa72a013820a3d3d8ce4986002" ] ], "10": [ @@ -239,7 +239,7 @@ { "id": "test" }, - "test_forward0_warp.nii.gz:md5,5c8e9c98b60070dde6e93d27454a7c84" + "test_forward0_warp.nii.gz:md5,806c26fdf31077d4b035a2009db54c95" ] ], "3": [ @@ -247,7 +247,7 @@ { "id": "test" }, - "test_backward1_warp.nii.gz:md5,c68cb4dc8b8f642b38ee34962ddd2108" + "test_backward1_warp.nii.gz:md5,4cca843970b2ed3d02ecf43a31502857" ] ], "4": [ @@ -255,7 +255,7 @@ { "id": "test" }, - "test_backward0_affine.mat:md5,39d0956c44fc5b7cb554886f38516ae9" + "test_backward0_affine.mat:md5,9b6845301aaeaf43a1cf9da4e4cb671f" ] ], "5": [ @@ -264,8 +264,8 @@ "id": "test" }, [ - "test_forward0_warp.nii.gz:md5,5c8e9c98b60070dde6e93d27454a7c84", - "test_forward1_affine.mat:md5,4b73494b62eeb43d1660478ab6d259c8" + "test_forward0_warp.nii.gz:md5,806c26fdf31077d4b035a2009db54c95", + "test_forward1_affine.mat:md5,41afa6fa72a013820a3d3d8ce4986002" ] ] ], @@ -275,8 +275,8 @@ "id": "test" }, [ - "test_backward0_affine.mat:md5,39d0956c44fc5b7cb554886f38516ae9", - "test_backward1_warp.nii.gz:md5,c68cb4dc8b8f642b38ee34962ddd2108" + "test_backward0_affine.mat:md5,9b6845301aaeaf43a1cf9da4e4cb671f", + "test_backward1_warp.nii.gz:md5,4cca843970b2ed3d02ecf43a31502857" ] ] ], @@ -286,8 +286,8 @@ "id": "test" }, [ - "test_backward0_affine.mat:md5,39d0956c44fc5b7cb554886f38516ae9", - "test_backward1_warp.nii.gz:md5,c68cb4dc8b8f642b38ee34962ddd2108" + "test_backward0_affine.mat:md5,9b6845301aaeaf43a1cf9da4e4cb671f", + "test_backward1_warp.nii.gz:md5,4cca843970b2ed3d02ecf43a31502857" ] ] ], @@ -297,8 +297,8 @@ "id": "test" }, [ - "test_forward0_warp.nii.gz:md5,5c8e9c98b60070dde6e93d27454a7c84", - "test_forward1_affine.mat:md5,4b73494b62eeb43d1660478ab6d259c8" + "test_forward0_warp.nii.gz:md5,806c26fdf31077d4b035a2009db54c95", + "test_forward1_affine.mat:md5,41afa6fa72a013820a3d3d8ce4986002" ] ] ], @@ -307,7 +307,7 @@ { "id": "test" }, - "test_T1_to_T1_slab_registration_ants_mqc.gif:md5,0702b94648153d4044d8138864b35bfa" + "test_T1_to_T1_slab_registration_ants_mqc.gif:md5,b685aa586e6b61196b442740c1056eb5" ] ], "backward_affine": [ @@ -315,7 +315,7 @@ { "id": "test" }, - "test_backward0_affine.mat:md5,39d0956c44fc5b7cb554886f38516ae9" + "test_backward0_affine.mat:md5,9b6845301aaeaf43a1cf9da4e4cb671f" ] ], "backward_image_transform": [ @@ -324,8 +324,8 @@ "id": "test" }, [ - "test_backward0_affine.mat:md5,39d0956c44fc5b7cb554886f38516ae9", - "test_backward1_warp.nii.gz:md5,c68cb4dc8b8f642b38ee34962ddd2108" + "test_backward0_affine.mat:md5,9b6845301aaeaf43a1cf9da4e4cb671f", + "test_backward1_warp.nii.gz:md5,4cca843970b2ed3d02ecf43a31502857" ] ] ], @@ -335,8 +335,8 @@ "id": "test" }, [ - "test_forward0_warp.nii.gz:md5,5c8e9c98b60070dde6e93d27454a7c84", - "test_forward1_affine.mat:md5,4b73494b62eeb43d1660478ab6d259c8" + "test_forward0_warp.nii.gz:md5,806c26fdf31077d4b035a2009db54c95", + "test_forward1_affine.mat:md5,41afa6fa72a013820a3d3d8ce4986002" ] ] ], @@ -345,7 +345,7 @@ { "id": "test" }, - "test_backward1_warp.nii.gz:md5,c68cb4dc8b8f642b38ee34962ddd2108" + "test_backward1_warp.nii.gz:md5,4cca843970b2ed3d02ecf43a31502857" ] ], "forward_affine": [ @@ -353,7 +353,7 @@ { "id": "test" }, - "test_forward1_affine.mat:md5,4b73494b62eeb43d1660478ab6d259c8" + "test_forward1_affine.mat:md5,41afa6fa72a013820a3d3d8ce4986002" ] ], "forward_image_transform": [ @@ -362,8 +362,8 @@ "id": "test" }, [ - "test_forward0_warp.nii.gz:md5,5c8e9c98b60070dde6e93d27454a7c84", - "test_forward1_affine.mat:md5,4b73494b62eeb43d1660478ab6d259c8" + "test_forward0_warp.nii.gz:md5,806c26fdf31077d4b035a2009db54c95", + "test_forward1_affine.mat:md5,41afa6fa72a013820a3d3d8ce4986002" ] ] ], @@ -373,8 +373,8 @@ "id": "test" }, [ - "test_backward0_affine.mat:md5,39d0956c44fc5b7cb554886f38516ae9", - "test_backward1_warp.nii.gz:md5,c68cb4dc8b8f642b38ee34962ddd2108" + "test_backward0_affine.mat:md5,9b6845301aaeaf43a1cf9da4e4cb671f", + "test_backward1_warp.nii.gz:md5,4cca843970b2ed3d02ecf43a31502857" ] ] ], @@ -383,7 +383,7 @@ { "id": "test" }, - "test_forward0_warp.nii.gz:md5,5c8e9c98b60070dde6e93d27454a7c84" + "test_forward0_warp.nii.gz:md5,806c26fdf31077d4b035a2009db54c95" ] ], "image_warped": [ @@ -391,7 +391,7 @@ { "id": "test" }, - "test_t1_warped.nii.gz:md5,9a0bb219ad17eff32fd95550c7e73ebf" + "test_t1_warped.nii.gz:md5,c74eb8a596f1f6959f8db828d0d9ddc1" ] ], "mqc": [ @@ -399,7 +399,7 @@ { "id": "test" }, - "test_T1_to_T1_slab_registration_ants_mqc.gif:md5,0702b94648153d4044d8138864b35bfa" + "test_T1_to_T1_slab_registration_ants_mqc.gif:md5,b685aa586e6b61196b442740c1056eb5" ] ], "versions": [ @@ -411,7 +411,7 @@ "nf-test": "0.9.3", "nextflow": "25.10.2" }, - "timestamp": "2026-07-10T10:49:46.156144247" + "timestamp": "2026-07-10T17:32:31.640927711" }, "registration - ants - SyN": { "content": [ @@ -421,7 +421,7 @@ { "id": "test" }, - "test_t1_warped.nii.gz:md5,2ae1a6986238b8ebd58d237979061623" + "test_t1_warped.nii.gz:md5,7c5756d1bdcf72eac1541e9c5d98f9db" ] ], "1": [ @@ -429,7 +429,7 @@ { "id": "test" }, - "test_forward1_affine.mat:md5,cef396215549c098bd4f1e9e32baf54f" + "test_forward1_affine.mat:md5,0fb5879b315f32bb8e06aa2993009115" ] ], "10": [ @@ -440,7 +440,7 @@ { "id": "test" }, - "test_forward0_warp.nii.gz:md5,3a2c82d85d0b8c8e7b88684db3e10611" + "test_forward0_warp.nii.gz:md5,a32206a00e93b79054e9b8fa0f7c8015" ] ], "3": [ @@ -448,7 +448,7 @@ { "id": "test" }, - "test_backward1_warp.nii.gz:md5,e3bdf358ce296e7dc4190f12abe1b292" + "test_backward1_warp.nii.gz:md5,4e85fa2257f7364fde205adfa1b3c8d3" ] ], "4": [ @@ -456,7 +456,7 @@ { "id": "test" }, - "test_backward0_affine.mat:md5,1d79bdbe5af542e4ae8cce1d6a290c8b" + "test_backward0_affine.mat:md5,ff00be1483698e5478bfa94abf2b42b2" ] ], "5": [ @@ -465,8 +465,8 @@ "id": "test" }, [ - "test_forward0_warp.nii.gz:md5,3a2c82d85d0b8c8e7b88684db3e10611", - "test_forward1_affine.mat:md5,cef396215549c098bd4f1e9e32baf54f" + "test_forward0_warp.nii.gz:md5,a32206a00e93b79054e9b8fa0f7c8015", + "test_forward1_affine.mat:md5,0fb5879b315f32bb8e06aa2993009115" ] ] ], @@ -476,8 +476,8 @@ "id": "test" }, [ - "test_backward0_affine.mat:md5,1d79bdbe5af542e4ae8cce1d6a290c8b", - "test_backward1_warp.nii.gz:md5,e3bdf358ce296e7dc4190f12abe1b292" + "test_backward0_affine.mat:md5,ff00be1483698e5478bfa94abf2b42b2", + "test_backward1_warp.nii.gz:md5,4e85fa2257f7364fde205adfa1b3c8d3" ] ] ], @@ -487,8 +487,8 @@ "id": "test" }, [ - "test_backward0_affine.mat:md5,1d79bdbe5af542e4ae8cce1d6a290c8b", - "test_backward1_warp.nii.gz:md5,e3bdf358ce296e7dc4190f12abe1b292" + "test_backward0_affine.mat:md5,ff00be1483698e5478bfa94abf2b42b2", + "test_backward1_warp.nii.gz:md5,4e85fa2257f7364fde205adfa1b3c8d3" ] ] ], @@ -498,8 +498,8 @@ "id": "test" }, [ - "test_forward0_warp.nii.gz:md5,3a2c82d85d0b8c8e7b88684db3e10611", - "test_forward1_affine.mat:md5,cef396215549c098bd4f1e9e32baf54f" + "test_forward0_warp.nii.gz:md5,a32206a00e93b79054e9b8fa0f7c8015", + "test_forward1_affine.mat:md5,0fb5879b315f32bb8e06aa2993009115" ] ] ], @@ -511,7 +511,7 @@ { "id": "test" }, - "test_backward0_affine.mat:md5,1d79bdbe5af542e4ae8cce1d6a290c8b" + "test_backward0_affine.mat:md5,ff00be1483698e5478bfa94abf2b42b2" ] ], "backward_image_transform": [ @@ -520,8 +520,8 @@ "id": "test" }, [ - "test_backward0_affine.mat:md5,1d79bdbe5af542e4ae8cce1d6a290c8b", - "test_backward1_warp.nii.gz:md5,e3bdf358ce296e7dc4190f12abe1b292" + "test_backward0_affine.mat:md5,ff00be1483698e5478bfa94abf2b42b2", + "test_backward1_warp.nii.gz:md5,4e85fa2257f7364fde205adfa1b3c8d3" ] ] ], @@ -531,8 +531,8 @@ "id": "test" }, [ - "test_forward0_warp.nii.gz:md5,3a2c82d85d0b8c8e7b88684db3e10611", - "test_forward1_affine.mat:md5,cef396215549c098bd4f1e9e32baf54f" + "test_forward0_warp.nii.gz:md5,a32206a00e93b79054e9b8fa0f7c8015", + "test_forward1_affine.mat:md5,0fb5879b315f32bb8e06aa2993009115" ] ] ], @@ -541,7 +541,7 @@ { "id": "test" }, - "test_backward1_warp.nii.gz:md5,e3bdf358ce296e7dc4190f12abe1b292" + "test_backward1_warp.nii.gz:md5,4e85fa2257f7364fde205adfa1b3c8d3" ] ], "forward_affine": [ @@ -549,7 +549,7 @@ { "id": "test" }, - "test_forward1_affine.mat:md5,cef396215549c098bd4f1e9e32baf54f" + "test_forward1_affine.mat:md5,0fb5879b315f32bb8e06aa2993009115" ] ], "forward_image_transform": [ @@ -558,8 +558,8 @@ "id": "test" }, [ - "test_forward0_warp.nii.gz:md5,3a2c82d85d0b8c8e7b88684db3e10611", - "test_forward1_affine.mat:md5,cef396215549c098bd4f1e9e32baf54f" + "test_forward0_warp.nii.gz:md5,a32206a00e93b79054e9b8fa0f7c8015", + "test_forward1_affine.mat:md5,0fb5879b315f32bb8e06aa2993009115" ] ] ], @@ -569,8 +569,8 @@ "id": "test" }, [ - "test_backward0_affine.mat:md5,1d79bdbe5af542e4ae8cce1d6a290c8b", - "test_backward1_warp.nii.gz:md5,e3bdf358ce296e7dc4190f12abe1b292" + "test_backward0_affine.mat:md5,ff00be1483698e5478bfa94abf2b42b2", + "test_backward1_warp.nii.gz:md5,4e85fa2257f7364fde205adfa1b3c8d3" ] ] ], @@ -579,7 +579,7 @@ { "id": "test" }, - "test_forward0_warp.nii.gz:md5,3a2c82d85d0b8c8e7b88684db3e10611" + "test_forward0_warp.nii.gz:md5,a32206a00e93b79054e9b8fa0f7c8015" ] ], "image_warped": [ @@ -587,7 +587,7 @@ { "id": "test" }, - "test_t1_warped.nii.gz:md5,2ae1a6986238b8ebd58d237979061623" + "test_t1_warped.nii.gz:md5,7c5756d1bdcf72eac1541e9c5d98f9db" ] ], "mqc": [ @@ -602,7 +602,7 @@ "nf-test": "0.9.3", "nextflow": "25.10.2" }, - "timestamp": "2026-07-10T10:48:35.425395985" + "timestamp": "2026-07-10T17:31:29.622156975" }, "registration - ants - both - fixed mask": { "content": [ @@ -612,7 +612,7 @@ { "id": "test" }, - "test_t1_warped.nii.gz:md5,ea7f1bc0540975d6484a15c7a74fb115" + "test_t1_warped.nii.gz:md5,8089d84a4f511207f26307ce92353bbb" ] ], "1": [ @@ -620,7 +620,7 @@ { "id": "test" }, - "test_forward1_affine.mat:md5,3f5500ed1d3e896ab2b53a5c92cd3f76" + "test_forward1_affine.mat:md5,18c2ec8b5cf3fb4e038cce665eb53e7c" ] ], "10": [ @@ -631,7 +631,7 @@ { "id": "test" }, - "test_forward0_warp.nii.gz:md5,e815d27e3d69c9337919a3ad76815806" + "test_forward0_warp.nii.gz:md5,d1f0ce951610683042aab377c665295d" ] ], "3": [ @@ -639,7 +639,7 @@ { "id": "test" }, - "test_backward1_warp.nii.gz:md5,6f16542b188b1bfe068c12e9ce6ee8f8" + "test_backward1_warp.nii.gz:md5,e5324ab5af8cceda46e0bb642dfc02aa" ] ], "4": [ @@ -647,7 +647,7 @@ { "id": "test" }, - "test_backward0_affine.mat:md5,0f1af73ef9da3e722592701432a1a340" + "test_backward0_affine.mat:md5,ba4cdd24110970c8d08b8df39ee4fd95" ] ], "5": [ @@ -656,8 +656,8 @@ "id": "test" }, [ - "test_forward0_warp.nii.gz:md5,e815d27e3d69c9337919a3ad76815806", - "test_forward1_affine.mat:md5,3f5500ed1d3e896ab2b53a5c92cd3f76" + "test_forward0_warp.nii.gz:md5,d1f0ce951610683042aab377c665295d", + "test_forward1_affine.mat:md5,18c2ec8b5cf3fb4e038cce665eb53e7c" ] ] ], @@ -667,8 +667,8 @@ "id": "test" }, [ - "test_backward0_affine.mat:md5,0f1af73ef9da3e722592701432a1a340", - "test_backward1_warp.nii.gz:md5,6f16542b188b1bfe068c12e9ce6ee8f8" + "test_backward0_affine.mat:md5,ba4cdd24110970c8d08b8df39ee4fd95", + "test_backward1_warp.nii.gz:md5,e5324ab5af8cceda46e0bb642dfc02aa" ] ] ], @@ -678,8 +678,8 @@ "id": "test" }, [ - "test_backward0_affine.mat:md5,0f1af73ef9da3e722592701432a1a340", - "test_backward1_warp.nii.gz:md5,6f16542b188b1bfe068c12e9ce6ee8f8" + "test_backward0_affine.mat:md5,ba4cdd24110970c8d08b8df39ee4fd95", + "test_backward1_warp.nii.gz:md5,e5324ab5af8cceda46e0bb642dfc02aa" ] ] ], @@ -689,8 +689,8 @@ "id": "test" }, [ - "test_forward0_warp.nii.gz:md5,e815d27e3d69c9337919a3ad76815806", - "test_forward1_affine.mat:md5,3f5500ed1d3e896ab2b53a5c92cd3f76" + "test_forward0_warp.nii.gz:md5,d1f0ce951610683042aab377c665295d", + "test_forward1_affine.mat:md5,18c2ec8b5cf3fb4e038cce665eb53e7c" ] ] ], @@ -699,7 +699,7 @@ { "id": "test" }, - "test_T1_to_T1_slab_registration_ants_mqc.gif:md5,3de94aa1d262a96423c0415846d3a7db" + "test_T1_to_T1_slab_registration_ants_mqc.gif:md5,fba29c34dd2cebde98e9c72e5c991550" ] ], "backward_affine": [ @@ -707,7 +707,7 @@ { "id": "test" }, - "test_backward0_affine.mat:md5,0f1af73ef9da3e722592701432a1a340" + "test_backward0_affine.mat:md5,ba4cdd24110970c8d08b8df39ee4fd95" ] ], "backward_image_transform": [ @@ -716,8 +716,8 @@ "id": "test" }, [ - "test_backward0_affine.mat:md5,0f1af73ef9da3e722592701432a1a340", - "test_backward1_warp.nii.gz:md5,6f16542b188b1bfe068c12e9ce6ee8f8" + "test_backward0_affine.mat:md5,ba4cdd24110970c8d08b8df39ee4fd95", + "test_backward1_warp.nii.gz:md5,e5324ab5af8cceda46e0bb642dfc02aa" ] ] ], @@ -727,8 +727,8 @@ "id": "test" }, [ - "test_forward0_warp.nii.gz:md5,e815d27e3d69c9337919a3ad76815806", - "test_forward1_affine.mat:md5,3f5500ed1d3e896ab2b53a5c92cd3f76" + "test_forward0_warp.nii.gz:md5,d1f0ce951610683042aab377c665295d", + "test_forward1_affine.mat:md5,18c2ec8b5cf3fb4e038cce665eb53e7c" ] ] ], @@ -737,7 +737,7 @@ { "id": "test" }, - "test_backward1_warp.nii.gz:md5,6f16542b188b1bfe068c12e9ce6ee8f8" + "test_backward1_warp.nii.gz:md5,e5324ab5af8cceda46e0bb642dfc02aa" ] ], "forward_affine": [ @@ -745,7 +745,7 @@ { "id": "test" }, - "test_forward1_affine.mat:md5,3f5500ed1d3e896ab2b53a5c92cd3f76" + "test_forward1_affine.mat:md5,18c2ec8b5cf3fb4e038cce665eb53e7c" ] ], "forward_image_transform": [ @@ -754,8 +754,8 @@ "id": "test" }, [ - "test_forward0_warp.nii.gz:md5,e815d27e3d69c9337919a3ad76815806", - "test_forward1_affine.mat:md5,3f5500ed1d3e896ab2b53a5c92cd3f76" + "test_forward0_warp.nii.gz:md5,d1f0ce951610683042aab377c665295d", + "test_forward1_affine.mat:md5,18c2ec8b5cf3fb4e038cce665eb53e7c" ] ] ], @@ -765,8 +765,8 @@ "id": "test" }, [ - "test_backward0_affine.mat:md5,0f1af73ef9da3e722592701432a1a340", - "test_backward1_warp.nii.gz:md5,6f16542b188b1bfe068c12e9ce6ee8f8" + "test_backward0_affine.mat:md5,ba4cdd24110970c8d08b8df39ee4fd95", + "test_backward1_warp.nii.gz:md5,e5324ab5af8cceda46e0bb642dfc02aa" ] ] ], @@ -775,7 +775,7 @@ { "id": "test" }, - "test_forward0_warp.nii.gz:md5,e815d27e3d69c9337919a3ad76815806" + "test_forward0_warp.nii.gz:md5,d1f0ce951610683042aab377c665295d" ] ], "image_warped": [ @@ -783,7 +783,7 @@ { "id": "test" }, - "test_t1_warped.nii.gz:md5,ea7f1bc0540975d6484a15c7a74fb115" + "test_t1_warped.nii.gz:md5,8089d84a4f511207f26307ce92353bbb" ] ], "mqc": [ @@ -791,7 +791,7 @@ { "id": "test" }, - "test_T1_to_T1_slab_registration_ants_mqc.gif:md5,3de94aa1d262a96423c0415846d3a7db" + "test_T1_to_T1_slab_registration_ants_mqc.gif:md5,fba29c34dd2cebde98e9c72e5c991550" ] ], "versions": [ @@ -803,7 +803,7 @@ "nf-test": "0.9.3", "nextflow": "25.10.2" }, - "timestamp": "2026-07-10T14:00:10.265843278" + "timestamp": "2026-07-10T17:36:45.524357151" }, "registration - ants - no warps": { "content": [ @@ -813,7 +813,7 @@ { "id": "test" }, - "test_t1_warped.nii.gz:md5,e8c78a1c57ae3a51ebf0611e09bc3c59" + "test_t1_warped.nii.gz:md5,9f4d57c0e9cde3da4ab4718f360abce6" ] ], "1": [ @@ -821,7 +821,7 @@ { "id": "test" }, - "test_forward1_affine.mat:md5,6e47b89fcdd230c852b25ce8036438e9" + "test_forward1_affine.mat:md5,72aee9284d5e624be5dbc15cfce8151c" ] ], "10": [ @@ -838,7 +838,7 @@ { "id": "test" }, - "test_backward0_affine.mat:md5,1038f3b4b63d8dbd572947d68d7ed90d" + "test_backward0_affine.mat:md5,862976c1966b1af64acd7b40d0f922e4" ] ], "5": [ @@ -847,7 +847,7 @@ "id": "test" }, [ - "test_forward1_affine.mat:md5,6e47b89fcdd230c852b25ce8036438e9" + "test_forward1_affine.mat:md5,72aee9284d5e624be5dbc15cfce8151c" ] ] ], @@ -857,7 +857,7 @@ "id": "test" }, [ - "test_backward0_affine.mat:md5,1038f3b4b63d8dbd572947d68d7ed90d" + "test_backward0_affine.mat:md5,862976c1966b1af64acd7b40d0f922e4" ] ] ], @@ -867,7 +867,7 @@ "id": "test" }, [ - "test_backward0_affine.mat:md5,1038f3b4b63d8dbd572947d68d7ed90d" + "test_backward0_affine.mat:md5,862976c1966b1af64acd7b40d0f922e4" ] ] ], @@ -877,7 +877,7 @@ "id": "test" }, [ - "test_forward1_affine.mat:md5,6e47b89fcdd230c852b25ce8036438e9" + "test_forward1_affine.mat:md5,72aee9284d5e624be5dbc15cfce8151c" ] ] ], @@ -889,7 +889,7 @@ { "id": "test" }, - "test_backward0_affine.mat:md5,1038f3b4b63d8dbd572947d68d7ed90d" + "test_backward0_affine.mat:md5,862976c1966b1af64acd7b40d0f922e4" ] ], "backward_image_transform": [ @@ -898,7 +898,7 @@ "id": "test" }, [ - "test_backward0_affine.mat:md5,1038f3b4b63d8dbd572947d68d7ed90d" + "test_backward0_affine.mat:md5,862976c1966b1af64acd7b40d0f922e4" ] ] ], @@ -908,7 +908,7 @@ "id": "test" }, [ - "test_forward1_affine.mat:md5,6e47b89fcdd230c852b25ce8036438e9" + "test_forward1_affine.mat:md5,72aee9284d5e624be5dbc15cfce8151c" ] ] ], @@ -920,7 +920,7 @@ { "id": "test" }, - "test_forward1_affine.mat:md5,6e47b89fcdd230c852b25ce8036438e9" + "test_forward1_affine.mat:md5,72aee9284d5e624be5dbc15cfce8151c" ] ], "forward_image_transform": [ @@ -929,7 +929,7 @@ "id": "test" }, [ - "test_forward1_affine.mat:md5,6e47b89fcdd230c852b25ce8036438e9" + "test_forward1_affine.mat:md5,72aee9284d5e624be5dbc15cfce8151c" ] ] ], @@ -939,7 +939,7 @@ "id": "test" }, [ - "test_backward0_affine.mat:md5,1038f3b4b63d8dbd572947d68d7ed90d" + "test_backward0_affine.mat:md5,862976c1966b1af64acd7b40d0f922e4" ] ] ], @@ -951,7 +951,7 @@ { "id": "test" }, - "test_t1_warped.nii.gz:md5,e8c78a1c57ae3a51ebf0611e09bc3c59" + "test_t1_warped.nii.gz:md5,9f4d57c0e9cde3da4ab4718f360abce6" ] ], "mqc": [ @@ -966,6 +966,6 @@ "nf-test": "0.9.3", "nextflow": "25.10.2" }, - "timestamp": "2026-07-10T10:50:04.991990693" + "timestamp": "2026-07-10T17:32:43.930354571" } } \ No newline at end of file From 591c6a8597cf1abdd6593b44841f60c224dfc7e2 Mon Sep 17 00:00:00 2001 From: arnaudbore Date: Fri, 10 Jul 2026 21:40:33 -0400 Subject: [PATCH 08/14] fix claude comments --- .../nf-neuro/registration/anattodwi/main.nf | 2 +- .../nf-neuro/registration/anattodwi/meta.yml | 2 +- modules/nf-neuro/registration/ants/main.nf | 2 +- modules/nf-neuro/registration/ants/meta.yml | 2 +- subworkflows/nf-neuro/registration/main.nf | 49 ++++++++++--------- subworkflows/nf-neuro/registration/meta.yml | 6 +-- 6 files changed, 34 insertions(+), 29 deletions(-) diff --git a/modules/nf-neuro/registration/anattodwi/main.nf b/modules/nf-neuro/registration/anattodwi/main.nf index 29532f43..d00accb4 100644 --- a/modules/nf-neuro/registration/anattodwi/main.nf +++ b/modules/nf-neuro/registration/anattodwi/main.nf @@ -28,7 +28,7 @@ process REGISTRATION_ANATTODWI { def run_qc = task.ext.run_qc as Boolean || false def args = task.ext.args ?: '' - if ( task.ext.masking_strategy == "both" || task.ext.masking_strategy == "internal" ) args += " -x ${fixed_mask ?: 'NULL'},${moving_mask ?: 'NULL'}" + if ( task.ext.masking_strategy == "both" || task.ext.masking_strategy == "internal" ) args += " -x \"${fixed_mask ?: 'NULL'},${moving_mask ?: 'NULL'}\"" """ export ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS=${task.ext.single_thread ? 1 : task.cpus} export OMP_NUM_THREADS=${task.ext.single_thread ? 1 : task.cpus} diff --git a/modules/nf-neuro/registration/anattodwi/meta.yml b/modules/nf-neuro/registration/anattodwi/meta.yml index c15c7632..0f5d79a4 100644 --- a/modules/nf-neuro/registration/anattodwi/meta.yml +++ b/modules/nf-neuro/registration/anattodwi/meta.yml @@ -45,7 +45,7 @@ args: default: 1234 - masking_strategy: type: string - description: Masking strategy to use for registration. Options are 'none', 'apriori', 'both'. + description: Masking strategy to use for registration. Options are 'none', 'apriori', 'internal' or 'both'. default: "none" input: - - meta: diff --git a/modules/nf-neuro/registration/ants/main.nf b/modules/nf-neuro/registration/ants/main.nf index 04d79efe..43b7abe3 100644 --- a/modules/nf-neuro/registration/ants/main.nf +++ b/modules/nf-neuro/registration/ants/main.nf @@ -44,7 +44,7 @@ process REGISTRATION_ANTS { if ( task.ext.histogram_matching ) args += " -j $task.ext.histogram_matching" if ( task.ext.repro_mode ) args += " -y $task.ext.repro_mode" if ( task.ext.collapse_output ) args += " -z $task.ext.collapse_output" - if ( task.ext.masking_strategy == "both" || task.ext.masking_strategy == "internal" ) args += " -x ${fixed_mask ?: 'NULL'},${moving_mask ?: 'NULL'}" + if ( task.ext.masking_strategy == "both" || task.ext.masking_strategy == "internal" ) args += " -x \"${fixed_mask ?: 'NULL'},${moving_mask ?: 'NULL'}\"" """ export ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS=${task.ext.single_thread ? 1 : task.cpus} diff --git a/modules/nf-neuro/registration/ants/meta.yml b/modules/nf-neuro/registration/ants/meta.yml index b7b134ed..89d7e2a5 100644 --- a/modules/nf-neuro/registration/ants/meta.yml +++ b/modules/nf-neuro/registration/ants/meta.yml @@ -127,7 +127,7 @@ args: default: false - masking_strategy: type: string - description: Masking strategy to use for registration. Options are 'none', 'apriori', 'both'. + description: Masking strategy to use for registration. Options are 'none', 'apriori', 'internal' or 'both'. default: "none" input: - - meta: diff --git a/subworkflows/nf-neuro/registration/main.nf b/subworkflows/nf-neuro/registration/main.nf index 09c33d1b..1c520fac 100644 --- a/subworkflows/nf-neuro/registration/main.nf +++ b/subworkflows/nf-neuro/registration/main.nf @@ -5,8 +5,8 @@ include { REGISTRATION_SYNTHMORPH } from '../../../modules/nf-neuro/registration include { REGISTRATION_CONVERT } from '../../../modules/nf-neuro/registration/convert/main' include { UTILS_OPTIONS } from '../utils_options/main' include { IMAGE_APPLYMASK as MASK_FIXED_IMAGE} from '../../../modules/nf-neuro/image/applymask/main' +include { IMAGE_APPLYMASK as MASK_FIXED_METRIC} from '../../../modules/nf-neuro/image/applymask/main' include { IMAGE_APPLYMASK as MASK_MOVING_IMAGE} from '../../../modules/nf-neuro/image/applymask/main' -include { IMAGE_APPLYMASK as MASK_MOVING_METRIC} from '../../../modules/nf-neuro/image/applymask/main' include { REGISTRATION_ANTSAPPLYTRANSFORMS as WARP_IMAGE_TO_FIXED } from '../../../modules/nf-neuro/registration/antsapplytransforms/main' include { REGISTRATION_ANTSAPPLYTRANSFORMS as WARP_IMAGE_TO_MOVING } from '../../../modules/nf-neuro/registration/antsapplytransforms/main' @@ -44,6 +44,16 @@ workflow REGISTRATION { ch_fixed_image_ready = ch_fixed_image.join(MASK_FIXED_IMAGE.out.image, remainder: true) .map({ meta, orig, masked -> [meta, masked?: orig] }) ch_versions = ch_versions.mix(MASK_FIXED_IMAGE.out.versions.first()) + + if ( ch_metric ) { + MASK_FIXED_METRIC ( ch_metric.join(ch_fixed_mask) ) + ch_fixed_metric_ready = ch_metric.join(MASK_FIXED_METRIC.out.image, remainder: true) + .map({ meta, orig, masked -> [meta, masked?: orig] }) + ch_versions = ch_versions.mix(MASK_FIXED_METRIC.out.versions.first()) + } + else { + ch_fixed_metric_ready = ch_metric + } } else { ch_fixed_image_ready = ch_fixed_image @@ -53,16 +63,6 @@ workflow REGISTRATION { ch_moving_image_ready = ch_moving_image.join(MASK_MOVING_IMAGE.out.image, remainder: true) .map({ meta, orig, masked -> [meta, masked?: orig] }) ch_versions = ch_versions.mix(MASK_MOVING_IMAGE.out.versions.first()) - - if ( ch_metric ) { - MASK_MOVING_METRIC ( ch_metric.join(ch_moving_mask) ) - ch_moving_metric_ready = ch_metric.join(MASK_MOVING_METRIC.out.image, remainder: true) - .map({ meta, orig, masked -> [meta, masked?: orig] }) - ch_versions = ch_versions.mix(MASK_MOVING_METRIC.out.versions.first()) - } - else { - ch_moving_metric_ready = ch_metric - } } else { ch_moving_image_ready = ch_moving_image @@ -71,7 +71,7 @@ workflow REGISTRATION { else { ch_fixed_image_ready = ch_fixed_image ch_moving_image_ready = ch_moving_image - ch_moving_metric_ready = ch_metric + ch_fixed_metric_ready = ch_metric } if ( ( options.masking_strategy == "both" || options.masking_strategy == "internal" ) && ( options.run_easyreg || options.run_synthmorph ) ) { @@ -212,7 +212,7 @@ workflow REGISTRATION { // - ants_syn : doesn't have a metric at index 3 ( [] or null ) ch_register = ch_fixed_image_ready .join(ch_moving_image_ready) - .join(ch_moving_metric_ready, remainder: true) + .join(ch_fixed_metric_ready, remainder: true) .join(ch_fixed_mask, remainder: true) .join(ch_moving_mask, remainder: true) .map{ it[0..2] + [it[3] ?: []] + [it[4] ?: [], it[5] ?: []] } @@ -269,19 +269,23 @@ workflow REGISTRATION { out_image_warped_masked = out_image_warped .join(ch_moving_mask) - .map{ meta, warped, mask -> mask ? [meta, warped] : [] } + .filter{ _meta, _warped, mask -> mask } + .map{ meta, warped, _mask -> [meta, warped] } + out_ref_warped_masked = out_ref_warped - .join(ch_fixed_mask) - .map{ meta, warped, mask -> mask ? [meta, warped] : [] } + .filter{ _meta, _warped, mask -> mask } + .map{ meta, warped, _mask -> [meta, warped] } + // Register original moving image WARP_IMAGE_TO_FIXED ( ch_moving_image .join(ch_fixed_image) .join(out_forward_image_transform) .join(ch_moving_mask) - .map{ meta, moving, fixed, transform, mask -> mask ? [meta, moving, fixed, transform] : [] } ) + .filter{ _meta, _moving, _fixed, _transform, mask -> mask } + .map{ meta, moving, fixed, transform, _mask -> [meta, moving, fixed, transform] } ) out_image_warped = out_image_warped - .join(WARP_IMAGE_TO_FIXED.out.warped_image) - .map{ meta, warped, masked_warped -> masked_warped :[meta, masked_warped ?: warped] } + .join(WARP_IMAGE_TO_FIXED.out.warped_image, remainder: true) + .map{ meta, warped, warped_from_mask -> [meta, (warped_from_mask ?: warped)] } ch_versions = ch_versions.mix(WARP_IMAGE_TO_FIXED.out.versions.first()) // Register original ref image @@ -289,10 +293,11 @@ workflow REGISTRATION { .join(ch_moving_image) .join(out_backward_image_transform) .join(ch_fixed_mask) - .map{ meta, moving, fixed, transform, mask -> mask ? [meta, moving, fixed, transform] : [] } ) + .filter{ _meta, _moving, _fixed, _transform, mask -> mask } + .map{ meta, moving, fixed, transform, _mask -> [meta, moving, fixed, transform] } ) out_ref_warped = out_ref_warped - .join(WARP_IMAGE_TO_MOVING.out.warped_image) - .map{ meta, warped, masked_warped -> [meta, masked_warped ?: warped] } + .join(WARP_IMAGE_TO_MOVING.out.warped_image, remainder: true) + .map{ meta, warped, warped_from_mask -> [meta, (warped_from_mask ?: warped)] } ch_versions = ch_versions.mix(WARP_IMAGE_TO_MOVING.out.versions.first()) emit: diff --git a/subworkflows/nf-neuro/registration/meta.yml b/subworkflows/nf-neuro/registration/meta.yml index 287abcf4..26e49c36 100644 --- a/subworkflows/nf-neuro/registration/meta.yml +++ b/subworkflows/nf-neuro/registration/meta.yml @@ -95,7 +95,7 @@ input: - ch_fixed_mask: type: file description: | - Fixed mask will be use to mask the fixed image during registration. + Fixed mask will be used to mask the fixed image during registration. structure: - meta: type: map @@ -108,7 +108,7 @@ input: - ch_moving_mask: type: file description: | - Moving mask will be use to mask the moving image during registration. + Moving mask will be used to mask the moving image during registration. structure: - meta: type: map @@ -139,7 +139,7 @@ input: entries: masking_strategy: type: string - description: Masking strategy to use for registration. Options are 'none', 'apriori', 'both'. + description: Masking strategy to use for registration. Options are 'none', 'apriori', 'internal' or 'both'. default: "none" run_easyreg: type: boolean From e425d5cee67a87ba665b0d32ea4a49b1e1da5ddd Mon Sep 17 00:00:00 2001 From: arnaudbore Date: Fri, 10 Jul 2026 23:55:35 -0400 Subject: [PATCH 09/14] fix the fix --- .../tests/main.nf.test.snap | 155 ++++++- subworkflows/nf-neuro/registration/main.nf | 1 + .../registration/tests/main.nf.test.snap | 56 ++- .../tractoflow/tests/main.nf.test.snap | 430 +++++++++++++++++- 4 files changed, 633 insertions(+), 9 deletions(-) diff --git a/subworkflows/nf-neuro/output_template_space/tests/main.nf.test.snap b/subworkflows/nf-neuro/output_template_space/tests/main.nf.test.snap index 0847bbc3..c4932e00 100644 --- a/subworkflows/nf-neuro/output_template_space/tests/main.nf.test.snap +++ b/subworkflows/nf-neuro/output_template_space/tests/main.nf.test.snap @@ -2,6 +2,40 @@ "Template MNI152NLin2009bSym - no brain mask": { "content": [ { + "ch_registered_anat": [ + [ + { + "id": "test" + }, + "test_t1_warped.nii.gz" + ] + ], + "ch_registered_labels_files": [ + [ + { + "id": "test" + }, + "test_IFGWM_labels_map_warped.nii.gz" + ] + ], + "ch_registered_nifti_files": [ + [ + { + "id": "test" + }, + "test_IFGWM_warped.nii.gz" + ] + ], + "ch_registered_trk_files": [ + [ + { + "id": "test" + }, + "test_IFGWM_color_warped.trk", + "test_IFGWM_uni_warped.trk", + "test_IFGWM_warped.trk" + ] + ], "ch_t1w_tpl": [ "MNI152NLin2009bSym_T1w.nii.gz" ], @@ -9,6 +43,18 @@ "MNI152NLin2009bSym_T2w.nii.gz" ], "mqc": [ + [ + { + "id": "test" + }, + "test_IFGWM_labels_map_registration_antsapplytransforms_mqc.gif" + ], + [ + { + "id": "test" + }, + "test_IFGWM_registration_antsapplytransforms_mqc.gif" + ], [ { "id": "test" @@ -18,8 +64,11 @@ ], "versions": [ "versions.yml:md5,08c023826481c9130c3914096cda7f63", + "versions.yml:md5,16dbf59818dee83cc2d0df98ab8bca83", + "versions.yml:md5,1eb68be05dd453a43bd7e4c84aa65435", "versions.yml:md5,596d9223aafe3b087eff98891aa55207", "versions.yml:md5,cd1137ba5811cb376ecce1e90a8f3461", + "versions.yml:md5,ce9c7ec52ed86a19d0a7ee301e444344", "versions.yml:md5,fe45b823234eb14a9e13fa03cca099d1" ] } @@ -28,22 +77,73 @@ "nf-test": "0.9.3", "nextflow": "25.10.2" }, - "timestamp": "2026-07-10T16:07:51.293391383" + "timestamp": "2026-07-10T22:36:55.080186253" }, "Template MNI152NLin2009aAsym - using synthmorph registration": { "content": [ { + "ch_registered_anat": [ + [ + { + "id": "test" + }, + "test_warped.nii.gz" + ] + ], + "ch_registered_labels_files": [ + [ + { + "id": "test" + }, + "test_IFGWM_labels_map_warped.nii.gz" + ] + ], + "ch_registered_nifti_files": [ + [ + { + "id": "test" + }, + "test_IFGWM_warped.nii.gz" + ] + ], + "ch_registered_trk_files": [ + [ + { + "id": "test" + }, + "test_IFGWM_color_warped.trk", + "test_IFGWM_uni_warped.trk", + "test_IFGWM_warped.trk" + ] + ], "ch_t1w_tpl": [ "MNI152NLin2009bSym_T1w.nii.gz" ], "ch_t2w_tpl": [ "MNI152NLin2009bSym_T2w.nii.gz" ], + "mqc": [ + [ + { + "id": "test" + }, + "test_IFGWM_labels_map_registration_antsapplytransforms_mqc.gif" + ], + [ + { + "id": "test" + }, + "test_IFGWM_registration_antsapplytransforms_mqc.gif" + ] + ], "versions": [ "versions.yml:md5,08c023826481c9130c3914096cda7f63", + "versions.yml:md5,16dbf59818dee83cc2d0df98ab8bca83", + "versions.yml:md5,1eb68be05dd453a43bd7e4c84aa65435", "versions.yml:md5,837bc1b10db6cb6c459b8871725ba254", "versions.yml:md5,9013974da5ab5a7ae91e580948968e75", "versions.yml:md5,cd1137ba5811cb376ecce1e90a8f3461", + "versions.yml:md5,ce9c7ec52ed86a19d0a7ee301e444344", "versions.yml:md5,fe45b823234eb14a9e13fa03cca099d1" ] } @@ -52,11 +152,45 @@ "nf-test": "0.9.3", "nextflow": "25.10.2" }, - "timestamp": "2026-07-10T15:43:07.339463531" + "timestamp": "2026-07-10T22:37:33.271078795" }, "Template MNI152NLin2009cAsym - local templates": { "content": [ { + "ch_registered_anat": [ + [ + { + "id": "test" + }, + "test_t1_warped.nii.gz" + ] + ], + "ch_registered_labels_files": [ + [ + { + "id": "test" + }, + "test_IFGWM_labels_map_warped.nii.gz" + ] + ], + "ch_registered_nifti_files": [ + [ + { + "id": "test" + }, + "test_IFGWM_warped.nii.gz" + ] + ], + "ch_registered_trk_files": [ + [ + { + "id": "test" + }, + "test_IFGWM_color_warped.trk", + "test_IFGWM_uni_warped.trk", + "test_IFGWM_warped.trk" + ] + ], "ch_t1w_tpl": [ "MNI152NLin2009cAsym_T1w.nii.gz" ], @@ -64,6 +198,18 @@ "MNI152NLin2009cAsym_T2w.nii.gz" ], "mqc": [ + [ + { + "id": "test" + }, + "test_IFGWM_labels_map_registration_antsapplytransforms_mqc.gif" + ], + [ + { + "id": "test" + }, + "test_IFGWM_registration_antsapplytransforms_mqc.gif" + ], [ { "id": "test" @@ -73,8 +219,11 @@ ], "versions": [ "versions.yml:md5,08c023826481c9130c3914096cda7f63", + "versions.yml:md5,16dbf59818dee83cc2d0df98ab8bca83", + "versions.yml:md5,1eb68be05dd453a43bd7e4c84aa65435", "versions.yml:md5,596d9223aafe3b087eff98891aa55207", "versions.yml:md5,cd1137ba5811cb376ecce1e90a8f3461", + "versions.yml:md5,ce9c7ec52ed86a19d0a7ee301e444344", "versions.yml:md5,fe45b823234eb14a9e13fa03cca099d1" ] } @@ -83,6 +232,6 @@ "nf-test": "0.9.3", "nextflow": "25.10.2" }, - "timestamp": "2026-07-10T16:07:24.77429114" + "timestamp": "2026-07-10T22:36:13.853694569" } } \ No newline at end of file diff --git a/subworkflows/nf-neuro/registration/main.nf b/subworkflows/nf-neuro/registration/main.nf index 1c520fac..0b9dbf62 100644 --- a/subworkflows/nf-neuro/registration/main.nf +++ b/subworkflows/nf-neuro/registration/main.nf @@ -273,6 +273,7 @@ workflow REGISTRATION { .map{ meta, warped, _mask -> [meta, warped] } out_ref_warped_masked = out_ref_warped + .join(ch_fixed_mask) .filter{ _meta, _warped, mask -> mask } .map{ meta, warped, _mask -> [meta, warped] } diff --git a/subworkflows/nf-neuro/registration/tests/main.nf.test.snap b/subworkflows/nf-neuro/registration/tests/main.nf.test.snap index b9648fe5..38454bd7 100644 --- a/subworkflows/nf-neuro/registration/tests/main.nf.test.snap +++ b/subworkflows/nf-neuro/registration/tests/main.nf.test.snap @@ -54,6 +54,14 @@ "test_out_warp.nii.gz" ] ], + "image_warped": [ + [ + { + "id": "test" + }, + "test_warped.nii.gz" + ] + ], "versions": [ "versions.yml:md5,300199ef2ea6dd6438553c3ec2615e58", "versions.yml:md5,5bc0d347809508f4b94ebe433b0f21b9" @@ -64,7 +72,7 @@ "nf-test": "0.9.3", "nextflow": "25.10.2" }, - "timestamp": "2026-07-10T12:17:50.130253183" + "timestamp": "2026-07-10T22:38:54.809065239" }, "registration - easyreg": { "content": [ @@ -117,6 +125,14 @@ "test_forward0_warp.nii.gz" ] ], + "image_warped": [ + [ + { + "id": "test" + }, + "test_warped.nii.gz" + ] + ], "reference_segmentation": [ [ { @@ -125,6 +141,14 @@ "test_warped_reference_segmentation.nii.gz" ] ], + "reference_warped": [ + [ + { + "id": "test" + }, + "test_warped_reference.nii.gz" + ] + ], "segmentation": [ [ { @@ -142,7 +166,7 @@ "nf-test": "0.9.3", "nextflow": "25.10.2" }, - "timestamp": "2026-07-10T12:17:39.385111058" + "timestamp": "2026-07-10T22:38:45.322600977" }, "registration - ANTs - SyNQuick": { "content": [ @@ -215,6 +239,14 @@ "test_forward0_warp.nii.gz" ] ], + "image_warped": [ + [ + { + "id": "test" + }, + "test_t1_warped.nii.gz" + ] + ], "mqc": [ [ { @@ -223,6 +255,14 @@ "test__registration_ants_mqc.gif" ] ], + "reference_warped": [ + [ + { + "id": "test" + }, + "test_T1w_warped.nii.gz" + ] + ], "versions": [ "versions.yml:md5,3764dd2f067db355da3536c1b0c94619", "versions.yml:md5,a338911f46f2c623d87eab600c524ffb" @@ -233,7 +273,7 @@ "nf-test": "0.9.3", "nextflow": "25.10.2" }, - "timestamp": "2026-07-10T12:17:25.989995681" + "timestamp": "2026-07-10T22:38:31.882107231" }, "registration - ANTs - Anat to DWI": { "content": [ @@ -306,6 +346,14 @@ "test_forward0_warp.nii.gz" ] ], + "image_warped": [ + [ + { + "id": "test" + }, + "test_T1w_warped.nii.gz" + ] + ], "mqc": [ [ { @@ -323,6 +371,6 @@ "nf-test": "0.9.3", "nextflow": "25.10.2" }, - "timestamp": "2026-07-10T12:17:07.629766386" + "timestamp": "2026-07-10T22:38:14.73218299" } } \ No newline at end of file diff --git a/subworkflows/nf-neuro/tractoflow/tests/main.nf.test.snap b/subworkflows/nf-neuro/tractoflow/tests/main.nf.test.snap index 84fcf394..15177c9e 100644 --- a/subworkflows/nf-neuro/tractoflow/tests/main.nf.test.snap +++ b/subworkflows/nf-neuro/tractoflow/tests/main.nf.test.snap @@ -2,6 +2,30 @@ "tractoflow - qball tracking": { "content": [ { + "afd_max": [ + [ + { + "id": "test" + }, + "test__afd_max.nii.gz" + ] + ], + "afd_sum": [ + [ + { + "id": "test" + }, + "test__afd_sum.nii.gz" + ] + ], + "afd_total": [ + [ + { + "id": "test" + }, + "test__afd_total.nii.gz" + ] + ], "anatomical_to_diffusion": [ [ { @@ -27,6 +51,30 @@ "test_dwi_mask_resampled.nii.gz" ] ], + "csf_fodf": [ + [ + { + "id": "test" + }, + "test__csf_fodf.nii.gz" + ] + ], + "csf_map": [ + [ + { + "id": "test" + }, + "test__map_csf.nii.gz" + ] + ], + "csf_mask": [ + [ + { + "id": "test" + }, + "test__mask_csf.nii.gz" + ] + ], "diffusion_to_anatomical": [ [ { @@ -158,6 +206,70 @@ "test_copy_dwi.bvec" ] ], + "fiber_response": [ + [ + { + "id": "test" + }, + "test__frf.txt" + ], + [ + { + "id": "test" + }, + "test__wm_frf.txt", + "test__gm_frf.txt", + "test__csf_frf.txt" + ] + ], + "fodf": [ + [ + { + "id": "test" + }, + "test__fodf.nii.gz" + ] + ], + "fodf_peaks": [ + [ + { + "id": "test" + }, + "test__peaks.nii.gz" + ] + ], + "fodf_rgb": [ + [ + { + "id": "test" + }, + "test__vf_rgb.nii.gz" + ] + ], + "gm_fodf": [ + [ + { + "id": "test" + }, + "test__gm_fodf.nii.gz" + ] + ], + "gm_map": [ + [ + { + "id": "test" + }, + "test__map_gm.nii.gz" + ] + ], + "gm_mask": [ + [ + { + "id": "test" + }, + "test__mask_gm.nii.gz" + ] + ], "mqc": [ [ { @@ -198,6 +310,14 @@ "test__nonphysical.nii.gz" ] ], + "nufo": [ + [ + { + "id": "test" + }, + "test__nufo.nii.gz" + ] + ], "pulsation_in_b0": [ [ { @@ -254,6 +374,14 @@ "test__peaks.nii.gz" ] ], + "t1": [ + [ + { + "id": "test" + }, + "test_t1_cropped_warped.nii.gz" + ] + ], "t1_native": [ [ { @@ -264,13 +392,48 @@ ], "versions": [ "versions.yml:md5,229b67add04c70923f1bca378b7b2187", + "versions.yml:md5,68aaff09474ed3ae149c1cffb0651f0d", "versions.yml:md5,7cabc91ec64b5e824e9b8f60d7dcf930", "versions.yml:md5,7fae1f6758d48901013496c0a680b81b", + "versions.yml:md5,85cf18214259841972e1ea51961dc19d", "versions.yml:md5,a5331c4c8a6ec9521bc5f43a127d6c0f", "versions.yml:md5,b1f30072384bba1505d84f60281dfc24", "versions.yml:md5,cdfc3f4153b62c413e2fc6e948f2ef21", + "versions.yml:md5,e808fc7967f50aad087f14c8cbcdc7e1", "versions.yml:md5,f63f0d3dff7878bb46899a6b96ac2497", "versions.yml:md5,fee3d07623cc095a898f0a1de534a05b" + ], + "volume_fraction": [ + [ + { + "id": "test" + }, + "test__vf.nii.gz" + ] + ], + "wm_fodf": [ + [ + { + "id": "test" + }, + "test__wm_fodf.nii.gz" + ] + ], + "wm_map": [ + [ + { + "id": "test" + }, + "test__map_wm.nii.gz" + ] + ], + "wm_mask": [ + [ + { + "id": "test" + }, + "test__mask_wm.nii.gz" + ] ] } ], @@ -278,11 +441,35 @@ "nf-test": "0.9.3", "nextflow": "25.10.2" }, - "timestamp": "2026-07-10T16:18:41.932225309" + "timestamp": "2026-07-10T22:29:38.90763159" }, "tractoflow - no rev": { "content": [ { + "afd_max": [ + [ + { + "id": "test" + }, + "test__afd_max.nii.gz" + ] + ], + "afd_sum": [ + [ + { + "id": "test" + }, + "test__afd_sum.nii.gz" + ] + ], + "afd_total": [ + [ + { + "id": "test" + }, + "test__afd_total.nii.gz" + ] + ], "anatomical_to_diffusion": [ [ { @@ -308,6 +495,30 @@ "test_dwi_mask_resampled.nii.gz" ] ], + "csf_fodf": [ + [ + { + "id": "test" + }, + "test__csf_fodf.nii.gz" + ] + ], + "csf_map": [ + [ + { + "id": "test" + }, + "test__map_csf.nii.gz" + ] + ], + "csf_mask": [ + [ + { + "id": "test" + }, + "test__mask_csf.nii.gz" + ] + ], "diffusion_to_anatomical": [ [ { @@ -439,6 +650,116 @@ "test_copy_dwi.bvec" ] ], + "fiber_response": [ + [ + { + "id": "test" + }, + "test__frf.txt" + ], + [ + { + "id": "test" + }, + "test__wm_frf.txt", + "test__gm_frf.txt", + "test__csf_frf.txt" + ] + ], + "fodf": [ + [ + { + "id": "test" + }, + "test__fodf.nii.gz" + ] + ], + "fodf_peaks": [ + [ + { + "id": "test" + }, + "test__peaks.nii.gz" + ] + ], + "fodf_rgb": [ + [ + { + "id": "test" + }, + "test__vf_rgb.nii.gz" + ] + ], + "global_mqc": [ + [ + { + "id": "test" + }, + "test__local_tracking_stats.json" + ], + [ + { + "id": "test" + }, + "test__pft_tracking_stats.json" + ] + ], + "gm_fodf": [ + [ + { + "id": "test" + }, + "test__gm_fodf.nii.gz" + ] + ], + "gm_map": [ + [ + { + "id": "test" + }, + "test__map_gm.nii.gz" + ] + ], + "gm_mask": [ + [ + { + "id": "test" + }, + "test__mask_gm.nii.gz" + ] + ], + "local_config": [ + [ + { + "id": "test" + }, + "test__local_tracking_config.json" + ] + ], + "local_seeding_mask": [ + [ + { + "id": "test" + }, + "test__local_seeding_mask.nii.gz" + ] + ], + "local_tracking_mask": [ + [ + { + "id": "test" + }, + "test__local_tracking_mask.nii.gz" + ] + ], + "local_tractogram": [ + [ + { + "id": "test" + }, + "test__local_tracking.trk" + ] + ], "mqc": [ [ { @@ -458,6 +779,18 @@ }, "test__dwi_eddy_restricted_movement_rms.txt" ], + [ + { + "id": "test" + }, + "test__local_tracking_mqc.png" + ], + [ + { + "id": "test" + }, + "test__pft_tracking_mqc.png" + ], [ { "id": "test" @@ -479,6 +812,54 @@ "test__nonphysical.nii.gz" ] ], + "nufo": [ + [ + { + "id": "test" + }, + "test__nufo.nii.gz" + ] + ], + "pft_config": [ + [ + { + "id": "test" + }, + "test__pft_tracking_config.json" + ] + ], + "pft_map_exclude": [ + [ + { + "id": "test" + }, + "test__map_exclude.nii.gz" + ] + ], + "pft_map_include": [ + [ + { + "id": "test" + }, + "test__map_include.nii.gz" + ] + ], + "pft_seeding_mask": [ + [ + { + "id": "test" + }, + "test__pft_seeding_mask.nii.gz" + ] + ], + "pft_tractogram": [ + [ + { + "id": "test" + }, + "test__pft_tracking.trk" + ] + ], "pulsation_in_b0": [ [ { @@ -495,6 +876,14 @@ "test__pulsation_std_dwi.nii.gz" ] ], + "t1": [ + [ + { + "id": "test" + }, + "test_t1_cropped_warped.nii.gz" + ] + ], "t1_native": [ [ { @@ -504,10 +893,47 @@ ] ], "versions": [ + "versions.yml:md5,35eb6cc8d3a3b200123613abf38d6c98", + "versions.yml:md5,68aaff09474ed3ae149c1cffb0651f0d", + "versions.yml:md5,772acc9a4938fc99817db1c00efd2100", "versions.yml:md5,7cabc91ec64b5e824e9b8f60d7dcf930", "versions.yml:md5,7fae1f6758d48901013496c0a680b81b", + "versions.yml:md5,85cf18214259841972e1ea51961dc19d", "versions.yml:md5,cdfc3f4153b62c413e2fc6e948f2ef21", + "versions.yml:md5,e808fc7967f50aad087f14c8cbcdc7e1", "versions.yml:md5,fee3d07623cc095a898f0a1de534a05b" + ], + "volume_fraction": [ + [ + { + "id": "test" + }, + "test__vf.nii.gz" + ] + ], + "wm_fodf": [ + [ + { + "id": "test" + }, + "test__wm_fodf.nii.gz" + ] + ], + "wm_map": [ + [ + { + "id": "test" + }, + "test__map_wm.nii.gz" + ] + ], + "wm_mask": [ + [ + { + "id": "test" + }, + "test__mask_wm.nii.gz" + ] ] } ], @@ -515,6 +941,6 @@ "nf-test": "0.9.3", "nextflow": "25.10.2" }, - "timestamp": "2026-07-10T16:17:18.986906066" + "timestamp": "2026-07-10T22:27:22.059261717" } } \ No newline at end of file From 205e55fdc96049175d8a2cdba1cda29ef160381e Mon Sep 17 00:00:00 2001 From: arnaudbore Date: Sat, 11 Jul 2026 01:01:36 -0400 Subject: [PATCH 10/14] fix stub ants --- modules/nf-neuro/registration/ants/main.nf | 7 ++++++- subworkflows/nf-neuro/output_template_space/main.nf | 1 + .../output_template_space/tests/main.nf.test.snap | 8 ++++---- .../nf-neuro/output_template_space/tests/nextflow.config | 4 +++- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/modules/nf-neuro/registration/ants/main.nf b/modules/nf-neuro/registration/ants/main.nf index 43b7abe3..62f2857f 100644 --- a/modules/nf-neuro/registration/ants/main.nf +++ b/modules/nf-neuro/registration/ants/main.nf @@ -151,11 +151,16 @@ process REGISTRATION_ANTS { antsRegistrationSyNQuick.sh -h } + moving_base=\$(basename "${moving_image}") + ext=\${moving_base#*.} + moving_id=\${moving_base%.\${ext}} + moving_id=\${moving_id#${prefix}_*} + antsApplyTransforms -h convert -help . scil_viz_volume_screenshot -h - touch ${prefix}_t1_warped.nii.gz + touch ${prefix}_\${moving_id}_warped.nii.gz touch ${prefix}_forward1_affine.mat touch ${prefix}_forward0_warp.nii.gz touch ${prefix}_backward1_warp.nii.gz diff --git a/subworkflows/nf-neuro/output_template_space/main.nf b/subworkflows/nf-neuro/output_template_space/main.nf index 1d9558a2..97189442 100644 --- a/subworkflows/nf-neuro/output_template_space/main.nf +++ b/subworkflows/nf-neuro/output_template_space/main.nf @@ -161,6 +161,7 @@ workflow OUTPUT_TEMPLATE_SPACE { [ "run_easyreg": options.run_easyreg, "run_synthmorph": options.run_synthmorph, + "masking_strategy": options.masking_strategy ] ) ch_versions = ch_versions.mix(REGISTRATION.out.versions) diff --git a/subworkflows/nf-neuro/output_template_space/tests/main.nf.test.snap b/subworkflows/nf-neuro/output_template_space/tests/main.nf.test.snap index c4932e00..a8d4951b 100644 --- a/subworkflows/nf-neuro/output_template_space/tests/main.nf.test.snap +++ b/subworkflows/nf-neuro/output_template_space/tests/main.nf.test.snap @@ -7,7 +7,7 @@ { "id": "test" }, - "test_t1_warped.nii.gz" + "test_mni_masked_warped.nii.gz" ] ], "ch_registered_labels_files": [ @@ -77,7 +77,7 @@ "nf-test": "0.9.3", "nextflow": "25.10.2" }, - "timestamp": "2026-07-10T22:36:55.080186253" + "timestamp": "2026-07-11T00:51:58.045151125" }, "Template MNI152NLin2009aAsym - using synthmorph registration": { "content": [ @@ -162,7 +162,7 @@ { "id": "test" }, - "test_t1_warped.nii.gz" + "test_mni_masked_warped.nii.gz" ] ], "ch_registered_labels_files": [ @@ -232,6 +232,6 @@ "nf-test": "0.9.3", "nextflow": "25.10.2" }, - "timestamp": "2026-07-10T22:36:13.853694569" + "timestamp": "2026-07-11T00:51:24.259893277" } } \ No newline at end of file diff --git a/subworkflows/nf-neuro/output_template_space/tests/nextflow.config b/subworkflows/nf-neuro/output_template_space/tests/nextflow.config index 805dfe50..7b8ba1ff 100644 --- a/subworkflows/nf-neuro/output_template_space/tests/nextflow.config +++ b/subworkflows/nf-neuro/output_template_space/tests/nextflow.config @@ -3,6 +3,7 @@ process { cpus = 1 withName: "REGISTRATION_ANTS" { + ext.masking_strategy = "internal" ext.repro_mode = 1 ext.transform = "s" ext.quick = true @@ -57,7 +58,7 @@ process { ext.bet_f = 0.6 ext.crop = false ext.dilate = false - } + } } params.templateflow_home = "./" @@ -65,3 +66,4 @@ params.template = "MNI152NLin2009aAsym" params.templateflow_res = 1 params.templateflow_cohort = null params.use_template_t2w = false +params.masking_strategy = "internal" From ebd3270412cf74025d0d299649e8636783bdcb75 Mon Sep 17 00:00:00 2001 From: arnaudbore Date: Mon, 13 Jul 2026 11:31:03 -0400 Subject: [PATCH 11/14] fix claude comments add out_ref_warped for other module than easyreg --- .../nf-neuro/registration/anattodwi/main.nf | 11 +- .../nf-neuro/registration/anattodwi/meta.yml | 12 + .../anattodwi/tests/main.nf.test.snap | 92 +++++--- modules/nf-neuro/registration/ants/main.nf | 5 +- modules/nf-neuro/registration/ants/meta.yml | 12 + .../registration/ants/tests/main.nf.test.snap | 208 ++++++++++++------ modules/nf-neuro/registration/easyreg/main.nf | 14 +- .../easyreg/tests/main.nf.test.snap | 8 +- .../nf-neuro/registration/synthmorph/main.nf | 21 +- .../nf-neuro/registration/synthmorph/meta.yml | 12 + .../synthmorph/tests/main.nf.test.snap | 17 +- subworkflows/nf-neuro/registration/main.nf | 5 +- .../registration/tests/main.nf.test.snap | 36 ++- .../registration/tests/nextflow.config | 1 - 14 files changed, 334 insertions(+), 120 deletions(-) diff --git a/modules/nf-neuro/registration/anattodwi/main.nf b/modules/nf-neuro/registration/anattodwi/main.nf index d00accb4..fffe312d 100644 --- a/modules/nf-neuro/registration/anattodwi/main.nf +++ b/modules/nf-neuro/registration/anattodwi/main.nf @@ -9,6 +9,7 @@ process REGISTRATION_ANATTODWI { output: tuple val(meta), path("*_warped.nii.gz") , emit: anat_warped + tuple val(meta), path("*_warped_reference.nii.gz") , emit: fixed_warped tuple val(meta), path("*_forward1_affine.mat") , emit: forward_affine tuple val(meta), path("*_forward0_warp.nii.gz") , emit: forward_warp tuple val(meta), path("*_backward1_warp.nii.gz") , emit: backward_warp @@ -28,14 +29,14 @@ process REGISTRATION_ANATTODWI { def run_qc = task.ext.run_qc as Boolean || false def args = task.ext.args ?: '' - if ( task.ext.masking_strategy == "both" || task.ext.masking_strategy == "internal" ) args += " -x \"${fixed_mask ?: 'NULL'},${moving_mask ?: 'NULL'}\"" + if (( task.ext.masking_strategy == "both" || task.ext.masking_strategy == "internal" ) && (fixed_mask || moving_mask)) args += " -x \"${fixed_mask ?: 'NULL'},${moving_mask ?: 'NULL'}\"" """ export ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS=${task.ext.single_thread ? 1 : task.cpus} export OMP_NUM_THREADS=${task.ext.single_thread ? 1 : task.cpus} export ANTS_RANDOM_SEED=${task.ext.ants_rng_seed ? task.ext.ants_rng_seed : "1234"} antsRegistration --dimensionality 3 --float 0\ - --output [forward,warped.nii.gz]\ + --output [forward,warped.nii.gz,InverseWarped.nii.gz]\ --interpolation Linear --use-histogram-matching 0\ --winsorize-image-intensities [0.005,0.995]\ --initial-moving-transform [$fixed_reference,$moving_anat,1]\ @@ -54,12 +55,11 @@ process REGISTRATION_ANATTODWI { --smoothing-sigmas 3x2x1\ $args - moving_base=\$(basename "${moving_anat}") - ext=\${moving_base#*.} - moving_id=\${moving_base%.\${ext}} + moving_id=\$(basename $moving_anat .nii.gz) moving_id=\${moving_id#${prefix}_*} mv warped.nii.gz ${prefix}_\${moving_id}_warped.nii.gz + mv InverseWarped.nii.gz ${prefix}_warped_reference.nii.gz mv forward0GenericAffine.mat ${prefix}_forward1_affine.mat mv forward1Warp.nii.gz ${prefix}_forward0_warp.nii.gz mv forward1InverseWarp.nii.gz ${prefix}_backward1_warp.nii.gz @@ -143,6 +143,7 @@ process REGISTRATION_ANATTODWI { moving_id=\${moving_id#${prefix}_*} touch ${prefix}_\${moving_id}_warped.nii.gz + touch ${prefix}_warped_reference.nii.gz touch ${prefix}_forward1_affine.mat touch ${prefix}_forward0_warp.nii.gz touch ${prefix}_backward1_warp.nii.gz diff --git a/modules/nf-neuro/registration/anattodwi/meta.yml b/modules/nf-neuro/registration/anattodwi/meta.yml index 0f5d79a4..ddeec99f 100644 --- a/modules/nf-neuro/registration/anattodwi/meta.yml +++ b/modules/nf-neuro/registration/anattodwi/meta.yml @@ -101,6 +101,18 @@ output: pattern: "*_warped.nii.gz" ontologies: - edam: http://edamontology.org/format_4001 # NIFTI format + fixed_warped: + - - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'test', single_end:false ]` + - "*_warped_reference.nii.gz": + type: file + description: B0 warped to T1 space + pattern: "*_warped_reference.nii.gz" + ontologies: + - edam: http://edamontology.org/format_4001 # NIFTI format forward_affine: - - meta: type: map diff --git a/modules/nf-neuro/registration/anattodwi/tests/main.nf.test.snap b/modules/nf-neuro/registration/anattodwi/tests/main.nf.test.snap index 2f808c1e..2a6464e3 100644 --- a/modules/nf-neuro/registration/anattodwi/tests/main.nf.test.snap +++ b/modules/nf-neuro/registration/anattodwi/tests/main.nf.test.snap @@ -17,10 +17,19 @@ "id": "test", "single_end": false }, - "test_forward1_affine.mat:md5,984ac5023aca49f513af811d0f1e3e89" + "test_warped_reference.nii.gz:md5,f6969de8c75d8e4a5a6d264c3ac50ab1" ] ], "10": [ + [ + { + "id": "test", + "single_end": false + }, + "test_registration_anattodwi_mqc.gif:md5,9cbc1ce8755821996dae18080cf0a23c" + ] + ], + "11": [ "versions.yml:md5,37249bcc3b9ecbaf310960d876fd802d" ], "2": [ @@ -29,7 +38,7 @@ "id": "test", "single_end": false }, - "test_forward0_warp.nii.gz:md5,464d7b291ab9c9aaead7ecbfec6a6693" + "test_forward1_affine.mat:md5,984ac5023aca49f513af811d0f1e3e89" ] ], "3": [ @@ -38,7 +47,7 @@ "id": "test", "single_end": false }, - "test_backward1_warp.nii.gz:md5,4ea6f41a8246f3cb0b1ad39c94028c1f" + "test_forward0_warp.nii.gz:md5,464d7b291ab9c9aaead7ecbfec6a6693" ] ], "4": [ @@ -47,7 +56,7 @@ "id": "test", "single_end": false }, - "test_backward0_affine.mat:md5,177325d18b5a5fa457bd3a2e052463d9" + "test_backward1_warp.nii.gz:md5,4ea6f41a8246f3cb0b1ad39c94028c1f" ] ], "5": [ @@ -56,10 +65,7 @@ "id": "test", "single_end": false }, - [ - "test_forward0_warp.nii.gz:md5,464d7b291ab9c9aaead7ecbfec6a6693", - "test_forward1_affine.mat:md5,984ac5023aca49f513af811d0f1e3e89" - ] + "test_backward0_affine.mat:md5,177325d18b5a5fa457bd3a2e052463d9" ] ], "6": [ @@ -69,8 +75,8 @@ "single_end": false }, [ - "test_backward0_affine.mat:md5,177325d18b5a5fa457bd3a2e052463d9", - "test_backward1_warp.nii.gz:md5,4ea6f41a8246f3cb0b1ad39c94028c1f" + "test_forward0_warp.nii.gz:md5,464d7b291ab9c9aaead7ecbfec6a6693", + "test_forward1_affine.mat:md5,984ac5023aca49f513af811d0f1e3e89" ] ] ], @@ -93,8 +99,8 @@ "single_end": false }, [ - "test_forward0_warp.nii.gz:md5,464d7b291ab9c9aaead7ecbfec6a6693", - "test_forward1_affine.mat:md5,984ac5023aca49f513af811d0f1e3e89" + "test_backward0_affine.mat:md5,177325d18b5a5fa457bd3a2e052463d9", + "test_backward1_warp.nii.gz:md5,4ea6f41a8246f3cb0b1ad39c94028c1f" ] ] ], @@ -104,7 +110,10 @@ "id": "test", "single_end": false }, - "test_registration_anattodwi_mqc.gif:md5,9cbc1ce8755821996dae18080cf0a23c" + [ + "test_forward0_warp.nii.gz:md5,464d7b291ab9c9aaead7ecbfec6a6693", + "test_forward1_affine.mat:md5,984ac5023aca49f513af811d0f1e3e89" + ] ] ], "anat_warped": [ @@ -158,6 +167,15 @@ "test_backward1_warp.nii.gz:md5,4ea6f41a8246f3cb0b1ad39c94028c1f" ] ], + "fixed_warped": [ + [ + { + "id": "test", + "single_end": false + }, + "test_warped_reference.nii.gz:md5,f6969de8c75d8e4a5a6d264c3ac50ab1" + ] + ], "forward_affine": [ [ { @@ -218,7 +236,7 @@ "nf-test": "0.9.3", "nextflow": "25.10.2" }, - "timestamp": "2026-05-02T12:00:04.565708322" + "timestamp": "2026-07-13T10:01:47.364973792" }, "registration - anattodwi -stub-run": { "content": [ @@ -250,10 +268,19 @@ "id": "test", "single_end": false }, - "test_forward1_affine.mat:md5,984ac5023aca49f513af811d0f1e3e89" + "test_warped_reference.nii.gz:md5,f6969de8c75d8e4a5a6d264c3ac50ab1" ] ], "10": [ + [ + { + "id": "test", + "single_end": false + }, + "test_registration_anattodwi_mqc.gif:md5,9cbc1ce8755821996dae18080cf0a23c" + ] + ], + "11": [ "versions.yml:md5,37249bcc3b9ecbaf310960d876fd802d" ], "2": [ @@ -262,7 +289,7 @@ "id": "test", "single_end": false }, - "test_forward0_warp.nii.gz:md5,464d7b291ab9c9aaead7ecbfec6a6693" + "test_forward1_affine.mat:md5,984ac5023aca49f513af811d0f1e3e89" ] ], "3": [ @@ -271,7 +298,7 @@ "id": "test", "single_end": false }, - "test_backward1_warp.nii.gz:md5,4ea6f41a8246f3cb0b1ad39c94028c1f" + "test_forward0_warp.nii.gz:md5,464d7b291ab9c9aaead7ecbfec6a6693" ] ], "4": [ @@ -280,7 +307,7 @@ "id": "test", "single_end": false }, - "test_backward0_affine.mat:md5,177325d18b5a5fa457bd3a2e052463d9" + "test_backward1_warp.nii.gz:md5,4ea6f41a8246f3cb0b1ad39c94028c1f" ] ], "5": [ @@ -289,10 +316,7 @@ "id": "test", "single_end": false }, - [ - "test_forward0_warp.nii.gz:md5,464d7b291ab9c9aaead7ecbfec6a6693", - "test_forward1_affine.mat:md5,984ac5023aca49f513af811d0f1e3e89" - ] + "test_backward0_affine.mat:md5,177325d18b5a5fa457bd3a2e052463d9" ] ], "6": [ @@ -302,8 +326,8 @@ "single_end": false }, [ - "test_backward0_affine.mat:md5,177325d18b5a5fa457bd3a2e052463d9", - "test_backward1_warp.nii.gz:md5,4ea6f41a8246f3cb0b1ad39c94028c1f" + "test_forward0_warp.nii.gz:md5,464d7b291ab9c9aaead7ecbfec6a6693", + "test_forward1_affine.mat:md5,984ac5023aca49f513af811d0f1e3e89" ] ] ], @@ -326,8 +350,8 @@ "single_end": false }, [ - "test_forward0_warp.nii.gz:md5,464d7b291ab9c9aaead7ecbfec6a6693", - "test_forward1_affine.mat:md5,984ac5023aca49f513af811d0f1e3e89" + "test_backward0_affine.mat:md5,177325d18b5a5fa457bd3a2e052463d9", + "test_backward1_warp.nii.gz:md5,4ea6f41a8246f3cb0b1ad39c94028c1f" ] ] ], @@ -337,7 +361,10 @@ "id": "test", "single_end": false }, - "test_registration_anattodwi_mqc.gif:md5,9cbc1ce8755821996dae18080cf0a23c" + [ + "test_forward0_warp.nii.gz:md5,464d7b291ab9c9aaead7ecbfec6a6693", + "test_forward1_affine.mat:md5,984ac5023aca49f513af811d0f1e3e89" + ] ] ], "anat_warped": [ @@ -391,6 +418,15 @@ "test_backward1_warp.nii.gz:md5,4ea6f41a8246f3cb0b1ad39c94028c1f" ] ], + "fixed_warped": [ + [ + { + "id": "test", + "single_end": false + }, + "test_warped_reference.nii.gz:md5,f6969de8c75d8e4a5a6d264c3ac50ab1" + ] + ], "forward_affine": [ [ { @@ -451,6 +487,6 @@ "nf-test": "0.9.3", "nextflow": "25.10.2" }, - "timestamp": "2026-07-10T14:35:36.061250786" + "timestamp": "2026-07-13T10:04:42.169706966" } } \ No newline at end of file diff --git a/modules/nf-neuro/registration/ants/main.nf b/modules/nf-neuro/registration/ants/main.nf index 62f2857f..bc990b87 100644 --- a/modules/nf-neuro/registration/ants/main.nf +++ b/modules/nf-neuro/registration/ants/main.nf @@ -10,6 +10,7 @@ process REGISTRATION_ANTS { output: tuple val(meta), path("*_warped.nii.gz") , emit: image_warped + tuple val(meta), path("*_warped_reference.nii.gz") , emit: fixed_warped tuple val(meta), path("*_forward1_affine.mat") , emit: forward_affine, optional: true tuple val(meta), path("*_forward0_warp.nii.gz") , emit: forward_warp, optional: true tuple val(meta), path("*_backward1_warp.nii.gz") , emit: backward_warp, optional: true @@ -44,7 +45,7 @@ process REGISTRATION_ANTS { if ( task.ext.histogram_matching ) args += " -j $task.ext.histogram_matching" if ( task.ext.repro_mode ) args += " -y $task.ext.repro_mode" if ( task.ext.collapse_output ) args += " -z $task.ext.collapse_output" - if ( task.ext.masking_strategy == "both" || task.ext.masking_strategy == "internal" ) args += " -x \"${fixed_mask ?: 'NULL'},${moving_mask ?: 'NULL'}\"" + if ( (task.ext.masking_strategy == "both" || task.ext.masking_strategy == "internal") && (fixed_mask || moving_mask) ) args += " -x \"${fixed_mask ?: 'NULL'},${moving_mask ?: 'NULL'}\"" """ export ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS=${task.ext.single_thread ? 1 : task.cpus} @@ -59,6 +60,7 @@ process REGISTRATION_ANTS { moving_id=\${moving_id#${prefix}_*} mv outputWarped.nii.gz ${prefix}_\${moving_id}_warped.nii.gz + mv outputInverseWarped.nii.gz ${prefix}_warped_reference.nii.gz if [ $transform != "bo" ] && [ $transform != "so" ]; then mv output0GenericAffine.mat ${prefix}_forward1_affine.mat @@ -161,6 +163,7 @@ process REGISTRATION_ANTS { scil_viz_volume_screenshot -h touch ${prefix}_\${moving_id}_warped.nii.gz + touch ${prefix}_warped_reference.nii.gz touch ${prefix}_forward1_affine.mat touch ${prefix}_forward0_warp.nii.gz touch ${prefix}_backward1_warp.nii.gz diff --git a/modules/nf-neuro/registration/ants/meta.yml b/modules/nf-neuro/registration/ants/meta.yml index 89d7e2a5..71ff8b08 100644 --- a/modules/nf-neuro/registration/ants/meta.yml +++ b/modules/nf-neuro/registration/ants/meta.yml @@ -176,6 +176,18 @@ output: pattern: "*_warped.nii.gz" ontologies: - edam: http://edamontology.org/format_3989 # GZIP format + fixed_warped: + - - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'test', single_end:false ]` + - "*_warped_reference.nii.gz": + type: file + description: Reference warped to moving space. + pattern: "*_warped_reference.nii.gz" + ontologies: + - edam: http://edamontology.org/format_3989 # GZIP format forward_affine: - - meta: type: map diff --git a/modules/nf-neuro/registration/ants/tests/main.nf.test.snap b/modules/nf-neuro/registration/ants/tests/main.nf.test.snap index 02cf9179..0e9fe2b3 100644 --- a/modules/nf-neuro/registration/ants/tests/main.nf.test.snap +++ b/modules/nf-neuro/registration/ants/tests/main.nf.test.snap @@ -15,10 +15,18 @@ { "id": "test" }, - "test_forward1_affine.mat:md5,3bc315e13074f374dda32e29e13f201a" + "test_warped_reference.nii.gz:md5,aecd2a8b83026219078af73aaa0fdeb7" ] ], "10": [ + [ + { + "id": "test" + }, + "test_T1_to_T1_slab_registration_ants_mqc.gif:md5,6cb6f9efc4910087b32943da4f579ee4" + ] + ], + "11": [ "versions.yml:md5,0b121e44c28b1c3efb04ae0dfc9ec76c" ], "2": [ @@ -26,7 +34,7 @@ { "id": "test" }, - "test_forward0_warp.nii.gz:md5,384082f9f4c14f3235abc5d572dc8336" + "test_forward1_affine.mat:md5,3bc315e13074f374dda32e29e13f201a" ] ], "3": [ @@ -34,7 +42,7 @@ { "id": "test" }, - "test_backward1_warp.nii.gz:md5,06e37e91eb8b489cb41e8f8501e9ecc8" + "test_forward0_warp.nii.gz:md5,384082f9f4c14f3235abc5d572dc8336" ] ], "4": [ @@ -42,7 +50,7 @@ { "id": "test" }, - "test_backward0_affine.mat:md5,9344bac7ae2d83e4e45367377bc37455" + "test_backward1_warp.nii.gz:md5,06e37e91eb8b489cb41e8f8501e9ecc8" ] ], "5": [ @@ -50,10 +58,7 @@ { "id": "test" }, - [ - "test_forward0_warp.nii.gz:md5,384082f9f4c14f3235abc5d572dc8336", - "test_forward1_affine.mat:md5,3bc315e13074f374dda32e29e13f201a" - ] + "test_backward0_affine.mat:md5,9344bac7ae2d83e4e45367377bc37455" ] ], "6": [ @@ -62,8 +67,8 @@ "id": "test" }, [ - "test_backward0_affine.mat:md5,9344bac7ae2d83e4e45367377bc37455", - "test_backward1_warp.nii.gz:md5,06e37e91eb8b489cb41e8f8501e9ecc8" + "test_forward0_warp.nii.gz:md5,384082f9f4c14f3235abc5d572dc8336", + "test_forward1_affine.mat:md5,3bc315e13074f374dda32e29e13f201a" ] ] ], @@ -84,8 +89,8 @@ "id": "test" }, [ - "test_forward0_warp.nii.gz:md5,384082f9f4c14f3235abc5d572dc8336", - "test_forward1_affine.mat:md5,3bc315e13074f374dda32e29e13f201a" + "test_backward0_affine.mat:md5,9344bac7ae2d83e4e45367377bc37455", + "test_backward1_warp.nii.gz:md5,06e37e91eb8b489cb41e8f8501e9ecc8" ] ] ], @@ -94,7 +99,10 @@ { "id": "test" }, - "test_T1_to_T1_slab_registration_ants_mqc.gif:md5,6cb6f9efc4910087b32943da4f579ee4" + [ + "test_forward0_warp.nii.gz:md5,384082f9f4c14f3235abc5d572dc8336", + "test_forward1_affine.mat:md5,3bc315e13074f374dda32e29e13f201a" + ] ] ], "backward_affine": [ @@ -135,6 +143,14 @@ "test_backward1_warp.nii.gz:md5,06e37e91eb8b489cb41e8f8501e9ecc8" ] ], + "fixed_warped": [ + [ + { + "id": "test" + }, + "test_warped_reference.nii.gz:md5,aecd2a8b83026219078af73aaa0fdeb7" + ] + ], "forward_affine": [ [ { @@ -198,7 +214,7 @@ "nf-test": "0.9.3", "nextflow": "25.10.2" }, - "timestamp": "2026-07-10T17:35:19.380059833" + "timestamp": "2026-07-13T09:01:12.623392808" }, "registration - ants - stub": { "content": [ @@ -210,7 +226,7 @@ "nf-test": "0.9.3", "nextflow": "25.10.2" }, - "timestamp": "2026-02-26T22:31:18.974318044" + "timestamp": "2026-07-13T09:14:31.190460359" }, "registration - ants - SyN quick": { "content": [ @@ -228,10 +244,18 @@ { "id": "test" }, - "test_forward1_affine.mat:md5,41afa6fa72a013820a3d3d8ce4986002" + "test_warped_reference.nii.gz:md5,3cbad0d0163e9bd59b3f6b865e464ffb" ] ], "10": [ + [ + { + "id": "test" + }, + "test_T1_to_T1_slab_registration_ants_mqc.gif:md5,b685aa586e6b61196b442740c1056eb5" + ] + ], + "11": [ "versions.yml:md5,0b121e44c28b1c3efb04ae0dfc9ec76c" ], "2": [ @@ -239,7 +263,7 @@ { "id": "test" }, - "test_forward0_warp.nii.gz:md5,806c26fdf31077d4b035a2009db54c95" + "test_forward1_affine.mat:md5,41afa6fa72a013820a3d3d8ce4986002" ] ], "3": [ @@ -247,7 +271,7 @@ { "id": "test" }, - "test_backward1_warp.nii.gz:md5,4cca843970b2ed3d02ecf43a31502857" + "test_forward0_warp.nii.gz:md5,806c26fdf31077d4b035a2009db54c95" ] ], "4": [ @@ -255,7 +279,7 @@ { "id": "test" }, - "test_backward0_affine.mat:md5,9b6845301aaeaf43a1cf9da4e4cb671f" + "test_backward1_warp.nii.gz:md5,4cca843970b2ed3d02ecf43a31502857" ] ], "5": [ @@ -263,10 +287,7 @@ { "id": "test" }, - [ - "test_forward0_warp.nii.gz:md5,806c26fdf31077d4b035a2009db54c95", - "test_forward1_affine.mat:md5,41afa6fa72a013820a3d3d8ce4986002" - ] + "test_backward0_affine.mat:md5,9b6845301aaeaf43a1cf9da4e4cb671f" ] ], "6": [ @@ -275,8 +296,8 @@ "id": "test" }, [ - "test_backward0_affine.mat:md5,9b6845301aaeaf43a1cf9da4e4cb671f", - "test_backward1_warp.nii.gz:md5,4cca843970b2ed3d02ecf43a31502857" + "test_forward0_warp.nii.gz:md5,806c26fdf31077d4b035a2009db54c95", + "test_forward1_affine.mat:md5,41afa6fa72a013820a3d3d8ce4986002" ] ] ], @@ -297,8 +318,8 @@ "id": "test" }, [ - "test_forward0_warp.nii.gz:md5,806c26fdf31077d4b035a2009db54c95", - "test_forward1_affine.mat:md5,41afa6fa72a013820a3d3d8ce4986002" + "test_backward0_affine.mat:md5,9b6845301aaeaf43a1cf9da4e4cb671f", + "test_backward1_warp.nii.gz:md5,4cca843970b2ed3d02ecf43a31502857" ] ] ], @@ -307,7 +328,10 @@ { "id": "test" }, - "test_T1_to_T1_slab_registration_ants_mqc.gif:md5,b685aa586e6b61196b442740c1056eb5" + [ + "test_forward0_warp.nii.gz:md5,806c26fdf31077d4b035a2009db54c95", + "test_forward1_affine.mat:md5,41afa6fa72a013820a3d3d8ce4986002" + ] ] ], "backward_affine": [ @@ -348,6 +372,14 @@ "test_backward1_warp.nii.gz:md5,4cca843970b2ed3d02ecf43a31502857" ] ], + "fixed_warped": [ + [ + { + "id": "test" + }, + "test_warped_reference.nii.gz:md5,3cbad0d0163e9bd59b3f6b865e464ffb" + ] + ], "forward_affine": [ [ { @@ -411,7 +443,7 @@ "nf-test": "0.9.3", "nextflow": "25.10.2" }, - "timestamp": "2026-07-10T17:32:31.640927711" + "timestamp": "2026-07-13T08:57:44.546094663" }, "registration - ants - SyN": { "content": [ @@ -429,10 +461,13 @@ { "id": "test" }, - "test_forward1_affine.mat:md5,0fb5879b315f32bb8e06aa2993009115" + "test_warped_reference.nii.gz:md5,8d9d3bd39214d9b4fd0cedfc2458d093" ] ], "10": [ + + ], + "11": [ "versions.yml:md5,0b121e44c28b1c3efb04ae0dfc9ec76c" ], "2": [ @@ -440,7 +475,7 @@ { "id": "test" }, - "test_forward0_warp.nii.gz:md5,a32206a00e93b79054e9b8fa0f7c8015" + "test_forward1_affine.mat:md5,0fb5879b315f32bb8e06aa2993009115" ] ], "3": [ @@ -448,7 +483,7 @@ { "id": "test" }, - "test_backward1_warp.nii.gz:md5,4e85fa2257f7364fde205adfa1b3c8d3" + "test_forward0_warp.nii.gz:md5,a32206a00e93b79054e9b8fa0f7c8015" ] ], "4": [ @@ -456,10 +491,18 @@ { "id": "test" }, - "test_backward0_affine.mat:md5,ff00be1483698e5478bfa94abf2b42b2" + "test_backward1_warp.nii.gz:md5,4e85fa2257f7364fde205adfa1b3c8d3" ] ], "5": [ + [ + { + "id": "test" + }, + "test_backward0_affine.mat:md5,ff00be1483698e5478bfa94abf2b42b2" + ] + ], + "6": [ [ { "id": "test" @@ -470,7 +513,7 @@ ] ] ], - "6": [ + "7": [ [ { "id": "test" @@ -481,7 +524,7 @@ ] ] ], - "7": [ + "8": [ [ { "id": "test" @@ -492,7 +535,7 @@ ] ] ], - "8": [ + "9": [ [ { "id": "test" @@ -502,9 +545,6 @@ "test_forward1_affine.mat:md5,0fb5879b315f32bb8e06aa2993009115" ] ] - ], - "9": [ - ], "backward_affine": [ [ @@ -544,6 +584,14 @@ "test_backward1_warp.nii.gz:md5,4e85fa2257f7364fde205adfa1b3c8d3" ] ], + "fixed_warped": [ + [ + { + "id": "test" + }, + "test_warped_reference.nii.gz:md5,8d9d3bd39214d9b4fd0cedfc2458d093" + ] + ], "forward_affine": [ [ { @@ -602,7 +650,7 @@ "nf-test": "0.9.3", "nextflow": "25.10.2" }, - "timestamp": "2026-07-10T17:31:29.622156975" + "timestamp": "2026-07-13T08:56:23.888876135" }, "registration - ants - both - fixed mask": { "content": [ @@ -620,10 +668,18 @@ { "id": "test" }, - "test_forward1_affine.mat:md5,18c2ec8b5cf3fb4e038cce665eb53e7c" + "test_warped_reference.nii.gz:md5,e29b6d5f67b52afa7ab5b6ae90afd375" ] ], "10": [ + [ + { + "id": "test" + }, + "test_T1_to_T1_slab_registration_ants_mqc.gif:md5,fba29c34dd2cebde98e9c72e5c991550" + ] + ], + "11": [ "versions.yml:md5,0b121e44c28b1c3efb04ae0dfc9ec76c" ], "2": [ @@ -631,7 +687,7 @@ { "id": "test" }, - "test_forward0_warp.nii.gz:md5,d1f0ce951610683042aab377c665295d" + "test_forward1_affine.mat:md5,18c2ec8b5cf3fb4e038cce665eb53e7c" ] ], "3": [ @@ -639,7 +695,7 @@ { "id": "test" }, - "test_backward1_warp.nii.gz:md5,e5324ab5af8cceda46e0bb642dfc02aa" + "test_forward0_warp.nii.gz:md5,d1f0ce951610683042aab377c665295d" ] ], "4": [ @@ -647,7 +703,7 @@ { "id": "test" }, - "test_backward0_affine.mat:md5,ba4cdd24110970c8d08b8df39ee4fd95" + "test_backward1_warp.nii.gz:md5,e5324ab5af8cceda46e0bb642dfc02aa" ] ], "5": [ @@ -655,10 +711,7 @@ { "id": "test" }, - [ - "test_forward0_warp.nii.gz:md5,d1f0ce951610683042aab377c665295d", - "test_forward1_affine.mat:md5,18c2ec8b5cf3fb4e038cce665eb53e7c" - ] + "test_backward0_affine.mat:md5,ba4cdd24110970c8d08b8df39ee4fd95" ] ], "6": [ @@ -667,8 +720,8 @@ "id": "test" }, [ - "test_backward0_affine.mat:md5,ba4cdd24110970c8d08b8df39ee4fd95", - "test_backward1_warp.nii.gz:md5,e5324ab5af8cceda46e0bb642dfc02aa" + "test_forward0_warp.nii.gz:md5,d1f0ce951610683042aab377c665295d", + "test_forward1_affine.mat:md5,18c2ec8b5cf3fb4e038cce665eb53e7c" ] ] ], @@ -689,8 +742,8 @@ "id": "test" }, [ - "test_forward0_warp.nii.gz:md5,d1f0ce951610683042aab377c665295d", - "test_forward1_affine.mat:md5,18c2ec8b5cf3fb4e038cce665eb53e7c" + "test_backward0_affine.mat:md5,ba4cdd24110970c8d08b8df39ee4fd95", + "test_backward1_warp.nii.gz:md5,e5324ab5af8cceda46e0bb642dfc02aa" ] ] ], @@ -699,7 +752,10 @@ { "id": "test" }, - "test_T1_to_T1_slab_registration_ants_mqc.gif:md5,fba29c34dd2cebde98e9c72e5c991550" + [ + "test_forward0_warp.nii.gz:md5,d1f0ce951610683042aab377c665295d", + "test_forward1_affine.mat:md5,18c2ec8b5cf3fb4e038cce665eb53e7c" + ] ] ], "backward_affine": [ @@ -740,6 +796,14 @@ "test_backward1_warp.nii.gz:md5,e5324ab5af8cceda46e0bb642dfc02aa" ] ], + "fixed_warped": [ + [ + { + "id": "test" + }, + "test_warped_reference.nii.gz:md5,e29b6d5f67b52afa7ab5b6ae90afd375" + ] + ], "forward_affine": [ [ { @@ -803,7 +867,7 @@ "nf-test": "0.9.3", "nextflow": "25.10.2" }, - "timestamp": "2026-07-10T17:36:45.524357151" + "timestamp": "2026-07-13T09:02:40.930435009" }, "registration - ants - no warps": { "content": [ @@ -821,19 +885,30 @@ { "id": "test" }, - "test_forward1_affine.mat:md5,72aee9284d5e624be5dbc15cfce8151c" + "test_warped_reference.nii.gz:md5,0636f939cf940ac053f86286797c0982" ] ], "10": [ + + ], + "11": [ "versions.yml:md5,0b121e44c28b1c3efb04ae0dfc9ec76c" ], "2": [ - + [ + { + "id": "test" + }, + "test_forward1_affine.mat:md5,72aee9284d5e624be5dbc15cfce8151c" + ] ], "3": [ ], "4": [ + + ], + "5": [ [ { "id": "test" @@ -841,7 +916,7 @@ "test_backward0_affine.mat:md5,862976c1966b1af64acd7b40d0f922e4" ] ], - "5": [ + "6": [ [ { "id": "test" @@ -851,7 +926,7 @@ ] ] ], - "6": [ + "7": [ [ { "id": "test" @@ -861,7 +936,7 @@ ] ] ], - "7": [ + "8": [ [ { "id": "test" @@ -871,7 +946,7 @@ ] ] ], - "8": [ + "9": [ [ { "id": "test" @@ -880,9 +955,6 @@ "test_forward1_affine.mat:md5,72aee9284d5e624be5dbc15cfce8151c" ] ] - ], - "9": [ - ], "backward_affine": [ [ @@ -914,6 +986,14 @@ ], "backward_warp": [ + ], + "fixed_warped": [ + [ + { + "id": "test" + }, + "test_warped_reference.nii.gz:md5,0636f939cf940ac053f86286797c0982" + ] ], "forward_affine": [ [ @@ -966,6 +1046,6 @@ "nf-test": "0.9.3", "nextflow": "25.10.2" }, - "timestamp": "2026-07-10T17:32:43.930354571" + "timestamp": "2026-07-13T08:58:13.291148166" } } \ No newline at end of file diff --git a/modules/nf-neuro/registration/easyreg/main.nf b/modules/nf-neuro/registration/easyreg/main.nf index c6cc5815..ad83b6cc 100644 --- a/modules/nf-neuro/registration/easyreg/main.nf +++ b/modules/nf-neuro/registration/easyreg/main.nf @@ -30,9 +30,14 @@ process REGISTRATION_EASYREG { """ export OMP_NUM_THREADS=${task.ext.single_thread ? 1 : task.cpus} + moving_base=\$(basename "${moving_image}") + ext=\${moving_base#*.} + moving_id=\${moving_base%.\${ext}} + moving_id=\${moving_id#${prefix}_*} + mri_easyreg --ref $fixed_image \ --flo $moving_image \ - --flo_reg ${prefix}_warped.nii.gz \ + --flo_reg ${prefix}_\${moving_id}_warped.nii.gz \ --ref_reg ${prefix}_warped_reference.nii.gz \ --fwd_field ${prefix}_forward0_warp.nii.gz \ --bak_field ${prefix}_backward0_warp.nii.gz \ @@ -51,7 +56,12 @@ process REGISTRATION_EASYREG { """ mri_easyreg -h - touch ${prefix}_warped.nii.gz + moving_base=\$(basename "${moving_image}") + ext=\${moving_base#*.} + moving_id=\${moving_base%.\${ext}} + moving_id=\${moving_id#${prefix}_*} + + touch ${prefix}_\${moving_id}_warped.nii.gz touch ${prefix}_warped_reference.nii.gz touch ${prefix}_warped_segmentation.nii.gz touch ${prefix}_warped_reference_segmentation.nii.gz diff --git a/modules/nf-neuro/registration/easyreg/tests/main.nf.test.snap b/modules/nf-neuro/registration/easyreg/tests/main.nf.test.snap index d9c53e2f..6fd2f38f 100644 --- a/modules/nf-neuro/registration/easyreg/tests/main.nf.test.snap +++ b/modules/nf-neuro/registration/easyreg/tests/main.nf.test.snap @@ -4,7 +4,7 @@ "test_warped_reference_segmentation.nii.gz", "test_warped_segmentation.nii.gz", "test_warped_reference.nii.gz:md5:header,c5e41f89848f91c53a9a7be44970d4b1,data,1501221fe23cd62bfdafb33367cadf4d", - "test_warped.nii.gz:md5:header,ec5893cd9ea024e630c4444bd914c331,data,d75ae3fc935cd5cc70ea6797a4c70775", + "test_b0_warped.nii.gz:md5:header,ec5893cd9ea024e630c4444bd914c331,data,d75ae3fc935cd5cc70ea6797a4c70775", "test_forward0_warp.nii.gz:md5:header,0db0a80786ff39864cc17506ed1a0146,data,e4fa6c626729cbf236c34680e5c76df4", "test_backward0_warp.nii.gz:md5:header,74c92ee4cd3c4abfecf3da6cdb1d4650,data,8f26afa5c3de21469466213498542486", [ @@ -12,10 +12,10 @@ ] ], "meta": { - "nf-test": "0.9.0", - "nextflow": "25.04.8" + "nf-test": "0.9.3", + "nextflow": "25.10.2" }, - "timestamp": "2025-10-16T15:11:21.026914183" + "timestamp": "2026-07-13T10:18:12.32065037" }, "registration - easyreg - stub-run": { "content": [ diff --git a/modules/nf-neuro/registration/synthmorph/main.nf b/modules/nf-neuro/registration/synthmorph/main.nf index 72573dc1..4333d90f 100644 --- a/modules/nf-neuro/registration/synthmorph/main.nf +++ b/modules/nf-neuro/registration/synthmorph/main.nf @@ -10,6 +10,7 @@ process REGISTRATION_SYNTHMORPH { output: tuple val(meta), path("*_warped.nii.gz") , emit: image_warped + tuple val(meta), path("*_warped_reference.nii.gz") , emit: fixed_warped tuple val(meta), path("*_forward{0,1,_standalone}_affine.lta") , emit: forward_affine, optional: true tuple val(meta), path("*_forward0_deform.nii.gz") , emit: forward_warp, optional: true tuple val(meta), path("*_backward1_deform.nii.gz") , emit: backward_warp, optional: true @@ -39,6 +40,11 @@ process REGISTRATION_SYNTHMORPH { export OMP_NUM_THREADS=${task.ext.single_thread ? 1 : task.cpus} export CUDA_VISIBLE_DEVICES="-1" + moving_base=\$(basename "${moving_image}") + ext=\${moving_base#*.} + moving_id=\${moving_base%.\${ext}} + moving_id=\${moving_id#${prefix}_*} + echo "Available memory : ${task.memory}" moving=$moving_image @@ -91,7 +97,9 @@ process REGISTRATION_SYNTHMORPH { mri_synthmorph register \$moving fixed.nii.gz -v -m \$model \$weight \$args \ -t ${prefix}_forward\${j}_\$model.\${extension[\$model]} \ -T ${prefix}_backward\${i}_\$model.\${extension[\$model]} \ - -o warped.nii.gz -j ${nthreads} $extent $use_gpu + -o warped.nii.gz \ + -O fixed_warped.nii.gz \ + -j ${nthreads} $extent $use_gpu if [ \$initializer ]; then # Retag initializer file to standalone using sed @@ -112,7 +120,8 @@ process REGISTRATION_SYNTHMORPH { done - mv warped.nii.gz ${prefix}_warped.nii.gz + mv warped.nii.gz ${prefix}_\${moving_id}_warped.nii.gz + mv fixed_warped.nii.gz ${prefix}_warped_reference.nii.gz cat <<-END_VERSIONS > versions.yml "${task.process}": @@ -126,7 +135,13 @@ process REGISTRATION_SYNTHMORPH { """ mri_synthmorph -h - touch ${prefix}_warped.nii.gz + moving_base=\$(basename "${moving_image}") + ext=\${moving_base#*.} + moving_id=\${moving_base%.\${ext}} + moving_id=\${moving_id#${prefix}_*} + + touch ${prefix}_\${moving_id}_warped.nii.gz + touch ${prefix}_warped_reference.nii.gz touch ${prefix}_forward1_affine.lta touch ${prefix}_forward0_warp.nii.gz touch ${prefix}_backward1_warp.nii.gz diff --git a/modules/nf-neuro/registration/synthmorph/meta.yml b/modules/nf-neuro/registration/synthmorph/meta.yml index 03d47d27..6fcbd17c 100644 --- a/modules/nf-neuro/registration/synthmorph/meta.yml +++ b/modules/nf-neuro/registration/synthmorph/meta.yml @@ -103,6 +103,18 @@ output: pattern: "*_warped.nii.gz" ontologies: - edam: http://edamontology.org/format_4001 # NIFTI format + fixed_warped: + - - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'test', single_end:false ]` + - "*_fixed_warped.nii.gz": + type: file + description: Fixed/Reference warped image + pattern: "*_fixed_warped.nii.gz" + ontologies: + - edam: http://edamontology.org/format_4001 # NIFTI format forward_affine: - - meta: type: map diff --git a/modules/nf-neuro/registration/synthmorph/tests/main.nf.test.snap b/modules/nf-neuro/registration/synthmorph/tests/main.nf.test.snap index 2f86a41a..cc18805b 100644 --- a/modules/nf-neuro/registration/synthmorph/tests/main.nf.test.snap +++ b/modules/nf-neuro/registration/synthmorph/tests/main.nf.test.snap @@ -38,6 +38,15 @@ "test_backward1_deform.nii.gz" ] ], + "fixed_warped": [ + [ + { + "id": "test", + "single_end": false + }, + "test_warped_reference.nii.gz" + ] + ], "forward_affine": [ [ { @@ -80,7 +89,7 @@ "id": "test", "single_end": false }, - "test_warped.nii.gz" + "test_b0_mean_warped.nii.gz" ] ], "versions": [ @@ -89,10 +98,10 @@ } ], "meta": { - "nf-test": "0.9.0", - "nextflow": "25.04.8" + "nf-test": "0.9.3", + "nextflow": "25.10.2" }, - "timestamp": "2025-10-16T19:51:21.67628815" + "timestamp": "2026-07-13T10:27:23.471066239" }, "registration - synthmorph - stub-run": { "content": [ diff --git a/subworkflows/nf-neuro/registration/main.nf b/subworkflows/nf-neuro/registration/main.nf index 0b9dbf62..75f70d68 100644 --- a/subworkflows/nf-neuro/registration/main.nf +++ b/subworkflows/nf-neuro/registration/main.nf @@ -183,6 +183,7 @@ workflow REGISTRATION { // ** Set compulsory outputs ** // out_image_warped = REGISTRATION_SYNTHMORPH.out.image_warped + out_ref_warped = REGISTRATION_SYNTHMORPH.out.fixed_warped out_forward_affine = ch_conversion_outputs.forward_affine out_forward_warp = ch_conversion_outputs.forward_warp out_backward_affine = ch_conversion_outputs.backward_affine @@ -196,7 +197,6 @@ workflow REGISTRATION { out_forward_tractogram_transform = out_backward_image_transform out_backward_tractogram_transform = out_forward_image_transform // ** and optional outputs. ** // - out_ref_warped = channel.empty() out_segmentation = channel.empty() out_ref_segmentation = channel.empty() } @@ -229,6 +229,7 @@ workflow REGISTRATION { // ** Set compulsory outputs ** // out_image_warped = REGISTRATION_ANATTODWI.out.anat_warped + out_ref_warped = REGISTRATION_ANATTODWI.out.fixed_warped out_forward_affine = REGISTRATION_ANATTODWI.out.forward_affine out_forward_warp = REGISTRATION_ANATTODWI.out.forward_warp out_backward_affine = REGISTRATION_ANATTODWI.out.backward_affine @@ -252,6 +253,7 @@ workflow REGISTRATION { // ** Set compulsory outputs ** // out_image_warped = out_image_warped.mix(REGISTRATION_ANTS.out.image_warped) + out_ref_warped = out_ref_warped.mix(REGISTRATION_ANTS.out.fixed_warped) out_forward_affine = out_forward_affine.mix(REGISTRATION_ANTS.out.forward_affine) out_forward_warp = out_forward_warp.mix(REGISTRATION_ANTS.out.forward_warp) out_backward_affine = out_backward_affine.mix(REGISTRATION_ANTS.out.backward_affine) @@ -262,7 +264,6 @@ workflow REGISTRATION { out_backward_tractogram_transform = out_backward_tractogram_transform.mix(REGISTRATION_ANTS.out.backward_tractogram_transform) // **and optional outputs **// - out_ref_warped = channel.empty() out_segmentation = channel.empty() out_ref_segmentation = channel.empty() } diff --git a/subworkflows/nf-neuro/registration/tests/main.nf.test.snap b/subworkflows/nf-neuro/registration/tests/main.nf.test.snap index 38454bd7..6a052590 100644 --- a/subworkflows/nf-neuro/registration/tests/main.nf.test.snap +++ b/subworkflows/nf-neuro/registration/tests/main.nf.test.snap @@ -59,7 +59,15 @@ { "id": "test" }, - "test_warped.nii.gz" + "test_b0_warped.nii.gz" + ] + ], + "reference_warped": [ + [ + { + "id": "test" + }, + "test_warped_reference.nii.gz" ] ], "versions": [ @@ -72,7 +80,7 @@ "nf-test": "0.9.3", "nextflow": "25.10.2" }, - "timestamp": "2026-07-10T22:38:54.809065239" + "timestamp": "2026-07-13T10:29:59.551538877" }, "registration - easyreg": { "content": [ @@ -130,7 +138,7 @@ { "id": "test" }, - "test_warped.nii.gz" + "test_T1w_warped.nii.gz" ] ], "reference_segmentation": [ @@ -166,7 +174,7 @@ "nf-test": "0.9.3", "nextflow": "25.10.2" }, - "timestamp": "2026-07-10T22:38:45.322600977" + "timestamp": "2026-07-13T10:29:45.268529864" }, "registration - ANTs - SyNQuick": { "content": [ @@ -263,6 +271,14 @@ "test_T1w_warped.nii.gz" ] ], + "reference_warped_masked": [ + [ + { + "id": "test" + }, + "test_warped_reference.nii.gz" + ] + ], "versions": [ "versions.yml:md5,3764dd2f067db355da3536c1b0c94619", "versions.yml:md5,a338911f46f2c623d87eab600c524ffb" @@ -273,7 +289,7 @@ "nf-test": "0.9.3", "nextflow": "25.10.2" }, - "timestamp": "2026-07-10T22:38:31.882107231" + "timestamp": "2026-07-13T11:21:06.660214686" }, "registration - ANTs - Anat to DWI": { "content": [ @@ -362,6 +378,14 @@ "test_registration_anattodwi_mqc.gif" ] ], + "reference_warped": [ + [ + { + "id": "test" + }, + "test_warped_reference.nii.gz" + ] + ], "versions": [ "versions.yml:md5,03b958f14a890b541bb76c73f7a72847" ] @@ -371,6 +395,6 @@ "nf-test": "0.9.3", "nextflow": "25.10.2" }, - "timestamp": "2026-07-10T22:38:14.73218299" + "timestamp": "2026-07-13T11:20:24.201960901" } } \ No newline at end of file diff --git a/subworkflows/nf-neuro/registration/tests/nextflow.config b/subworkflows/nf-neuro/registration/tests/nextflow.config index 91c91d03..1e36e35a 100644 --- a/subworkflows/nf-neuro/registration/tests/nextflow.config +++ b/subworkflows/nf-neuro/registration/tests/nextflow.config @@ -11,7 +11,6 @@ process { } withName: "REGISTRATION_ANATTODWI" { - ext.masking_strategy = "internal" ext.run_qc = true } From 84f37ce7d55a61523cdde621c129ee5fac25a83c Mon Sep 17 00:00:00 2001 From: arnaudbore Date: Mon, 13 Jul 2026 14:13:45 -0400 Subject: [PATCH 12/14] fix linting and output_template_space --- modules/nf-neuro/registration/synthmorph/meta.yml | 4 ++-- .../nf-neuro/output_template_space/tests/main.nf.test.snap | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/nf-neuro/registration/synthmorph/meta.yml b/modules/nf-neuro/registration/synthmorph/meta.yml index 6fcbd17c..35591f3f 100644 --- a/modules/nf-neuro/registration/synthmorph/meta.yml +++ b/modules/nf-neuro/registration/synthmorph/meta.yml @@ -109,10 +109,10 @@ output: description: | Groovy Map containing sample information e.g. `[ id:'test', single_end:false ]` - - "*_fixed_warped.nii.gz": + - "*_warped_reference.nii.gz": type: file description: Fixed/Reference warped image - pattern: "*_fixed_warped.nii.gz" + pattern: "*_warped_reference.nii.gz" ontologies: - edam: http://edamontology.org/format_4001 # NIFTI format forward_affine: diff --git a/subworkflows/nf-neuro/output_template_space/tests/main.nf.test.snap b/subworkflows/nf-neuro/output_template_space/tests/main.nf.test.snap index a8d4951b..2a89eef0 100644 --- a/subworkflows/nf-neuro/output_template_space/tests/main.nf.test.snap +++ b/subworkflows/nf-neuro/output_template_space/tests/main.nf.test.snap @@ -87,7 +87,7 @@ { "id": "test" }, - "test_warped.nii.gz" + "test_mni_masked_warped.nii.gz" ] ], "ch_registered_labels_files": [ @@ -152,7 +152,7 @@ "nf-test": "0.9.3", "nextflow": "25.10.2" }, - "timestamp": "2026-07-10T22:37:33.271078795" + "timestamp": "2026-07-13T14:12:45.301916755" }, "Template MNI152NLin2009cAsym - local templates": { "content": [ From 78131dc91e8da374377f6f91e006dfcfdc1a59f9 Mon Sep 17 00:00:00 2001 From: arnaudbore Date: Mon, 13 Jul 2026 17:27:35 -0400 Subject: [PATCH 13/14] answer Gab and Claude comments --- modules/nf-neuro/image/applymask/main.nf | 2 +- .../nf-neuro/registration/anattodwi/main.nf | 23 +++++++------ .../nf-neuro/registration/anattodwi/meta.yml | 5 +++ .../anattodwi/tests/main.nf.test.snap | 2 +- modules/nf-neuro/registration/ants/meta.yml | 5 +++ subworkflows/nf-neuro/registration/main.nf | 5 +-- subworkflows/nf-neuro/registration/meta.yml | 32 ++++++++++++++++++- .../registration/tests/main.nf.test.snap | 12 ++----- 8 files changed, 62 insertions(+), 24 deletions(-) diff --git a/modules/nf-neuro/image/applymask/main.nf b/modules/nf-neuro/image/applymask/main.nf index c5d44ba4..aaee32bd 100644 --- a/modules/nf-neuro/image/applymask/main.nf +++ b/modules/nf-neuro/image/applymask/main.nf @@ -18,7 +18,7 @@ process IMAGE_APPLYMASK { def prefix = task.ext.prefix ?: "${meta.id}" def suffix = task.ext.first_suffix ? task.ext.first_suffix + "_masked" : "masked" def nthreads_mrtrix = task.ext.single_thread ? "-nthreads 0" : "-nthreads ${task.cpus}" - def data_type = task.ext.data_type ? "-datatype ${task.ext.data_type}" : " -datatype float32" + def data_type = task.ext.data_type ? "-datatype ${task.ext.data_type}" : "-datatype float32" """ export OMP_NUM_THREADS=${task.ext.single_thread ? 1 : task.cpus} diff --git a/modules/nf-neuro/registration/anattodwi/main.nf b/modules/nf-neuro/registration/anattodwi/main.nf index fffe312d..dd919abd 100644 --- a/modules/nf-neuro/registration/anattodwi/main.nf +++ b/modules/nf-neuro/registration/anattodwi/main.nf @@ -26,6 +26,7 @@ process REGISTRATION_ANATTODWI { script: def prefix = task.ext.prefix ?: "${meta.id}" + def suffix = task.ext.suffix ? "${task.ext.suffix}_warped" : "warped" def run_qc = task.ext.run_qc as Boolean || false def args = task.ext.args ?: '' @@ -55,10 +56,12 @@ process REGISTRATION_ANATTODWI { --smoothing-sigmas 3x2x1\ $args - moving_id=\$(basename $moving_anat .nii.gz) + moving_base=\$(basename $moving_anat .nii.gz) + ext=\${moving_base#*.} + moving_id=\${moving_base%.\${ext}} moving_id=\${moving_id#${prefix}_*} - mv warped.nii.gz ${prefix}_\${moving_id}_warped.nii.gz + mv warped.nii.gz ${prefix}_\${moving_id}_${suffix}.nii.gz mv InverseWarped.nii.gz ${prefix}_warped_reference.nii.gz mv forward0GenericAffine.mat ${prefix}_forward1_affine.mat mv forward1Warp.nii.gz ${prefix}_forward0_warp.nii.gz @@ -70,7 +73,7 @@ process REGISTRATION_ANATTODWI { ### ** QC ** ### if $run_qc; then # Extract dimensions. - dim=\$(mrinfo ${prefix}_\${moving_id}_warped.nii.gz -size) + dim=\$(mrinfo ${prefix}_\${moving_id}_${suffix}.nii.gz -size) read sagittal_dim coronal_dim axial_dim <<< "\${dim}" # Get middle slices. @@ -86,7 +89,7 @@ process REGISTRATION_ANATTODWI { fixed_id=\${fixed_id#${prefix}_*} # Iterate over images. - for image in \${moving_id}_warped \${fixed_id}; do + for image in \${moving_id}_${suffix} \${fixed_id}; do mrconvert *\${image}.nii.gz \${image}_viz.nii.gz -stride -1,2,3 scil_viz_volume_screenshot \${image}_viz.nii.gz \${image}_coronal.png \ --slices \$coronal_mid --axis coronal \$viz_params @@ -112,11 +115,11 @@ process REGISTRATION_ANATTODWI { # Create GIF. convert -delay 10 -loop 0 -morph 10 \ - \${moving_id}_warped_mosaic.png \${fixed_id}_mosaic.png \${moving_id}_warped_mosaic.png \ + \${moving_id}_${suffix}_mosaic.png \${fixed_id}_mosaic.png \${moving_id}_${suffix}_mosaic.png \ ${prefix}_registration_anattodwi_mqc.gif # Clean up. - rm \${moving_id}_warped_mosaic.png \${fixed_id}_mosaic.png + rm \${moving_id}_${suffix}_mosaic.png \${fixed_id}_mosaic.png fi cat <<-END_VERSIONS > versions.yml @@ -131,7 +134,7 @@ process REGISTRATION_ANATTODWI { stub: def prefix = task.ext.prefix ?: "${meta.id}" def run_qc = task.ext.run_qc as Boolean || false - + def suffix = task.ext.suffix ? "${task.ext.suffix}_warped" : "warped" """ antsRegistration -h antsApplyTransforms -h @@ -139,10 +142,12 @@ process REGISTRATION_ANATTODWI { scil_viz_volume_screenshot -h convert -help . - moving_id=\$(basename $moving_anat .nii.gz) + moving_base=\$(basename $moving_anat .nii.gz) + ext=\${moving_base#*.} + moving_id=\${moving_base%.\${ext}} moving_id=\${moving_id#${prefix}_*} - touch ${prefix}_\${moving_id}_warped.nii.gz + touch ${prefix}_\${moving_id}_${suffix}.nii.gz touch ${prefix}_warped_reference.nii.gz touch ${prefix}_forward1_affine.mat touch ${prefix}_forward0_warp.nii.gz diff --git a/modules/nf-neuro/registration/anattodwi/meta.yml b/modules/nf-neuro/registration/anattodwi/meta.yml index ddeec99f..92afa732 100644 --- a/modules/nf-neuro/registration/anattodwi/meta.yml +++ b/modules/nf-neuro/registration/anattodwi/meta.yml @@ -45,6 +45,11 @@ args: default: 1234 - masking_strategy: type: string + choices: + - none + - apriori + - internal + - both description: Masking strategy to use for registration. Options are 'none', 'apriori', 'internal' or 'both'. default: "none" input: diff --git a/modules/nf-neuro/registration/anattodwi/tests/main.nf.test.snap b/modules/nf-neuro/registration/anattodwi/tests/main.nf.test.snap index 2a6464e3..0c7183cd 100644 --- a/modules/nf-neuro/registration/anattodwi/tests/main.nf.test.snap +++ b/modules/nf-neuro/registration/anattodwi/tests/main.nf.test.snap @@ -236,7 +236,7 @@ "nf-test": "0.9.3", "nextflow": "25.10.2" }, - "timestamp": "2026-07-13T10:01:47.364973792" + "timestamp": "2026-07-13T17:10:55.4552583" }, "registration - anattodwi -stub-run": { "content": [ diff --git a/modules/nf-neuro/registration/ants/meta.yml b/modules/nf-neuro/registration/ants/meta.yml index e2b010f8..ba9e6363 100644 --- a/modules/nf-neuro/registration/ants/meta.yml +++ b/modules/nf-neuro/registration/ants/meta.yml @@ -133,6 +133,11 @@ args: default: false - masking_strategy: type: string + choices: + - none + - apriori + - internal + - both description: Masking strategy to use for registration. Options are 'none', 'apriori', 'internal' or 'both'. default: "none" input: diff --git a/subworkflows/nf-neuro/registration/main.nf b/subworkflows/nf-neuro/registration/main.nf index 75f70d68..64056e9e 100644 --- a/subworkflows/nf-neuro/registration/main.nf +++ b/subworkflows/nf-neuro/registration/main.nf @@ -56,6 +56,7 @@ workflow REGISTRATION { } } else { + ch_fixed_metric_ready = ch_metric ch_fixed_image_ready = ch_fixed_image } if ( ch_moving_mask ) { @@ -270,12 +271,12 @@ workflow REGISTRATION { out_image_warped_masked = out_image_warped .join(ch_moving_mask) - .filter{ _meta, _warped, mask -> mask } + .filter{ _meta, _warped, mask -> options.masking_strategy in ["both", "apriori"] && mask } .map{ meta, warped, _mask -> [meta, warped] } out_ref_warped_masked = out_ref_warped .join(ch_fixed_mask) - .filter{ _meta, _warped, mask -> mask } + .filter{ _meta, _warped, mask -> options.masking_strategy in ["both", "apriori"] && mask } .map{ meta, warped, _mask -> [meta, warped] } // Register original moving image diff --git a/subworkflows/nf-neuro/registration/meta.yml b/subworkflows/nf-neuro/registration/meta.yml index 26e49c36..5addc162 100644 --- a/subworkflows/nf-neuro/registration/meta.yml +++ b/subworkflows/nf-neuro/registration/meta.yml @@ -139,6 +139,11 @@ input: entries: masking_strategy: type: string + choices: + - none + - apriori + - internal + - both description: Masking strategy to use for registration. Options are 'none', 'apriori', 'internal' or 'both'. default: "none" run_easyreg: @@ -165,7 +170,7 @@ output: - reference_warped: type: file description: | - ONLY PROVIDED BY REGISTRATION_EASYREG. Channel containing the reference image warped in moving space. + Channel containing the reference image warped in moving space. structure: - meta: type: map @@ -175,6 +180,31 @@ output: description: Warped reference image in moving space. pattern: "*.{nii,nii.gz}" mandatory: false + - image_warped_masked: + type: file + description: | + Channel containing images warped in fixed space. + structure: + - meta: + type: map + description: Metadata map. + - image: + type: file + description: Warped image masked in fixed space. + pattern: "*.{nii,nii.gz}" + - reference_warped_masked: + type: file + description: | + Channel containing the reference image warped in moving space. + structure: + - meta: + type: map + description: Metadata map. + - image: + type: file + description: Warped reference image masked in moving space. + pattern: "*.{nii,nii.gz}" + mandatory: false - forward_affine: type: file description: | diff --git a/subworkflows/nf-neuro/registration/tests/main.nf.test.snap b/subworkflows/nf-neuro/registration/tests/main.nf.test.snap index 6a052590..29f0e724 100644 --- a/subworkflows/nf-neuro/registration/tests/main.nf.test.snap +++ b/subworkflows/nf-neuro/registration/tests/main.nf.test.snap @@ -271,14 +271,6 @@ "test_T1w_warped.nii.gz" ] ], - "reference_warped_masked": [ - [ - { - "id": "test" - }, - "test_warped_reference.nii.gz" - ] - ], "versions": [ "versions.yml:md5,3764dd2f067db355da3536c1b0c94619", "versions.yml:md5,a338911f46f2c623d87eab600c524ffb" @@ -289,7 +281,7 @@ "nf-test": "0.9.3", "nextflow": "25.10.2" }, - "timestamp": "2026-07-13T11:21:06.660214686" + "timestamp": "2026-07-13T16:59:05.118623545" }, "registration - ANTs - Anat to DWI": { "content": [ @@ -395,6 +387,6 @@ "nf-test": "0.9.3", "nextflow": "25.10.2" }, - "timestamp": "2026-07-13T11:20:24.201960901" + "timestamp": "2026-07-13T17:02:40.341565686" } } \ No newline at end of file From d6e29abde86d41c122a2874b217c42fd40fe2927 Mon Sep 17 00:00:00 2001 From: arnaudbore Date: Thu, 23 Jul 2026 16:10:02 -0400 Subject: [PATCH 14/14] fix, answer comments, add tests --- subworkflows/nf-neuro/registration/main.nf | 19 +- .../nf-neuro/registration/tests/main.nf.test | 143 ++++++++++++- .../registration/tests/main.nf.test.snap | 200 +++++++++++++++++- .../tests/nextflow_ANTS_both.config | 14 ++ .../tests/nextflow_ANTS_internal.config | 14 ++ 5 files changed, 373 insertions(+), 17 deletions(-) create mode 100644 subworkflows/nf-neuro/registration/tests/nextflow_ANTS_both.config create mode 100644 subworkflows/nf-neuro/registration/tests/nextflow_ANTS_internal.config diff --git a/subworkflows/nf-neuro/registration/main.nf b/subworkflows/nf-neuro/registration/main.nf index 64056e9e..0cecdb4e 100644 --- a/subworkflows/nf-neuro/registration/main.nf +++ b/subworkflows/nf-neuro/registration/main.nf @@ -38,6 +38,10 @@ workflow REGISTRATION { UTILS_OPTIONS("${moduleDir}/meta.yml", options, true) options = UTILS_OPTIONS.out.options.value + // Initialize channels + ch_fixed_image_ready = ch_fixed_image + ch_moving_image_ready = ch_moving_image + ch_fixed_metric_ready = ch_metric if ( ( options.masking_strategy == "apriori" || options.masking_strategy == "both" ) && ( ch_fixed_mask || ch_moving_mask || ch_metric ) ) { if ( ch_fixed_mask ) { MASK_FIXED_IMAGE ( ch_fixed_image.join(ch_fixed_mask) ) @@ -51,13 +55,6 @@ workflow REGISTRATION { .map({ meta, orig, masked -> [meta, masked?: orig] }) ch_versions = ch_versions.mix(MASK_FIXED_METRIC.out.versions.first()) } - else { - ch_fixed_metric_ready = ch_metric - } - } - else { - ch_fixed_metric_ready = ch_metric - ch_fixed_image_ready = ch_fixed_image } if ( ch_moving_mask ) { MASK_MOVING_IMAGE ( ch_moving_image.join(ch_moving_mask) ) @@ -65,14 +62,6 @@ workflow REGISTRATION { .map({ meta, orig, masked -> [meta, masked?: orig] }) ch_versions = ch_versions.mix(MASK_MOVING_IMAGE.out.versions.first()) } - else { - ch_moving_image_ready = ch_moving_image - } - } - else { - ch_fixed_image_ready = ch_fixed_image - ch_moving_image_ready = ch_moving_image - ch_fixed_metric_ready = ch_metric } if ( ( options.masking_strategy == "both" || options.masking_strategy == "internal" ) && ( options.run_easyreg || options.run_synthmorph ) ) { diff --git a/subworkflows/nf-neuro/registration/tests/main.nf.test b/subworkflows/nf-neuro/registration/tests/main.nf.test index eb675d6d..af650bbd 100644 --- a/subworkflows/nf-neuro/registration/tests/main.nf.test +++ b/subworkflows/nf-neuro/registration/tests/main.nf.test @@ -3,7 +3,6 @@ nextflow_workflow { name "Test Subworkflow REGISTRATION" script "../main.nf" workflow "REGISTRATION" - config "./nextflow.config" tag "subworkflows" tag "subworkflows_nfneuro" @@ -38,6 +37,7 @@ nextflow_workflow { } test("registration - ANTs - Anat to DWI") { + config "./nextflow.config" when { workflow { """ @@ -102,6 +102,7 @@ nextflow_workflow { } test("registration - ANTs - SyNQuick") { + config "./nextflow.config" when { workflow { """ @@ -161,7 +162,146 @@ nextflow_workflow { } } + test("registration - ANTs - SyNQuick - internal") { + config "./nextflow_ANTS_internal.config" + when { + workflow { + """ + ch_split_test_data = LOAD_DATA.out.test_data_directory + .branch{ + t1w: it.simpleName == "T1w" + moving: it.simpleName == "others" + } + input[0] = ch_split_test_data.t1w.map{ + test_data_directory -> [ + [ id:'test' ], + file("\${test_data_directory}/T1w.nii.gz").copyTo( + "\${test_data_directory}/fixed.nii.gz") + ]} + input[1] = ch_split_test_data.t1w.map{ + test_data_directory -> [ + [ id:'test' ], + file("\${test_data_directory}/T1w.nii.gz").copyTo( + "\${test_data_directory}/moving.nii.gz") + ]} + input[2] = ch_split_test_data.t1w.map{ + test_data_directory -> [ + [ id:'test' ], + file("\${test_data_directory}/T1w_mask.nii.gz").copyTo( + "\${test_data_directory}/fixed_mask.nii.gz") + ]} + input[3] = ch_split_test_data.t1w.map{ + test_data_directory -> [ + [ id:'test' ], + file("\${test_data_directory}/T1w_mask.nii.gz").copyTo( + "\${test_data_directory}/moving_mask.nii.gz") + ]} + input[4] = channel.empty() + input[5] = channel.empty() + input[6] = channel.empty() + input[7] = channel.empty() + input[8] = [:] + """ + } + } + then { + assertAll( + { assert workflow.success}, + { assert snapshot( + workflow.out + .findAll{ channel -> !channel.key.isInteger() && channel.value } + .collectEntries{ channel -> + [(channel.key): ["versions"].contains(channel.key) + ? channel.value + : channel.value.collect{ subject -> + [ subject[0] ] + subject[1..-1].flatten().collect{ entry -> entry ? file(entry).name : "" } + } ] + } + ).match() }, + { assert workflow.out + .findAll{ channel -> !channel.key.isInteger() } + .every{ channel -> ["ref_warped", + "segmentation", + "ref_segmentation"].contains(channel.key) + ? channel.value.size() == 0 + : channel.value.every{ subject -> subject instanceof ArrayList + ? subject.every() + : subject } } } + ) + } + } + + test("registration - ANTs - SyNQuick - both") { + config "./nextflow_ANTS_both.config" + when { + workflow { + """ + ch_split_test_data = LOAD_DATA.out.test_data_directory + .branch{ + t1w: it.simpleName == "T1w" + moving: it.simpleName == "others" + } + input[0] = ch_split_test_data.t1w.map{ + test_data_directory -> [ + [ id:'test' ], + file("\${test_data_directory}/T1w.nii.gz").copyTo( + "\${test_data_directory}/fixed.nii.gz") + ]} + input[1] = ch_split_test_data.t1w.map{ + test_data_directory -> [ + [ id:'test' ], + file("\${test_data_directory}/T1w.nii.gz").copyTo( + "\${test_data_directory}/moving.nii.gz") + ]} + input[2] = ch_split_test_data.t1w.map{ + test_data_directory -> [ + [ id:'test' ], + file("\${test_data_directory}/T1w_mask.nii.gz").copyTo( + "\${test_data_directory}/fixed_mask.nii.gz") + ]} + input[3] = ch_split_test_data.t1w.map{ + test_data_directory -> [ + [ id:'test' ], + file("\${test_data_directory}/T1w_mask.nii.gz").copyTo( + "\${test_data_directory}/moving_mask.nii.gz") + ]} + input[4] = channel.empty() + input[5] = channel.empty() + input[6] = channel.empty() + input[7] = channel.empty() + input[8] = [:] + """ + } + } + then { + assertAll( + { assert workflow.success}, + { assert snapshot( + workflow.out + .findAll{ channel -> !channel.key.isInteger() && channel.value } + .collectEntries{ channel -> + [(channel.key): ["versions"].contains(channel.key) + ? channel.value + : channel.value.collect{ subject -> + [ subject[0] ] + subject[1..-1].flatten().collect{ entry -> entry ? file(entry).name : "" } + } ] + } + ).match() }, + { assert workflow.out + .findAll{ channel -> !channel.key.isInteger() } + .every{ channel -> ["ref_warped", + "segmentation", + "ref_segmentation"].contains(channel.key) + ? channel.value.size() == 0 + : channel.value.every{ subject -> subject instanceof ArrayList + ? subject.every() + : subject } } } + ) + } + } + test("registration - easyreg") { + config "./nextflow.config" when { workflow { """ @@ -211,6 +351,7 @@ nextflow_workflow { } test("registration - Synthmorph") { + config "./nextflow.config" when { workflow { """ diff --git a/subworkflows/nf-neuro/registration/tests/main.nf.test.snap b/subworkflows/nf-neuro/registration/tests/main.nf.test.snap index 29f0e724..5323f94b 100644 --- a/subworkflows/nf-neuro/registration/tests/main.nf.test.snap +++ b/subworkflows/nf-neuro/registration/tests/main.nf.test.snap @@ -80,7 +80,7 @@ "nf-test": "0.9.3", "nextflow": "25.10.2" }, - "timestamp": "2026-07-13T10:29:59.551538877" + "timestamp": "2026-07-23T10:57:52.364469596" }, "registration - easyreg": { "content": [ @@ -283,6 +283,105 @@ }, "timestamp": "2026-07-13T16:59:05.118623545" }, + "registration - ANTs - SyNQuick - both": { + "content": [ + { + "backward_affine": [ + [ + { + "id": "test" + }, + "test_backward0_affine.mat" + ] + ], + "backward_image_transform": [ + [ + { + "id": "test" + }, + "test_backward0_affine.mat", + "test_backward1_warp.nii.gz" + ] + ], + "backward_tractogram_transform": [ + [ + { + "id": "test" + }, + "test_forward0_warp.nii.gz", + "test_forward1_affine.mat" + ] + ], + "backward_warp": [ + [ + { + "id": "test" + }, + "test_backward1_warp.nii.gz" + ] + ], + "forward_affine": [ + [ + { + "id": "test" + }, + "test_forward1_affine.mat" + ] + ], + "forward_image_transform": [ + [ + { + "id": "test" + }, + "test_forward0_warp.nii.gz", + "test_forward1_affine.mat" + ] + ], + "forward_tractogram_transform": [ + [ + { + "id": "test" + }, + "test_backward0_affine.mat", + "test_backward1_warp.nii.gz" + ] + ], + "forward_warp": [ + [ + { + "id": "test" + }, + "test_forward0_warp.nii.gz" + ] + ], + "image_warped": [ + [ + { + "id": "test" + }, + "test_moving_warped.nii.gz" + ] + ], + "reference_warped": [ + [ + { + "id": "test" + }, + "test_fixed_warped.nii.gz" + ] + ], + "versions": [ + "versions.yml:md5,03b958f14a890b541bb76c73f7a72847", + "versions.yml:md5,3764dd2f067db355da3536c1b0c94619" + ] + } + ], + "meta": { + "nf-test": "0.9.3", + "nextflow": "25.10.2" + }, + "timestamp": "2026-07-23T14:59:19.70904228" + }, "registration - ANTs - Anat to DWI": { "content": [ { @@ -388,5 +487,104 @@ "nextflow": "25.10.2" }, "timestamp": "2026-07-13T17:02:40.341565686" + }, + "registration - ANTs - SyNQuick - internal": { + "content": [ + { + "backward_affine": [ + [ + { + "id": "test" + }, + "test_backward0_affine.mat" + ] + ], + "backward_image_transform": [ + [ + { + "id": "test" + }, + "test_backward0_affine.mat", + "test_backward1_warp.nii.gz" + ] + ], + "backward_tractogram_transform": [ + [ + { + "id": "test" + }, + "test_forward0_warp.nii.gz", + "test_forward1_affine.mat" + ] + ], + "backward_warp": [ + [ + { + "id": "test" + }, + "test_backward1_warp.nii.gz" + ] + ], + "forward_affine": [ + [ + { + "id": "test" + }, + "test_forward1_affine.mat" + ] + ], + "forward_image_transform": [ + [ + { + "id": "test" + }, + "test_forward0_warp.nii.gz", + "test_forward1_affine.mat" + ] + ], + "forward_tractogram_transform": [ + [ + { + "id": "test" + }, + "test_backward0_affine.mat", + "test_backward1_warp.nii.gz" + ] + ], + "forward_warp": [ + [ + { + "id": "test" + }, + "test_forward0_warp.nii.gz" + ] + ], + "image_warped": [ + [ + { + "id": "test" + }, + "test_moving_warped.nii.gz" + ] + ], + "reference_warped": [ + [ + { + "id": "test" + }, + "test_fixed_warped.nii.gz" + ] + ], + "versions": [ + "versions.yml:md5,03b958f14a890b541bb76c73f7a72847", + "versions.yml:md5,3764dd2f067db355da3536c1b0c94619" + ] + } + ], + "meta": { + "nf-test": "0.9.3", + "nextflow": "25.10.2" + }, + "timestamp": "2026-07-23T14:58:58.17950799" } } \ No newline at end of file diff --git a/subworkflows/nf-neuro/registration/tests/nextflow_ANTS_both.config b/subworkflows/nf-neuro/registration/tests/nextflow_ANTS_both.config new file mode 100644 index 00000000..69483721 --- /dev/null +++ b/subworkflows/nf-neuro/registration/tests/nextflow_ANTS_both.config @@ -0,0 +1,14 @@ +process { + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } + cpus = 1 + + withName: "REGISTRATION_ANTS" { + ext.masking_strategy = "both" + ext.quick = true + ext.repro_mode = true + ext.transform = "a" + ext.initial_transform = "intensities" + ext.run_qc = true + ext.random_seed = 44 + } +} diff --git a/subworkflows/nf-neuro/registration/tests/nextflow_ANTS_internal.config b/subworkflows/nf-neuro/registration/tests/nextflow_ANTS_internal.config new file mode 100644 index 00000000..6463390f --- /dev/null +++ b/subworkflows/nf-neuro/registration/tests/nextflow_ANTS_internal.config @@ -0,0 +1,14 @@ +process { + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } + cpus = 1 + + withName: "REGISTRATION_ANTS" { + ext.masking_strategy = "apriori" + ext.quick = true + ext.repro_mode = true + ext.transform = "a" + ext.initial_transform = "intensities" + ext.run_qc = true + ext.random_seed = 44 + } +}