From e88e5c9c21a78cfe72b11438f205bf968f85987f Mon Sep 17 00:00:00 2001 From: Thoumyre Stanislas Date: Thu, 11 Jul 2024 19:44:53 +0000 Subject: [PATCH 01/35] add module easyreg --- .../registration/easyreg/environment.yml | 9 +++ modules/nf-scil/registration/easyreg/main.nf | 74 +++++++++++++++++++ modules/nf-scil/registration/easyreg/meta.yml | 53 +++++++++++++ .../registration/easyreg/tests/main.nf.test | 74 +++++++++++++++++++ .../registration/easyreg/tests/tags.yml | 2 + 5 files changed, 212 insertions(+) create mode 100644 modules/nf-scil/registration/easyreg/environment.yml create mode 100644 modules/nf-scil/registration/easyreg/main.nf create mode 100644 modules/nf-scil/registration/easyreg/meta.yml create mode 100644 modules/nf-scil/registration/easyreg/tests/main.nf.test create mode 100644 modules/nf-scil/registration/easyreg/tests/tags.yml diff --git a/modules/nf-scil/registration/easyreg/environment.yml b/modules/nf-scil/registration/easyreg/environment.yml new file mode 100644 index 00000000..8fd3a56f --- /dev/null +++ b/modules/nf-scil/registration/easyreg/environment.yml @@ -0,0 +1,9 @@ +--- +# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json +name: "registration_easyreg" +channels: + - conda-forge + - bioconda + - defaults +dependencies: + - "YOUR-TOOL-HERE" diff --git a/modules/nf-scil/registration/easyreg/main.nf b/modules/nf-scil/registration/easyreg/main.nf new file mode 100644 index 00000000..1e606c6e --- /dev/null +++ b/modules/nf-scil/registration/easyreg/main.nf @@ -0,0 +1,74 @@ + + +process REGISTRATION_EASYREG { + tag "$meta.id" + label 'process_single' + + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://scil.usherbrooke.ca/containers/scilus_2.0.2.sif': + 'scilus/scilus:2.0.2' }" + + input: + tuple val(meta), path(reference), path(floating), path(ref_segmentation), path(flo_segmentation) + + output: + tuple val(meta), path("${prefix}_reference_segmentation.nii.gz") , emit: ref_seg + tuple val(meta), path("${prefix}_floating_segmentation.nii.gz") , emit: flo_seg + tuple val(meta), path("${prefix}_reference_registered.nii.gz") , emit: ref_reg + tuple val(meta), path("${prefix}_floating_registered.nii.gz") , emit: flo_reg + tuple val(meta), path("${prefix}_forward_field.nii.gz") , emit: fwd_field + tuple val(meta), path("${prefix}_backward_field.nii.gz") , emit: bak_field + path "versions.yml" , emit: versions + + when: + task.ext.when == null || task.ext.when + + script: + def prefix = task.ext.prefix ?: "${meta.id}" + def threads = task.ext.threads ? "--threads " + task.ext.threads : "" + def affine = task.ext.affine ? "--affine_only " : "" + + """ + if [[ -f "$ref_segmentation" ]]; + then + reference_segmentation = $ref_segmentation + else + reference_segmentation = ${prefix}_reference_segmentation.nii.gz + fi + + if [[ -f "$flo_segmentation" ]]; + then + floating_segmentation = $flo_segmentation + else + floating_segmentation = ${prefix}_floating_segmentation.nii.gz + fi + + mri_easyreg --ref $reference --flo $floating --ref_seg \${reference_segmentation} --flo_seg --ref_seg \${reference_segmentation} \ + --flo_reg ${prefix}_floating_registered.nii.gz --ref_reg ${prefix}_reference_registered.nii.gz --fwd_field ${prefix}_forward_field.nii.gz \ + --bak_field ${prefix}_backward_field.nii.gz $threads $affine + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + freesurfer: 7.4 + END_VERSIONS + """ + + stub: + def prefix = task.ext.prefix ?: "${meta.id}" + + """ + mri_easyreg -h + + touch ${prefix}_reference_segmentation.nii.gz + touch ${prefix}_floating_segmentation.nii.gz + touch ${prefix}_reference_registered.nii.gz + touch ${prefix}_floating_registered.nii.gz + touch ${prefix}_forward_field.nii.gz + touch ${prefix}_backward_field.nii.gz + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + freesurfer: 7.4 + END_VERSIONS + """ +} diff --git a/modules/nf-scil/registration/easyreg/meta.yml b/modules/nf-scil/registration/easyreg/meta.yml new file mode 100644 index 00000000..41bbc2f1 --- /dev/null +++ b/modules/nf-scil/registration/easyreg/meta.yml @@ -0,0 +1,53 @@ +--- +# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json +name: "registration_easyreg" +description: write your description here +keywords: + - sort + - example + - genomics +tools: + - "registration": + description: "" + homepage: "" + documentation: "" + tool_dev_url: "" + doi: "" + licence: + +input: + # Only when we have meta + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'sample1', single_end:false ]` + + + - input: + type: file + description: + pattern: + +output: + #Only when we have meta + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'sample1', single_end:false ]` + + - versions: + type: file + description: File containing software versions + pattern: "versions.yml" + + - output: + type: file + description: + pattern: + +authors: + - "@ThoumyreStanislas" +maintainers: + - "@ThoumyreStanislas" diff --git a/modules/nf-scil/registration/easyreg/tests/main.nf.test b/modules/nf-scil/registration/easyreg/tests/main.nf.test new file mode 100644 index 00000000..98c74351 --- /dev/null +++ b/modules/nf-scil/registration/easyreg/tests/main.nf.test @@ -0,0 +1,74 @@ +// TODO nf-core: Once you have added the required tests, please run the following command to build this file: +// nf-core modules test registration/easyreg +nextflow_process { + + name "Test Process REGISTRATION_EASYREG" + script "../main.nf" + process "REGISTRATION_EASYREG" + + tag "modules" + tag "modules_nfcore" + tag "registration" + tag "registration/easyreg" + + // TODO nf-core: Change the test name preferably indicating the test-data and file-format used + test("sarscov2 - bam") { + + // TODO nf-core: If you are created a test for a chained module + // (the module requires running more than one process to generate the required output) + // add the 'setup' method here. + // You can find more information about how to use a 'setup' method in the docs (https://nf-co.re/docs/contributing/modules#steps-for-creating-nf-test-for-chained-modules). + + when { + process { + """ + // TODO nf-core: define inputs of the process here. Example: + + input[0] = [ + [ id:'test', single_end:false ], // meta map + file(params.test_data['sarscov2']['illumina']['test_paired_end_bam'], checkIfExists: true) + ] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + //TODO nf-core: Add all required assertions to verify the test output. + // See https://nf-co.re/docs/contributing/tutorials/nf-test_assertions for more information and examples. + ) + } + + } + + // TODO nf-core: Change the test name preferably indicating the test-data and file-format used but keep the " - stub" suffix. + test("sarscov2 - bam - stub") { + + options "-stub" + + when { + process { + """ + // TODO nf-core: define inputs of the process here. Example: + + input[0] = [ + [ id:'test', single_end:false ], // meta map + file(params.test_data['sarscov2']['illumina']['test_paired_end_bam'], checkIfExists: true) + ] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + //TODO nf-core: Add all required assertions to verify the test output. + ) + } + + } + +} diff --git a/modules/nf-scil/registration/easyreg/tests/tags.yml b/modules/nf-scil/registration/easyreg/tests/tags.yml new file mode 100644 index 00000000..14d95af4 --- /dev/null +++ b/modules/nf-scil/registration/easyreg/tests/tags.yml @@ -0,0 +1,2 @@ +registration/easyreg: + - "modules/nf-scil/registration/easyreg/**" From a16fe83c72be487b6020346ce99c3e49429a3928 Mon Sep 17 00:00:00 2001 From: Thoumyre Stanislas Date: Mon, 15 Jul 2024 12:33:27 +0000 Subject: [PATCH 02/35] complete module easyreg --- .../registration/easyreg/environment.yml | 7 +- modules/nf-scil/registration/easyreg/main.nf | 17 ++-- modules/nf-scil/registration/easyreg/meta.yml | 90 +++++++++++++------ .../registration/easyreg/tests/main.nf.test | 68 +++++--------- .../easyreg/tests/main.nf.test.snap | 55 ++++++++++++ .../easyreg/tests/nextflow.config | 6 ++ 6 files changed, 159 insertions(+), 84 deletions(-) create mode 100644 modules/nf-scil/registration/easyreg/tests/main.nf.test.snap create mode 100644 modules/nf-scil/registration/easyreg/tests/nextflow.config diff --git a/modules/nf-scil/registration/easyreg/environment.yml b/modules/nf-scil/registration/easyreg/environment.yml index 8fd3a56f..15ba99f2 100644 --- a/modules/nf-scil/registration/easyreg/environment.yml +++ b/modules/nf-scil/registration/easyreg/environment.yml @@ -2,8 +2,7 @@ # yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json name: "registration_easyreg" channels: - - conda-forge - - bioconda - - defaults + - Docker + - Apptainer dependencies: - - "YOUR-TOOL-HERE" + - "Freesurfer" diff --git a/modules/nf-scil/registration/easyreg/main.nf b/modules/nf-scil/registration/easyreg/main.nf index 1e606c6e..0d3f6496 100644 --- a/modules/nf-scil/registration/easyreg/main.nf +++ b/modules/nf-scil/registration/easyreg/main.nf @@ -4,9 +4,8 @@ process REGISTRATION_EASYREG { tag "$meta.id" label 'process_single' - container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? - 'https://scil.usherbrooke.ca/containers/scilus_2.0.2.sif': - 'scilus/scilus:2.0.2' }" + container "freesurfer/synthstrip:latest" + containerOptions "--entrypoint ''" input: tuple val(meta), path(reference), path(floating), path(ref_segmentation), path(flo_segmentation) @@ -25,27 +24,27 @@ process REGISTRATION_EASYREG { script: def prefix = task.ext.prefix ?: "${meta.id}" + def field = task.ext.field ? "--fwd_field ${prefix}_forward_field.nii.gz --bak_field ${prefix}_backward_field.nii.gz " : "" def threads = task.ext.threads ? "--threads " + task.ext.threads : "" def affine = task.ext.affine ? "--affine_only " : "" """ if [[ -f "$ref_segmentation" ]]; then - reference_segmentation = $ref_segmentation + reference_segmentation=$ref_segmentation else - reference_segmentation = ${prefix}_reference_segmentation.nii.gz + reference_segmentation="${prefix}_reference_segmentation.nii.gz" fi if [[ -f "$flo_segmentation" ]]; then - floating_segmentation = $flo_segmentation + floating_segmentation=$flo_segmentation else - floating_segmentation = ${prefix}_floating_segmentation.nii.gz + floating_segmentation="${prefix}_floating_segmentation.nii.gz" fi mri_easyreg --ref $reference --flo $floating --ref_seg \${reference_segmentation} --flo_seg --ref_seg \${reference_segmentation} \ - --flo_reg ${prefix}_floating_registered.nii.gz --ref_reg ${prefix}_reference_registered.nii.gz --fwd_field ${prefix}_forward_field.nii.gz \ - --bak_field ${prefix}_backward_field.nii.gz $threads $affine + --flo_reg ${prefix}_floating_registered.nii.gz --ref_reg ${prefix}_reference_registered.nii.gz $field $threads $affine cat <<-END_VERSIONS > versions.yml "${task.process}": diff --git a/modules/nf-scil/registration/easyreg/meta.yml b/modules/nf-scil/registration/easyreg/meta.yml index 41bbc2f1..fc4c91e7 100644 --- a/modules/nf-scil/registration/easyreg/meta.yml +++ b/modules/nf-scil/registration/easyreg/meta.yml @@ -1,51 +1,91 @@ --- -# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json name: "registration_easyreg" -description: write your description here +description: Image registration and gray matter segmentation with easyreg from freesurfer keywords: - - sort - - example - - genomics + - nifti + - registration + - segmentation + - easyreg + - freesurfer tools: - - "registration": - description: "" - homepage: "" - documentation: "" - tool_dev_url: "" - doi: "" - licence: + - "Freesurfer": + description: "Software package for the analysis and visualization of structural and functional neuroimaging data." + homepage: "https://surfer.nmr.mgh.harvard.edu/fswiki" input: - # Only when we have meta - meta: type: map description: | Groovy Map containing sample information e.g. `[ id:'sample1', single_end:false ]` - - - - input: + + - reference: + type: file + description: the reference image in .nii(.gz) or .mgz format (note that, since the method is symmetric, the choice of reference vs floating is arbitrary). + pattern: "*.{nii,nii.gz,mgz}" + + - floating: type: file - description: - pattern: + description: the floating image in .nii(.gz) or .mgz format. + pattern: "*.{nii,nii.gz,mgz}" + + - ref_segmentation: + type: file + description: + file with the SynthSeg v2 (non-robust) segmentation + parcellation of the reference image. + If it does not exist, EasyReg will create it. If it already exists (e.g., from a previous EasyReg run), then EasyReg will read it from disk (which is faster than segmenting). + pattern: "*.{nii,nii.gz}" + + - flo_segmentation: + type: file + description: + file with the SynthSeg v2 (non-robust) segmentation + parcellation of the floating image. + If it does not exist, EasyReg will create it. If it already exists (e.g., from a previous EasyReg run), then EasyReg will read it from disk (which is faster than segmenting). + pattern: "*.{nii,nii.gz}" output: - #Only when we have meta - meta: type: map description: | Groovy Map containing sample information e.g. `[ id:'sample1', single_end:false ]` - + + - ref_seg: + type: file + description: file with the SynthSeg v2 (non-robust) segmentation + parcellation of the reference image. + pattern: "*_reference_segmentation.nii.gz" + + - flo_seg: + type: file + description: file with the SynthSeg v2 (non-robust) segmentation + parcellation of the floating image. + pattern: "*_floating_segmentation.nii.gz" + + - ref_reg: + type: file + description: this is the file where the deformed (registered) reference image is written. + pattern: "*_reference_registered.nii.gz" + + - flo_reg: + type: file + description: this is the file where the deformed (registered) floating image is written. + pattern: "*_floating_registered.nii.gz" + + - fwd_field: + type: file + description: + this is the file where the forward deformation field is written. The deformation includes both the affine and nonlinear components. + Must be a nifti (.nii/.nii.gz) or .mgz file; it is encoded as the real world (RAS) coordinates of the target location for each voxel. + pattern: "*_forward_field.nii.gz" + + - bak_field: + type: file + description: this is the file where the backward deformation field is written. It must also be a nifty or mgz file. + pattern: "*_backward_field.nii.gz" + - versions: type: file description: File containing software versions pattern: "versions.yml" - - - output: - type: file - description: - pattern: authors: - "@ThoumyreStanislas" diff --git a/modules/nf-scil/registration/easyreg/tests/main.nf.test b/modules/nf-scil/registration/easyreg/tests/main.nf.test index 98c74351..b461ae9b 100644 --- a/modules/nf-scil/registration/easyreg/tests/main.nf.test +++ b/modules/nf-scil/registration/easyreg/tests/main.nf.test @@ -1,5 +1,3 @@ -// TODO nf-core: Once you have added the required tests, please run the following command to build this file: -// nf-core modules test registration/easyreg nextflow_process { name "Test Process REGISTRATION_EASYREG" @@ -11,64 +9,42 @@ nextflow_process { tag "registration" tag "registration/easyreg" - // TODO nf-core: Change the test name preferably indicating the test-data and file-format used - test("sarscov2 - bam") { - - // TODO nf-core: If you are created a test for a chained module - // (the module requires running more than one process to generate the required output) - // add the 'setup' method here. - // You can find more information about how to use a 'setup' method in the docs (https://nf-co.re/docs/contributing/modules#steps-for-creating-nf-test-for-chained-modules). - - when { - process { - """ - // TODO nf-core: define inputs of the process here. Example: - - input[0] = [ - [ id:'test', single_end:false ], // meta map - file(params.test_data['sarscov2']['illumina']['test_paired_end_bam'], checkIfExists: true) - ] - """ + tag "subworkflows" + tag "subworkflows/load_test_data" + + setup { + run("LOAD_TEST_DATA", alias: "LOAD_DATA") { + script "../../../../../subworkflows/nf-scil/load_test_data/main.nf" + process { + """ + input[0] = Channel.from( [ "others.zip" ] ) + input[1] = "test.load-test-data" + """ + } } } - then { - assertAll( - { assert process.success }, - { assert snapshot(process.out).match() } - //TODO nf-core: Add all required assertions to verify the test output. - // See https://nf-co.re/docs/contributing/tutorials/nf-test_assertions for more information and examples. - ) - } - - } - - // TODO nf-core: Change the test name preferably indicating the test-data and file-format used but keep the " - stub" suffix. - test("sarscov2 - bam - stub") { - - options "-stub" - + test("registration - easyreg") { + config "./nextflow.config" when { process { """ - // TODO nf-core: define inputs of the process here. Example: - - input[0] = [ - [ id:'test', single_end:false ], // meta map - file(params.test_data['sarscov2']['illumina']['test_paired_end_bam'], checkIfExists: true) - ] + input[0] = LOAD_DATA.out.test_data_directory + .map{ test_data_directory -> [ + [ id:'test', single_end:false ], + file("\${test_data_directory}/t1_crop.nii.gz"), + file("\${test_data_directory}/t1_resample.nii.gz"), + [], + [] + ]} """ } } - then { assertAll( { assert process.success }, { assert snapshot(process.out).match() } - //TODO nf-core: Add all required assertions to verify the test output. ) } - } - } diff --git a/modules/nf-scil/registration/easyreg/tests/main.nf.test.snap b/modules/nf-scil/registration/easyreg/tests/main.nf.test.snap new file mode 100644 index 00000000..a7196a26 --- /dev/null +++ b/modules/nf-scil/registration/easyreg/tests/main.nf.test.snap @@ -0,0 +1,55 @@ +{ + "registration - easyreg": { + "content": [ + { + "0": [ + + ], + "1": [ + + ], + "2": [ + + ], + "3": [ + + ], + "4": [ + + ], + "5": [ + + ], + "6": [ + + ], + "bak_field": [ + + ], + "flo_reg": [ + + ], + "flo_seg": [ + + ], + "fwd_field": [ + + ], + "ref_reg": [ + + ], + "ref_seg": [ + + ], + "versions": [ + + ] + } + ], + "meta": { + "nf-test": "0.9.0-rc1", + "nextflow": "24.04.3" + }, + "timestamp": "2024-07-12T20:08:25.376075" + } +} \ No newline at end of file diff --git a/modules/nf-scil/registration/easyreg/tests/nextflow.config b/modules/nf-scil/registration/easyreg/tests/nextflow.config new file mode 100644 index 00000000..1ad29ffa --- /dev/null +++ b/modules/nf-scil/registration/easyreg/tests/nextflow.config @@ -0,0 +1,6 @@ +process { + withName: "REGISTRATION_EASYREG" { + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } + ext.field = true + } +} From 48698053b9605c8d51d7fcd163b40f8ae397f6e5 Mon Sep 17 00:00:00 2001 From: Thoumyre Stanislas Date: Mon, 15 Jul 2024 12:55:01 +0000 Subject: [PATCH 03/35] description fix --- modules/nf-scil/registration/easyreg/meta.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/nf-scil/registration/easyreg/meta.yml b/modules/nf-scil/registration/easyreg/meta.yml index fc4c91e7..89a46b48 100644 --- a/modules/nf-scil/registration/easyreg/meta.yml +++ b/modules/nf-scil/registration/easyreg/meta.yml @@ -1,6 +1,6 @@ --- name: "registration_easyreg" -description: Image registration and gray matter segmentation with easyreg from freesurfer +description: Image registration and SynthSeg v2 segmentation with easyreg from freesurfer keywords: - nifti - registration From 83293415b0bbb028ba0053d912bbabc07977223d Mon Sep 17 00:00:00 2001 From: Thoumyre Stanislas Date: Mon, 15 Jul 2024 12:55:52 +0000 Subject: [PATCH 04/35] prettier fix --- modules/nf-scil/registration/easyreg/meta.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/modules/nf-scil/registration/easyreg/meta.yml b/modules/nf-scil/registration/easyreg/meta.yml index 89a46b48..950a770a 100644 --- a/modules/nf-scil/registration/easyreg/meta.yml +++ b/modules/nf-scil/registration/easyreg/meta.yml @@ -26,20 +26,18 @@ input: - floating: type: file - description: the floating image in .nii(.gz) or .mgz format. + description: the floating image in .nii(.gz) or .mgz format. pattern: "*.{nii,nii.gz,mgz}" - ref_segmentation: type: file - description: - file with the SynthSeg v2 (non-robust) segmentation + parcellation of the reference image. + description: file with the SynthSeg v2 (non-robust) segmentation + parcellation of the reference image. If it does not exist, EasyReg will create it. If it already exists (e.g., from a previous EasyReg run), then EasyReg will read it from disk (which is faster than segmenting). pattern: "*.{nii,nii.gz}" - flo_segmentation: type: file - description: - file with the SynthSeg v2 (non-robust) segmentation + parcellation of the floating image. + description: file with the SynthSeg v2 (non-robust) segmentation + parcellation of the floating image. If it does not exist, EasyReg will create it. If it already exists (e.g., from a previous EasyReg run), then EasyReg will read it from disk (which is faster than segmenting). pattern: "*.{nii,nii.gz}" From a548425b18ae7a8b96545eb68419ab4329583c31 Mon Sep 17 00:00:00 2001 From: Thoumyre Stanislas Date: Wed, 17 Jul 2024 12:24:37 +0000 Subject: [PATCH 05/35] fix environment.yml --- modules/nf-scil/registration/easyreg/environment.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/nf-scil/registration/easyreg/environment.yml b/modules/nf-scil/registration/easyreg/environment.yml index 15ba99f2..6b1ae190 100644 --- a/modules/nf-scil/registration/easyreg/environment.yml +++ b/modules/nf-scil/registration/easyreg/environment.yml @@ -1,5 +1,3 @@ ---- -# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json name: "registration_easyreg" channels: - Docker From 0cf94afe34f83bf823c35cae96e0ccd019ca6d09 Mon Sep 17 00:00:00 2001 From: Thoumyre Stanislas Date: Thu, 25 Jul 2024 20:44:27 +0000 Subject: [PATCH 06/35] add container freesurfer 7.4.1 --- modules/nf-scil/registration/easyreg/main.nf | 23 ++-- .../easyreg/tests/main.nf.test.snap | 102 +++++++++++++++--- .../easyreg/tests/nextflow.config | 1 + 3 files changed, 99 insertions(+), 27 deletions(-) diff --git a/modules/nf-scil/registration/easyreg/main.nf b/modules/nf-scil/registration/easyreg/main.nf index 0d3f6496..bd9a16c6 100644 --- a/modules/nf-scil/registration/easyreg/main.nf +++ b/modules/nf-scil/registration/easyreg/main.nf @@ -4,20 +4,19 @@ process REGISTRATION_EASYREG { tag "$meta.id" label 'process_single' - container "freesurfer/synthstrip:latest" - containerOptions "--entrypoint ''" + container "freesurfer/freesurfer:7.4.1" input: tuple val(meta), path(reference), path(floating), path(ref_segmentation), path(flo_segmentation) output: - tuple val(meta), path("${prefix}_reference_segmentation.nii.gz") , emit: ref_seg - tuple val(meta), path("${prefix}_floating_segmentation.nii.gz") , emit: flo_seg - tuple val(meta), path("${prefix}_reference_registered.nii.gz") , emit: ref_reg - tuple val(meta), path("${prefix}_floating_registered.nii.gz") , emit: flo_reg - tuple val(meta), path("${prefix}_forward_field.nii.gz") , emit: fwd_field - tuple val(meta), path("${prefix}_backward_field.nii.gz") , emit: bak_field - path "versions.yml" , emit: versions + tuple val(meta), path("*_reference_segmentation.nii.gz") , emit: ref_seg + tuple val(meta), path("*_floating_segmentation.nii.gz") , emit: flo_seg + tuple val(meta), path("*_reference_registered.nii.gz") , emit: ref_reg + tuple val(meta), path("*_floating_registered.nii.gz") , emit: flo_reg + tuple val(meta), path("*_forward_field.nii.gz") , emit: fwd_field, optional: true + tuple val(meta), path("*_backward_field.nii.gz") , emit: bak_field, optional: true + path "versions.yml" , emit: versions when: task.ext.when == null || task.ext.when @@ -43,12 +42,12 @@ process REGISTRATION_EASYREG { floating_segmentation="${prefix}_floating_segmentation.nii.gz" fi - mri_easyreg --ref $reference --flo $floating --ref_seg \${reference_segmentation} --flo_seg --ref_seg \${reference_segmentation} \ + mri_easyreg --ref $reference --flo $floating --ref_seg \${reference_segmentation} --flo_seg \${floating_segmentation} \ --flo_reg ${prefix}_floating_registered.nii.gz --ref_reg ${prefix}_reference_registered.nii.gz $field $threads $affine cat <<-END_VERSIONS > versions.yml "${task.process}": - freesurfer: 7.4 + freesurfer: 7.4.1 END_VERSIONS """ @@ -67,7 +66,7 @@ process REGISTRATION_EASYREG { cat <<-END_VERSIONS > versions.yml "${task.process}": - freesurfer: 7.4 + freesurfer: 7.4.1 END_VERSIONS """ } diff --git a/modules/nf-scil/registration/easyreg/tests/main.nf.test.snap b/modules/nf-scil/registration/easyreg/tests/main.nf.test.snap index a7196a26..d559d1d5 100644 --- a/modules/nf-scil/registration/easyreg/tests/main.nf.test.snap +++ b/modules/nf-scil/registration/easyreg/tests/main.nf.test.snap @@ -3,46 +3,118 @@ "content": [ { "0": [ - + [ + { + "id": "test", + "single_end": false + }, + "test_reference_segmentation.nii.gz:md5,aeac0f1cf19381a7f40464408dc6b9e9" + ] ], "1": [ - + [ + { + "id": "test", + "single_end": false + }, + "test_floating_segmentation.nii.gz:md5,c895e33807532642f197806b230aaa79" + ] ], "2": [ - + [ + { + "id": "test", + "single_end": false + }, + "test_reference_registered.nii.gz:md5,cfaa3b3c6d30d25ef0b8dd5c6ecce0e4" + ] ], "3": [ - + [ + { + "id": "test", + "single_end": false + }, + "test_floating_registered.nii.gz:md5,817e5d3913acdfe1176889ee8566f714" + ] ], "4": [ - + [ + { + "id": "test", + "single_end": false + }, + "test_forward_field.nii.gz:md5,76e3ffa48bf6ba1b97d7e782e20686b8" + ] ], "5": [ - + [ + { + "id": "test", + "single_end": false + }, + "test_backward_field.nii.gz:md5,99b2624aecaa1d0fe3e0633eab433344" + ] ], "6": [ - + "versions.yml:md5,4661210880c42a986923e8257f64c760" ], "bak_field": [ - + [ + { + "id": "test", + "single_end": false + }, + "test_backward_field.nii.gz:md5,99b2624aecaa1d0fe3e0633eab433344" + ] ], "flo_reg": [ - + [ + { + "id": "test", + "single_end": false + }, + "test_floating_registered.nii.gz:md5,817e5d3913acdfe1176889ee8566f714" + ] ], "flo_seg": [ - + [ + { + "id": "test", + "single_end": false + }, + "test_floating_segmentation.nii.gz:md5,c895e33807532642f197806b230aaa79" + ] ], "fwd_field": [ - + [ + { + "id": "test", + "single_end": false + }, + "test_forward_field.nii.gz:md5,76e3ffa48bf6ba1b97d7e782e20686b8" + ] ], "ref_reg": [ - + [ + { + "id": "test", + "single_end": false + }, + "test_reference_registered.nii.gz:md5,cfaa3b3c6d30d25ef0b8dd5c6ecce0e4" + ] ], "ref_seg": [ - + [ + { + "id": "test", + "single_end": false + }, + "test_reference_segmentation.nii.gz:md5,aeac0f1cf19381a7f40464408dc6b9e9" + ] ], "versions": [ - + "versions.yml:md5,4661210880c42a986923e8257f64c760" ] } ], @@ -50,6 +122,6 @@ "nf-test": "0.9.0-rc1", "nextflow": "24.04.3" }, - "timestamp": "2024-07-12T20:08:25.376075" + "timestamp": "2024-07-25T20:31:22.056733" } } \ No newline at end of file diff --git a/modules/nf-scil/registration/easyreg/tests/nextflow.config b/modules/nf-scil/registration/easyreg/tests/nextflow.config index 1ad29ffa..7b5ec24c 100644 --- a/modules/nf-scil/registration/easyreg/tests/nextflow.config +++ b/modules/nf-scil/registration/easyreg/tests/nextflow.config @@ -2,5 +2,6 @@ process { withName: "REGISTRATION_EASYREG" { publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } ext.field = true + memory = 10.GB } } From b0a170c5a7eeea8b53a6c4bc9bafed81e5957b75 Mon Sep 17 00:00:00 2001 From: Thoumyre Stanislas Date: Mon, 29 Jul 2024 16:03:30 +0000 Subject: [PATCH 07/35] change_memory_capacity --- modules/nf-scil/registration/easyreg/tests/nextflow.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/nf-scil/registration/easyreg/tests/nextflow.config b/modules/nf-scil/registration/easyreg/tests/nextflow.config index 7b5ec24c..47569e12 100644 --- a/modules/nf-scil/registration/easyreg/tests/nextflow.config +++ b/modules/nf-scil/registration/easyreg/tests/nextflow.config @@ -2,6 +2,6 @@ process { withName: "REGISTRATION_EASYREG" { publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } ext.field = true - memory = 10.GB + memory = 12.GB } } From 1b509cf58dbaf9dbbde1484665af37e2d863a90a Mon Sep 17 00:00:00 2001 From: Thoumyre Stanislas Date: Mon, 29 Jul 2024 16:19:32 +0000 Subject: [PATCH 08/35] reset 10gb memory --- modules/nf-scil/registration/easyreg/tests/nextflow.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/nf-scil/registration/easyreg/tests/nextflow.config b/modules/nf-scil/registration/easyreg/tests/nextflow.config index 47569e12..7b5ec24c 100644 --- a/modules/nf-scil/registration/easyreg/tests/nextflow.config +++ b/modules/nf-scil/registration/easyreg/tests/nextflow.config @@ -2,6 +2,6 @@ process { withName: "REGISTRATION_EASYREG" { publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } ext.field = true - memory = 12.GB + memory = 10.GB } } From 06aa488c2a27ae156b99216f7660711fed03d572 Mon Sep 17 00:00:00 2001 From: Thoumyre Stanislas Date: Mon, 29 Jul 2024 16:22:54 +0000 Subject: [PATCH 09/35] last_fix_memory --- modules/nf-scil/registration/easyreg/main.nf | 1 + modules/nf-scil/registration/easyreg/tests/nextflow.config | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/nf-scil/registration/easyreg/main.nf b/modules/nf-scil/registration/easyreg/main.nf index bd9a16c6..8ec4cd9c 100644 --- a/modules/nf-scil/registration/easyreg/main.nf +++ b/modules/nf-scil/registration/easyreg/main.nf @@ -3,6 +3,7 @@ process REGISTRATION_EASYREG { tag "$meta.id" label 'process_single' + label 'process_high' container "freesurfer/freesurfer:7.4.1" diff --git a/modules/nf-scil/registration/easyreg/tests/nextflow.config b/modules/nf-scil/registration/easyreg/tests/nextflow.config index 7b5ec24c..1ad29ffa 100644 --- a/modules/nf-scil/registration/easyreg/tests/nextflow.config +++ b/modules/nf-scil/registration/easyreg/tests/nextflow.config @@ -2,6 +2,5 @@ process { withName: "REGISTRATION_EASYREG" { publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } ext.field = true - memory = 10.GB } } From 346c0f94f8928f29fad3b62a178355db3ce38b25 Mon Sep 17 00:00:00 2001 From: Thoumyre Stanislas Date: Thu, 29 Aug 2024 19:11:57 +0000 Subject: [PATCH 10/35] add memory and change runner --- .github/workflows/checks.yml | 6 +++--- .../nf-scil/registration/easyreg/tests/main.nf.test.snap | 4 ++-- modules/nf-scil/registration/easyreg/tests/nextflow.config | 1 + 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 404dca20..cb254c28 100755 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -121,10 +121,10 @@ jobs: fail-fast: false matrix: path: [ "${{ fromJson(needs.nf-test-changes.outputs.paths) }}" ] - profile: ["docker"] - runner: ["scilus-nf-scil-runners"] include: - - runner: "scilus-nf-scil-bigmem-runners" + - profile: docker + - runner: scilus-nf-scil-runners + - runner: scilus-nf-scil-bigmem-runners path: modules/nf-scil/registration/easyreg exclude: - path: subworkflows/nf-scil/load_test_data diff --git a/modules/nf-scil/registration/easyreg/tests/main.nf.test.snap b/modules/nf-scil/registration/easyreg/tests/main.nf.test.snap index d559d1d5..97e15b31 100644 --- a/modules/nf-scil/registration/easyreg/tests/main.nf.test.snap +++ b/modules/nf-scil/registration/easyreg/tests/main.nf.test.snap @@ -120,8 +120,8 @@ ], "meta": { "nf-test": "0.9.0-rc1", - "nextflow": "24.04.3" + "nextflow": "24.04.4" }, - "timestamp": "2024-07-25T20:31:22.056733" + "timestamp": "2024-08-29T18:36:12.752289" } } \ No newline at end of file diff --git a/modules/nf-scil/registration/easyreg/tests/nextflow.config b/modules/nf-scil/registration/easyreg/tests/nextflow.config index 1ad29ffa..6b359bfe 100644 --- a/modules/nf-scil/registration/easyreg/tests/nextflow.config +++ b/modules/nf-scil/registration/easyreg/tests/nextflow.config @@ -1,4 +1,5 @@ process { + memory = '10G' withName: "REGISTRATION_EASYREG" { publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } ext.field = true From a46eab071a4b7bb53f829be7f7e97dd397e949ad Mon Sep 17 00:00:00 2001 From: Thoumyre Stanislas Date: Thu, 11 Jul 2024 19:44:53 +0000 Subject: [PATCH 11/35] add module easyreg --- .../registration/easyreg/environment.yml | 9 +++ modules/nf-scil/registration/easyreg/main.nf | 74 +++++++++++++++++++ modules/nf-scil/registration/easyreg/meta.yml | 53 +++++++++++++ .../registration/easyreg/tests/main.nf.test | 74 +++++++++++++++++++ .../registration/easyreg/tests/tags.yml | 2 + 5 files changed, 212 insertions(+) create mode 100644 modules/nf-scil/registration/easyreg/environment.yml create mode 100644 modules/nf-scil/registration/easyreg/main.nf create mode 100644 modules/nf-scil/registration/easyreg/meta.yml create mode 100644 modules/nf-scil/registration/easyreg/tests/main.nf.test create mode 100644 modules/nf-scil/registration/easyreg/tests/tags.yml diff --git a/modules/nf-scil/registration/easyreg/environment.yml b/modules/nf-scil/registration/easyreg/environment.yml new file mode 100644 index 00000000..8fd3a56f --- /dev/null +++ b/modules/nf-scil/registration/easyreg/environment.yml @@ -0,0 +1,9 @@ +--- +# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json +name: "registration_easyreg" +channels: + - conda-forge + - bioconda + - defaults +dependencies: + - "YOUR-TOOL-HERE" diff --git a/modules/nf-scil/registration/easyreg/main.nf b/modules/nf-scil/registration/easyreg/main.nf new file mode 100644 index 00000000..1e606c6e --- /dev/null +++ b/modules/nf-scil/registration/easyreg/main.nf @@ -0,0 +1,74 @@ + + +process REGISTRATION_EASYREG { + tag "$meta.id" + label 'process_single' + + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://scil.usherbrooke.ca/containers/scilus_2.0.2.sif': + 'scilus/scilus:2.0.2' }" + + input: + tuple val(meta), path(reference), path(floating), path(ref_segmentation), path(flo_segmentation) + + output: + tuple val(meta), path("${prefix}_reference_segmentation.nii.gz") , emit: ref_seg + tuple val(meta), path("${prefix}_floating_segmentation.nii.gz") , emit: flo_seg + tuple val(meta), path("${prefix}_reference_registered.nii.gz") , emit: ref_reg + tuple val(meta), path("${prefix}_floating_registered.nii.gz") , emit: flo_reg + tuple val(meta), path("${prefix}_forward_field.nii.gz") , emit: fwd_field + tuple val(meta), path("${prefix}_backward_field.nii.gz") , emit: bak_field + path "versions.yml" , emit: versions + + when: + task.ext.when == null || task.ext.when + + script: + def prefix = task.ext.prefix ?: "${meta.id}" + def threads = task.ext.threads ? "--threads " + task.ext.threads : "" + def affine = task.ext.affine ? "--affine_only " : "" + + """ + if [[ -f "$ref_segmentation" ]]; + then + reference_segmentation = $ref_segmentation + else + reference_segmentation = ${prefix}_reference_segmentation.nii.gz + fi + + if [[ -f "$flo_segmentation" ]]; + then + floating_segmentation = $flo_segmentation + else + floating_segmentation = ${prefix}_floating_segmentation.nii.gz + fi + + mri_easyreg --ref $reference --flo $floating --ref_seg \${reference_segmentation} --flo_seg --ref_seg \${reference_segmentation} \ + --flo_reg ${prefix}_floating_registered.nii.gz --ref_reg ${prefix}_reference_registered.nii.gz --fwd_field ${prefix}_forward_field.nii.gz \ + --bak_field ${prefix}_backward_field.nii.gz $threads $affine + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + freesurfer: 7.4 + END_VERSIONS + """ + + stub: + def prefix = task.ext.prefix ?: "${meta.id}" + + """ + mri_easyreg -h + + touch ${prefix}_reference_segmentation.nii.gz + touch ${prefix}_floating_segmentation.nii.gz + touch ${prefix}_reference_registered.nii.gz + touch ${prefix}_floating_registered.nii.gz + touch ${prefix}_forward_field.nii.gz + touch ${prefix}_backward_field.nii.gz + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + freesurfer: 7.4 + END_VERSIONS + """ +} diff --git a/modules/nf-scil/registration/easyreg/meta.yml b/modules/nf-scil/registration/easyreg/meta.yml new file mode 100644 index 00000000..41bbc2f1 --- /dev/null +++ b/modules/nf-scil/registration/easyreg/meta.yml @@ -0,0 +1,53 @@ +--- +# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json +name: "registration_easyreg" +description: write your description here +keywords: + - sort + - example + - genomics +tools: + - "registration": + description: "" + homepage: "" + documentation: "" + tool_dev_url: "" + doi: "" + licence: + +input: + # Only when we have meta + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'sample1', single_end:false ]` + + + - input: + type: file + description: + pattern: + +output: + #Only when we have meta + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'sample1', single_end:false ]` + + - versions: + type: file + description: File containing software versions + pattern: "versions.yml" + + - output: + type: file + description: + pattern: + +authors: + - "@ThoumyreStanislas" +maintainers: + - "@ThoumyreStanislas" diff --git a/modules/nf-scil/registration/easyreg/tests/main.nf.test b/modules/nf-scil/registration/easyreg/tests/main.nf.test new file mode 100644 index 00000000..98c74351 --- /dev/null +++ b/modules/nf-scil/registration/easyreg/tests/main.nf.test @@ -0,0 +1,74 @@ +// TODO nf-core: Once you have added the required tests, please run the following command to build this file: +// nf-core modules test registration/easyreg +nextflow_process { + + name "Test Process REGISTRATION_EASYREG" + script "../main.nf" + process "REGISTRATION_EASYREG" + + tag "modules" + tag "modules_nfcore" + tag "registration" + tag "registration/easyreg" + + // TODO nf-core: Change the test name preferably indicating the test-data and file-format used + test("sarscov2 - bam") { + + // TODO nf-core: If you are created a test for a chained module + // (the module requires running more than one process to generate the required output) + // add the 'setup' method here. + // You can find more information about how to use a 'setup' method in the docs (https://nf-co.re/docs/contributing/modules#steps-for-creating-nf-test-for-chained-modules). + + when { + process { + """ + // TODO nf-core: define inputs of the process here. Example: + + input[0] = [ + [ id:'test', single_end:false ], // meta map + file(params.test_data['sarscov2']['illumina']['test_paired_end_bam'], checkIfExists: true) + ] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + //TODO nf-core: Add all required assertions to verify the test output. + // See https://nf-co.re/docs/contributing/tutorials/nf-test_assertions for more information and examples. + ) + } + + } + + // TODO nf-core: Change the test name preferably indicating the test-data and file-format used but keep the " - stub" suffix. + test("sarscov2 - bam - stub") { + + options "-stub" + + when { + process { + """ + // TODO nf-core: define inputs of the process here. Example: + + input[0] = [ + [ id:'test', single_end:false ], // meta map + file(params.test_data['sarscov2']['illumina']['test_paired_end_bam'], checkIfExists: true) + ] + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + //TODO nf-core: Add all required assertions to verify the test output. + ) + } + + } + +} diff --git a/modules/nf-scil/registration/easyreg/tests/tags.yml b/modules/nf-scil/registration/easyreg/tests/tags.yml new file mode 100644 index 00000000..14d95af4 --- /dev/null +++ b/modules/nf-scil/registration/easyreg/tests/tags.yml @@ -0,0 +1,2 @@ +registration/easyreg: + - "modules/nf-scil/registration/easyreg/**" From 1725e3316797028d9b4eb987cec56f2493cbf050 Mon Sep 17 00:00:00 2001 From: Thoumyre Stanislas Date: Mon, 15 Jul 2024 12:33:27 +0000 Subject: [PATCH 12/35] complete module easyreg --- .../registration/easyreg/environment.yml | 7 +- modules/nf-scil/registration/easyreg/main.nf | 17 ++-- modules/nf-scil/registration/easyreg/meta.yml | 90 +++++++++++++------ .../registration/easyreg/tests/main.nf.test | 68 +++++--------- .../easyreg/tests/main.nf.test.snap | 55 ++++++++++++ .../easyreg/tests/nextflow.config | 6 ++ 6 files changed, 159 insertions(+), 84 deletions(-) create mode 100644 modules/nf-scil/registration/easyreg/tests/main.nf.test.snap create mode 100644 modules/nf-scil/registration/easyreg/tests/nextflow.config diff --git a/modules/nf-scil/registration/easyreg/environment.yml b/modules/nf-scil/registration/easyreg/environment.yml index 8fd3a56f..15ba99f2 100644 --- a/modules/nf-scil/registration/easyreg/environment.yml +++ b/modules/nf-scil/registration/easyreg/environment.yml @@ -2,8 +2,7 @@ # yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json name: "registration_easyreg" channels: - - conda-forge - - bioconda - - defaults + - Docker + - Apptainer dependencies: - - "YOUR-TOOL-HERE" + - "Freesurfer" diff --git a/modules/nf-scil/registration/easyreg/main.nf b/modules/nf-scil/registration/easyreg/main.nf index 1e606c6e..0d3f6496 100644 --- a/modules/nf-scil/registration/easyreg/main.nf +++ b/modules/nf-scil/registration/easyreg/main.nf @@ -4,9 +4,8 @@ process REGISTRATION_EASYREG { tag "$meta.id" label 'process_single' - container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? - 'https://scil.usherbrooke.ca/containers/scilus_2.0.2.sif': - 'scilus/scilus:2.0.2' }" + container "freesurfer/synthstrip:latest" + containerOptions "--entrypoint ''" input: tuple val(meta), path(reference), path(floating), path(ref_segmentation), path(flo_segmentation) @@ -25,27 +24,27 @@ process REGISTRATION_EASYREG { script: def prefix = task.ext.prefix ?: "${meta.id}" + def field = task.ext.field ? "--fwd_field ${prefix}_forward_field.nii.gz --bak_field ${prefix}_backward_field.nii.gz " : "" def threads = task.ext.threads ? "--threads " + task.ext.threads : "" def affine = task.ext.affine ? "--affine_only " : "" """ if [[ -f "$ref_segmentation" ]]; then - reference_segmentation = $ref_segmentation + reference_segmentation=$ref_segmentation else - reference_segmentation = ${prefix}_reference_segmentation.nii.gz + reference_segmentation="${prefix}_reference_segmentation.nii.gz" fi if [[ -f "$flo_segmentation" ]]; then - floating_segmentation = $flo_segmentation + floating_segmentation=$flo_segmentation else - floating_segmentation = ${prefix}_floating_segmentation.nii.gz + floating_segmentation="${prefix}_floating_segmentation.nii.gz" fi mri_easyreg --ref $reference --flo $floating --ref_seg \${reference_segmentation} --flo_seg --ref_seg \${reference_segmentation} \ - --flo_reg ${prefix}_floating_registered.nii.gz --ref_reg ${prefix}_reference_registered.nii.gz --fwd_field ${prefix}_forward_field.nii.gz \ - --bak_field ${prefix}_backward_field.nii.gz $threads $affine + --flo_reg ${prefix}_floating_registered.nii.gz --ref_reg ${prefix}_reference_registered.nii.gz $field $threads $affine cat <<-END_VERSIONS > versions.yml "${task.process}": diff --git a/modules/nf-scil/registration/easyreg/meta.yml b/modules/nf-scil/registration/easyreg/meta.yml index 41bbc2f1..fc4c91e7 100644 --- a/modules/nf-scil/registration/easyreg/meta.yml +++ b/modules/nf-scil/registration/easyreg/meta.yml @@ -1,51 +1,91 @@ --- -# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json name: "registration_easyreg" -description: write your description here +description: Image registration and gray matter segmentation with easyreg from freesurfer keywords: - - sort - - example - - genomics + - nifti + - registration + - segmentation + - easyreg + - freesurfer tools: - - "registration": - description: "" - homepage: "" - documentation: "" - tool_dev_url: "" - doi: "" - licence: + - "Freesurfer": + description: "Software package for the analysis and visualization of structural and functional neuroimaging data." + homepage: "https://surfer.nmr.mgh.harvard.edu/fswiki" input: - # Only when we have meta - meta: type: map description: | Groovy Map containing sample information e.g. `[ id:'sample1', single_end:false ]` - - - - input: + + - reference: + type: file + description: the reference image in .nii(.gz) or .mgz format (note that, since the method is symmetric, the choice of reference vs floating is arbitrary). + pattern: "*.{nii,nii.gz,mgz}" + + - floating: type: file - description: - pattern: + description: the floating image in .nii(.gz) or .mgz format. + pattern: "*.{nii,nii.gz,mgz}" + + - ref_segmentation: + type: file + description: + file with the SynthSeg v2 (non-robust) segmentation + parcellation of the reference image. + If it does not exist, EasyReg will create it. If it already exists (e.g., from a previous EasyReg run), then EasyReg will read it from disk (which is faster than segmenting). + pattern: "*.{nii,nii.gz}" + + - flo_segmentation: + type: file + description: + file with the SynthSeg v2 (non-robust) segmentation + parcellation of the floating image. + If it does not exist, EasyReg will create it. If it already exists (e.g., from a previous EasyReg run), then EasyReg will read it from disk (which is faster than segmenting). + pattern: "*.{nii,nii.gz}" output: - #Only when we have meta - meta: type: map description: | Groovy Map containing sample information e.g. `[ id:'sample1', single_end:false ]` - + + - ref_seg: + type: file + description: file with the SynthSeg v2 (non-robust) segmentation + parcellation of the reference image. + pattern: "*_reference_segmentation.nii.gz" + + - flo_seg: + type: file + description: file with the SynthSeg v2 (non-robust) segmentation + parcellation of the floating image. + pattern: "*_floating_segmentation.nii.gz" + + - ref_reg: + type: file + description: this is the file where the deformed (registered) reference image is written. + pattern: "*_reference_registered.nii.gz" + + - flo_reg: + type: file + description: this is the file where the deformed (registered) floating image is written. + pattern: "*_floating_registered.nii.gz" + + - fwd_field: + type: file + description: + this is the file where the forward deformation field is written. The deformation includes both the affine and nonlinear components. + Must be a nifti (.nii/.nii.gz) or .mgz file; it is encoded as the real world (RAS) coordinates of the target location for each voxel. + pattern: "*_forward_field.nii.gz" + + - bak_field: + type: file + description: this is the file where the backward deformation field is written. It must also be a nifty or mgz file. + pattern: "*_backward_field.nii.gz" + - versions: type: file description: File containing software versions pattern: "versions.yml" - - - output: - type: file - description: - pattern: authors: - "@ThoumyreStanislas" diff --git a/modules/nf-scil/registration/easyreg/tests/main.nf.test b/modules/nf-scil/registration/easyreg/tests/main.nf.test index 98c74351..b461ae9b 100644 --- a/modules/nf-scil/registration/easyreg/tests/main.nf.test +++ b/modules/nf-scil/registration/easyreg/tests/main.nf.test @@ -1,5 +1,3 @@ -// TODO nf-core: Once you have added the required tests, please run the following command to build this file: -// nf-core modules test registration/easyreg nextflow_process { name "Test Process REGISTRATION_EASYREG" @@ -11,64 +9,42 @@ nextflow_process { tag "registration" tag "registration/easyreg" - // TODO nf-core: Change the test name preferably indicating the test-data and file-format used - test("sarscov2 - bam") { - - // TODO nf-core: If you are created a test for a chained module - // (the module requires running more than one process to generate the required output) - // add the 'setup' method here. - // You can find more information about how to use a 'setup' method in the docs (https://nf-co.re/docs/contributing/modules#steps-for-creating-nf-test-for-chained-modules). - - when { - process { - """ - // TODO nf-core: define inputs of the process here. Example: - - input[0] = [ - [ id:'test', single_end:false ], // meta map - file(params.test_data['sarscov2']['illumina']['test_paired_end_bam'], checkIfExists: true) - ] - """ + tag "subworkflows" + tag "subworkflows/load_test_data" + + setup { + run("LOAD_TEST_DATA", alias: "LOAD_DATA") { + script "../../../../../subworkflows/nf-scil/load_test_data/main.nf" + process { + """ + input[0] = Channel.from( [ "others.zip" ] ) + input[1] = "test.load-test-data" + """ + } } } - then { - assertAll( - { assert process.success }, - { assert snapshot(process.out).match() } - //TODO nf-core: Add all required assertions to verify the test output. - // See https://nf-co.re/docs/contributing/tutorials/nf-test_assertions for more information and examples. - ) - } - - } - - // TODO nf-core: Change the test name preferably indicating the test-data and file-format used but keep the " - stub" suffix. - test("sarscov2 - bam - stub") { - - options "-stub" - + test("registration - easyreg") { + config "./nextflow.config" when { process { """ - // TODO nf-core: define inputs of the process here. Example: - - input[0] = [ - [ id:'test', single_end:false ], // meta map - file(params.test_data['sarscov2']['illumina']['test_paired_end_bam'], checkIfExists: true) - ] + input[0] = LOAD_DATA.out.test_data_directory + .map{ test_data_directory -> [ + [ id:'test', single_end:false ], + file("\${test_data_directory}/t1_crop.nii.gz"), + file("\${test_data_directory}/t1_resample.nii.gz"), + [], + [] + ]} """ } } - then { assertAll( { assert process.success }, { assert snapshot(process.out).match() } - //TODO nf-core: Add all required assertions to verify the test output. ) } - } - } diff --git a/modules/nf-scil/registration/easyreg/tests/main.nf.test.snap b/modules/nf-scil/registration/easyreg/tests/main.nf.test.snap new file mode 100644 index 00000000..a7196a26 --- /dev/null +++ b/modules/nf-scil/registration/easyreg/tests/main.nf.test.snap @@ -0,0 +1,55 @@ +{ + "registration - easyreg": { + "content": [ + { + "0": [ + + ], + "1": [ + + ], + "2": [ + + ], + "3": [ + + ], + "4": [ + + ], + "5": [ + + ], + "6": [ + + ], + "bak_field": [ + + ], + "flo_reg": [ + + ], + "flo_seg": [ + + ], + "fwd_field": [ + + ], + "ref_reg": [ + + ], + "ref_seg": [ + + ], + "versions": [ + + ] + } + ], + "meta": { + "nf-test": "0.9.0-rc1", + "nextflow": "24.04.3" + }, + "timestamp": "2024-07-12T20:08:25.376075" + } +} \ No newline at end of file diff --git a/modules/nf-scil/registration/easyreg/tests/nextflow.config b/modules/nf-scil/registration/easyreg/tests/nextflow.config new file mode 100644 index 00000000..1ad29ffa --- /dev/null +++ b/modules/nf-scil/registration/easyreg/tests/nextflow.config @@ -0,0 +1,6 @@ +process { + withName: "REGISTRATION_EASYREG" { + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } + ext.field = true + } +} From b8058ed73f0c0f4a6e9a0e296544b0e4c2791ef8 Mon Sep 17 00:00:00 2001 From: Thoumyre Stanislas Date: Mon, 15 Jul 2024 12:55:01 +0000 Subject: [PATCH 13/35] description fix --- modules/nf-scil/registration/easyreg/meta.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/nf-scil/registration/easyreg/meta.yml b/modules/nf-scil/registration/easyreg/meta.yml index fc4c91e7..89a46b48 100644 --- a/modules/nf-scil/registration/easyreg/meta.yml +++ b/modules/nf-scil/registration/easyreg/meta.yml @@ -1,6 +1,6 @@ --- name: "registration_easyreg" -description: Image registration and gray matter segmentation with easyreg from freesurfer +description: Image registration and SynthSeg v2 segmentation with easyreg from freesurfer keywords: - nifti - registration From ec38444ae8ef0bbc10d13be2f8d7b5cde0e0994d Mon Sep 17 00:00:00 2001 From: Thoumyre Stanislas Date: Mon, 15 Jul 2024 12:55:52 +0000 Subject: [PATCH 14/35] prettier fix --- modules/nf-scil/registration/easyreg/meta.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/modules/nf-scil/registration/easyreg/meta.yml b/modules/nf-scil/registration/easyreg/meta.yml index 89a46b48..950a770a 100644 --- a/modules/nf-scil/registration/easyreg/meta.yml +++ b/modules/nf-scil/registration/easyreg/meta.yml @@ -26,20 +26,18 @@ input: - floating: type: file - description: the floating image in .nii(.gz) or .mgz format. + description: the floating image in .nii(.gz) or .mgz format. pattern: "*.{nii,nii.gz,mgz}" - ref_segmentation: type: file - description: - file with the SynthSeg v2 (non-robust) segmentation + parcellation of the reference image. + description: file with the SynthSeg v2 (non-robust) segmentation + parcellation of the reference image. If it does not exist, EasyReg will create it. If it already exists (e.g., from a previous EasyReg run), then EasyReg will read it from disk (which is faster than segmenting). pattern: "*.{nii,nii.gz}" - flo_segmentation: type: file - description: - file with the SynthSeg v2 (non-robust) segmentation + parcellation of the floating image. + description: file with the SynthSeg v2 (non-robust) segmentation + parcellation of the floating image. If it does not exist, EasyReg will create it. If it already exists (e.g., from a previous EasyReg run), then EasyReg will read it from disk (which is faster than segmenting). pattern: "*.{nii,nii.gz}" From d70c93b939d0c3218ad38a757e9f03e5bfc171c5 Mon Sep 17 00:00:00 2001 From: Thoumyre Stanislas Date: Wed, 17 Jul 2024 12:24:37 +0000 Subject: [PATCH 15/35] fix environment.yml --- modules/nf-scil/registration/easyreg/environment.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/nf-scil/registration/easyreg/environment.yml b/modules/nf-scil/registration/easyreg/environment.yml index 15ba99f2..6b1ae190 100644 --- a/modules/nf-scil/registration/easyreg/environment.yml +++ b/modules/nf-scil/registration/easyreg/environment.yml @@ -1,5 +1,3 @@ ---- -# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json name: "registration_easyreg" channels: - Docker From f11140e238b148de22c5172d5711c3cd3e42d07f Mon Sep 17 00:00:00 2001 From: Thoumyre Stanislas Date: Thu, 25 Jul 2024 20:44:27 +0000 Subject: [PATCH 16/35] add container freesurfer 7.4.1 --- modules/nf-scil/registration/easyreg/main.nf | 23 ++-- .../easyreg/tests/main.nf.test.snap | 102 +++++++++++++++--- .../easyreg/tests/nextflow.config | 1 + 3 files changed, 99 insertions(+), 27 deletions(-) diff --git a/modules/nf-scil/registration/easyreg/main.nf b/modules/nf-scil/registration/easyreg/main.nf index 0d3f6496..bd9a16c6 100644 --- a/modules/nf-scil/registration/easyreg/main.nf +++ b/modules/nf-scil/registration/easyreg/main.nf @@ -4,20 +4,19 @@ process REGISTRATION_EASYREG { tag "$meta.id" label 'process_single' - container "freesurfer/synthstrip:latest" - containerOptions "--entrypoint ''" + container "freesurfer/freesurfer:7.4.1" input: tuple val(meta), path(reference), path(floating), path(ref_segmentation), path(flo_segmentation) output: - tuple val(meta), path("${prefix}_reference_segmentation.nii.gz") , emit: ref_seg - tuple val(meta), path("${prefix}_floating_segmentation.nii.gz") , emit: flo_seg - tuple val(meta), path("${prefix}_reference_registered.nii.gz") , emit: ref_reg - tuple val(meta), path("${prefix}_floating_registered.nii.gz") , emit: flo_reg - tuple val(meta), path("${prefix}_forward_field.nii.gz") , emit: fwd_field - tuple val(meta), path("${prefix}_backward_field.nii.gz") , emit: bak_field - path "versions.yml" , emit: versions + tuple val(meta), path("*_reference_segmentation.nii.gz") , emit: ref_seg + tuple val(meta), path("*_floating_segmentation.nii.gz") , emit: flo_seg + tuple val(meta), path("*_reference_registered.nii.gz") , emit: ref_reg + tuple val(meta), path("*_floating_registered.nii.gz") , emit: flo_reg + tuple val(meta), path("*_forward_field.nii.gz") , emit: fwd_field, optional: true + tuple val(meta), path("*_backward_field.nii.gz") , emit: bak_field, optional: true + path "versions.yml" , emit: versions when: task.ext.when == null || task.ext.when @@ -43,12 +42,12 @@ process REGISTRATION_EASYREG { floating_segmentation="${prefix}_floating_segmentation.nii.gz" fi - mri_easyreg --ref $reference --flo $floating --ref_seg \${reference_segmentation} --flo_seg --ref_seg \${reference_segmentation} \ + mri_easyreg --ref $reference --flo $floating --ref_seg \${reference_segmentation} --flo_seg \${floating_segmentation} \ --flo_reg ${prefix}_floating_registered.nii.gz --ref_reg ${prefix}_reference_registered.nii.gz $field $threads $affine cat <<-END_VERSIONS > versions.yml "${task.process}": - freesurfer: 7.4 + freesurfer: 7.4.1 END_VERSIONS """ @@ -67,7 +66,7 @@ process REGISTRATION_EASYREG { cat <<-END_VERSIONS > versions.yml "${task.process}": - freesurfer: 7.4 + freesurfer: 7.4.1 END_VERSIONS """ } diff --git a/modules/nf-scil/registration/easyreg/tests/main.nf.test.snap b/modules/nf-scil/registration/easyreg/tests/main.nf.test.snap index a7196a26..d559d1d5 100644 --- a/modules/nf-scil/registration/easyreg/tests/main.nf.test.snap +++ b/modules/nf-scil/registration/easyreg/tests/main.nf.test.snap @@ -3,46 +3,118 @@ "content": [ { "0": [ - + [ + { + "id": "test", + "single_end": false + }, + "test_reference_segmentation.nii.gz:md5,aeac0f1cf19381a7f40464408dc6b9e9" + ] ], "1": [ - + [ + { + "id": "test", + "single_end": false + }, + "test_floating_segmentation.nii.gz:md5,c895e33807532642f197806b230aaa79" + ] ], "2": [ - + [ + { + "id": "test", + "single_end": false + }, + "test_reference_registered.nii.gz:md5,cfaa3b3c6d30d25ef0b8dd5c6ecce0e4" + ] ], "3": [ - + [ + { + "id": "test", + "single_end": false + }, + "test_floating_registered.nii.gz:md5,817e5d3913acdfe1176889ee8566f714" + ] ], "4": [ - + [ + { + "id": "test", + "single_end": false + }, + "test_forward_field.nii.gz:md5,76e3ffa48bf6ba1b97d7e782e20686b8" + ] ], "5": [ - + [ + { + "id": "test", + "single_end": false + }, + "test_backward_field.nii.gz:md5,99b2624aecaa1d0fe3e0633eab433344" + ] ], "6": [ - + "versions.yml:md5,4661210880c42a986923e8257f64c760" ], "bak_field": [ - + [ + { + "id": "test", + "single_end": false + }, + "test_backward_field.nii.gz:md5,99b2624aecaa1d0fe3e0633eab433344" + ] ], "flo_reg": [ - + [ + { + "id": "test", + "single_end": false + }, + "test_floating_registered.nii.gz:md5,817e5d3913acdfe1176889ee8566f714" + ] ], "flo_seg": [ - + [ + { + "id": "test", + "single_end": false + }, + "test_floating_segmentation.nii.gz:md5,c895e33807532642f197806b230aaa79" + ] ], "fwd_field": [ - + [ + { + "id": "test", + "single_end": false + }, + "test_forward_field.nii.gz:md5,76e3ffa48bf6ba1b97d7e782e20686b8" + ] ], "ref_reg": [ - + [ + { + "id": "test", + "single_end": false + }, + "test_reference_registered.nii.gz:md5,cfaa3b3c6d30d25ef0b8dd5c6ecce0e4" + ] ], "ref_seg": [ - + [ + { + "id": "test", + "single_end": false + }, + "test_reference_segmentation.nii.gz:md5,aeac0f1cf19381a7f40464408dc6b9e9" + ] ], "versions": [ - + "versions.yml:md5,4661210880c42a986923e8257f64c760" ] } ], @@ -50,6 +122,6 @@ "nf-test": "0.9.0-rc1", "nextflow": "24.04.3" }, - "timestamp": "2024-07-12T20:08:25.376075" + "timestamp": "2024-07-25T20:31:22.056733" } } \ No newline at end of file diff --git a/modules/nf-scil/registration/easyreg/tests/nextflow.config b/modules/nf-scil/registration/easyreg/tests/nextflow.config index 1ad29ffa..7b5ec24c 100644 --- a/modules/nf-scil/registration/easyreg/tests/nextflow.config +++ b/modules/nf-scil/registration/easyreg/tests/nextflow.config @@ -2,5 +2,6 @@ process { withName: "REGISTRATION_EASYREG" { publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } ext.field = true + memory = 10.GB } } From 059c8223429d9205daac4112242d897c4bc72755 Mon Sep 17 00:00:00 2001 From: Thoumyre Stanislas Date: Mon, 29 Jul 2024 16:03:30 +0000 Subject: [PATCH 17/35] change_memory_capacity --- modules/nf-scil/registration/easyreg/tests/nextflow.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/nf-scil/registration/easyreg/tests/nextflow.config b/modules/nf-scil/registration/easyreg/tests/nextflow.config index 7b5ec24c..47569e12 100644 --- a/modules/nf-scil/registration/easyreg/tests/nextflow.config +++ b/modules/nf-scil/registration/easyreg/tests/nextflow.config @@ -2,6 +2,6 @@ process { withName: "REGISTRATION_EASYREG" { publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } ext.field = true - memory = 10.GB + memory = 12.GB } } From 5a02f0a531ec18ba942ea85f8a6613285bb4bc6e Mon Sep 17 00:00:00 2001 From: Thoumyre Stanislas Date: Mon, 29 Jul 2024 16:19:32 +0000 Subject: [PATCH 18/35] reset 10gb memory --- modules/nf-scil/registration/easyreg/tests/nextflow.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/nf-scil/registration/easyreg/tests/nextflow.config b/modules/nf-scil/registration/easyreg/tests/nextflow.config index 47569e12..7b5ec24c 100644 --- a/modules/nf-scil/registration/easyreg/tests/nextflow.config +++ b/modules/nf-scil/registration/easyreg/tests/nextflow.config @@ -2,6 +2,6 @@ process { withName: "REGISTRATION_EASYREG" { publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } ext.field = true - memory = 12.GB + memory = 10.GB } } From 6ed49cdce2f62525df022b937ef2f15e7e229826 Mon Sep 17 00:00:00 2001 From: Thoumyre Stanislas Date: Mon, 29 Jul 2024 16:22:54 +0000 Subject: [PATCH 19/35] last_fix_memory --- modules/nf-scil/registration/easyreg/main.nf | 1 + modules/nf-scil/registration/easyreg/tests/nextflow.config | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/nf-scil/registration/easyreg/main.nf b/modules/nf-scil/registration/easyreg/main.nf index bd9a16c6..8ec4cd9c 100644 --- a/modules/nf-scil/registration/easyreg/main.nf +++ b/modules/nf-scil/registration/easyreg/main.nf @@ -3,6 +3,7 @@ process REGISTRATION_EASYREG { tag "$meta.id" label 'process_single' + label 'process_high' container "freesurfer/freesurfer:7.4.1" diff --git a/modules/nf-scil/registration/easyreg/tests/nextflow.config b/modules/nf-scil/registration/easyreg/tests/nextflow.config index 7b5ec24c..1ad29ffa 100644 --- a/modules/nf-scil/registration/easyreg/tests/nextflow.config +++ b/modules/nf-scil/registration/easyreg/tests/nextflow.config @@ -2,6 +2,5 @@ process { withName: "REGISTRATION_EASYREG" { publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } ext.field = true - memory = 10.GB } } From 779d296f05bce0f4454ddb6821909d473718b85c Mon Sep 17 00:00:00 2001 From: Thoumyre Stanislas Date: Thu, 29 Aug 2024 19:11:57 +0000 Subject: [PATCH 20/35] add memory and change runner --- modules/nf-scil/registration/easyreg/tests/main.nf.test.snap | 4 ++-- modules/nf-scil/registration/easyreg/tests/nextflow.config | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/nf-scil/registration/easyreg/tests/main.nf.test.snap b/modules/nf-scil/registration/easyreg/tests/main.nf.test.snap index d559d1d5..97e15b31 100644 --- a/modules/nf-scil/registration/easyreg/tests/main.nf.test.snap +++ b/modules/nf-scil/registration/easyreg/tests/main.nf.test.snap @@ -120,8 +120,8 @@ ], "meta": { "nf-test": "0.9.0-rc1", - "nextflow": "24.04.3" + "nextflow": "24.04.4" }, - "timestamp": "2024-07-25T20:31:22.056733" + "timestamp": "2024-08-29T18:36:12.752289" } } \ No newline at end of file diff --git a/modules/nf-scil/registration/easyreg/tests/nextflow.config b/modules/nf-scil/registration/easyreg/tests/nextflow.config index 1ad29ffa..6b359bfe 100644 --- a/modules/nf-scil/registration/easyreg/tests/nextflow.config +++ b/modules/nf-scil/registration/easyreg/tests/nextflow.config @@ -1,4 +1,5 @@ process { + memory = '10G' withName: "REGISTRATION_EASYREG" { publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } ext.field = true From bc7484a7f265bbd6dc46fa7802a4369dd5b23d81 Mon Sep 17 00:00:00 2001 From: Thoumyre Stanislas Date: Tue, 3 Sep 2024 19:54:05 +0000 Subject: [PATCH 21/35] add plugin --- .../registration/easyreg/tests/main.nf.test | 10 +- .../easyreg/tests/main.nf.test.snap | 127 ++---------------- 2 files changed, 19 insertions(+), 118 deletions(-) diff --git a/modules/nf-scil/registration/easyreg/tests/main.nf.test b/modules/nf-scil/registration/easyreg/tests/main.nf.test index b461ae9b..699dcc33 100644 --- a/modules/nf-scil/registration/easyreg/tests/main.nf.test +++ b/modules/nf-scil/registration/easyreg/tests/main.nf.test @@ -43,7 +43,15 @@ nextflow_process { then { assertAll( { assert process.success }, - { assert snapshot(process.out).match() } + { assert snapshot( + niftiMD5SUM(process.out.ref_seg.get(0).get(1), 6), + niftiMD5SUM(process.out.flo_seg.get(0).get(1), 6), + niftiMD5SUM(process.out.ref_reg.get(0).get(1), 6), + niftiMD5SUM(process.out.flo_reg.get(0).get(1), 6), + niftiMD5SUM(process.out.fwd_field.get(0).get(1), 6), + niftiMD5SUM(process.out.bak_field.get(0).get(1), 6), + process.out.versions + ).match() } ) } } diff --git a/modules/nf-scil/registration/easyreg/tests/main.nf.test.snap b/modules/nf-scil/registration/easyreg/tests/main.nf.test.snap index 97e15b31..900c57ee 100644 --- a/modules/nf-scil/registration/easyreg/tests/main.nf.test.snap +++ b/modules/nf-scil/registration/easyreg/tests/main.nf.test.snap @@ -1,127 +1,20 @@ { "registration - easyreg": { "content": [ - { - "0": [ - [ - { - "id": "test", - "single_end": false - }, - "test_reference_segmentation.nii.gz:md5,aeac0f1cf19381a7f40464408dc6b9e9" - ] - ], - "1": [ - [ - { - "id": "test", - "single_end": false - }, - "test_floating_segmentation.nii.gz:md5,c895e33807532642f197806b230aaa79" - ] - ], - "2": [ - [ - { - "id": "test", - "single_end": false - }, - "test_reference_registered.nii.gz:md5,cfaa3b3c6d30d25ef0b8dd5c6ecce0e4" - ] - ], - "3": [ - [ - { - "id": "test", - "single_end": false - }, - "test_floating_registered.nii.gz:md5,817e5d3913acdfe1176889ee8566f714" - ] - ], - "4": [ - [ - { - "id": "test", - "single_end": false - }, - "test_forward_field.nii.gz:md5,76e3ffa48bf6ba1b97d7e782e20686b8" - ] - ], - "5": [ - [ - { - "id": "test", - "single_end": false - }, - "test_backward_field.nii.gz:md5,99b2624aecaa1d0fe3e0633eab433344" - ] - ], - "6": [ - "versions.yml:md5,4661210880c42a986923e8257f64c760" - ], - "bak_field": [ - [ - { - "id": "test", - "single_end": false - }, - "test_backward_field.nii.gz:md5,99b2624aecaa1d0fe3e0633eab433344" - ] - ], - "flo_reg": [ - [ - { - "id": "test", - "single_end": false - }, - "test_floating_registered.nii.gz:md5,817e5d3913acdfe1176889ee8566f714" - ] - ], - "flo_seg": [ - [ - { - "id": "test", - "single_end": false - }, - "test_floating_segmentation.nii.gz:md5,c895e33807532642f197806b230aaa79" - ] - ], - "fwd_field": [ - [ - { - "id": "test", - "single_end": false - }, - "test_forward_field.nii.gz:md5,76e3ffa48bf6ba1b97d7e782e20686b8" - ] - ], - "ref_reg": [ - [ - { - "id": "test", - "single_end": false - }, - "test_reference_registered.nii.gz:md5,cfaa3b3c6d30d25ef0b8dd5c6ecce0e4" - ] - ], - "ref_seg": [ - [ - { - "id": "test", - "single_end": false - }, - "test_reference_segmentation.nii.gz:md5,aeac0f1cf19381a7f40464408dc6b9e9" - ] - ], - "versions": [ - "versions.yml:md5,4661210880c42a986923e8257f64c760" - ] - } + "test_reference_segmentation.nii.gz:md5:header,d7d123ff54be81edabd50a08e6c0ef86,data,8043f2a051e6c31c80405fd2ae6b5c3d", + "test_floating_segmentation.nii.gz:md5:header,d773c9507f9637b269ff0293e5b571b6,data,9f90a28d360043b9a9a2f6caecd9d97f", + "test_reference_registered.nii.gz:md5:header,d1b4c1d6ea3958a942237859fc5c8bf9,data,db57287a4b6d1f2136e0f148a19a9afd", + "test_floating_registered.nii.gz:md5:header,5c6a53aecafb33aa215890c921911298,data,4bf56478dc20f15903c8933825a4d875", + "test_forward_field.nii.gz:md5:header,a44c016d46c40fb91d2b859a3452afe3,data,323c4eafea83b75bea61ec69b2911ae4", + "test_backward_field.nii.gz:md5:header,de97fc6763dae228667018a601d72f54,data,3991957cdd92a5519848eeb3cb30e949", + [ + "versions.yml:md5,4661210880c42a986923e8257f64c760" + ] ], "meta": { "nf-test": "0.9.0-rc1", "nextflow": "24.04.4" }, - "timestamp": "2024-08-29T18:36:12.752289" + "timestamp": "2024-09-03T19:44:38.393973" } } \ No newline at end of file From f29a9d06fd0e2e9281eaf86a1b8efe62e725f04e Mon Sep 17 00:00:00 2001 From: Thoumyre Stanislas Date: Fri, 6 Sep 2024 16:44:44 +0000 Subject: [PATCH 22/35] change data test --- .../registration/easyreg/tests/main.nf.test | 6 +++--- .../registration/easyreg/tests/main.nf.test.snap | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/modules/nf-scil/registration/easyreg/tests/main.nf.test b/modules/nf-scil/registration/easyreg/tests/main.nf.test index 699dcc33..904ee495 100644 --- a/modules/nf-scil/registration/easyreg/tests/main.nf.test +++ b/modules/nf-scil/registration/easyreg/tests/main.nf.test @@ -17,7 +17,7 @@ nextflow_process { script "../../../../../subworkflows/nf-scil/load_test_data/main.nf" process { """ - input[0] = Channel.from( [ "others.zip" ] ) + input[0] = Channel.from( [ "freesurfer.zip" ] ) input[1] = "test.load-test-data" """ } @@ -32,8 +32,8 @@ nextflow_process { input[0] = LOAD_DATA.out.test_data_directory .map{ test_data_directory -> [ [ id:'test', single_end:false ], - file("\${test_data_directory}/t1_crop.nii.gz"), - file("\${test_data_directory}/t1_resample.nii.gz"), + file("\${test_data_directory}/fa.nii.gz"), + file("\${test_data_directory}/t1.nii.gz"), [], [] ]} diff --git a/modules/nf-scil/registration/easyreg/tests/main.nf.test.snap b/modules/nf-scil/registration/easyreg/tests/main.nf.test.snap index 900c57ee..5504c8a2 100644 --- a/modules/nf-scil/registration/easyreg/tests/main.nf.test.snap +++ b/modules/nf-scil/registration/easyreg/tests/main.nf.test.snap @@ -1,12 +1,12 @@ { "registration - easyreg": { "content": [ - "test_reference_segmentation.nii.gz:md5:header,d7d123ff54be81edabd50a08e6c0ef86,data,8043f2a051e6c31c80405fd2ae6b5c3d", - "test_floating_segmentation.nii.gz:md5:header,d773c9507f9637b269ff0293e5b571b6,data,9f90a28d360043b9a9a2f6caecd9d97f", - "test_reference_registered.nii.gz:md5:header,d1b4c1d6ea3958a942237859fc5c8bf9,data,db57287a4b6d1f2136e0f148a19a9afd", - "test_floating_registered.nii.gz:md5:header,5c6a53aecafb33aa215890c921911298,data,4bf56478dc20f15903c8933825a4d875", - "test_forward_field.nii.gz:md5:header,a44c016d46c40fb91d2b859a3452afe3,data,323c4eafea83b75bea61ec69b2911ae4", - "test_backward_field.nii.gz:md5:header,de97fc6763dae228667018a601d72f54,data,3991957cdd92a5519848eeb3cb30e949", + "test_reference_segmentation.nii.gz:md5:header,6d3dcf7b63ee63325ce7ee31be7addee,data,e695f03c01ea4ee87e44dc5181ce7508", + "test_floating_segmentation.nii.gz:md5:header,d559b931014ef191f9af17abf1152a3c,data,acdf1eb0b07f70506b090eba821e81ef", + "test_reference_registered.nii.gz:md5:header,ec5893cd9ea024e630c4444bd914c331,data,9f4213a80ce723b03f63a08ef9d25bbd", + "test_floating_registered.nii.gz:md5:header,36bc13971b50b21d2534552b329a064b,data,193460c56f25251e16fc4f27b1b56d10", + "test_forward_field.nii.gz:md5:header,e16d57d81d3089b9b7d86e5fda020a01,data,12cc0196e12a3c8a8ca32c46ffcdc3ff", + "test_backward_field.nii.gz:md5:header,0db0a80786ff39864cc17506ed1a0146,data,3ba229de526ae136e8e5aeae0f1e29bc", [ "versions.yml:md5,4661210880c42a986923e8257f64c760" ] @@ -15,6 +15,6 @@ "nf-test": "0.9.0-rc1", "nextflow": "24.04.4" }, - "timestamp": "2024-09-03T19:44:38.393973" + "timestamp": "2024-09-06T15:36:15.876796" } } \ No newline at end of file From 2fa066d66fc2917b64d995adb7474fb590681716 Mon Sep 17 00:00:00 2001 From: Thoumyre Stanislas Date: Fri, 6 Sep 2024 19:02:29 +0000 Subject: [PATCH 23/35] change numbers treads --- modules/nf-scil/registration/easyreg/main.nf | 4 ++++ modules/nf-scil/registration/easyreg/tests/nextflow.config | 1 + 2 files changed, 5 insertions(+) diff --git a/modules/nf-scil/registration/easyreg/main.nf b/modules/nf-scil/registration/easyreg/main.nf index 8ec4cd9c..9dca7451 100644 --- a/modules/nf-scil/registration/easyreg/main.nf +++ b/modules/nf-scil/registration/easyreg/main.nf @@ -29,6 +29,10 @@ process REGISTRATION_EASYREG { def affine = task.ext.affine ? "--affine_only " : "" """ + export ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS=1 + export OMP_NUM_THREADS=1 + export OPENBLAS_NUM_THREADS=1 + if [[ -f "$ref_segmentation" ]]; then reference_segmentation=$ref_segmentation diff --git a/modules/nf-scil/registration/easyreg/tests/nextflow.config b/modules/nf-scil/registration/easyreg/tests/nextflow.config index 6b359bfe..7f049e3e 100644 --- a/modules/nf-scil/registration/easyreg/tests/nextflow.config +++ b/modules/nf-scil/registration/easyreg/tests/nextflow.config @@ -3,5 +3,6 @@ process { withName: "REGISTRATION_EASYREG" { publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } ext.field = true + ext.threads = 4 } } From 75644e61560ecbcc4b001522157f2ab1d122a76d Mon Sep 17 00:00:00 2001 From: Thoumyre Stanislas Date: Fri, 6 Sep 2024 21:32:08 +0000 Subject: [PATCH 24/35] no multi threading --- modules/nf-scil/registration/easyreg/tests/nextflow.config | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/nf-scil/registration/easyreg/tests/nextflow.config b/modules/nf-scil/registration/easyreg/tests/nextflow.config index 7f049e3e..6b359bfe 100644 --- a/modules/nf-scil/registration/easyreg/tests/nextflow.config +++ b/modules/nf-scil/registration/easyreg/tests/nextflow.config @@ -3,6 +3,5 @@ process { withName: "REGISTRATION_EASYREG" { publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } ext.field = true - ext.threads = 4 } } From 660e564eed3b86aa1e2c47ed2a62a96f1fff1f4c Mon Sep 17 00:00:00 2001 From: Thoumyre Stanislas Date: Tue, 10 Sep 2024 17:54:42 +0000 Subject: [PATCH 25/35] change precision snapshot --- .../nf-scil/registration/easyreg/tests/main.nf.test | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/nf-scil/registration/easyreg/tests/main.nf.test b/modules/nf-scil/registration/easyreg/tests/main.nf.test index 904ee495..2ade2027 100644 --- a/modules/nf-scil/registration/easyreg/tests/main.nf.test +++ b/modules/nf-scil/registration/easyreg/tests/main.nf.test @@ -44,12 +44,12 @@ nextflow_process { assertAll( { assert process.success }, { assert snapshot( - niftiMD5SUM(process.out.ref_seg.get(0).get(1), 6), - niftiMD5SUM(process.out.flo_seg.get(0).get(1), 6), - niftiMD5SUM(process.out.ref_reg.get(0).get(1), 6), - niftiMD5SUM(process.out.flo_reg.get(0).get(1), 6), - niftiMD5SUM(process.out.fwd_field.get(0).get(1), 6), - niftiMD5SUM(process.out.bak_field.get(0).get(1), 6), + niftiMD5SUM(process.out.ref_seg.get(0).get(1), 4), + niftiMD5SUM(process.out.flo_seg.get(0).get(1), 4), + niftiMD5SUM(process.out.ref_reg.get(0).get(1), 4), + niftiMD5SUM(process.out.flo_reg.get(0).get(1), 4), + niftiMD5SUM(process.out.fwd_field.get(0).get(1), 4), + niftiMD5SUM(process.out.bak_field.get(0).get(1), 4), process.out.versions ).match() } ) From e7378f1aae72fc4096b0cbba37dc24b26ed10d42 Mon Sep 17 00:00:00 2001 From: Thoumyre Stanislas Date: Tue, 10 Sep 2024 18:26:19 +0000 Subject: [PATCH 26/35] update snapshot --- .../registration/easyreg/tests/main.nf.test.snap | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/nf-scil/registration/easyreg/tests/main.nf.test.snap b/modules/nf-scil/registration/easyreg/tests/main.nf.test.snap index 5504c8a2..715e42fa 100644 --- a/modules/nf-scil/registration/easyreg/tests/main.nf.test.snap +++ b/modules/nf-scil/registration/easyreg/tests/main.nf.test.snap @@ -3,10 +3,10 @@ "content": [ "test_reference_segmentation.nii.gz:md5:header,6d3dcf7b63ee63325ce7ee31be7addee,data,e695f03c01ea4ee87e44dc5181ce7508", "test_floating_segmentation.nii.gz:md5:header,d559b931014ef191f9af17abf1152a3c,data,acdf1eb0b07f70506b090eba821e81ef", - "test_reference_registered.nii.gz:md5:header,ec5893cd9ea024e630c4444bd914c331,data,9f4213a80ce723b03f63a08ef9d25bbd", - "test_floating_registered.nii.gz:md5:header,36bc13971b50b21d2534552b329a064b,data,193460c56f25251e16fc4f27b1b56d10", - "test_forward_field.nii.gz:md5:header,e16d57d81d3089b9b7d86e5fda020a01,data,12cc0196e12a3c8a8ca32c46ffcdc3ff", - "test_backward_field.nii.gz:md5:header,0db0a80786ff39864cc17506ed1a0146,data,3ba229de526ae136e8e5aeae0f1e29bc", + "test_reference_registered.nii.gz:md5:header,ec5893cd9ea024e630c4444bd914c331,data,3a485a0d8382edbfda60980df3acd7a2", + "test_floating_registered.nii.gz:md5:header,36bc13971b50b21d2534552b329a064b,data,b42d4415c99636907a8b0c22f6aa3fdd", + "test_forward_field.nii.gz:md5:header,e16d57d81d3089b9b7d86e5fda020a01,data,6587f1286914bc418bbfdee4227b9119", + "test_backward_field.nii.gz:md5:header,0db0a80786ff39864cc17506ed1a0146,data,51a8f8924c7e59e9b16ed2a68779f93d", [ "versions.yml:md5,4661210880c42a986923e8257f64c760" ] @@ -15,6 +15,6 @@ "nf-test": "0.9.0-rc1", "nextflow": "24.04.4" }, - "timestamp": "2024-09-06T15:36:15.876796" + "timestamp": "2024-09-10T18:09:21.248592" } } \ No newline at end of file From 0e7f14824a9508f5b8a7e38d3bb896780e1b6101 Mon Sep 17 00:00:00 2001 From: Thoumyre Stanislas Date: Tue, 10 Sep 2024 20:41:43 +0000 Subject: [PATCH 27/35] change data-test --- .../registration/easyreg/tests/main.nf.test | 29 +++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/modules/nf-scil/registration/easyreg/tests/main.nf.test b/modules/nf-scil/registration/easyreg/tests/main.nf.test index 2ade2027..7088c338 100644 --- a/modules/nf-scil/registration/easyreg/tests/main.nf.test +++ b/modules/nf-scil/registration/easyreg/tests/main.nf.test @@ -17,7 +17,7 @@ nextflow_process { script "../../../../../subworkflows/nf-scil/load_test_data/main.nf" process { """ - input[0] = Channel.from( [ "freesurfer.zip" ] ) + input[0] = Channel.from( [ "freesurfer.zip, registration.zip" ] ) input[1] = "test.load-test-data" """ } @@ -29,14 +29,25 @@ nextflow_process { when { process { """ - input[0] = LOAD_DATA.out.test_data_directory - .map{ test_data_directory -> [ - [ id:'test', single_end:false ], - file("\${test_data_directory}/fa.nii.gz"), - file("\${test_data_directory}/t1.nii.gz"), - [], - [] - ]} + ch_split_test_data = LOAD_DATA.out.test_data_directory + .branch{ + t1: it.simpleName == "freesurfer" + b0: it.simpleName == "registration" + } + ch_t1 = ch_split_test_data.t1.map{ + test_data_directory -> [ + [ id:'test' ], + file("\${test_data_directory}/t1.nii.gz") + ] + } + ch_b0 = ch_split_test_data.b0.map{ + test_data_directory -> [ + [ id:'test' ], + file("\${test_data_directory}/b0.nii.gz") + ] + } + input[0] = ch_t1 + .join(ch_b0) """ } } From 5bc96ca6304b5cb77dfa44dbbeb8c24a24574609 Mon Sep 17 00:00:00 2001 From: Thoumyre Stanislas Date: Tue, 10 Sep 2024 20:43:44 +0000 Subject: [PATCH 28/35] fix data --- modules/nf-scil/registration/easyreg/tests/main.nf.test | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/nf-scil/registration/easyreg/tests/main.nf.test b/modules/nf-scil/registration/easyreg/tests/main.nf.test index 7088c338..31226f39 100644 --- a/modules/nf-scil/registration/easyreg/tests/main.nf.test +++ b/modules/nf-scil/registration/easyreg/tests/main.nf.test @@ -43,7 +43,9 @@ nextflow_process { ch_b0 = ch_split_test_data.b0.map{ test_data_directory -> [ [ id:'test' ], - file("\${test_data_directory}/b0.nii.gz") + file("\${test_data_directory}/b0.nii.gz"), + [], + [] ] } input[0] = ch_t1 From 8dd5274c412b68588dfe3fa1f1bea8dbf9511480 Mon Sep 17 00:00:00 2001 From: Thoumyre Stanislas Date: Wed, 11 Sep 2024 13:16:37 +0000 Subject: [PATCH 29/35] fix main.nf.test --- .../registration/easyreg/tests/main.nf.test | 2 +- .../registration/easyreg/tests/main.nf.test.snap | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/nf-scil/registration/easyreg/tests/main.nf.test b/modules/nf-scil/registration/easyreg/tests/main.nf.test index 31226f39..818eccc7 100644 --- a/modules/nf-scil/registration/easyreg/tests/main.nf.test +++ b/modules/nf-scil/registration/easyreg/tests/main.nf.test @@ -17,7 +17,7 @@ nextflow_process { script "../../../../../subworkflows/nf-scil/load_test_data/main.nf" process { """ - input[0] = Channel.from( [ "freesurfer.zip, registration.zip" ] ) + input[0] = Channel.from( [ "freesurfer.zip", "registration.zip" ] ) input[1] = "test.load-test-data" """ } diff --git a/modules/nf-scil/registration/easyreg/tests/main.nf.test.snap b/modules/nf-scil/registration/easyreg/tests/main.nf.test.snap index 715e42fa..df82ae9c 100644 --- a/modules/nf-scil/registration/easyreg/tests/main.nf.test.snap +++ b/modules/nf-scil/registration/easyreg/tests/main.nf.test.snap @@ -1,12 +1,12 @@ { "registration - easyreg": { "content": [ - "test_reference_segmentation.nii.gz:md5:header,6d3dcf7b63ee63325ce7ee31be7addee,data,e695f03c01ea4ee87e44dc5181ce7508", - "test_floating_segmentation.nii.gz:md5:header,d559b931014ef191f9af17abf1152a3c,data,acdf1eb0b07f70506b090eba821e81ef", - "test_reference_registered.nii.gz:md5:header,ec5893cd9ea024e630c4444bd914c331,data,3a485a0d8382edbfda60980df3acd7a2", - "test_floating_registered.nii.gz:md5:header,36bc13971b50b21d2534552b329a064b,data,b42d4415c99636907a8b0c22f6aa3fdd", - "test_forward_field.nii.gz:md5:header,e16d57d81d3089b9b7d86e5fda020a01,data,6587f1286914bc418bbfdee4227b9119", - "test_backward_field.nii.gz:md5:header,0db0a80786ff39864cc17506ed1a0146,data,51a8f8924c7e59e9b16ed2a68779f93d", + "test_reference_segmentation.nii.gz:md5:header,d559b931014ef191f9af17abf1152a3c,data,acdf1eb0b07f70506b090eba821e81ef", + "test_floating_segmentation.nii.gz:md5:header,b3c282f86451ca606b428bd9ffcacd10,data,6b5ed67cf63a32966fee1ae179539053", + "test_reference_registered.nii.gz:md5:header,c5e41f89848f91c53a9a7be44970d4b1,data,0e820bbcccbaeb0fdd653c83074d3d1c", + "test_floating_registered.nii.gz:md5:header,ec5893cd9ea024e630c4444bd914c331,data,18dcdd9696f14f213f31a23a7dc64b1e", + "test_forward_field.nii.gz:md5:header,0db0a80786ff39864cc17506ed1a0146,data,bb2a3503c31ce3e815ab1792b3774a10", + "test_backward_field.nii.gz:md5:header,74c92ee4cd3c4abfecf3da6cdb1d4650,data,cbcf9cff2c4e0d131723214d81698280", [ "versions.yml:md5,4661210880c42a986923e8257f64c760" ] @@ -15,6 +15,6 @@ "nf-test": "0.9.0-rc1", "nextflow": "24.04.4" }, - "timestamp": "2024-09-10T18:09:21.248592" + "timestamp": "2024-09-11T12:58:10.644262" } } \ No newline at end of file From dd4f5d793bd7a61720733cfde18fae3c97359d99 Mon Sep 17 00:00:00 2001 From: Thoumyre Stanislas Date: Wed, 11 Sep 2024 14:53:15 +0000 Subject: [PATCH 30/35] change data --- .../registration/easyreg/tests/main.nf.test | 26 +++++-------------- .../easyreg/tests/main.nf.test.snap | 14 +++++----- 2 files changed, 14 insertions(+), 26 deletions(-) diff --git a/modules/nf-scil/registration/easyreg/tests/main.nf.test b/modules/nf-scil/registration/easyreg/tests/main.nf.test index 818eccc7..00912d92 100644 --- a/modules/nf-scil/registration/easyreg/tests/main.nf.test +++ b/modules/nf-scil/registration/easyreg/tests/main.nf.test @@ -12,12 +12,13 @@ nextflow_process { tag "subworkflows" tag "subworkflows/load_test_data" + setup { run("LOAD_TEST_DATA", alias: "LOAD_DATA") { script "../../../../../subworkflows/nf-scil/load_test_data/main.nf" process { """ - input[0] = Channel.from( [ "freesurfer.zip", "registration.zip" ] ) + input[0] = Channel.from( [ "registration.zip" ] ) input[1] = "test.load-test-data" """ } @@ -29,27 +30,14 @@ nextflow_process { when { process { """ - ch_split_test_data = LOAD_DATA.out.test_data_directory - .branch{ - t1: it.simpleName == "freesurfer" - b0: it.simpleName == "registration" - } - ch_t1 = ch_split_test_data.t1.map{ - test_data_directory -> [ - [ id:'test' ], - file("\${test_data_directory}/t1.nii.gz") - ] - } - ch_b0 = ch_split_test_data.b0.map{ - test_data_directory -> [ - [ id:'test' ], + input[0] = LOAD_DATA.out.test_data_directory + .map{ test_data_directory -> [ + [ id:'test', single_end:false ], file("\${test_data_directory}/b0.nii.gz"), + file("\${test_data_directory}/mni_masked_2x2x2.nii.gz"), [], [] - ] - } - input[0] = ch_t1 - .join(ch_b0) + ]} """ } } diff --git a/modules/nf-scil/registration/easyreg/tests/main.nf.test.snap b/modules/nf-scil/registration/easyreg/tests/main.nf.test.snap index df82ae9c..38d2741a 100644 --- a/modules/nf-scil/registration/easyreg/tests/main.nf.test.snap +++ b/modules/nf-scil/registration/easyreg/tests/main.nf.test.snap @@ -1,12 +1,12 @@ { "registration - easyreg": { "content": [ - "test_reference_segmentation.nii.gz:md5:header,d559b931014ef191f9af17abf1152a3c,data,acdf1eb0b07f70506b090eba821e81ef", - "test_floating_segmentation.nii.gz:md5:header,b3c282f86451ca606b428bd9ffcacd10,data,6b5ed67cf63a32966fee1ae179539053", - "test_reference_registered.nii.gz:md5:header,c5e41f89848f91c53a9a7be44970d4b1,data,0e820bbcccbaeb0fdd653c83074d3d1c", - "test_floating_registered.nii.gz:md5:header,ec5893cd9ea024e630c4444bd914c331,data,18dcdd9696f14f213f31a23a7dc64b1e", - "test_forward_field.nii.gz:md5:header,0db0a80786ff39864cc17506ed1a0146,data,bb2a3503c31ce3e815ab1792b3774a10", - "test_backward_field.nii.gz:md5:header,74c92ee4cd3c4abfecf3da6cdb1d4650,data,cbcf9cff2c4e0d131723214d81698280", + "test_reference_segmentation.nii.gz:md5:header,b3c282f86451ca606b428bd9ffcacd10,data,6b5ed67cf63a32966fee1ae179539053", + "test_floating_segmentation.nii.gz:md5:header,ff063c025479983639fd545e1e8fd690,data,7e70ecf0bdb68271b0f9a0aa22711365", + "test_reference_registered.nii.gz:md5:header,83b3e1eaaaa72c367ffcdd4cfa002406,data,fcbb08556a5d6950d79d661900c1b1c8", + "test_floating_registered.nii.gz:md5:header,c5e41f89848f91c53a9a7be44970d4b1,data,236aff072c85b1405d1d3095f7a5267b", + "test_forward_field.nii.gz:md5:header,74c92ee4cd3c4abfecf3da6cdb1d4650,data,2826360a14ad92253cea497bb2e5d055", + "test_backward_field.nii.gz:md5:header,2184515d220e6c1eeb48adae2134ce7e,data,06b7b17a98829d7c75f3e1ebb77cfdc2", [ "versions.yml:md5,4661210880c42a986923e8257f64c760" ] @@ -15,6 +15,6 @@ "nf-test": "0.9.0-rc1", "nextflow": "24.04.4" }, - "timestamp": "2024-09-11T12:58:10.644262" + "timestamp": "2024-09-11T14:02:22.638457" } } \ No newline at end of file From b1ec3ba221de7d50a8df1acab5932be2b9aae977 Mon Sep 17 00:00:00 2001 From: Thoumyre Stanislas Date: Thu, 12 Sep 2024 14:47:38 +0000 Subject: [PATCH 31/35] final change data --- .../registration/easyreg/tests/main.nf.test | 25 ++++++++++++++----- .../easyreg/tests/main.nf.test.snap | 14 +++++------ 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/modules/nf-scil/registration/easyreg/tests/main.nf.test b/modules/nf-scil/registration/easyreg/tests/main.nf.test index 00912d92..0c30b9c6 100644 --- a/modules/nf-scil/registration/easyreg/tests/main.nf.test +++ b/modules/nf-scil/registration/easyreg/tests/main.nf.test @@ -18,7 +18,7 @@ nextflow_process { script "../../../../../subworkflows/nf-scil/load_test_data/main.nf" process { """ - input[0] = Channel.from( [ "registration.zip" ] ) + input[0] = Channel.from( [ "freesurfer.zip", "registration.zip" ] ) input[1] = "test.load-test-data" """ } @@ -30,14 +30,27 @@ nextflow_process { when { process { """ - input[0] = LOAD_DATA.out.test_data_directory - .map{ test_data_directory -> [ - [ id:'test', single_end:false ], + ch_split_test_data = LOAD_DATA.out.test_data_directory + .branch{ + t1: it.simpleName == "freesurfer" + b0: it.simpleName == "registration" + } + ch_t1 = ch_split_test_data.t1.map{ + test_data_directory -> [ + [ id:'test' ], + file("\${test_data_directory}/t1.nii.gz") + ] + } + ch_b0 = ch_split_test_data.b0.map{ + test_data_directory -> [ + [ id:'test' ], file("\${test_data_directory}/b0.nii.gz"), - file("\${test_data_directory}/mni_masked_2x2x2.nii.gz"), [], [] - ]} + ] + } + input[0] = ch_t1 + .join(ch_b0) """ } } diff --git a/modules/nf-scil/registration/easyreg/tests/main.nf.test.snap b/modules/nf-scil/registration/easyreg/tests/main.nf.test.snap index 38d2741a..6be46003 100644 --- a/modules/nf-scil/registration/easyreg/tests/main.nf.test.snap +++ b/modules/nf-scil/registration/easyreg/tests/main.nf.test.snap @@ -1,12 +1,12 @@ { "registration - easyreg": { "content": [ - "test_reference_segmentation.nii.gz:md5:header,b3c282f86451ca606b428bd9ffcacd10,data,6b5ed67cf63a32966fee1ae179539053", - "test_floating_segmentation.nii.gz:md5:header,ff063c025479983639fd545e1e8fd690,data,7e70ecf0bdb68271b0f9a0aa22711365", - "test_reference_registered.nii.gz:md5:header,83b3e1eaaaa72c367ffcdd4cfa002406,data,fcbb08556a5d6950d79d661900c1b1c8", - "test_floating_registered.nii.gz:md5:header,c5e41f89848f91c53a9a7be44970d4b1,data,236aff072c85b1405d1d3095f7a5267b", - "test_forward_field.nii.gz:md5:header,74c92ee4cd3c4abfecf3da6cdb1d4650,data,2826360a14ad92253cea497bb2e5d055", - "test_backward_field.nii.gz:md5:header,2184515d220e6c1eeb48adae2134ce7e,data,06b7b17a98829d7c75f3e1ebb77cfdc2", + "test_reference_segmentation.nii.gz:md5:header,d559b931014ef191f9af17abf1152a3c,data,acdf1eb0b07f70506b090eba821e81ef", + "test_floating_segmentation.nii.gz:md5:header,b3c282f86451ca606b428bd9ffcacd10,data,6b5ed67cf63a32966fee1ae179539053", + "test_reference_registered.nii.gz:md5:header,c5e41f89848f91c53a9a7be44970d4b1,data,0e820bbcccbaeb0fdd653c83074d3d1c", + "test_floating_registered.nii.gz:md5:header,ec5893cd9ea024e630c4444bd914c331,data,18dcdd9696f14f213f31a23a7dc64b1e", + "test_forward_field.nii.gz:md5:header,0db0a80786ff39864cc17506ed1a0146,data,bb2a3503c31ce3e815ab1792b3774a10", + "test_backward_field.nii.gz:md5:header,74c92ee4cd3c4abfecf3da6cdb1d4650,data,cbcf9cff2c4e0d131723214d81698280", [ "versions.yml:md5,4661210880c42a986923e8257f64c760" ] @@ -15,6 +15,6 @@ "nf-test": "0.9.0-rc1", "nextflow": "24.04.4" }, - "timestamp": "2024-09-11T14:02:22.638457" + "timestamp": "2024-09-12T13:20:06.2764" } } \ No newline at end of file From 4d067e00f5f5c9f32c55a17db67bd9a75ebca7cf Mon Sep 17 00:00:00 2001 From: Thoumyre Stanislas Date: Thu, 12 Sep 2024 15:13:03 +0000 Subject: [PATCH 32/35] affine registration --- .../registration/easyreg/tests/main.nf.test.snap | 10 +++++----- .../nf-scil/registration/easyreg/tests/nextflow.config | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/modules/nf-scil/registration/easyreg/tests/main.nf.test.snap b/modules/nf-scil/registration/easyreg/tests/main.nf.test.snap index 6be46003..0e5de8ed 100644 --- a/modules/nf-scil/registration/easyreg/tests/main.nf.test.snap +++ b/modules/nf-scil/registration/easyreg/tests/main.nf.test.snap @@ -3,10 +3,10 @@ "content": [ "test_reference_segmentation.nii.gz:md5:header,d559b931014ef191f9af17abf1152a3c,data,acdf1eb0b07f70506b090eba821e81ef", "test_floating_segmentation.nii.gz:md5:header,b3c282f86451ca606b428bd9ffcacd10,data,6b5ed67cf63a32966fee1ae179539053", - "test_reference_registered.nii.gz:md5:header,c5e41f89848f91c53a9a7be44970d4b1,data,0e820bbcccbaeb0fdd653c83074d3d1c", - "test_floating_registered.nii.gz:md5:header,ec5893cd9ea024e630c4444bd914c331,data,18dcdd9696f14f213f31a23a7dc64b1e", - "test_forward_field.nii.gz:md5:header,0db0a80786ff39864cc17506ed1a0146,data,bb2a3503c31ce3e815ab1792b3774a10", - "test_backward_field.nii.gz:md5:header,74c92ee4cd3c4abfecf3da6cdb1d4650,data,cbcf9cff2c4e0d131723214d81698280", + "test_reference_registered.nii.gz:md5:header,c5e41f89848f91c53a9a7be44970d4b1,data,be1be38b195f8767a359a5ba6cf01621", + "test_floating_registered.nii.gz:md5:header,ec5893cd9ea024e630c4444bd914c331,data,ec1c9900c9e0383e7ceda0c18bdc896d", + "test_forward_field.nii.gz:md5:header,0db0a80786ff39864cc17506ed1a0146,data,acb545f917aa46922f959f433cb5fab1", + "test_backward_field.nii.gz:md5:header,74c92ee4cd3c4abfecf3da6cdb1d4650,data,a1f3ebb3a582e8116537781cb128355f", [ "versions.yml:md5,4661210880c42a986923e8257f64c760" ] @@ -15,6 +15,6 @@ "nf-test": "0.9.0-rc1", "nextflow": "24.04.4" }, - "timestamp": "2024-09-12T13:20:06.2764" + "timestamp": "2024-09-12T15:09:28.340764" } } \ No newline at end of file diff --git a/modules/nf-scil/registration/easyreg/tests/nextflow.config b/modules/nf-scil/registration/easyreg/tests/nextflow.config index 6b359bfe..1f80c446 100644 --- a/modules/nf-scil/registration/easyreg/tests/nextflow.config +++ b/modules/nf-scil/registration/easyreg/tests/nextflow.config @@ -3,5 +3,6 @@ process { withName: "REGISTRATION_EASYREG" { publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } ext.field = true + ext.affine = true } } From b2bed2bc103f0c752364b1b41ae117ec55eaad0b Mon Sep 17 00:00:00 2001 From: Thoumyre Stanislas Date: Thu, 12 Sep 2024 16:50:24 +0000 Subject: [PATCH 33/35] final commit --- .../registration/easyreg/tests/main.nf.test | 12 ++++++------ .../registration/easyreg/tests/main.nf.test.snap | 14 +++++++------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/modules/nf-scil/registration/easyreg/tests/main.nf.test b/modules/nf-scil/registration/easyreg/tests/main.nf.test index 0c30b9c6..0d7e0fb9 100644 --- a/modules/nf-scil/registration/easyreg/tests/main.nf.test +++ b/modules/nf-scil/registration/easyreg/tests/main.nf.test @@ -58,12 +58,12 @@ nextflow_process { assertAll( { assert process.success }, { assert snapshot( - niftiMD5SUM(process.out.ref_seg.get(0).get(1), 4), - niftiMD5SUM(process.out.flo_seg.get(0).get(1), 4), - niftiMD5SUM(process.out.ref_reg.get(0).get(1), 4), - niftiMD5SUM(process.out.flo_reg.get(0).get(1), 4), - niftiMD5SUM(process.out.fwd_field.get(0).get(1), 4), - niftiMD5SUM(process.out.bak_field.get(0).get(1), 4), + file(process.out.ref_seg.get(0).get(1)).name, + file(process.out.flo_seg.get(0).get(1)).name, + niftiMD5SUM(process.out.ref_reg.get(0).get(1), 6), + niftiMD5SUM(process.out.flo_reg.get(0).get(1), 6), + niftiMD5SUM(process.out.fwd_field.get(0).get(1), 6), + niftiMD5SUM(process.out.bak_field.get(0).get(1), 6), process.out.versions ).match() } ) diff --git a/modules/nf-scil/registration/easyreg/tests/main.nf.test.snap b/modules/nf-scil/registration/easyreg/tests/main.nf.test.snap index 0e5de8ed..abb85387 100644 --- a/modules/nf-scil/registration/easyreg/tests/main.nf.test.snap +++ b/modules/nf-scil/registration/easyreg/tests/main.nf.test.snap @@ -1,12 +1,12 @@ { "registration - easyreg": { "content": [ - "test_reference_segmentation.nii.gz:md5:header,d559b931014ef191f9af17abf1152a3c,data,acdf1eb0b07f70506b090eba821e81ef", - "test_floating_segmentation.nii.gz:md5:header,b3c282f86451ca606b428bd9ffcacd10,data,6b5ed67cf63a32966fee1ae179539053", - "test_reference_registered.nii.gz:md5:header,c5e41f89848f91c53a9a7be44970d4b1,data,be1be38b195f8767a359a5ba6cf01621", - "test_floating_registered.nii.gz:md5:header,ec5893cd9ea024e630c4444bd914c331,data,ec1c9900c9e0383e7ceda0c18bdc896d", - "test_forward_field.nii.gz:md5:header,0db0a80786ff39864cc17506ed1a0146,data,acb545f917aa46922f959f433cb5fab1", - "test_backward_field.nii.gz:md5:header,74c92ee4cd3c4abfecf3da6cdb1d4650,data,a1f3ebb3a582e8116537781cb128355f", + "test_reference_segmentation.nii.gz", + "test_floating_segmentation.nii.gz", + "test_reference_registered.nii.gz:md5:header,c5e41f89848f91c53a9a7be44970d4b1,data,1501221fe23cd62bfdafb33367cadf4d", + "test_floating_registered.nii.gz:md5:header,ec5893cd9ea024e630c4444bd914c331,data,d75ae3fc935cd5cc70ea6797a4c70775", + "test_forward_field.nii.gz:md5:header,0db0a80786ff39864cc17506ed1a0146,data,e4fa6c626729cbf236c34680e5c76df4", + "test_backward_field.nii.gz:md5:header,74c92ee4cd3c4abfecf3da6cdb1d4650,data,8f26afa5c3de21469466213498542486", [ "versions.yml:md5,4661210880c42a986923e8257f64c760" ] @@ -15,6 +15,6 @@ "nf-test": "0.9.0-rc1", "nextflow": "24.04.4" }, - "timestamp": "2024-09-12T15:09:28.340764" + "timestamp": "2024-09-12T16:01:24.00559" } } \ No newline at end of file From 610eb3e439e49a4c79bb81dbf3d5012d19935769 Mon Sep 17 00:00:00 2001 From: Thoumyre Stanislas Date: Thu, 12 Sep 2024 17:30:10 +0000 Subject: [PATCH 34/35] last final commit --- modules/nf-scil/registration/easyreg/main.nf | 2 +- modules/nf-scil/registration/easyreg/tests/nextflow.config | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/nf-scil/registration/easyreg/main.nf b/modules/nf-scil/registration/easyreg/main.nf index 9dca7451..48063417 100644 --- a/modules/nf-scil/registration/easyreg/main.nf +++ b/modules/nf-scil/registration/easyreg/main.nf @@ -40,7 +40,7 @@ process REGISTRATION_EASYREG { reference_segmentation="${prefix}_reference_segmentation.nii.gz" fi - if [[ -f "$flo_segmentation" ]]; + if [[ -f "$flo_segmentation" ]]; then floating_segmentation=$flo_segmentation else diff --git a/modules/nf-scil/registration/easyreg/tests/nextflow.config b/modules/nf-scil/registration/easyreg/tests/nextflow.config index 1f80c446..71494b4d 100644 --- a/modules/nf-scil/registration/easyreg/tests/nextflow.config +++ b/modules/nf-scil/registration/easyreg/tests/nextflow.config @@ -4,5 +4,6 @@ process { publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } ext.field = true ext.affine = true + ext.threads = 1 } } From 2f85490ee408572cb4b4b6fb053191dea02db687 Mon Sep 17 00:00:00 2001 From: Thoumyre Stanislas Date: Thu, 12 Sep 2024 18:33:45 +0000 Subject: [PATCH 35/35] the last ultimate final decisive commit --- modules/nf-scil/registration/easyreg/main.nf | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/nf-scil/registration/easyreg/main.nf b/modules/nf-scil/registration/easyreg/main.nf index 48063417..66dcde02 100644 --- a/modules/nf-scil/registration/easyreg/main.nf +++ b/modules/nf-scil/registration/easyreg/main.nf @@ -47,8 +47,13 @@ process REGISTRATION_EASYREG { floating_segmentation="${prefix}_floating_segmentation.nii.gz" fi - mri_easyreg --ref $reference --flo $floating --ref_seg \${reference_segmentation} --flo_seg \${floating_segmentation} \ - --flo_reg ${prefix}_floating_registered.nii.gz --ref_reg ${prefix}_reference_registered.nii.gz $field $threads $affine + mri_easyreg \ + --ref $reference --flo $floating \ + --ref_seg \${reference_segmentation} \ + --flo_seg \${floating_segmentation} \ + --flo_reg ${prefix}_floating_registered.nii.gz \ + --ref_reg ${prefix}_reference_registered.nii.gz \ + $field $threads $affine cat <<-END_VERSIONS > versions.yml "${task.process}":