From 4ff186bc4a7d528ce41b5cf9081132fb237c0e1a Mon Sep 17 00:00:00 2001 From: anroy1 Date: Sun, 22 Sep 2024 20:53:42 +0000 Subject: [PATCH 1/9] initial nf-neuro commit (following nf-scil:PR#186) --- .../segmentation/synthseg/environment.yml | 7 + .../nf-neuro/segmentation/synthseg/main.nf | 110 ++++++++++++ .../nf-neuro/segmentation/synthseg/meta.yml | 84 ++++++++++ .../segmentation/synthseg/tests/main.nf.test | 156 ++++++++++++++++++ .../synthseg/tests/nextflow_basic.config | 5 + .../synthseg/tests/nextflow_options.config | 10 ++ .../segmentation/synthseg/tests/tags.yml | 2 + 7 files changed, 374 insertions(+) create mode 100644 modules/nf-neuro/segmentation/synthseg/environment.yml create mode 100644 modules/nf-neuro/segmentation/synthseg/main.nf create mode 100644 modules/nf-neuro/segmentation/synthseg/meta.yml create mode 100644 modules/nf-neuro/segmentation/synthseg/tests/main.nf.test create mode 100644 modules/nf-neuro/segmentation/synthseg/tests/nextflow_basic.config create mode 100644 modules/nf-neuro/segmentation/synthseg/tests/nextflow_options.config create mode 100644 modules/nf-neuro/segmentation/synthseg/tests/tags.yml diff --git a/modules/nf-neuro/segmentation/synthseg/environment.yml b/modules/nf-neuro/segmentation/synthseg/environment.yml new file mode 100644 index 0000000..ed5dd01 --- /dev/null +++ b/modules/nf-neuro/segmentation/synthseg/environment.yml @@ -0,0 +1,7 @@ +--- +name: "segmentation_synthseg" +channels: + - Docker + - Apptainer +dependencies: + - "Freesurfer" diff --git a/modules/nf-neuro/segmentation/synthseg/main.nf b/modules/nf-neuro/segmentation/synthseg/main.nf new file mode 100644 index 0000000..930c287 --- /dev/null +++ b/modules/nf-neuro/segmentation/synthseg/main.nf @@ -0,0 +1,110 @@ +process SEGMENTATION_SYNTHSEG { + tag "$meta.id" + label 'process_single' + label 'process_high' + + container "freesurfer/freesurfer:7.4.1" + + input: + tuple val(meta), path(image), path(lesion) /* optional, input = [] */, path(fs_license) /* optional, input = [] */ + + output: + 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("*__parc.nii.gz") , emit: parc, optional: true + 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 + path "versions.yml" , emit: versions + + when: + task.ext.when == null || task.ext.when + + script: + def args = task.ext.args ?: '' + def prefix = task.ext.prefix ?: "${meta.id}" + + def gpu = task.ext.gpu ? "" : "--cpu" + def parc = task.ext.parc ? "--parc" : "" + 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 crop = task.ext.crop ? "--crop " + task.ext.crop: "" + + """ + export ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS=1 + export OMP_NUM_THREADS=1 + export OPENBLAS_NUM_THREADS=1 + + cp $fs_license \$FREESURFER_HOME/license.txt + + mri_synthseg --i $image --o seg.nii.gz --threads $task.cpus $gpu $robust $fast $ct $output_resample $output_vol $output_qc $crop + + if [[ $task.parc ]]; + then + # Cortical parcellation + mri_synthseg --i $image --o ${prefix}__parc.nii.gz --threads $task.cpus $gpu $parc $robust $fast $crop + mri_convert -i ${prefix}__parc.nii.gz --out_data_type uchar -o ${prefix}__parc.nii.gz + fi + + # WM Mask + mri_binarize --i seg.nii.gz \ + --match 2 7 10 12 13 16 28 41 46 49 51 52 60 \ + --o ${prefix}__mask_wm.nii.gz + + # GM Mask + mri_binarize --i seg.nii.gz \ + --match 3 8 11 17 18 26 42 47 50 52 53 54 58 \ + --o ${prefix}__mask_gm.nii.gz + + # CSF Mask + mri_binarize --i seg.nii.gz \ + --match 4 5 14 15 24 43 44 \ + --o ${prefix}__mask_csf.nii.gz + + if [[ -f "$lesion" ]]; + then + mri_binarize --i ${prefix}__mask_wm.nii.gz --merge $lesion --min 0.5 --o ${prefix}__mask_wm.nii.gz + fi + + mri_convert -i ${prefix}__mask_wm.nii.gz --out_data_type uchar -o ${prefix}__mask_wm.nii.gz + mri_convert -i ${prefix}__mask_gm.nii.gz --out_data_type uchar -o ${prefix}__mask_gm.nii.gz + mri_convert -i ${prefix}__mask_csf.nii.gz --out_data_type uchar -o ${prefix}__mask_csf.nii.gz + mri_convert -i ${prefix}__parc.nii.gz --out_data_type uchar ${prefix}__parc.nii.gz + + rm \$FREESURFER_HOME/license.txt + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + Freesurfer: 7.4.1 + END_VERSIONS + """ + + stub: + def args = task.ext.args ?: '' + def prefix = task.ext.prefix ?: "${meta.id}" + + """ + mri_synthseg -h + mri_binarize -h + mri_convert -h + + touch ${prefix}__mask_wm.nii.gz + touch ${prefix}__mask_gm.nii.gz + touch ${prefix}__mask_csf.nii.gz + touch ${prefix}__parc.nii.gz + touch ${prefix}__resampled_image.nii.gz + touch ${prefix}__vol.csv + touch ${prefix}__qc.csv + + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + Freesurfer: 7.4.1 + END_VERSIONS + """ +} diff --git a/modules/nf-neuro/segmentation/synthseg/meta.yml b/modules/nf-neuro/segmentation/synthseg/meta.yml new file mode 100644 index 0000000..9847135 --- /dev/null +++ b/modules/nf-neuro/segmentation/synthseg/meta.yml @@ -0,0 +1,84 @@ +name: "segmentation_synthseg" +description: Perform Brain Tissues Segmentation using Freesurfer synthseg on a T1 image. Optionally, a binary mask of lesion can be add to correct the white matter mask. +keywords: + - Segmentation + - Freesurfer + - Tissues +tools: + - "Freesurfer": + description: "An open source neuroimaging toolkit for processing, analyzing, and visualizing human brain MR images." + homepage: "https://surfer.nmr.mgh.harvard.edu/" + +input: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'sample1', single_end:false ]` + + - image: + type: file + description: Nifti T1 volume to segment into tissue maps. + pattern: "*.{nii,nii.gz}" + + - lesion: + type: file + description: Nifti lesion volume to correct the white matter with a lesion mask. The lesion mask must be a binary mask. + pattern: "*.{nii,nii.gz}" + + - fs_license: + type: file + description: The path to your FreeSurfer license. To get one, go to https://surfer.nmr.mgh.harvard.edu/registration.html. Optional. If you have already set your license as prescribed by Freesurfer (copied to a .license file in your $FREESURFER_HOME), this is not required. + pattern: "*.txt" + +output: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'sample1', single_end:false ]` + + - wm_mask: + type: file + description: Nifti WM mask volume. + pattern: "*.{nii,nii.gz}" + + - gm_mask: + type: file + description: Nifti GM mask volume. + pattern: "*.{nii,nii.gz}" + + - csf_mask: + type: file + description: Nifti CSF mask volume. + pattern: "*.{nii,nii.gz}" + + - parc: + type: file + description: (optional) Nifti cortical parcellation volume. + pattern: "*.{nii,nii.gz}" + + - vol: + type: file + description: (optional) Output CSV file with volumes for all structures and subjects. + pattern: "*.csv" + + - qc: + type: file + description: (optional) Output CSV file with qc scores for all subjects. + pattern: "*.csv" + + - resample: + type: file + description: (optional) in order to return segmentations at 1mm resolution, the input images are internally resampled (except if they already are at 1mm). Use this optional flag to save the resampled images. This must be the same type as --i. + pattern: "*.{nii,nii.gz}" + + - versions: + type: file + description: File containing software versions + pattern: "versions.yml" + +authors: + - "@anroy1" +maintainers: + - "@anroy1" diff --git a/modules/nf-neuro/segmentation/synthseg/tests/main.nf.test b/modules/nf-neuro/segmentation/synthseg/tests/main.nf.test new file mode 100644 index 0000000..235597a --- /dev/null +++ b/modules/nf-neuro/segmentation/synthseg/tests/main.nf.test @@ -0,0 +1,156 @@ +nextflow_process { + + name "Test Process SEGMENTATION_SYNTHSEG" + script "../main.nf" + process "SEGMENTATION_SYNTHSEG" + + tag "modules" + tag "modules_nfcore" + tag "segmentation" + tag "segmentation/synthseg" + + tag "subworkflows" + tag "subworkflows/load_test_data" + + setup { + run("LOAD_TEST_DATA", alias: "LOAD_DATA") { + script "../../../../../subworkflows/nf-neuro/load_test_data/main.nf" + process { + """ + input[0] = Channel.from( [ "heavy.zip", "freesurfer.zip" ] ) + input[1] = "test.load-test-data" + """ + } + } + } + + test("segmentation - synthseg - basic") { + config "./nextflow_basic.config" + when { + process { + """ + ch_split_test_data = LOAD_DATA.out.test_data_directory + .branch{ + heavy: it.simpleName == "heavy" + freesurfer: it.simpleName == "freesurfer" + } + ch_anat = ch_split_test_data.heavy.map{ + test_data_directory -> [ + [ id:'test' ], + file("\${test_data_directory}/anat/anat_image.nii.gz"), + [] + ] + } + ch_license = ch_split_test_data.freesurfer.map{ + test_data_directory -> [ + [ id:'test' ], + file("\${test_data_directory}/license.txt") + ] + } + input[0] = ch_anat + .join(ch_license) + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot( + niftiMD5SUM(process.out.wm_mask.get(0).get(1)), + niftiMD5SUM(process.out.gm_mask.get(0).get(1)), + niftiMD5SUM(process.out.csf_mask.get(0).get(1)), + process.out.versions + ).match() } + ) + } + } + + test("segmentation - synthseg - options") { + config "./nextflow_options.config" + when { + process { + """ + ch_split_test_data = LOAD_DATA.out.test_data_directory + .branch{ + heavy: it.simpleName == "heavy" + freesurfer: it.simpleName == "freesurfer" + } + ch_anat = ch_split_test_data.heavy.map{ + test_data_directory -> [ + [ id:'test' ], + file("\${test_data_directory}/anat/anat_image.nii.gz"), + [] + ] + } + ch_license = ch_split_test_data.freesurfer.map{ + test_data_directory -> [ + [ id:'test' ], + file("\${test_data_directory}/license.txt") + ] + } + input[0] = ch_anat + .join(ch_license) + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot( + niftiMD5SUM(process.out.wm_mask.get(0).get(1)), + niftiMD5SUM(process.out.gm_mask.get(0).get(1)), + niftiMD5SUM(process.out.csf_mask.get(0).get(1)), + niftiMD5SUM(process.out.parc.get(0).get(1)), + process.out.resample, + process.out.vol, + process.out.qc, + process.out.versions + ).match() } + ) + } + } + + test("segmentation - synthseg - lesion") { + config "./nextflow_basic.config" + when { + process { + """ + ch_split_test_data = LOAD_DATA.out.test_data_directory + .branch{ + heavy: it.simpleName == "heavy" + freesurfer: it.simpleName == "freesurfer" + } + ch_anat = ch_split_test_data.heavy.map{ + test_data_directory -> [ + [ id:'test' ], + file("\${test_data_directory}/anat/anat_image.nii.gz"), + file("\${test_data_directory}/anat/anat_mask.nii.gz") + ] + } + ch_license = ch_split_test_data.freesurfer.map{ + test_data_directory -> [ + [ id:'test' ], + file("\${test_data_directory}/license.txt") + ] + } + input[0] = ch_anat + .join(ch_license) + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot( + niftiMD5SUM(process.out.wm_mask.get(0).get(1)), + niftiMD5SUM(process.out.gm_mask.get(0).get(1)), + niftiMD5SUM(process.out.csf_mask.get(0).get(1)), + process.out.versions + ).match() } + ) + } + } +} diff --git a/modules/nf-neuro/segmentation/synthseg/tests/nextflow_basic.config b/modules/nf-neuro/segmentation/synthseg/tests/nextflow_basic.config new file mode 100644 index 0000000..b520af9 --- /dev/null +++ b/modules/nf-neuro/segmentation/synthseg/tests/nextflow_basic.config @@ -0,0 +1,5 @@ +process { + memory = "8G" + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } + ext.fast = true +} diff --git a/modules/nf-neuro/segmentation/synthseg/tests/nextflow_options.config b/modules/nf-neuro/segmentation/synthseg/tests/nextflow_options.config new file mode 100644 index 0000000..e4962ee --- /dev/null +++ b/modules/nf-neuro/segmentation/synthseg/tests/nextflow_options.config @@ -0,0 +1,10 @@ +process { + memory = "8G" + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } + ext.robust = true + ext.output_resample = true + ext.output_vol = true + ext.output_qc = true + ext.crop = 150 + ext.parc = true +} diff --git a/modules/nf-neuro/segmentation/synthseg/tests/tags.yml b/modules/nf-neuro/segmentation/synthseg/tests/tags.yml new file mode 100644 index 0000000..d6461c7 --- /dev/null +++ b/modules/nf-neuro/segmentation/synthseg/tests/tags.yml @@ -0,0 +1,2 @@ +segmentation/synthseg: + - "modules/nf-neuro/segmentation/synthseg/**" From 9984eb32dda72d58e51a8da935d943b0d172bd28 Mon Sep 17 00:00:00 2001 From: anroy1 Date: Tue, 24 Sep 2024 16:47:07 +0000 Subject: [PATCH 2/9] Run tests --- .../synthseg/tests/main.nf.test.snap | 67 +++++++++++++++++++ .../synthseg/tests/nextflow_basic.config | 2 +- 2 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 modules/nf-neuro/segmentation/synthseg/tests/main.nf.test.snap diff --git a/modules/nf-neuro/segmentation/synthseg/tests/main.nf.test.snap b/modules/nf-neuro/segmentation/synthseg/tests/main.nf.test.snap new file mode 100644 index 0000000..a60de29 --- /dev/null +++ b/modules/nf-neuro/segmentation/synthseg/tests/main.nf.test.snap @@ -0,0 +1,67 @@ +{ + "segmentation - synthseg - options": { + "content": [ + "test__mask_wm.nii.gz:md5:header,a0430ca63ccc3bb2b925694cb7568388,data,95946cf22f6adf539b65c72b49eb3b32", + "test__mask_gm.nii.gz:md5:header,a0430ca63ccc3bb2b925694cb7568388,data,a54f8c03a17a16d9271534c387434720", + "test__mask_csf.nii.gz:md5:header,a0430ca63ccc3bb2b925694cb7568388,data,3895c471bc8b06446a8adbba9fe235f7", + "test__parc.nii.gz:md5:header,a0430ca63ccc3bb2b925694cb7568388,data,cb9a481316ae64dceb229879bd0c6619", + [ + + ], + [ + [ + { + "id": "test" + }, + "test__vol.csv:md5,c5c29a038e4f43abcce1845bc429952c" + ] + ], + [ + [ + { + "id": "test" + }, + "test__qc.csv:md5,333de3d7b60916596f0460c808b598f5" + ] + ], + [ + "versions.yml:md5,b65418e9ce2ab1cce590b1f659e18c1d" + ] + ], + "meta": { + "nf-test": "0.9.0", + "nextflow": "24.04.4" + }, + "timestamp": "2024-09-24T15:18:05.139687" + }, + "segmentation - synthseg - basic": { + "content": [ + "test__mask_wm.nii.gz:md5:header,a0430ca63ccc3bb2b925694cb7568388,data,1b5a4d63ae2b56d9d6936313b5225b55", + "test__mask_gm.nii.gz:md5:header,a0430ca63ccc3bb2b925694cb7568388,data,c093a4b4c8c5804342b7ea8eea6164fb", + "test__mask_csf.nii.gz:md5:header,a0430ca63ccc3bb2b925694cb7568388,data,c9abaab9c5e047fadf928a6520929d5e", + [ + "versions.yml:md5,b65418e9ce2ab1cce590b1f659e18c1d" + ] + ], + "meta": { + "nf-test": "0.9.0", + "nextflow": "24.04.4" + }, + "timestamp": "2024-09-24T16:30:16.454647" + }, + "segmentation - synthseg - lesion": { + "content": [ + "test__mask_wm.nii.gz:md5:header,a0430ca63ccc3bb2b925694cb7568388,data,6d99d71cff4a2f9d147c45b1ee36dce0", + "test__mask_gm.nii.gz:md5:header,a0430ca63ccc3bb2b925694cb7568388,data,c093a4b4c8c5804342b7ea8eea6164fb", + "test__mask_csf.nii.gz:md5:header,a0430ca63ccc3bb2b925694cb7568388,data,c9abaab9c5e047fadf928a6520929d5e", + [ + "versions.yml:md5,b65418e9ce2ab1cce590b1f659e18c1d" + ] + ], + "meta": { + "nf-test": "0.9.0", + "nextflow": "24.04.4" + }, + "timestamp": "2024-09-24T15:19:58.108829" + } +} \ No newline at end of file diff --git a/modules/nf-neuro/segmentation/synthseg/tests/nextflow_basic.config b/modules/nf-neuro/segmentation/synthseg/tests/nextflow_basic.config index b520af9..a727a9f 100644 --- a/modules/nf-neuro/segmentation/synthseg/tests/nextflow_basic.config +++ b/modules/nf-neuro/segmentation/synthseg/tests/nextflow_basic.config @@ -1,5 +1,5 @@ process { - memory = "8G" + memory = "10G" publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } ext.fast = true } From 32e886ba71f774820f34983640f6075836549bca Mon Sep 17 00:00:00 2001 From: anroy1 Date: Wed, 25 Sep 2024 00:22:11 +0000 Subject: [PATCH 3/9] Fix Alex's comments --- .../segmentation/synthseg/environment.yml | 10 ++--- .../nf-neuro/segmentation/synthseg/main.nf | 42 +++++++++---------- .../nf-neuro/segmentation/synthseg/meta.yml | 9 ++-- .../segmentation/synthseg/tests/main.nf.test | 16 +++---- .../synthseg/tests/main.nf.test.snap | 26 ++++-------- .../synthseg/tests/nextflow_basic.config | 2 +- 6 files changed, 46 insertions(+), 59 deletions(-) diff --git a/modules/nf-neuro/segmentation/synthseg/environment.yml b/modules/nf-neuro/segmentation/synthseg/environment.yml index ed5dd01..2e10848 100644 --- a/modules/nf-neuro/segmentation/synthseg/environment.yml +++ b/modules/nf-neuro/segmentation/synthseg/environment.yml @@ -1,7 +1,3 @@ ---- -name: "segmentation_synthseg" -channels: - - Docker - - Apptainer -dependencies: - - "Freesurfer" +channels: [] +dependencies: [] +name: segmentation_synthseg diff --git a/modules/nf-neuro/segmentation/synthseg/main.nf b/modules/nf-neuro/segmentation/synthseg/main.nf index 930c287..7b9eec1 100644 --- a/modules/nf-neuro/segmentation/synthseg/main.nf +++ b/modules/nf-neuro/segmentation/synthseg/main.nf @@ -12,10 +12,10 @@ 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("*__parc.nii.gz") , emit: parc, optional: true + tuple val(meta), path("*__gm_parc.nii.gz") , emit: gm_parc, optional: true 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("*__volume.csv") , emit: volume, optional: true + tuple val(meta), path("*__qc_score.csv") , emit: qc_score, optional: true path "versions.yml" , emit: versions when: @@ -26,13 +26,13 @@ process SEGMENTATION_SYNTHSEG { def prefix = task.ext.prefix ?: "${meta.id}" def gpu = task.ext.gpu ? "" : "--cpu" - def parc = task.ext.parc ? "--parc" : "" + def gm_parc = task.ext.gm_parc ? "--parc" : "" 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_volume = task.ext.output_volume ? "--vol ${prefix}__volume.csv" : "" + def output_qc_score = task.ext.output_qc_score ? "--qc ${prefix}__qc_score.csv" : "" def crop = task.ext.crop ? "--crop " + task.ext.crop: "" """ @@ -42,29 +42,29 @@ process SEGMENTATION_SYNTHSEG { cp $fs_license \$FREESURFER_HOME/license.txt - mri_synthseg --i $image --o seg.nii.gz --threads $task.cpus $gpu $robust $fast $ct $output_resample $output_vol $output_qc $crop + mri_synthseg --i $image --o seg.nii.gz --threads $task.cpus $gpu $robust $fast $ct $output_resample $output_volume $output_qc_score $crop - if [[ $task.parc ]]; + if [[ $task.gm_parc ]]; then - # Cortical parcellation - mri_synthseg --i $image --o ${prefix}__parc.nii.gz --threads $task.cpus $gpu $parc $robust $fast $crop - mri_convert -i ${prefix}__parc.nii.gz --out_data_type uchar -o ${prefix}__parc.nii.gz + # Cortical grey matter parcellation + mri_synthseg --i $image --o ${prefix}__gm_parc.nii.gz --threads $task.cpus $gpu $gm_parc $robust $fast $crop + mri_convert -i ${prefix}__gm_parc.nii.gz --out_data_type uchar -o ${prefix}__gm_parc.nii.gz fi # WM Mask mri_binarize --i seg.nii.gz \ - --match 2 7 10 12 13 16 28 41 46 49 51 52 60 \ - --o ${prefix}__mask_wm.nii.gz + --match 2 7 10 12 13 16 28 41 46 49 51 52 60 \ + --o ${prefix}__mask_wm.nii.gz # GM Mask mri_binarize --i seg.nii.gz \ - --match 3 8 11 17 18 26 42 47 50 52 53 54 58 \ - --o ${prefix}__mask_gm.nii.gz + --match 3 8 11 17 18 26 42 47 50 52 53 54 58 \ + --o ${prefix}__mask_gm.nii.gz # CSF Mask mri_binarize --i seg.nii.gz \ - --match 4 5 14 15 24 43 44 \ - --o ${prefix}__mask_csf.nii.gz + --match 4 5 14 15 24 43 44 \ + --o ${prefix}__mask_csf.nii.gz if [[ -f "$lesion" ]]; then @@ -74,7 +74,7 @@ process SEGMENTATION_SYNTHSEG { mri_convert -i ${prefix}__mask_wm.nii.gz --out_data_type uchar -o ${prefix}__mask_wm.nii.gz mri_convert -i ${prefix}__mask_gm.nii.gz --out_data_type uchar -o ${prefix}__mask_gm.nii.gz mri_convert -i ${prefix}__mask_csf.nii.gz --out_data_type uchar -o ${prefix}__mask_csf.nii.gz - mri_convert -i ${prefix}__parc.nii.gz --out_data_type uchar ${prefix}__parc.nii.gz + mri_convert -i ${prefix}__gm_parc.nii.gz --out_data_type uchar ${prefix}__gm_parc.nii.gz rm \$FREESURFER_HOME/license.txt @@ -96,10 +96,10 @@ process SEGMENTATION_SYNTHSEG { touch ${prefix}__mask_wm.nii.gz touch ${prefix}__mask_gm.nii.gz touch ${prefix}__mask_csf.nii.gz - touch ${prefix}__parc.nii.gz + touch ${prefix}__gm_parc.nii.gz touch ${prefix}__resampled_image.nii.gz - touch ${prefix}__vol.csv - touch ${prefix}__qc.csv + touch ${prefix}__volume.csv + touch ${prefix}__qc_score.csv cat <<-END_VERSIONS > versions.yml diff --git a/modules/nf-neuro/segmentation/synthseg/meta.yml b/modules/nf-neuro/segmentation/synthseg/meta.yml index 9847135..32edfd6 100644 --- a/modules/nf-neuro/segmentation/synthseg/meta.yml +++ b/modules/nf-neuro/segmentation/synthseg/meta.yml @@ -4,6 +4,9 @@ keywords: - Segmentation - Freesurfer - Tissues + - Synthetic + - AI + - CNN tools: - "Freesurfer": description: "An open source neuroimaging toolkit for processing, analyzing, and visualizing human brain MR images." @@ -53,17 +56,17 @@ output: description: Nifti CSF mask volume. pattern: "*.{nii,nii.gz}" - - parc: + - gm_parc: type: file description: (optional) Nifti cortical parcellation volume. pattern: "*.{nii,nii.gz}" - - vol: + - volume: type: file description: (optional) Output CSV file with volumes for all structures and subjects. pattern: "*.csv" - - qc: + - qc_score: type: file description: (optional) Output CSV file with qc scores for all subjects. pattern: "*.csv" diff --git a/modules/nf-neuro/segmentation/synthseg/tests/main.nf.test b/modules/nf-neuro/segmentation/synthseg/tests/main.nf.test index 235597a..38ceae3 100644 --- a/modules/nf-neuro/segmentation/synthseg/tests/main.nf.test +++ b/modules/nf-neuro/segmentation/synthseg/tests/main.nf.test @@ -17,7 +17,7 @@ nextflow_process { script "../../../../../subworkflows/nf-neuro/load_test_data/main.nf" process { """ - input[0] = Channel.from( [ "heavy.zip", "freesurfer.zip" ] ) + input[0] = Channel.from( [ "heavy.zip", "freesurfer.zip", "processing.zip" ] ) input[1] = "test.load-test-data" """ } @@ -73,13 +73,13 @@ nextflow_process { """ ch_split_test_data = LOAD_DATA.out.test_data_directory .branch{ - heavy: it.simpleName == "heavy" + processing: it.simpleName == "processing" freesurfer: it.simpleName == "freesurfer" } - ch_anat = ch_split_test_data.heavy.map{ + ch_anat = ch_split_test_data.processing.map{ test_data_directory -> [ [ id:'test' ], - file("\${test_data_directory}/anat/anat_image.nii.gz"), + file("\${test_data_directory}/mni_masked_2x2x2.nii.gz"), [] ] } @@ -102,10 +102,10 @@ nextflow_process { niftiMD5SUM(process.out.wm_mask.get(0).get(1)), niftiMD5SUM(process.out.gm_mask.get(0).get(1)), niftiMD5SUM(process.out.csf_mask.get(0).get(1)), - niftiMD5SUM(process.out.parc.get(0).get(1)), - process.out.resample, - process.out.vol, - process.out.qc, + niftiMD5SUM(process.out.gm_parc.get(0).get(1)), + niftiMD5SUM(process.out.resample.get(0).get(1)), + process.out.volume, + process.out.qc_score, process.out.versions ).match() } ) diff --git a/modules/nf-neuro/segmentation/synthseg/tests/main.nf.test.snap b/modules/nf-neuro/segmentation/synthseg/tests/main.nf.test.snap index a60de29..3fce966 100644 --- a/modules/nf-neuro/segmentation/synthseg/tests/main.nf.test.snap +++ b/modules/nf-neuro/segmentation/synthseg/tests/main.nf.test.snap @@ -1,28 +1,16 @@ { "segmentation - synthseg - options": { "content": [ - "test__mask_wm.nii.gz:md5:header,a0430ca63ccc3bb2b925694cb7568388,data,95946cf22f6adf539b65c72b49eb3b32", - "test__mask_gm.nii.gz:md5:header,a0430ca63ccc3bb2b925694cb7568388,data,a54f8c03a17a16d9271534c387434720", - "test__mask_csf.nii.gz:md5:header,a0430ca63ccc3bb2b925694cb7568388,data,3895c471bc8b06446a8adbba9fe235f7", - "test__parc.nii.gz:md5:header,a0430ca63ccc3bb2b925694cb7568388,data,cb9a481316ae64dceb229879bd0c6619", + "test__mask_wm.nii.gz:md5:header,07555a083d94f8f52a4227cacb0ed0b1,data,8ffff7c6810fc860e647d468f78da688", + "test__mask_gm.nii.gz:md5:header,07555a083d94f8f52a4227cacb0ed0b1,data,ef5d0fff6236bfff594a5c43ef509bd7", + "test__mask_csf.nii.gz:md5:header,07555a083d94f8f52a4227cacb0ed0b1,data,f26e143ee6e50ba6de14ffa663009980", + "test__gm_parc.nii.gz:md5:header,07555a083d94f8f52a4227cacb0ed0b1,data,b31bd40a08fab18941c92f60cae1c3c1", + "test__resampled_image.nii.gz:md5:header,728dfc231a3dfcf567ac640930f68629,data,1f02837025def8b0701f79549c2955e1", [ ], [ - [ - { - "id": "test" - }, - "test__vol.csv:md5,c5c29a038e4f43abcce1845bc429952c" - ] - ], - [ - [ - { - "id": "test" - }, - "test__qc.csv:md5,333de3d7b60916596f0460c808b598f5" - ] + ], [ "versions.yml:md5,b65418e9ce2ab1cce590b1f659e18c1d" @@ -32,7 +20,7 @@ "nf-test": "0.9.0", "nextflow": "24.04.4" }, - "timestamp": "2024-09-24T15:18:05.139687" + "timestamp": "2024-09-24T21:47:54.367803" }, "segmentation - synthseg - basic": { "content": [ diff --git a/modules/nf-neuro/segmentation/synthseg/tests/nextflow_basic.config b/modules/nf-neuro/segmentation/synthseg/tests/nextflow_basic.config index a727a9f..7790196 100644 --- a/modules/nf-neuro/segmentation/synthseg/tests/nextflow_basic.config +++ b/modules/nf-neuro/segmentation/synthseg/tests/nextflow_basic.config @@ -1,5 +1,5 @@ process { - memory = "10G" + memory = "12G" publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } ext.fast = true } From 4b86d159f918e28ffdfa36630d26f1773077413d Mon Sep 17 00:00:00 2001 From: anroy1 Date: Thu, 26 Sep 2024 10:55:06 +0000 Subject: [PATCH 4/9] Fix runner big mem --- .github/workflows/run_checks_suite.yml | 2 ++ .../nf-neuro/segmentation/synthseg/tests/nextflow_basic.config | 2 +- .../segmentation/synthseg/tests/nextflow_options.config | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run_checks_suite.yml b/.github/workflows/run_checks_suite.yml index af6ecbd..13fef09 100644 --- a/.github/workflows/run_checks_suite.yml +++ b/.github/workflows/run_checks_suite.yml @@ -137,6 +137,8 @@ jobs: - runner: scilus-nf-neuro-runners - runner: scilus-nf-neuro-bigmem-runners path: modules/nf-neuro/registration/easyreg + - runner: scilus-nf-neuro-bigmem-runners + path: modules/nf-neuro/segmentation/synthseg exclude: - path: subworkflows/nf-neuro/load_test_data uses: ./.github/workflows/test_component.yml diff --git a/modules/nf-neuro/segmentation/synthseg/tests/nextflow_basic.config b/modules/nf-neuro/segmentation/synthseg/tests/nextflow_basic.config index 7790196..286dd59 100644 --- a/modules/nf-neuro/segmentation/synthseg/tests/nextflow_basic.config +++ b/modules/nf-neuro/segmentation/synthseg/tests/nextflow_basic.config @@ -1,5 +1,5 @@ process { - memory = "12G" + memory = "16G" publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } ext.fast = true } diff --git a/modules/nf-neuro/segmentation/synthseg/tests/nextflow_options.config b/modules/nf-neuro/segmentation/synthseg/tests/nextflow_options.config index e4962ee..cae196e 100644 --- a/modules/nf-neuro/segmentation/synthseg/tests/nextflow_options.config +++ b/modules/nf-neuro/segmentation/synthseg/tests/nextflow_options.config @@ -1,5 +1,5 @@ process { - memory = "8G" + memory = "16G" publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } ext.robust = true ext.output_resample = true From c5bf82c1b496a5fa009afb830d7ab9d9ddfed260 Mon Sep 17 00:00:00 2001 From: anroy1 Date: Thu, 26 Sep 2024 12:14:36 +0000 Subject: [PATCH 5/9] Fix local test --- .../nf-neuro/segmentation/synthseg/tests/nextflow_basic.config | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/nf-neuro/segmentation/synthseg/tests/nextflow_basic.config b/modules/nf-neuro/segmentation/synthseg/tests/nextflow_basic.config index 286dd59..379d2ef 100644 --- a/modules/nf-neuro/segmentation/synthseg/tests/nextflow_basic.config +++ b/modules/nf-neuro/segmentation/synthseg/tests/nextflow_basic.config @@ -1,5 +1,6 @@ process { memory = "16G" + cpus = 2 publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } ext.fast = true } From 49bca92e9d9633fe5b7c2b47725f8469128d8a56 Mon Sep 17 00:00:00 2001 From: anroy1 Date: Thu, 26 Sep 2024 18:12:38 +0000 Subject: [PATCH 6/9] add seg as output to test assertions --- modules/nf-neuro/segmentation/synthseg/main.nf | 7 +++++-- .../nf-neuro/segmentation/synthseg/tests/main.nf.test | 3 +++ .../segmentation/synthseg/tests/main.nf.test.snap | 11 +++++++---- .../segmentation/synthseg/tests/nextflow_basic.config | 1 - .../synthseg/tests/nextflow_options.config | 2 +- 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/modules/nf-neuro/segmentation/synthseg/main.nf b/modules/nf-neuro/segmentation/synthseg/main.nf index 7b9eec1..807a0a4 100644 --- a/modules/nf-neuro/segmentation/synthseg/main.nf +++ b/modules/nf-neuro/segmentation/synthseg/main.nf @@ -9,6 +9,7 @@ process SEGMENTATION_SYNTHSEG { tuple val(meta), path(image), path(lesion) /* optional, input = [] */, path(fs_license) /* optional, input = [] */ output: + tuple val(meta), path("*__seg.nii.gz") , emit: seg 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 @@ -44,7 +45,9 @@ process SEGMENTATION_SYNTHSEG { mri_synthseg --i $image --o seg.nii.gz --threads $task.cpus $gpu $robust $fast $ct $output_resample $output_volume $output_qc_score $crop - if [[ $task.gm_parc ]]; + cp seg.nii.gz ${prefix}__seg.nii.gz + + if [[ -n "$gm_parc" ]]; then # Cortical grey matter parcellation mri_synthseg --i $image --o ${prefix}__gm_parc.nii.gz --threads $task.cpus $gpu $gm_parc $robust $fast $crop @@ -74,7 +77,6 @@ process SEGMENTATION_SYNTHSEG { mri_convert -i ${prefix}__mask_wm.nii.gz --out_data_type uchar -o ${prefix}__mask_wm.nii.gz mri_convert -i ${prefix}__mask_gm.nii.gz --out_data_type uchar -o ${prefix}__mask_gm.nii.gz mri_convert -i ${prefix}__mask_csf.nii.gz --out_data_type uchar -o ${prefix}__mask_csf.nii.gz - mri_convert -i ${prefix}__gm_parc.nii.gz --out_data_type uchar ${prefix}__gm_parc.nii.gz rm \$FREESURFER_HOME/license.txt @@ -93,6 +95,7 @@ process SEGMENTATION_SYNTHSEG { mri_binarize -h mri_convert -h + touch ${prefix}__seg.nii.gz touch ${prefix}__mask_wm.nii.gz touch ${prefix}__mask_gm.nii.gz touch ${prefix}__mask_csf.nii.gz diff --git a/modules/nf-neuro/segmentation/synthseg/tests/main.nf.test b/modules/nf-neuro/segmentation/synthseg/tests/main.nf.test index 38ceae3..4fb59b8 100644 --- a/modules/nf-neuro/segmentation/synthseg/tests/main.nf.test +++ b/modules/nf-neuro/segmentation/synthseg/tests/main.nf.test @@ -57,6 +57,7 @@ nextflow_process { assertAll( { assert process.success }, { assert snapshot( + niftiMD5SUM(process.out.seg.get(0).get(1)), niftiMD5SUM(process.out.wm_mask.get(0).get(1)), niftiMD5SUM(process.out.gm_mask.get(0).get(1)), niftiMD5SUM(process.out.csf_mask.get(0).get(1)), @@ -99,6 +100,7 @@ nextflow_process { assertAll( { assert process.success }, { assert snapshot( + niftiMD5SUM(process.out.seg.get(0).get(1)), niftiMD5SUM(process.out.wm_mask.get(0).get(1)), niftiMD5SUM(process.out.gm_mask.get(0).get(1)), niftiMD5SUM(process.out.csf_mask.get(0).get(1)), @@ -145,6 +147,7 @@ nextflow_process { assertAll( { assert process.success }, { assert snapshot( + niftiMD5SUM(process.out.seg.get(0).get(1)), niftiMD5SUM(process.out.wm_mask.get(0).get(1)), niftiMD5SUM(process.out.gm_mask.get(0).get(1)), niftiMD5SUM(process.out.csf_mask.get(0).get(1)), diff --git a/modules/nf-neuro/segmentation/synthseg/tests/main.nf.test.snap b/modules/nf-neuro/segmentation/synthseg/tests/main.nf.test.snap index 3fce966..bf1ee9c 100644 --- a/modules/nf-neuro/segmentation/synthseg/tests/main.nf.test.snap +++ b/modules/nf-neuro/segmentation/synthseg/tests/main.nf.test.snap @@ -1,10 +1,11 @@ { "segmentation - synthseg - options": { "content": [ + "test__seg.nii.gz:md5:header,ff063c025479983639fd545e1e8fd690,data,adeeec0078924b2fde1cd4667a2c330d", "test__mask_wm.nii.gz:md5:header,07555a083d94f8f52a4227cacb0ed0b1,data,8ffff7c6810fc860e647d468f78da688", "test__mask_gm.nii.gz:md5:header,07555a083d94f8f52a4227cacb0ed0b1,data,ef5d0fff6236bfff594a5c43ef509bd7", "test__mask_csf.nii.gz:md5:header,07555a083d94f8f52a4227cacb0ed0b1,data,f26e143ee6e50ba6de14ffa663009980", - "test__gm_parc.nii.gz:md5:header,07555a083d94f8f52a4227cacb0ed0b1,data,b31bd40a08fab18941c92f60cae1c3c1", + "test__gm_parc.nii.gz:md5:header,07555a083d94f8f52a4227cacb0ed0b1,data,82fcf874a436dbdcd0b45b429cd8e0c1", "test__resampled_image.nii.gz:md5:header,728dfc231a3dfcf567ac640930f68629,data,1f02837025def8b0701f79549c2955e1", [ @@ -20,10 +21,11 @@ "nf-test": "0.9.0", "nextflow": "24.04.4" }, - "timestamp": "2024-09-24T21:47:54.367803" + "timestamp": "2024-09-26T18:04:30.619078" }, "segmentation - synthseg - basic": { "content": [ + "test__seg.nii.gz:md5:header,f84c3d38470f2b2c2741e78ee95b5367,data,f68a3f27105e7fe463bb108648b11459", "test__mask_wm.nii.gz:md5:header,a0430ca63ccc3bb2b925694cb7568388,data,1b5a4d63ae2b56d9d6936313b5225b55", "test__mask_gm.nii.gz:md5:header,a0430ca63ccc3bb2b925694cb7568388,data,c093a4b4c8c5804342b7ea8eea6164fb", "test__mask_csf.nii.gz:md5:header,a0430ca63ccc3bb2b925694cb7568388,data,c9abaab9c5e047fadf928a6520929d5e", @@ -35,10 +37,11 @@ "nf-test": "0.9.0", "nextflow": "24.04.4" }, - "timestamp": "2024-09-24T16:30:16.454647" + "timestamp": "2024-09-26T17:56:01.141662" }, "segmentation - synthseg - lesion": { "content": [ + "test__seg.nii.gz:md5:header,f84c3d38470f2b2c2741e78ee95b5367,data,f68a3f27105e7fe463bb108648b11459", "test__mask_wm.nii.gz:md5:header,a0430ca63ccc3bb2b925694cb7568388,data,6d99d71cff4a2f9d147c45b1ee36dce0", "test__mask_gm.nii.gz:md5:header,a0430ca63ccc3bb2b925694cb7568388,data,c093a4b4c8c5804342b7ea8eea6164fb", "test__mask_csf.nii.gz:md5:header,a0430ca63ccc3bb2b925694cb7568388,data,c9abaab9c5e047fadf928a6520929d5e", @@ -50,6 +53,6 @@ "nf-test": "0.9.0", "nextflow": "24.04.4" }, - "timestamp": "2024-09-24T15:19:58.108829" + "timestamp": "2024-09-26T17:57:43.31581" } } \ No newline at end of file diff --git a/modules/nf-neuro/segmentation/synthseg/tests/nextflow_basic.config b/modules/nf-neuro/segmentation/synthseg/tests/nextflow_basic.config index 379d2ef..286dd59 100644 --- a/modules/nf-neuro/segmentation/synthseg/tests/nextflow_basic.config +++ b/modules/nf-neuro/segmentation/synthseg/tests/nextflow_basic.config @@ -1,6 +1,5 @@ process { memory = "16G" - cpus = 2 publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } ext.fast = true } diff --git a/modules/nf-neuro/segmentation/synthseg/tests/nextflow_options.config b/modules/nf-neuro/segmentation/synthseg/tests/nextflow_options.config index cae196e..4f2ddb9 100644 --- a/modules/nf-neuro/segmentation/synthseg/tests/nextflow_options.config +++ b/modules/nf-neuro/segmentation/synthseg/tests/nextflow_options.config @@ -6,5 +6,5 @@ process { ext.output_vol = true ext.output_qc = true ext.crop = 150 - ext.parc = true + ext.gm_parc = true } From 44deee75165840b10b46577162e7708413eb60fe Mon Sep 17 00:00:00 2001 From: anroy1 Date: Thu, 26 Sep 2024 18:58:03 +0000 Subject: [PATCH 7/9] Assert name only for synthseg_s outputs --- .../nf-neuro/segmentation/synthseg/meta.yml | 3 +-- .../segmentation/synthseg/tests/main.nf.test | 27 ++++++++++--------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/modules/nf-neuro/segmentation/synthseg/meta.yml b/modules/nf-neuro/segmentation/synthseg/meta.yml index 32edfd6..9fe50c9 100644 --- a/modules/nf-neuro/segmentation/synthseg/meta.yml +++ b/modules/nf-neuro/segmentation/synthseg/meta.yml @@ -1,6 +1,5 @@ name: "segmentation_synthseg" -description: Perform Brain Tissues Segmentation using Freesurfer synthseg on a T1 image. Optionally, a binary mask of lesion can be add to correct the white matter mask. -keywords: +description: Perform Brain Tissues Segmentation using Freesurfer synthseg on a T1 image. Optionally, a binary mask of lesion can be add to correct the white matter mask. Note that Synthseg is an AI model and freesurfer does not control for randomness in computation yet, both in terms of seeding and operation ordering. - Segmentation - Freesurfer - Tissues diff --git a/modules/nf-neuro/segmentation/synthseg/tests/main.nf.test b/modules/nf-neuro/segmentation/synthseg/tests/main.nf.test index 4fb59b8..ce06155 100644 --- a/modules/nf-neuro/segmentation/synthseg/tests/main.nf.test +++ b/modules/nf-neuro/segmentation/synthseg/tests/main.nf.test @@ -24,6 +24,10 @@ nextflow_process { } } +// ** Assertion only uses file name since there is a discrepancy when tests are ran remotly. ** // +// ** Synthseg's direct output was emitted as an output to help assess its non-reproductibility ** // +// ** Synthseg is an AI model and freesurfer does not control for randomness in computation yet, both in terms of seeding and operation ordering.** // + test("segmentation - synthseg - basic") { config "./nextflow_basic.config" when { @@ -57,10 +61,9 @@ nextflow_process { assertAll( { assert process.success }, { assert snapshot( - niftiMD5SUM(process.out.seg.get(0).get(1)), - niftiMD5SUM(process.out.wm_mask.get(0).get(1)), - niftiMD5SUM(process.out.gm_mask.get(0).get(1)), - niftiMD5SUM(process.out.csf_mask.get(0).get(1)), + file(process.out.wm_mask.get(0).get(1)).name, + file(process.out.gm_mask.get(0).get(1)).name, + file(process.out.csf_mask.get(0).get(1)).name, process.out.versions ).match() } ) @@ -100,11 +103,10 @@ nextflow_process { assertAll( { assert process.success }, { assert snapshot( - niftiMD5SUM(process.out.seg.get(0).get(1)), - niftiMD5SUM(process.out.wm_mask.get(0).get(1)), - niftiMD5SUM(process.out.gm_mask.get(0).get(1)), - niftiMD5SUM(process.out.csf_mask.get(0).get(1)), - niftiMD5SUM(process.out.gm_parc.get(0).get(1)), + file(process.out.wm_mask.get(0).get(1)).name, + file(process.out.gm_mask.get(0).get(1)).name, + file(process.out.csf_mask.get(0).get(1)).name, + file(process.out.gm_parc.get(0).get(1)).name, niftiMD5SUM(process.out.resample.get(0).get(1)), process.out.volume, process.out.qc_score, @@ -147,10 +149,9 @@ nextflow_process { assertAll( { assert process.success }, { assert snapshot( - niftiMD5SUM(process.out.seg.get(0).get(1)), - niftiMD5SUM(process.out.wm_mask.get(0).get(1)), - niftiMD5SUM(process.out.gm_mask.get(0).get(1)), - niftiMD5SUM(process.out.csf_mask.get(0).get(1)), + file(process.out.wm_mask.get(0).get(1)).name, + file(process.out.gm_mask.get(0).get(1)).name, + file(process.out.csf_mask.get(0).get(1)).name, process.out.versions ).match() } ) From eeb9a9c90c571d9f17ad770c7cb0427e08b32a85 Mon Sep 17 00:00:00 2001 From: anroy1 Date: Thu, 26 Sep 2024 19:10:02 +0000 Subject: [PATCH 8/9] Fix typo --- modules/nf-neuro/segmentation/synthseg/meta.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/nf-neuro/segmentation/synthseg/meta.yml b/modules/nf-neuro/segmentation/synthseg/meta.yml index 9fe50c9..4037b51 100644 --- a/modules/nf-neuro/segmentation/synthseg/meta.yml +++ b/modules/nf-neuro/segmentation/synthseg/meta.yml @@ -1,5 +1,6 @@ name: "segmentation_synthseg" -description: Perform Brain Tissues Segmentation using Freesurfer synthseg on a T1 image. Optionally, a binary mask of lesion can be add to correct the white matter mask. Note that Synthseg is an AI model and freesurfer does not control for randomness in computation yet, both in terms of seeding and operation ordering. +description: Perform Brain Tissues Segmentation using Freesurfer synthseg on a T1 image. Optionally, a binary mask of lesion can be add to correct the white matter mask. Note that tests using synthseg are non-reproductible. +keywords: - Segmentation - Freesurfer - Tissues From 18acd4ea30540f12724d74476abd1127aebd4739 Mon Sep 17 00:00:00 2001 From: anroy1 Date: Thu, 26 Sep 2024 19:40:48 +0000 Subject: [PATCH 9/9] push tests snap --- .../synthseg/tests/main.nf.test.snap | 29 +++++++++---------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/modules/nf-neuro/segmentation/synthseg/tests/main.nf.test.snap b/modules/nf-neuro/segmentation/synthseg/tests/main.nf.test.snap index bf1ee9c..8057ea7 100644 --- a/modules/nf-neuro/segmentation/synthseg/tests/main.nf.test.snap +++ b/modules/nf-neuro/segmentation/synthseg/tests/main.nf.test.snap @@ -1,11 +1,10 @@ { "segmentation - synthseg - options": { "content": [ - "test__seg.nii.gz:md5:header,ff063c025479983639fd545e1e8fd690,data,adeeec0078924b2fde1cd4667a2c330d", - "test__mask_wm.nii.gz:md5:header,07555a083d94f8f52a4227cacb0ed0b1,data,8ffff7c6810fc860e647d468f78da688", - "test__mask_gm.nii.gz:md5:header,07555a083d94f8f52a4227cacb0ed0b1,data,ef5d0fff6236bfff594a5c43ef509bd7", - "test__mask_csf.nii.gz:md5:header,07555a083d94f8f52a4227cacb0ed0b1,data,f26e143ee6e50ba6de14ffa663009980", - "test__gm_parc.nii.gz:md5:header,07555a083d94f8f52a4227cacb0ed0b1,data,82fcf874a436dbdcd0b45b429cd8e0c1", + "test__mask_wm.nii.gz", + "test__mask_gm.nii.gz", + "test__mask_csf.nii.gz", + "test__gm_parc.nii.gz", "test__resampled_image.nii.gz:md5:header,728dfc231a3dfcf567ac640930f68629,data,1f02837025def8b0701f79549c2955e1", [ @@ -21,14 +20,13 @@ "nf-test": "0.9.0", "nextflow": "24.04.4" }, - "timestamp": "2024-09-26T18:04:30.619078" + "timestamp": "2024-09-26T19:29:31.173296" }, "segmentation - synthseg - basic": { "content": [ - "test__seg.nii.gz:md5:header,f84c3d38470f2b2c2741e78ee95b5367,data,f68a3f27105e7fe463bb108648b11459", - "test__mask_wm.nii.gz:md5:header,a0430ca63ccc3bb2b925694cb7568388,data,1b5a4d63ae2b56d9d6936313b5225b55", - "test__mask_gm.nii.gz:md5:header,a0430ca63ccc3bb2b925694cb7568388,data,c093a4b4c8c5804342b7ea8eea6164fb", - "test__mask_csf.nii.gz:md5:header,a0430ca63ccc3bb2b925694cb7568388,data,c9abaab9c5e047fadf928a6520929d5e", + "test__mask_wm.nii.gz", + "test__mask_gm.nii.gz", + "test__mask_csf.nii.gz", [ "versions.yml:md5,b65418e9ce2ab1cce590b1f659e18c1d" ] @@ -37,14 +35,13 @@ "nf-test": "0.9.0", "nextflow": "24.04.4" }, - "timestamp": "2024-09-26T17:56:01.141662" + "timestamp": "2024-09-26T19:27:57.646867" }, "segmentation - synthseg - lesion": { "content": [ - "test__seg.nii.gz:md5:header,f84c3d38470f2b2c2741e78ee95b5367,data,f68a3f27105e7fe463bb108648b11459", - "test__mask_wm.nii.gz:md5:header,a0430ca63ccc3bb2b925694cb7568388,data,6d99d71cff4a2f9d147c45b1ee36dce0", - "test__mask_gm.nii.gz:md5:header,a0430ca63ccc3bb2b925694cb7568388,data,c093a4b4c8c5804342b7ea8eea6164fb", - "test__mask_csf.nii.gz:md5:header,a0430ca63ccc3bb2b925694cb7568388,data,c9abaab9c5e047fadf928a6520929d5e", + "test__mask_wm.nii.gz", + "test__mask_gm.nii.gz", + "test__mask_csf.nii.gz", [ "versions.yml:md5,b65418e9ce2ab1cce590b1f659e18c1d" ] @@ -53,6 +50,6 @@ "nf-test": "0.9.0", "nextflow": "24.04.4" }, - "timestamp": "2024-09-26T17:57:43.31581" + "timestamp": "2024-09-26T19:30:24.018659" } } \ No newline at end of file