diff --git a/modules/nf-scil/segmentation/synthseg/main.nf b/modules/nf-scil/segmentation/synthseg/main.nf index f74c4365..911f90f9 100644 --- a/modules/nf-scil/segmentation/synthseg/main.nf +++ b/modules/nf-scil/segmentation/synthseg/main.nf @@ -12,9 +12,9 @@ process SEGMENTATION_SYNTHSEG { tuple val(meta), path("*__mask_wm.nii.gz") , emit: wm_mask tuple val(meta), path("*__mask_gm.nii.gz") , emit: gm_mask tuple val(meta), path("*__mask_csf.nii.gz") , emit: csf_mask + tuple val(meta), path("*__resampled_image.nii.gz") , emit: resample, optional: true tuple val(meta), path("*__vol.csv") , emit: vol, optional: true tuple val(meta), path("*__qc.csv") , emit: qc, optional: true - tuple val(meta), path("*__resampled_image.nii.gz") , emit: resample, optional: true path "versions.yml" , emit: versions when: @@ -29,9 +29,9 @@ process SEGMENTATION_SYNTHSEG { def robust = task.ext.robust ? "--robust" : "" def fast = task.ext.fast ? "--fast" : "" def ct = task.ext.ct ? "--ct" : "" + def output_resample = task.ext.output_resample ? "--resample ${prefix}__resampled_image.nii.gz": "" def output_vol = task.ext.output_vol ? "--vol ${prefix}__vol.csv" : "" def output_qc = task.ext.output_qc ? "--qc ${prefix}__qc.csv" : "" - def output_resample = task.ext.output_resample ? "--resample ${prefix}__resampled_image.nii.gz": "" def crop = task.ext.crop ? "--crop " + task.ext.crop: "" """ @@ -41,7 +41,11 @@ process SEGMENTATION_SYNTHSEG { cp $fs_license \$FREESURFER_HOME/license.txt - mri_synthseg --i $image --threads $task.cpus --o t1.nii.gz $gpu $parc $robust $fast $ct $output_vol $output_qc $output_resample $crop + mri_synthseg --i $image --threads $task.cpus --o t1.nii.gz $gpu $parc $robust $fast $ct $output_resample $output_vol $output_qc $crop + + if [${prefix}__resampled_image.nii.gz]; then + mv ${prefix}__resampled_image.nii.gz test_resample.nii.gz + fi # WM Mask mri_binarize --i t1.nii.gz \ @@ -87,6 +91,10 @@ process SEGMENTATION_SYNTHSEG { touch ${prefix}__mask_wm.nii.gz touch ${prefix}__mask_gm.nii.gz touch ${prefix}__mask_csf.nii.gz + touch ${prefix}__resampled_image.nii.gz + touch ${prefix}__vol.csv + touch ${prefix}__qc.csv + cat <<-END_VERSIONS > versions.yml "${task.process}": diff --git a/modules/nf-scil/segmentation/synthseg/tests/main.nf.test b/modules/nf-scil/segmentation/synthseg/tests/main.nf.test index 03fe9c10..714fc81a 100644 --- a/modules/nf-scil/segmentation/synthseg/tests/main.nf.test +++ b/modules/nf-scil/segmentation/synthseg/tests/main.nf.test @@ -44,8 +44,12 @@ nextflow_process { then { assertAll( { assert process.success }, - { assert snapshot(process.out).match() } - + { assert snapshot( + Nifti_md5sum(process.out.wm_mask.get(0).get(1)), + Nifti_md5sum(process.out.gm_mask.get(0).get(1)), + Nifti_md5sum(process.out.csf_mask.get(0).get(1)), + process.out.versions + ).match() } ) } } @@ -70,8 +74,15 @@ nextflow_process { then { assertAll( { assert process.success }, - { assert snapshot(process.out).match() } - + { assert snapshot( + Nifti_md5sum(process.out.wm_mask.get(0).get(1)), + Nifti_md5sum(process.out.gm_mask.get(0).get(1)), + Nifti_md5sum(process.out.csf_mask.get(0).get(1)), + file(process.out.vol.get(0).get(1)), + file(process.out.qc.get(0).get(1)), + // Nifti_md5sum(process.out.resample.get(0).get(1)), + process.out.versions + ).match() } ) } } diff --git a/modules/nf-scil/segmentation/synthseg/tests/main.nf.test.snap b/modules/nf-scil/segmentation/synthseg/tests/main.nf.test.snap index f4973488..3dc3f362 100644 --- a/modules/nf-scil/segmentation/synthseg/tests/main.nf.test.snap +++ b/modules/nf-scil/segmentation/synthseg/tests/main.nf.test.snap @@ -1,204 +1,34 @@ { "segmentation - synthseg - options": { "content": [ - { - "0": [ - [ - { - "id": "test", - "single_end": false - }, - "test__mask_wm.nii.gz:md5,8ca305b46341552159e15e6974274358" - ] - ], - "1": [ - [ - { - "id": "test", - "single_end": false - }, - "test__mask_gm.nii.gz:md5,c8c4f3027132011d98cf4a351230f519" - ] - ], - "2": [ - [ - { - "id": "test", - "single_end": false - }, - "test__mask_csf.nii.gz:md5,1deff8b0b3d9f883b75bcd5c9f52f2c5" - ] - ], - "3": [ - [ - { - "id": "test", - "single_end": false - }, - "test__vol.csv:md5,fe0078439655e81ab5777c73b4bd1edf" - ] - ], - "4": [ - [ - { - "id": "test", - "single_end": false - }, - "test__qc.csv:md5,ede51ac9221945293200793a46c15afa" - ] - ], - "5": [ - - ], - "6": [ - "versions.yml:md5,b65418e9ce2ab1cce590b1f659e18c1d" - ], - "csf_mask": [ - [ - { - "id": "test", - "single_end": false - }, - "test__mask_csf.nii.gz:md5,1deff8b0b3d9f883b75bcd5c9f52f2c5" - ] - ], - "gm_mask": [ - [ - { - "id": "test", - "single_end": false - }, - "test__mask_gm.nii.gz:md5,c8c4f3027132011d98cf4a351230f519" - ] - ], - "qc": [ - [ - { - "id": "test", - "single_end": false - }, - "test__qc.csv:md5,ede51ac9221945293200793a46c15afa" - ] - ], - "resample": [ - - ], - "versions": [ - "versions.yml:md5,b65418e9ce2ab1cce590b1f659e18c1d" - ], - "vol": [ - [ - { - "id": "test", - "single_end": false - }, - "test__vol.csv:md5,fe0078439655e81ab5777c73b4bd1edf" - ] - ], - "wm_mask": [ - [ - { - "id": "test", - "single_end": false - }, - "test__mask_wm.nii.gz:md5,8ca305b46341552159e15e6974274358" - ] - ] - } + "test__mask_wm.nii.gz:md5,42ac2ae7eab32edb16f230211e5e55c5", + "test__mask_gm.nii.gz:md5,7a205f13a6894200f0e1a4ea94447390", + "test__mask_csf.nii.gz:md5,7b6125a133adbaae10e94d95782c6678", + "test__vol.csv:md5,fe0078439655e81ab5777c73b4bd1edf", + "test__qc.csv:md5,ede51ac9221945293200793a46c15afa", + [ + "versions.yml:md5,b65418e9ce2ab1cce590b1f659e18c1d" + ] ], "meta": { "nf-test": "0.9.0-rc1", "nextflow": "24.04.4" }, - "timestamp": "2024-08-07T20:11:56.005332" + "timestamp": "2024-08-16T19:58:49.946322" }, "segmentation - synthseg - basic": { "content": [ - { - "0": [ - [ - { - "id": "test", - "single_end": false - }, - "test__mask_wm.nii.gz:md5,5aa95919bfa5b1dd2f8f7a0ae2667bfb" - ] - ], - "1": [ - [ - { - "id": "test", - "single_end": false - }, - "test__mask_gm.nii.gz:md5,432d6a28a10823c0ca5b2f40d2353e2f" - ] - ], - "2": [ - [ - { - "id": "test", - "single_end": false - }, - "test__mask_csf.nii.gz:md5,1307c8aeae9064d9a5108a01e918ffba" - ] - ], - "3": [ - - ], - "4": [ - - ], - "5": [ - - ], - "6": [ - "versions.yml:md5,b65418e9ce2ab1cce590b1f659e18c1d" - ], - "csf_mask": [ - [ - { - "id": "test", - "single_end": false - }, - "test__mask_csf.nii.gz:md5,1307c8aeae9064d9a5108a01e918ffba" - ] - ], - "gm_mask": [ - [ - { - "id": "test", - "single_end": false - }, - "test__mask_gm.nii.gz:md5,432d6a28a10823c0ca5b2f40d2353e2f" - ] - ], - "qc": [ - - ], - "resample": [ - - ], - "versions": [ - "versions.yml:md5,b65418e9ce2ab1cce590b1f659e18c1d" - ], - "vol": [ - - ], - "wm_mask": [ - [ - { - "id": "test", - "single_end": false - }, - "test__mask_wm.nii.gz:md5,5aa95919bfa5b1dd2f8f7a0ae2667bfb" - ] - ] - } + "test__mask_wm.nii.gz:md5,f35c2cd0f899d5a290083d09bac01670", + "test__mask_gm.nii.gz:md5,ef1aef14d90f78dcae60f3f73066af53", + "test__mask_csf.nii.gz:md5,fa08d8c09176d72b8f9b3667419c3d3e", + [ + "versions.yml:md5,b65418e9ce2ab1cce590b1f659e18c1d" + ] ], "meta": { "nf-test": "0.9.0-rc1", "nextflow": "24.04.4" }, - "timestamp": "2024-08-07T20:11:18.859041" + "timestamp": "2024-08-16T19:58:09.501194" } } \ No newline at end of file diff --git a/modules/nf-scil/segmentation/synthseg/tests/nextflow_options.config b/modules/nf-scil/segmentation/synthseg/tests/nextflow_options.config index 25cec894..19bb7045 100644 --- a/modules/nf-scil/segmentation/synthseg/tests/nextflow_options.config +++ b/modules/nf-scil/segmentation/synthseg/tests/nextflow_options.config @@ -2,8 +2,8 @@ process { publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } ext.robust = true ext.fast = true + ext.output_resample = true ext.output_vol = true ext.output_qc = true - ext.resample = true ext.crop = 64 }