diff --git a/modules/nf-neuro/registration/synthregistration/main.nf b/modules/nf-neuro/registration/synthregistration/main.nf index 52cabf43..b8b431f1 100644 --- a/modules/nf-neuro/registration/synthregistration/main.nf +++ b/modules/nf-neuro/registration/synthregistration/main.nf @@ -3,7 +3,9 @@ process REGISTRATION_SYNTHREGISTRATION { label 'process_high' container "freesurfer/synthmorph:3" - containerOptions "--entrypoint '' --env PYTHONPATH='/freesurfer/env/lib/python3.11/site-packages'" + containerOptions { + (workflow.containerEngine == 'docker') ? '--entrypoint "" --env PYTHONPATH="/freesurfer/env/lib/python3.11/site-packages"' : "--env PYTHONPATH='/freesurfer/env/lib/python3.11/site-packages'" + } input: tuple val(meta), path(moving), path(fixed) diff --git a/modules/nf-neuro/segmentation/fastseg/main.nf b/modules/nf-neuro/segmentation/fastseg/main.nf index 73ccba00..339ee448 100644 --- a/modules/nf-neuro/segmentation/fastseg/main.nf +++ b/modules/nf-neuro/segmentation/fastseg/main.nf @@ -54,9 +54,6 @@ process SEGMENTATION_FASTSEG { def prefix = task.ext.prefix ?: "${meta.id}" """ - fast -h - scil_volume_math.py -h - touch ${prefix}__mask_wm.nii.gz touch ${prefix}__mask_gm.nii.gz touch ${prefix}__mask_csf.nii.gz @@ -69,5 +66,15 @@ process SEGMENTATION_FASTSEG { scilpy: 2.0.0 fsl: \$(flirt -version 2>&1 | sed -n 's/FLIRT version \\([0-9.]\\+\\)/\\1/p') END_VERSIONS + + function handle_code () { + local code=\$? + ignore=( 1 ) + exit \$([[ " \${ignore[@]} " =~ " \$code " ]] && echo 0 || echo \$code) + } + trap 'handle_code' ERR + + fast -h + scil_volume_math.py -h """ } diff --git a/modules/nf-neuro/segmentation/fastseg/tests/main.nf.test b/modules/nf-neuro/segmentation/fastseg/tests/main.nf.test index 28969a78..c588800a 100644 --- a/modules/nf-neuro/segmentation/fastseg/tests/main.nf.test +++ b/modules/nf-neuro/segmentation/fastseg/tests/main.nf.test @@ -87,4 +87,27 @@ nextflow_process { ) } } + test("segmentation - fastseg - stub-run") { + options "-stub-run" + when { + process { + """ + input[0] = LOAD_DATA.out.test_data_directory.map{ + test_data_directory -> [ + [ id:'test', single_end:false ], // meta map + file("\${test_data_directory}/T1w.nii.gz", checkIfExists: true,), + [] + ] + } + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out.versions).match() } + ) + } + } } diff --git a/modules/nf-neuro/segmentation/fastseg/tests/main.nf.test.snap b/modules/nf-neuro/segmentation/fastseg/tests/main.nf.test.snap index 7778861a..f3ab1eb2 100644 --- a/modules/nf-neuro/segmentation/fastseg/tests/main.nf.test.snap +++ b/modules/nf-neuro/segmentation/fastseg/tests/main.nf.test.snap @@ -34,5 +34,17 @@ "nextflow": "24.04.4" }, "timestamp": "2024-09-04T20:03:24.730234" + }, + "segmentation - fastseg - stub-run": { + "content": [ + [ + "versions.yml:md5,e9c2afb5537207544dc1b54cbdc389a4" + ] + ], + "meta": { + "nf-test": "0.9.0", + "nextflow": "24.10.1" + }, + "timestamp": "2024-12-12T14:01:36.729872" } } \ No newline at end of file diff --git a/modules/nf-neuro/segmentation/fastsurfer/main.nf b/modules/nf-neuro/segmentation/fastsurfer/main.nf index 42eb4919..7a23b408 100644 --- a/modules/nf-neuro/segmentation/fastsurfer/main.nf +++ b/modules/nf-neuro/segmentation/fastsurfer/main.nf @@ -3,24 +3,25 @@ process SEGMENTATION_FASTSURFER { label 'process_single' container "${ 'deepmi/fastsurfer:cpu-v2.2.0' }" - - containerOptions '--entrypoint ""' + containerOptions { + (workflow.containerEngine == 'docker') ? '--entrypoint ""' : '' + } input: tuple val(meta), path(anat), path(fs_license) output: - tuple val(meta), path("*_fastsurfer") , emit: fastsurferdirectory - path "versions.yml" , emit: versions + tuple val(meta), path("*_fastsurfer") , emit: fastsurferdirectory + path "versions.yml" , emit: versions when: task.ext.when == null || task.ext.when script: - def prefix = task.ext.prefix ?: "${meta.id}" - def acq3T = task.ext.acq3T ? "--3T" : "" - def FASTSURFER_HOME = "/fastsurfer" - def SUBJECTS_DIR = "${prefix}_fastsurfer" + def prefix = task.ext.prefix ?: "${meta.id}" + def acq3T = task.ext.acq3T ? "--3T" : "" + def FASTSURFER_HOME = "/fastsurfer" + def SUBJECTS_DIR = "${prefix}_fastsurfer" """ mkdir ${prefix}_fastsurfer/ $FASTSURFER_HOME/run_fastsurfer.sh --allow_root \ @@ -38,14 +39,24 @@ process SEGMENTATION_FASTSURFER { """ stub: - def prefix = task.ext.prefix ?: "${meta.id}" + def prefix = task.ext.prefix ?: "${meta.id}" + def FASTSURFER_HOME = "/fastsurfer" """ - $FASTSURFER_HOME/run_fastsurfer.sh --version + mkdir ${prefix}_fastsurfer/ cat <<-END_VERSIONS > versions.yml "${task.process}": - fastersurfer: 2.2.0+9f37d02 + fastersurfer: \$($FASTSURFER_HOME/run_fastsurfer.sh --version) END_VERSIONS + + function handle_code () { + local code=\$? + ignore=( 1 ) + exit \$([[ " \${ignore[@]} " =~ " \$code " ]] && echo 0 || echo \$code) + } + trap 'handle_code' ERR + + $FASTSURFER_HOME/run_fastsurfer.sh --version """ } diff --git a/modules/nf-neuro/segmentation/fastsurfer/tests/main.nf.test b/modules/nf-neuro/segmentation/fastsurfer/tests/main.nf.test index 9ae88860..f28e3808 100644 --- a/modules/nf-neuro/segmentation/fastsurfer/tests/main.nf.test +++ b/modules/nf-neuro/segmentation/fastsurfer/tests/main.nf.test @@ -47,4 +47,27 @@ nextflow_process { ) } } + + test("segmentation - fastsurfer - stub-run") { + options "-stub-run" + when { + process { + """ + input[0] = LOAD_DATA.out.test_data_directory.map{ + test_data_directory -> [ + [ id:'test' ], + file("\${test_data_directory}/anat_image.nii.gz"), + file("\${test_data_directory}/license.txt") + ] + } + """ + } + } + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out.versions).match() } + ) + } + } } diff --git a/modules/nf-neuro/segmentation/fastsurfer/tests/main.nf.test.snap b/modules/nf-neuro/segmentation/fastsurfer/tests/main.nf.test.snap index af6bb9ec..0fc2160c 100644 --- a/modules/nf-neuro/segmentation/fastsurfer/tests/main.nf.test.snap +++ b/modules/nf-neuro/segmentation/fastsurfer/tests/main.nf.test.snap @@ -1,4 +1,16 @@ { + "segmentation - fastsurfer - stub-run": { + "content": [ + [ + "versions.yml:md5,b263ce2ef1818492be3805ba8e49b50f" + ] + ], + "meta": { + "nf-test": "0.9.0", + "nextflow": "24.10.1" + }, + "timestamp": "2024-12-12T13:38:50.551338" + }, "segmentation - fastsurfer": { "content": [ "test_fastsurfer", diff --git a/modules/nf-neuro/segmentation/fsreconall/main.nf b/modules/nf-neuro/segmentation/fsreconall/main.nf index 0707d21d..0f46e520 100644 --- a/modules/nf-neuro/segmentation/fsreconall/main.nf +++ b/modules/nf-neuro/segmentation/fsreconall/main.nf @@ -59,13 +59,20 @@ process SEGMENTATION_FSRECONALL { stub: def prefix = task.ext.prefix ?: "${meta.id}" """ - recon-all --help - mkdir ${prefix}__recon_all cat <<-END_VERSIONS > versions.yml "${task.process}": freesurfer: \$(mri_convert -version | grep "freesurfer" | sed -E 's/.* ([0-9]+\\.[0-9]+\\.[0-9]+).*/\\1/') END_VERSIONS + + function handle_code () { + local code=\$? + ignore=( 1 ) + exit \$([[ " \${ignore[@]} " =~ " \$code " ]] && echo 0 || echo \$code) + } + trap 'handle_code' ERR + + recon-all --help """ } diff --git a/modules/nf-neuro/segmentation/fsreconall/tests/main.nf.test b/modules/nf-neuro/segmentation/fsreconall/tests/main.nf.test index dbd4db6d..7d1b7935 100644 --- a/modules/nf-neuro/segmentation/fsreconall/tests/main.nf.test +++ b/modules/nf-neuro/segmentation/fsreconall/tests/main.nf.test @@ -80,4 +80,30 @@ nextflow_process { } + test("segmentation - fsreconall - stub-run") { + options "-stub-run" + when { + config "./nextflow_debug.config" + + process { + """ + input[0] = LOAD_DATA.out.test_data_directory.map{ + test_data_directory -> [ + [ id:'test', single_end:false ], // meta map + file("\${test_data_directory}/anat_image.nii.gz"), + file("\${test_data_directory}/license.txt") + ]} + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out.versions).match() } + ) + } + + } + } diff --git a/modules/nf-neuro/segmentation/fsreconall/tests/main.nf.test.snap b/modules/nf-neuro/segmentation/fsreconall/tests/main.nf.test.snap index 703c4ba2..4b9f2815 100644 --- a/modules/nf-neuro/segmentation/fsreconall/tests/main.nf.test.snap +++ b/modules/nf-neuro/segmentation/fsreconall/tests/main.nf.test.snap @@ -1,4 +1,16 @@ { + "segmentation - fsreconall - stub-run": { + "content": [ + [ + "versions.yml:md5,2a7185588fa8c664d53c4c08637285e6" + ] + ], + "meta": { + "nf-test": "0.9.0", + "nextflow": "24.10.1" + }, + "timestamp": "2024-12-12T13:55:39.259005" + }, "segmentation - fsreconall": { "content": [ "test__recon_all",