From 0b60476920662c041831531b4c8c88ab40f2c827 Mon Sep 17 00:00:00 2001 From: anroy1 Date: Sat, 31 Aug 2024 17:17:26 +0000 Subject: [PATCH 01/34] Change org_path --- .nf-core.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.nf-core.yml b/.nf-core.yml index 86885b8d..ab4e64f9 100755 --- a/.nf-core.yml +++ b/.nf-core.yml @@ -1,3 +1,3 @@ --- repository_type: modules -org_path: nf-scil +org_path: anroy1/nf-scil From e33d495b913e17dabf6d74b9635e9501a4e657e9 Mon Sep 17 00:00:00 2001 From: anroy1 Date: Mon, 8 Jan 2024 20:45:44 -0500 Subject: [PATCH 02/34] initial module commit --- .../registration/synthregistration/main.nf | 78 +++++++++++++++++++ .../registration/synthregistration/meta.yml | 61 +++++++++++++++ tests/config/pytest_modules.yml | 3 + .../registration/synthregistration/main.nf | 24 ++++++ .../synthregistration/nextflow.config | 8 ++ .../registration/synthregistration/test.yml | 13 ++++ 6 files changed, 187 insertions(+) create mode 100644 modules/nf-scil/registration/synthregistration/main.nf create mode 100644 modules/nf-scil/registration/synthregistration/meta.yml create mode 100755 tests/config/pytest_modules.yml create mode 100644 tests/modules/nf-scil/registration/synthregistration/main.nf create mode 100644 tests/modules/nf-scil/registration/synthregistration/nextflow.config create mode 100644 tests/modules/nf-scil/registration/synthregistration/test.yml diff --git a/modules/nf-scil/registration/synthregistration/main.nf b/modules/nf-scil/registration/synthregistration/main.nf new file mode 100644 index 00000000..793f672f --- /dev/null +++ b/modules/nf-scil/registration/synthregistration/main.nf @@ -0,0 +1,78 @@ +process REGISTRATION_SYNTHREGISTRATION { + tag "$meta.id" + label 'process_single' + + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://scil.usherbrooke.ca/containers/scilus_1.6.0.sif': + 'scilus/scilus:1.6.0' }" + + input: + tuple val(meta), path(moving), path(fixed) + + output: + tuple val(meta), path("*__*_output_warped.nii.gz"), emit: warped_image + tuple val(meta), path("*__output_warp.nii.gz"), emit: transform + path "versions.yml" , emit: versions + + when: + task.ext.when == null || task.ext.when + + script: + def args = task.ext.args ?: '' + def prefix = task.ext.prefix ?: "${meta.id}" + def suffix = task.ext.suffix ?: "${meta.}" + + def header = task.ext.header ? "-H " + task.ext.header : "" + def threads = task.ext.threads ? "-j " + task.ext.threads : "" + def gpu = task.ext.gpu ? "-g " + task.ext.gpu : "" + def smooth = task.ext.smooth ? "-s " + task.ext.smooth : "" + def extent = task.ext.extent ? "-e " + task.ext.extent : "" + def weight = task.ext.weight ? "-w " + task.ext.weight : "" + + def interp = task.ext.interp ? "-n " + task.ext.interp : "" + def dimensionality = task.ext.dimensionality ? "-d " + task.ext.dimensionality : "" + def imagetype = task.ext.imagetype ? "-e " + task.ext.imagetype : "" + + // TODO nf-core: Where possible, a command MUST be provided to obtain the version number of the software e.g. 1.10 + // If the software is unable to output a version number on the command-line then it can be manually specified + // e.g. https://github.com/nf-core/modules/blob/master/modules/nf-core/homer/annotatepeaks/main.nf + // Each software used MUST provide the software name and version number in the YAML version file (versions.yml) + // TODO nf-core: It MUST be possible to pass additional parameters to the tool as a command-line string via the "task.ext.args" directive + // TODO nf-core: If the tool supports multi-threading then you MUST provide the appropriate parameter + // using the Nextflow "task" variable e.g. "--threads $task.cpus" + // TODO nf-core: Please replace the example samtools command below with your module's command + // TODO nf-core: Please indent the command appropriately (4 spaces!!) to help with readability ;) + """ + export ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS=1 + export OMP_NUM_THREADS=1 + export OPENBLAS_NUM_THREADS=1 + + mri_synthmorph -m affine -t init.txt $moving $fixed + mri_synthmorph -m deform -i init.txt -t ${prefix}__output_warp.mgz -o ${prefix}__${suffix}_output_warped.nii.gz $moving $fixed + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + : \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//' )) + END_VERSIONS + """ + + stub: + def args = task.ext.args ?: '' + def prefix = task.ext.prefix ?: "${meta.id}" + def suffix = task.ext.suffix ?: "${meta.}" + // TODO nf-core: A stub section should mimic the execution of the original module as best as possible + // Have a look at the following examples: + // Simple example: https://github.com/nf-core/modules/blob/818474a292b4860ae8ff88e149fbcda68814114d/modules/nf-core/bcftools/annotate/main.nf#L47-L63 + // Complex example: https://github.com/nf-core/modules/blob/818474a292b4860ae8ff88e149fbcda68814114d/modules/nf-core/bedtools/split/main.nf#L38-L54 + """ + mri_synthmorph -h + + touch ${prefix}__${suffix}_output_warped.nii.gz + touch ${prefix}__output_warp.mgz + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + : \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//' )) + END_VERSIONS + """ +} diff --git a/modules/nf-scil/registration/synthregistration/meta.yml b/modules/nf-scil/registration/synthregistration/meta.yml new file mode 100644 index 00000000..53053229 --- /dev/null +++ b/modules/nf-scil/registration/synthregistration/meta.yml @@ -0,0 +1,61 @@ +--- +## DONT FORGET TO DECOMMENT yaml +## yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/yaml-schema.json + +name: "registration_synthregistration" +description: Perform registration using SynthMorph from Freesurfer +keywords: + - registration + - Brain imaging + - MRI +tools: + - "Freesurfer": + description: "Freesurfer Toolbox" + homepage: "https://surfer.nmr.mgh.harvard.edu/" + + +## TODO nf-core: Add a description of all of the variables used as input +input: + # Only when we have meta + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'test', single_end:false ]` + + - moving: + type: file + description: Nifti volume moving for registration + pattern: "*.{nii,nii.gz}" + + - fixed: + type: file + description: Nifti volume fixed for registration + pattern: "*.{nii,nii.gz}" + +## TODO nf-core: Add a description of all of the variables used as output +output: + #Only when we have meta + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. `[ id:'test', single_end:false ]` + + - warped: + type: file + description: Nifti volume moved after registration + pattern: "*.{nii,nii.gz}" + + - warp: + type: file + description: Displacement field + pattern: "*.{mgz}" + + - versions: + type: file + description: File containing software versions + pattern: "versions.yml" + +authors: + - "@scilus" diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml new file mode 100755 index 00000000..8fb708a6 --- /dev/null +++ b/tests/config/pytest_modules.yml @@ -0,0 +1,3 @@ +registration/synthregistration: + - modules/nf-scil/registration/synthregistration/** + - tests/modules/nf-scil/registration/synthregistration/** diff --git a/tests/modules/nf-scil/registration/synthregistration/main.nf b/tests/modules/nf-scil/registration/synthregistration/main.nf new file mode 100644 index 00000000..c7c8c15f --- /dev/null +++ b/tests/modules/nf-scil/registration/synthregistration/main.nf @@ -0,0 +1,24 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { LOAD_TEST_DATA } from '../../../../../modules/nf-scil/load_test_data/main.nf' +include { + REGISTRATION_SYNTHREGISTRATION as T1_FA; } from '../../../../../modules/nf-scil/registration/synthregistration/main.nf' + +workflow test_registration_synthregistration { + + input_fetch = Channel.from( [ "others.zip" ] ) + + LOAD_TEST_DATA ( input_fetch, "test.load-test-data" ) + + input_t1fa = LOAD_TEST_DATA.out.test_data_directory + .map{ test_data_directory -> [ + [ id:'test', single_end:false ], // meta map + file("${test_data_directory}/t1.nii.gz"), + file("${test_data_directory}/fa.nii.gz") + ]} + + REGISTRATION_SYNTHREGISTRATION ( input_t1fa ) + +} diff --git a/tests/modules/nf-scil/registration/synthregistration/nextflow.config b/tests/modules/nf-scil/registration/synthregistration/nextflow.config new file mode 100644 index 00000000..5c687e42 --- /dev/null +++ b/tests/modules/nf-scil/registration/synthregistration/nextflow.config @@ -0,0 +1,8 @@ +process { + + withName: "REGISTRATION_SYNTHREGISTRATION" { + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } + + } + +} \ No newline at end of file diff --git a/tests/modules/nf-scil/registration/synthregistration/test.yml b/tests/modules/nf-scil/registration/synthregistration/test.yml new file mode 100644 index 00000000..693eb329 --- /dev/null +++ b/tests/modules/nf-scil/registration/synthregistration/test.yml @@ -0,0 +1,13 @@ +## TODO nf-core: Please run the following command to build this file: +# nf-core modules create-test-yml /synthregistration +- name: "registration synthregistration" + command: nextflow run ./tests/modules/nf-scil/registration/synthregistration -entry test_registration_synthregistration -c ./tests/config/nextflow.config + tags: + - "registration" + - "registration/synthregistration" + files: + - path: "output/registration/test.bam" + md5sum: e667c7caad0bc4b7ac383fd023c654fc + - path: "output/registration/versions.yml" + md5sum: a01fe51bc4c6a3a6226fbf77b2c7cf3b + From bc367df647c4381154e8ba76c77724d4b6565eda Mon Sep 17 00:00:00 2001 From: anroy1 Date: Sun, 14 Jan 2024 14:42:25 -0500 Subject: [PATCH 03/34] manage output format for ants and include init transform as output --- .../registration/synthregistration/main.nf | 42 +++++++++---------- .../registration/synthregistration/meta.yml | 19 +++------ 2 files changed, 27 insertions(+), 34 deletions(-) diff --git a/modules/nf-scil/registration/synthregistration/main.nf b/modules/nf-scil/registration/synthregistration/main.nf index 793f672f..e14588c6 100644 --- a/modules/nf-scil/registration/synthregistration/main.nf +++ b/modules/nf-scil/registration/synthregistration/main.nf @@ -11,7 +11,8 @@ process REGISTRATION_SYNTHREGISTRATION { output: tuple val(meta), path("*__*_output_warped.nii.gz"), emit: warped_image - tuple val(meta), path("*__output_warp.nii.gz"), emit: transform + tuple val(meta), path("*__deform_warp.nii.gz"), emit: deform_transform + tuple val (meta), path("*__init_warp.txt"), emit: affine_transform path "versions.yml" , emit: versions when: @@ -29,26 +30,17 @@ process REGISTRATION_SYNTHREGISTRATION { def extent = task.ext.extent ? "-e " + task.ext.extent : "" def weight = task.ext.weight ? "-w " + task.ext.weight : "" - def interp = task.ext.interp ? "-n " + task.ext.interp : "" - def dimensionality = task.ext.dimensionality ? "-d " + task.ext.dimensionality : "" - def imagetype = task.ext.imagetype ? "-e " + task.ext.imagetype : "" - - // TODO nf-core: Where possible, a command MUST be provided to obtain the version number of the software e.g. 1.10 - // If the software is unable to output a version number on the command-line then it can be manually specified - // e.g. https://github.com/nf-core/modules/blob/master/modules/nf-core/homer/annotatepeaks/main.nf - // Each software used MUST provide the software name and version number in the YAML version file (versions.yml) - // TODO nf-core: It MUST be possible to pass additional parameters to the tool as a command-line string via the "task.ext.args" directive - // TODO nf-core: If the tool supports multi-threading then you MUST provide the appropriate parameter - // using the Nextflow "task" variable e.g. "--threads $task.cpus" - // TODO nf-core: Please replace the example samtools command below with your module's command - // TODO nf-core: Please indent the command appropriately (4 spaces!!) to help with readability ;) + def out = task.ext.out ? "--out" + task.ext.out : "lps" + """ export ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS=1 export OMP_NUM_THREADS=1 export OPENBLAS_NUM_THREADS=1 - mri_synthmorph -m affine -t init.txt $moving $fixed - mri_synthmorph -m deform -i init.txt -t ${prefix}__output_warp.mgz -o ${prefix}__${suffix}_output_warped.nii.gz $moving $fixed + mri_synthmorph -m affine -t ${prefix}__init_warp.txt $moving $fixed + mri_synthmorph -m deform -i ${prefix}__init_warp.txt -t temp.mgz -o ${prefix}__${suffix}_output_warped.nii.gz $moving $fixed + + mri_warp_convert -g $moving --inras temp.mgz $out ${prefix}__deform_warp.nii.gz cat <<-END_VERSIONS > versions.yml "${task.process}": @@ -60,15 +52,23 @@ process REGISTRATION_SYNTHREGISTRATION { def args = task.ext.args ?: '' def prefix = task.ext.prefix ?: "${meta.id}" def suffix = task.ext.suffix ?: "${meta.}" - // TODO nf-core: A stub section should mimic the execution of the original module as best as possible - // Have a look at the following examples: - // Simple example: https://github.com/nf-core/modules/blob/818474a292b4860ae8ff88e149fbcda68814114d/modules/nf-core/bcftools/annotate/main.nf#L47-L63 - // Complex example: https://github.com/nf-core/modules/blob/818474a292b4860ae8ff88e149fbcda68814114d/modules/nf-core/bedtools/split/main.nf#L38-L54 + + def header = task.ext.header ? "-H " + task.ext.header : "" + def threads = task.ext.threads ? "-j " + task.ext.threads : "" + def gpu = task.ext.gpu ? "-g " + task.ext.gpu : "" + def smooth = task.ext.smooth ? "-s " + task.ext.smooth : "" + def extent = task.ext.extent ? "-e " + task.ext.extent : "" + def weight = task.ext.weight ? "-w " + task.ext.weight : "" + + def out = task.ext.out ? "--out" + task.ext.out : "lps" """ mri_synthmorph -h + mri_warp_convert -h + touch ${prefix}__${suffix}_output_warped.nii.gz - touch ${prefix}__output_warp.mgz + touch ${prefix}__deform_warp.nii.gz + touch ${prefix}__init_warp.txt cat <<-END_VERSIONS > versions.yml "${task.process}": diff --git a/modules/nf-scil/registration/synthregistration/meta.yml b/modules/nf-scil/registration/synthregistration/meta.yml index 53053229..dcfa056f 100644 --- a/modules/nf-scil/registration/synthregistration/meta.yml +++ b/modules/nf-scil/registration/synthregistration/meta.yml @@ -1,7 +1,4 @@ --- -## DONT FORGET TO DECOMMENT yaml -## yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/yaml-schema.json - name: "registration_synthregistration" description: Perform registration using SynthMorph from Freesurfer keywords: @@ -14,9 +11,7 @@ tools: homepage: "https://surfer.nmr.mgh.harvard.edu/" -## TODO nf-core: Add a description of all of the variables used as input input: - # Only when we have meta - meta: type: map description: | @@ -33,24 +28,22 @@ input: description: Nifti volume fixed for registration pattern: "*.{nii,nii.gz}" -## TODO nf-core: Add a description of all of the variables used as output output: - #Only when we have meta - meta: type: map description: | Groovy Map containing sample information e.g. `[ id:'test', single_end:false ]` - - warped: + - init: type: file - description: Nifti volume moved after registration - pattern: "*.{nii,nii.gz}" + description: Affine transform for initialization + pattern: "*.{txt}" - - warp: + - deform: type: file - description: Displacement field - pattern: "*.{mgz}" + description: Deform transformation + pattern: "*.{nii,.nii.gz}" - versions: type: file From 972abf62c54d0b736fa0e9dfd285d05501d9ec50 Mon Sep 17 00:00:00 2001 From: anroy1 Date: Fri, 19 Jan 2024 14:19:11 -0500 Subject: [PATCH 04/34] quick fix --- modules/nf-scil/registration/synthregistration/main.nf | 8 +++++--- .../registration/synthregistration/nextflow.config | 8 ++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/modules/nf-scil/registration/synthregistration/main.nf b/modules/nf-scil/registration/synthregistration/main.nf index e14588c6..e200f652 100644 --- a/modules/nf-scil/registration/synthregistration/main.nf +++ b/modules/nf-scil/registration/synthregistration/main.nf @@ -9,6 +9,7 @@ process REGISTRATION_SYNTHREGISTRATION { input: tuple val(meta), path(moving), path(fixed) + output: tuple val(meta), path("*__*_output_warped.nii.gz"), emit: warped_image tuple val(meta), path("*__deform_warp.nii.gz"), emit: deform_transform @@ -16,12 +17,12 @@ process REGISTRATION_SYNTHREGISTRATION { path "versions.yml" , emit: versions when: - task.ext.when == null || task.ext.when + task.ext.when == null || task.ext.when_output_warped script: def args = task.ext.args ?: '' def prefix = task.ext.prefix ?: "${meta.id}" - def suffix = task.ext.suffix ?: "${meta.}" + def suffix = task.ext.suffix ?: "" def header = task.ext.header ? "-H " + task.ext.header : "" def threads = task.ext.threads ? "-j " + task.ext.threads : "" @@ -30,7 +31,8 @@ process REGISTRATION_SYNTHREGISTRATION { def extent = task.ext.extent ? "-e " + task.ext.extent : "" def weight = task.ext.weight ? "-w " + task.ext.weight : "" - def out = task.ext.out ? "--out" + task.ext.out : "lps" + //For argument definition, mri_warp_convert -h + def out = task.ext.out ? "--out" + task.ext.out : "--outlps" """ export ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS=1 diff --git a/tests/modules/nf-scil/registration/synthregistration/nextflow.config b/tests/modules/nf-scil/registration/synthregistration/nextflow.config index 5c687e42..f04adea8 100644 --- a/tests/modules/nf-scil/registration/synthregistration/nextflow.config +++ b/tests/modules/nf-scil/registration/synthregistration/nextflow.config @@ -1,8 +1,8 @@ process { + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } - withName: "REGISTRATION_SYNTHREGISTRATION" { - publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } - + withName: "T1_FA" { + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } + ext.out = "lps" } - } \ No newline at end of file From 4258f524295a9c9d9d83baa6a04b2cc5569a489b Mon Sep 17 00:00:00 2001 From: anroy1 Date: Fri, 26 Jan 2024 12:48:18 -0500 Subject: [PATCH 05/34] test fix 1 --- .../nf-scil/registration/synthregistration/main.nf | 8 ++++---- .../nf-scil/registration/synthregistration/meta.yml | 11 ++++++++--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/modules/nf-scil/registration/synthregistration/main.nf b/modules/nf-scil/registration/synthregistration/main.nf index e200f652..81568c2b 100644 --- a/modules/nf-scil/registration/synthregistration/main.nf +++ b/modules/nf-scil/registration/synthregistration/main.nf @@ -3,8 +3,8 @@ process REGISTRATION_SYNTHREGISTRATION { label 'process_single' container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? - 'https://scil.usherbrooke.ca/containers/scilus_1.6.0.sif': - 'scilus/scilus:1.6.0' }" + 'freesurfer/synthmorph:latest': + 'freesurfer/synthmorph:latest' }" input: tuple val(meta), path(moving), path(fixed) @@ -13,11 +13,11 @@ process REGISTRATION_SYNTHREGISTRATION { output: tuple val(meta), path("*__*_output_warped.nii.gz"), emit: warped_image tuple val(meta), path("*__deform_warp.nii.gz"), emit: deform_transform - tuple val (meta), path("*__init_warp.txt"), emit: affine_transform + tuple val (meta), path("*__init_warp.txt"), emit: init_transform path "versions.yml" , emit: versions when: - task.ext.when == null || task.ext.when_output_warped + task.ext.when == null || task.ext.when script: def args = task.ext.args ?: '' diff --git a/modules/nf-scil/registration/synthregistration/meta.yml b/modules/nf-scil/registration/synthregistration/meta.yml index dcfa056f..20b73831 100644 --- a/modules/nf-scil/registration/synthregistration/meta.yml +++ b/modules/nf-scil/registration/synthregistration/meta.yml @@ -35,16 +35,21 @@ output: Groovy Map containing sample information e.g. `[ id:'test', single_end:false ]` - - init: + - init_transform: type: file description: Affine transform for initialization pattern: "*.{txt}" - - deform: + - deform_transform: type: file description: Deform transformation pattern: "*.{nii,.nii.gz}" - + + - warped_image: + type: file + description: Warped image + pattern: "*.{nii,.nii.gz}" + - versions: type: file description: File containing software versions From d2d0e4ac3fe3ebe54c29ce4636293ec838e112d7 Mon Sep 17 00:00:00 2001 From: anroy1 Date: Fri, 26 Jan 2024 14:11:22 -0500 Subject: [PATCH 06/34] 2nd fix for tests --- modules/nf-scil/registration/synthregistration/main.nf | 6 ++---- .../modules/nf-scil/registration/synthregistration/test.yml | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/modules/nf-scil/registration/synthregistration/main.nf b/modules/nf-scil/registration/synthregistration/main.nf index 81568c2b..8b7af873 100644 --- a/modules/nf-scil/registration/synthregistration/main.nf +++ b/modules/nf-scil/registration/synthregistration/main.nf @@ -2,9 +2,7 @@ process REGISTRATION_SYNTHREGISTRATION { tag "$meta.id" label 'process_single' - container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? - 'freesurfer/synthmorph:latest': - 'freesurfer/synthmorph:latest' }" + container "freesurfer/synthmorph:latest" input: tuple val(meta), path(moving), path(fixed) @@ -31,7 +29,7 @@ process REGISTRATION_SYNTHREGISTRATION { def extent = task.ext.extent ? "-e " + task.ext.extent : "" def weight = task.ext.weight ? "-w " + task.ext.weight : "" - //For argument definition, mri_warp_convert -h + //For arguments definition, mri_warp_convert -h def out = task.ext.out ? "--out" + task.ext.out : "--outlps" """ diff --git a/tests/modules/nf-scil/registration/synthregistration/test.yml b/tests/modules/nf-scil/registration/synthregistration/test.yml index 693eb329..4e1c389d 100644 --- a/tests/modules/nf-scil/registration/synthregistration/test.yml +++ b/tests/modules/nf-scil/registration/synthregistration/test.yml @@ -1,6 +1,6 @@ ## TODO nf-core: Please run the following command to build this file: # nf-core modules create-test-yml /synthregistration -- name: "registration synthregistration" +- name: registration synthregistration test_registration_synthregistration command: nextflow run ./tests/modules/nf-scil/registration/synthregistration -entry test_registration_synthregistration -c ./tests/config/nextflow.config tags: - "registration" @@ -10,4 +10,4 @@ md5sum: e667c7caad0bc4b7ac383fd023c654fc - path: "output/registration/versions.yml" md5sum: a01fe51bc4c6a3a6226fbf77b2c7cf3b - + From 41131a853cc82ae17998451775599f2dd8fa9530 Mon Sep 17 00:00:00 2001 From: anroy1 Date: Tue, 13 Feb 2024 10:11:18 -0500 Subject: [PATCH 07/34] quick fix --- modules/nf-scil/registration/synthregistration/main.nf | 2 +- tests/modules/nf-scil/registration/synthregistration/test.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/nf-scil/registration/synthregistration/main.nf b/modules/nf-scil/registration/synthregistration/main.nf index 8b7af873..7b6d2d50 100644 --- a/modules/nf-scil/registration/synthregistration/main.nf +++ b/modules/nf-scil/registration/synthregistration/main.nf @@ -72,7 +72,7 @@ process REGISTRATION_SYNTHREGISTRATION { cat <<-END_VERSIONS > versions.yml "${task.process}": - : \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//' )) + Freesurfer: 7.4 END_VERSIONS """ } diff --git a/tests/modules/nf-scil/registration/synthregistration/test.yml b/tests/modules/nf-scil/registration/synthregistration/test.yml index 4e1c389d..49a88bab 100644 --- a/tests/modules/nf-scil/registration/synthregistration/test.yml +++ b/tests/modules/nf-scil/registration/synthregistration/test.yml @@ -1,5 +1,5 @@ ## TODO nf-core: Please run the following command to build this file: -# nf-core modules create-test-yml /synthregistration +# nf-core modules create-test-yml registration/synthregistration - name: registration synthregistration test_registration_synthregistration command: nextflow run ./tests/modules/nf-scil/registration/synthregistration -entry test_registration_synthregistration -c ./tests/config/nextflow.config tags: From d82ae8221c08d0a7c1faf9df12059f270203e64a Mon Sep 17 00:00:00 2001 From: anroy1 Date: Wed, 21 Feb 2024 19:44:39 +0000 Subject: [PATCH 08/34] test naming fix --- modules/nf-scil/registration/synthregistration/main.nf | 4 ++-- .../nf-scil/registration/synthregistration/main.nf | 6 +++--- .../registration/synthregistration/nextflow.config | 9 ++++++--- .../nf-scil/registration/synthregistration/test.yml | 2 -- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/modules/nf-scil/registration/synthregistration/main.nf b/modules/nf-scil/registration/synthregistration/main.nf index 7b6d2d50..0fc76c1b 100644 --- a/modules/nf-scil/registration/synthregistration/main.nf +++ b/modules/nf-scil/registration/synthregistration/main.nf @@ -44,14 +44,14 @@ process REGISTRATION_SYNTHREGISTRATION { cat <<-END_VERSIONS > versions.yml "${task.process}": - : \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//' )) + Freesurfer: 7.4 END_VERSIONS """ stub: def args = task.ext.args ?: '' def prefix = task.ext.prefix ?: "${meta.id}" - def suffix = task.ext.suffix ?: "${meta.}" + def suffix = task.ext.suffix ?: "" def header = task.ext.header ? "-H " + task.ext.header : "" def threads = task.ext.threads ? "-j " + task.ext.threads : "" diff --git a/tests/modules/nf-scil/registration/synthregistration/main.nf b/tests/modules/nf-scil/registration/synthregistration/main.nf index c7c8c15f..134628ba 100644 --- a/tests/modules/nf-scil/registration/synthregistration/main.nf +++ b/tests/modules/nf-scil/registration/synthregistration/main.nf @@ -4,10 +4,10 @@ nextflow.enable.dsl = 2 include { LOAD_TEST_DATA } from '../../../../../modules/nf-scil/load_test_data/main.nf' include { - REGISTRATION_SYNTHREGISTRATION as T1_FA; } from '../../../../../modules/nf-scil/registration/synthregistration/main.nf' + REGISTRATION_SYNTHREGISTRATION as REGISTRATION_SYNTHREGISTRATION_T1FA; } from '../../../../../modules/nf-scil/registration/synthregistration/main.nf' workflow test_registration_synthregistration { - + input_fetch = Channel.from( [ "others.zip" ] ) LOAD_TEST_DATA ( input_fetch, "test.load-test-data" ) @@ -19,6 +19,6 @@ workflow test_registration_synthregistration { file("${test_data_directory}/fa.nii.gz") ]} - REGISTRATION_SYNTHREGISTRATION ( input_t1fa ) + REGISTRATION_SYNTHREGISTRATION_T1FA ( input_t1fa ) } diff --git a/tests/modules/nf-scil/registration/synthregistration/nextflow.config b/tests/modules/nf-scil/registration/synthregistration/nextflow.config index f04adea8..2a40b80a 100644 --- a/tests/modules/nf-scil/registration/synthregistration/nextflow.config +++ b/tests/modules/nf-scil/registration/synthregistration/nextflow.config @@ -1,8 +1,11 @@ process { - publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } - withName: "T1_FA" { + withName: "REGISTRATION_SYNTHREGISTRATION" { + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } + } + + withName: "REGISTRATION_SYNTHREGISTRATION_T1FA" { publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } ext.out = "lps" } -} \ No newline at end of file +} diff --git a/tests/modules/nf-scil/registration/synthregistration/test.yml b/tests/modules/nf-scil/registration/synthregistration/test.yml index 49a88bab..49c0e31b 100644 --- a/tests/modules/nf-scil/registration/synthregistration/test.yml +++ b/tests/modules/nf-scil/registration/synthregistration/test.yml @@ -1,5 +1,3 @@ -## TODO nf-core: Please run the following command to build this file: -# nf-core modules create-test-yml registration/synthregistration - name: registration synthregistration test_registration_synthregistration command: nextflow run ./tests/modules/nf-scil/registration/synthregistration -entry test_registration_synthregistration -c ./tests/config/nextflow.config tags: From 7c274d0b8d4c6e741f088964769c5cce171fc308 Mon Sep 17 00:00:00 2001 From: anroy1 Date: Thu, 22 Feb 2024 15:06:05 +0000 Subject: [PATCH 09/34] fix scilpy fetcher path --- tests/modules/nf-scil/registration/synthregistration/main.nf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/modules/nf-scil/registration/synthregistration/main.nf b/tests/modules/nf-scil/registration/synthregistration/main.nf index 134628ba..2b181af0 100644 --- a/tests/modules/nf-scil/registration/synthregistration/main.nf +++ b/tests/modules/nf-scil/registration/synthregistration/main.nf @@ -2,7 +2,7 @@ nextflow.enable.dsl = 2 -include { LOAD_TEST_DATA } from '../../../../../modules/nf-scil/load_test_data/main.nf' +include { LOAD_TEST_DATA } from '../../../../../subworkflows/nf-scil/load_test_data/main.nf' include { REGISTRATION_SYNTHREGISTRATION as REGISTRATION_SYNTHREGISTRATION_T1FA; } from '../../../../../modules/nf-scil/registration/synthregistration/main.nf' From 1f34c3a15baccede4e932f61e097c3034458346f Mon Sep 17 00:00:00 2001 From: anroy1 Date: Thu, 22 Feb 2024 20:58:30 +0000 Subject: [PATCH 10/34] fix tests parameters --- .../registration/synthregistration/main.nf | 32 ++++++++----------- .../synthregistration/nextflow.config | 1 - 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/modules/nf-scil/registration/synthregistration/main.nf b/modules/nf-scil/registration/synthregistration/main.nf index 0fc76c1b..a8d9cc34 100644 --- a/modules/nf-scil/registration/synthregistration/main.nf +++ b/modules/nf-scil/registration/synthregistration/main.nf @@ -20,27 +20,29 @@ process REGISTRATION_SYNTHREGISTRATION { script: def args = task.ext.args ?: '' def prefix = task.ext.prefix ?: "${meta.id}" - def suffix = task.ext.suffix ?: "" + def suffix = task.ext.suffix ?: "${meta.id}" - def header = task.ext.header ? "-H " + task.ext.header : "" - def threads = task.ext.threads ? "-j " + task.ext.threads : "" - def gpu = task.ext.gpu ? "-g " + task.ext.gpu : "" - def smooth = task.ext.smooth ? "-s " + task.ext.smooth : "" - def extent = task.ext.extent ? "-e " + task.ext.extent : "" - def weight = task.ext.weight ? "-w " + task.ext.weight : "" + def init = task.ext.init ? "-m " + task.est.init : "-m affine" + def warp = task.ext.warp ? "-m " + task.est.warp : "-m deform" + def header = task.ext.header ? "-H " + task.ext.header : "" + def threads = task.ext.threads ? "-j " + task.ext.threads : "" + def gpu = task.ext.gpu ? "-g " + task.ext.gpu : "" + def smooth = task.ext.smooth ? "-s " + task.ext.smooth : "" + def extent = task.ext.extent ? "-e " + task.ext.extent : "" + def weight = task.ext.weight ? "-w " + task.ext.weight : "" //For arguments definition, mri_warp_convert -h - def out = task.ext.out ? "--out" + task.ext.out : "--outlps" + def out_format = task.ext.out_format ? "--out" + task.ext.out_format : "--outlps" """ export ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS=1 export OMP_NUM_THREADS=1 export OPENBLAS_NUM_THREADS=1 - mri_synthmorph -m affine -t ${prefix}__init_warp.txt $moving $fixed - mri_synthmorph -m deform -i ${prefix}__init_warp.txt -t temp.mgz -o ${prefix}__${suffix}_output_warped.nii.gz $moving $fixed + mri_synthmorph $init -t ${prefix}__init_warp.txt $moving $fixed + mri_synthmorph $warp -i ${prefix}__init_warp.txt -t temp.mgz -o ${prefix}__${suffix}_output_warped.nii.gz $moving $fixed - mri_warp_convert -g $moving --inras temp.mgz $out ${prefix}__deform_warp.nii.gz + mri_warp_convert -g $moving --inras temp.mgz $out_format ${prefix}__deform_warp.nii.gz cat <<-END_VERSIONS > versions.yml "${task.process}": @@ -53,14 +55,6 @@ process REGISTRATION_SYNTHREGISTRATION { def prefix = task.ext.prefix ?: "${meta.id}" def suffix = task.ext.suffix ?: "" - def header = task.ext.header ? "-H " + task.ext.header : "" - def threads = task.ext.threads ? "-j " + task.ext.threads : "" - def gpu = task.ext.gpu ? "-g " + task.ext.gpu : "" - def smooth = task.ext.smooth ? "-s " + task.ext.smooth : "" - def extent = task.ext.extent ? "-e " + task.ext.extent : "" - def weight = task.ext.weight ? "-w " + task.ext.weight : "" - - def out = task.ext.out ? "--out" + task.ext.out : "lps" """ mri_synthmorph -h diff --git a/tests/modules/nf-scil/registration/synthregistration/nextflow.config b/tests/modules/nf-scil/registration/synthregistration/nextflow.config index 2a40b80a..d347f93c 100644 --- a/tests/modules/nf-scil/registration/synthregistration/nextflow.config +++ b/tests/modules/nf-scil/registration/synthregistration/nextflow.config @@ -6,6 +6,5 @@ process { withName: "REGISTRATION_SYNTHREGISTRATION_T1FA" { publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } - ext.out = "lps" } } From 41f885941c1285c52de1247f984c9e69c002f36c Mon Sep 17 00:00:00 2001 From: anroy1 Date: Fri, 1 Mar 2024 20:31:32 +0000 Subject: [PATCH 11/34] [WIP] modify module and test to manage freesurfer license --- .test_data/heavy/freesurfer/license.txt | 3 +++ .../registration/synthregistration/main.nf | 16 ++++++++++++- .../registration/synthregistration/meta.yml | 5 ++++ tests/config/test_data.config | 6 +++++ .../registration/synthregistration/main.nf | 23 +++++++------------ .../synthregistration/nextflow.config | 7 +----- 6 files changed, 38 insertions(+), 22 deletions(-) create mode 100644 .test_data/heavy/freesurfer/license.txt diff --git a/.test_data/heavy/freesurfer/license.txt b/.test_data/heavy/freesurfer/license.txt new file mode 100644 index 00000000..9c31cab4 --- /dev/null +++ b/.test_data/heavy/freesurfer/license.txt @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:05d2a544719626968d938cca74effbd673474fdc0db1d134f77f38e2fc497f49 +size 102 diff --git a/modules/nf-scil/registration/synthregistration/main.nf b/modules/nf-scil/registration/synthregistration/main.nf index a8d9cc34..3589e7a2 100644 --- a/modules/nf-scil/registration/synthregistration/main.nf +++ b/modules/nf-scil/registration/synthregistration/main.nf @@ -5,7 +5,7 @@ process REGISTRATION_SYNTHREGISTRATION { container "freesurfer/synthmorph:latest" input: - tuple val(meta), path(moving), path(fixed) + tuple val(meta), path(moving), path(fixed), path(fs_license) /* optional, value = [] */ output: @@ -35,6 +35,15 @@ process REGISTRATION_SYNTHREGISTRATION { def out_format = task.ext.out_format ? "--out" + task.ext.out_format : "--outlps" """ + # Manage the license. (Save old one if existed.) + if [ $fs_license = [] ]; then + echo "License not given in input. Using default environment. " + else + cp $fs_license .license + here=`pwd` + export FS_LICENSE=\$here/.license + fi + export ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS=1 export OMP_NUM_THREADS=1 export OPENBLAS_NUM_THREADS=1 @@ -44,6 +53,11 @@ process REGISTRATION_SYNTHREGISTRATION { mri_warp_convert -g $moving --inras temp.mgz $out_format ${prefix}__deform_warp.nii.gz + # Remove the license + if [ ! $fs_license = [] ]; then + rm .license + fi + cat <<-END_VERSIONS > versions.yml "${task.process}": Freesurfer: 7.4 diff --git a/modules/nf-scil/registration/synthregistration/meta.yml b/modules/nf-scil/registration/synthregistration/meta.yml index 20b73831..1cca21c4 100644 --- a/modules/nf-scil/registration/synthregistration/meta.yml +++ b/modules/nf-scil/registration/synthregistration/meta.yml @@ -28,6 +28,11 @@ input: description: Nifti volume fixed for registration pattern: "*.{nii,nii.gz}" + - fs_license: + type: file + description: The path to your FreeSurfer license. To get one, go to https://surfer.nmr.mgh.harvard.edu/registration.html. Optional. If you have already set your license as prescribed by Freesurfer (copied to a .license file in your $FREESURFER_HOME), this is not required. + pattern: "*.txt" + output: - meta: type: map diff --git a/tests/config/test_data.config b/tests/config/test_data.config index f34a7443..8df513ef 100755 --- a/tests/config/test_data.config +++ b/tests/config/test_data.config @@ -80,6 +80,12 @@ params { frf = "${params.test_data_base}/reconst/frf.txt" } } + "registration" { + "synthregistration"{ + t1 = "${params.test_data_base}/heavy/anat/anat_image.nii.gz" + fa = "${params.test_data_base}/heavy/dwi/dwi.nii.gz" + fs_license = "${params.test_data_base}/heavy/freesurfer/license.txt" + } "segmentation" { "freesurferseg" { aparc_aseg = "${params.test_data_base}/heavy/freesurfer/aparc_aseg.nii.gz" diff --git a/tests/modules/nf-scil/registration/synthregistration/main.nf b/tests/modules/nf-scil/registration/synthregistration/main.nf index 2b181af0..dfa3dfe9 100644 --- a/tests/modules/nf-scil/registration/synthregistration/main.nf +++ b/tests/modules/nf-scil/registration/synthregistration/main.nf @@ -2,23 +2,16 @@ nextflow.enable.dsl = 2 -include { LOAD_TEST_DATA } from '../../../../../subworkflows/nf-scil/load_test_data/main.nf' -include { - REGISTRATION_SYNTHREGISTRATION as REGISTRATION_SYNTHREGISTRATION_T1FA; } from '../../../../../modules/nf-scil/registration/synthregistration/main.nf' +include { REGISTRATION_SYNTHREGISTRATION } from '../../../../../modules/nf-scil/registration/synthregistration/main.nf' workflow test_registration_synthregistration { - input_fetch = Channel.from( [ "others.zip" ] ) - - LOAD_TEST_DATA ( input_fetch, "test.load-test-data" ) - - input_t1fa = LOAD_TEST_DATA.out.test_data_directory - .map{ test_data_directory -> [ - [ id:'test', single_end:false ], // meta map - file("${test_data_directory}/t1.nii.gz"), - file("${test_data_directory}/fa.nii.gz") - ]} - - REGISTRATION_SYNTHREGISTRATION_T1FA ( input_t1fa ) + input = [ + [ id:'test', single_end:false ], // meta map + file(params.test_data['registration']['synthregistration']['t1'], checkIfExists: true), + file(params.test_data['registration']['synthregistration']['fa'], checkIfExists: true), + file(params.test_data['registration']['synthregistration']['fs_license'], checkIfExists: true) + ] + REGISTRATION_SYNTHREGISTRATION ( input ) } diff --git a/tests/modules/nf-scil/registration/synthregistration/nextflow.config b/tests/modules/nf-scil/registration/synthregistration/nextflow.config index d347f93c..8730f1c4 100644 --- a/tests/modules/nf-scil/registration/synthregistration/nextflow.config +++ b/tests/modules/nf-scil/registration/synthregistration/nextflow.config @@ -1,10 +1,5 @@ process { - withName: "REGISTRATION_SYNTHREGISTRATION" { - publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } - } + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } - withName: "REGISTRATION_SYNTHREGISTRATION_T1FA" { - publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } - } } From b51f537f54fd237676012602ceb60616bab59d61 Mon Sep 17 00:00:00 2001 From: anroy1 Date: Tue, 9 Apr 2024 19:16:44 +0000 Subject: [PATCH 12/34] fix test data, freesurfer license --- .../registration/synthregistration/main.nf | 29 +++++-------------- tests/config/test_data.config | 6 ---- .../registration/synthregistration/main.nf | 17 +++++++---- 3 files changed, 19 insertions(+), 33 deletions(-) diff --git a/modules/nf-scil/registration/synthregistration/main.nf b/modules/nf-scil/registration/synthregistration/main.nf index 3589e7a2..ab3024c7 100644 --- a/modules/nf-scil/registration/synthregistration/main.nf +++ b/modules/nf-scil/registration/synthregistration/main.nf @@ -2,14 +2,15 @@ process REGISTRATION_SYNTHREGISTRATION { tag "$meta.id" label 'process_single' - container "freesurfer/synthmorph:latest" + container "freesurfer/freesurfer:7.4.1" + containerOptions "--entrypoint ''" input: tuple val(meta), path(moving), path(fixed), path(fs_license) /* optional, value = [] */ output: - tuple val(meta), path("*__*_output_warped.nii.gz"), emit: warped_image + tuple val(meta), path("*__output_warped.nii.gz"), emit: warped_image tuple val(meta), path("*__deform_warp.nii.gz"), emit: deform_transform tuple val (meta), path("*__init_warp.txt"), emit: init_transform path "versions.yml" , emit: versions @@ -20,13 +21,12 @@ process REGISTRATION_SYNTHREGISTRATION { script: def args = task.ext.args ?: '' def prefix = task.ext.prefix ?: "${meta.id}" - def suffix = task.ext.suffix ?: "${meta.id}" def init = task.ext.init ? "-m " + task.est.init : "-m affine" def warp = task.ext.warp ? "-m " + task.est.warp : "-m deform" - def header = task.ext.header ? "-H " + task.ext.header : "" + def header = task.ext.header ? "-H" : "" def threads = task.ext.threads ? "-j " + task.ext.threads : "" - def gpu = task.ext.gpu ? "-g " + task.ext.gpu : "" + def gpu = task.ext.gpu ? "-g" : "" def smooth = task.ext.smooth ? "-s " + task.ext.smooth : "" def extent = task.ext.extent ? "-e " + task.ext.extent : "" def weight = task.ext.weight ? "-w " + task.ext.weight : "" @@ -35,29 +35,15 @@ process REGISTRATION_SYNTHREGISTRATION { def out_format = task.ext.out_format ? "--out" + task.ext.out_format : "--outlps" """ - # Manage the license. (Save old one if existed.) - if [ $fs_license = [] ]; then - echo "License not given in input. Using default environment. " - else - cp $fs_license .license - here=`pwd` - export FS_LICENSE=\$here/.license - fi - export ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS=1 export OMP_NUM_THREADS=1 export OPENBLAS_NUM_THREADS=1 mri_synthmorph $init -t ${prefix}__init_warp.txt $moving $fixed - mri_synthmorph $warp -i ${prefix}__init_warp.txt -t temp.mgz -o ${prefix}__${suffix}_output_warped.nii.gz $moving $fixed + mri_synthmorph $warp -i ${prefix}__init_warp.txt -t temp.mgz -o ${prefix}__output_warped.nii.gz $moving $fixed mri_warp_convert -g $moving --inras temp.mgz $out_format ${prefix}__deform_warp.nii.gz - # Remove the license - if [ ! $fs_license = [] ]; then - rm .license - fi - cat <<-END_VERSIONS > versions.yml "${task.process}": Freesurfer: 7.4 @@ -67,14 +53,13 @@ process REGISTRATION_SYNTHREGISTRATION { stub: def args = task.ext.args ?: '' def prefix = task.ext.prefix ?: "${meta.id}" - def suffix = task.ext.suffix ?: "" """ mri_synthmorph -h mri_warp_convert -h - touch ${prefix}__${suffix}_output_warped.nii.gz + touch ${prefix}__output_warped.nii.gz touch ${prefix}__deform_warp.nii.gz touch ${prefix}__init_warp.txt diff --git a/tests/config/test_data.config b/tests/config/test_data.config index 8df513ef..f34a7443 100755 --- a/tests/config/test_data.config +++ b/tests/config/test_data.config @@ -80,12 +80,6 @@ params { frf = "${params.test_data_base}/reconst/frf.txt" } } - "registration" { - "synthregistration"{ - t1 = "${params.test_data_base}/heavy/anat/anat_image.nii.gz" - fa = "${params.test_data_base}/heavy/dwi/dwi.nii.gz" - fs_license = "${params.test_data_base}/heavy/freesurfer/license.txt" - } "segmentation" { "freesurferseg" { aparc_aseg = "${params.test_data_base}/heavy/freesurfer/aparc_aseg.nii.gz" diff --git a/tests/modules/nf-scil/registration/synthregistration/main.nf b/tests/modules/nf-scil/registration/synthregistration/main.nf index dfa3dfe9..3d106ebc 100644 --- a/tests/modules/nf-scil/registration/synthregistration/main.nf +++ b/tests/modules/nf-scil/registration/synthregistration/main.nf @@ -2,16 +2,23 @@ nextflow.enable.dsl = 2 +include { LOAD_TEST_DATA } from '../../../../../subworkflows/nf-scil/load_test_data/main' include { REGISTRATION_SYNTHREGISTRATION } from '../../../../../modules/nf-scil/registration/synthregistration/main.nf' workflow test_registration_synthregistration { - input = [ + input_fetch = Channel.from( [ "freesurfer.zip" ] ) + + LOAD_TEST_DATA ( input_fetch, "test.load-test-data" ) + + input = LOAD_TEST_DATA.out.test_data_directory + .map{ test_data_directory -> [ [ id:'test', single_end:false ], // meta map - file(params.test_data['registration']['synthregistration']['t1'], checkIfExists: true), - file(params.test_data['registration']['synthregistration']['fa'], checkIfExists: true), - file(params.test_data['registration']['synthregistration']['fs_license'], checkIfExists: true) - ] + file("${test_data_directory}/t1.nii.gz"), + file("${test_data_directory}/fa.nii.gz"), + [] + + ]} REGISTRATION_SYNTHREGISTRATION ( input ) } From bacd6cb8e39a367bf3e251da0ff38fef342c6fd5 Mon Sep 17 00:00:00 2001 From: anroy1 Date: Wed, 10 Apr 2024 14:39:22 +0000 Subject: [PATCH 13/34] [WIP] improve test --- .../nf-scil/registration/synthregistration/main.nf | 14 +++++--------- .../registration/synthregistration/meta.yml | 4 ++-- .../nf-scil/registration/synthregistration/main.nf | 2 +- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/modules/nf-scil/registration/synthregistration/main.nf b/modules/nf-scil/registration/synthregistration/main.nf index ab3024c7..da027e7a 100644 --- a/modules/nf-scil/registration/synthregistration/main.nf +++ b/modules/nf-scil/registration/synthregistration/main.nf @@ -2,7 +2,7 @@ process REGISTRATION_SYNTHREGISTRATION { tag "$meta.id" label 'process_single' - container "freesurfer/freesurfer:7.4.1" + container "freesurfer/synthmorph:latest" containerOptions "--entrypoint ''" input: @@ -11,8 +11,8 @@ process REGISTRATION_SYNTHREGISTRATION { output: tuple val(meta), path("*__output_warped.nii.gz"), emit: warped_image - tuple val(meta), path("*__deform_warp.nii.gz"), emit: deform_transform - tuple val (meta), path("*__init_warp.txt"), emit: init_transform + tuple val(meta), path("*__deform_warp.m3z"), emit: deform_transform + tuple val (meta), path("*__init_warp.lta"), emit: init_transform path "versions.yml" , emit: versions when: @@ -39,10 +39,8 @@ process REGISTRATION_SYNTHREGISTRATION { export OMP_NUM_THREADS=1 export OPENBLAS_NUM_THREADS=1 - mri_synthmorph $init -t ${prefix}__init_warp.txt $moving $fixed - mri_synthmorph $warp -i ${prefix}__init_warp.txt -t temp.mgz -o ${prefix}__output_warped.nii.gz $moving $fixed - - mri_warp_convert -g $moving --inras temp.mgz $out_format ${prefix}__deform_warp.nii.gz + mri_synthmorph $init -g -t ${prefix}__init_warp.lta $moving $fixed + mri_synthmorph $warp -g -i ${prefix}__init_warp.lta -t ${prefix}__deform_warp.m3d -o ${prefix}__output_warped.nii.gz $moving $fixed cat <<-END_VERSIONS > versions.yml "${task.process}": @@ -57,8 +55,6 @@ process REGISTRATION_SYNTHREGISTRATION { """ mri_synthmorph -h - mri_warp_convert -h - touch ${prefix}__output_warped.nii.gz touch ${prefix}__deform_warp.nii.gz touch ${prefix}__init_warp.txt diff --git a/modules/nf-scil/registration/synthregistration/meta.yml b/modules/nf-scil/registration/synthregistration/meta.yml index 1cca21c4..2ec3d83f 100644 --- a/modules/nf-scil/registration/synthregistration/meta.yml +++ b/modules/nf-scil/registration/synthregistration/meta.yml @@ -43,12 +43,12 @@ output: - init_transform: type: file description: Affine transform for initialization - pattern: "*.{txt}" + pattern: "*.{lta}" - deform_transform: type: file description: Deform transformation - pattern: "*.{nii,.nii.gz}" + pattern: "*.{m3z}" - warped_image: type: file diff --git a/tests/modules/nf-scil/registration/synthregistration/main.nf b/tests/modules/nf-scil/registration/synthregistration/main.nf index 3d106ebc..c45a7bd2 100644 --- a/tests/modules/nf-scil/registration/synthregistration/main.nf +++ b/tests/modules/nf-scil/registration/synthregistration/main.nf @@ -16,7 +16,7 @@ workflow test_registration_synthregistration { [ id:'test', single_end:false ], // meta map file("${test_data_directory}/t1.nii.gz"), file("${test_data_directory}/fa.nii.gz"), - [] + file("${test_data_directory}/license.txt") ]} From 496ac487822a3084f8805f2e876eeb51fc2aa219 Mon Sep 17 00:00:00 2001 From: anroy1 Date: Tue, 16 Apr 2024 13:58:35 +0000 Subject: [PATCH 14/34] Adjust nextflow config and output format --- .../registration/synthregistration/main.nf | 7 ++---- .../registration/synthregistration/meta.yml | 6 ++--- tests/config/nextflow.config | 4 +-- .../registration/synthregistration/test.yml | 25 +++++++++++++------ 4 files changed, 25 insertions(+), 17 deletions(-) diff --git a/modules/nf-scil/registration/synthregistration/main.nf b/modules/nf-scil/registration/synthregistration/main.nf index da027e7a..5ceb177e 100644 --- a/modules/nf-scil/registration/synthregistration/main.nf +++ b/modules/nf-scil/registration/synthregistration/main.nf @@ -11,7 +11,7 @@ process REGISTRATION_SYNTHREGISTRATION { output: tuple val(meta), path("*__output_warped.nii.gz"), emit: warped_image - tuple val(meta), path("*__deform_warp.m3z"), emit: deform_transform + tuple val(meta), path("*__deform_warp.nii.gz"), emit: deform_transform tuple val (meta), path("*__init_warp.lta"), emit: init_transform path "versions.yml" , emit: versions @@ -31,16 +31,13 @@ process REGISTRATION_SYNTHREGISTRATION { def extent = task.ext.extent ? "-e " + task.ext.extent : "" def weight = task.ext.weight ? "-w " + task.ext.weight : "" - //For arguments definition, mri_warp_convert -h - def out_format = task.ext.out_format ? "--out" + task.ext.out_format : "--outlps" - """ export ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS=1 export OMP_NUM_THREADS=1 export OPENBLAS_NUM_THREADS=1 mri_synthmorph $init -g -t ${prefix}__init_warp.lta $moving $fixed - mri_synthmorph $warp -g -i ${prefix}__init_warp.lta -t ${prefix}__deform_warp.m3d -o ${prefix}__output_warped.nii.gz $moving $fixed + mri_synthmorph $warp -g -i ${prefix}__init_warp.lta -t ${prefix}__deform_warp.nii.gz -o ${prefix}__output_warped.nii.gz $moving $fixed cat <<-END_VERSIONS > versions.yml "${task.process}": diff --git a/modules/nf-scil/registration/synthregistration/meta.yml b/modules/nf-scil/registration/synthregistration/meta.yml index 2ec3d83f..e4ba7545 100644 --- a/modules/nf-scil/registration/synthregistration/meta.yml +++ b/modules/nf-scil/registration/synthregistration/meta.yml @@ -7,8 +7,8 @@ keywords: - MRI tools: - "Freesurfer": - description: "Freesurfer Toolbox" - homepage: "https://surfer.nmr.mgh.harvard.edu/" + description: "Freesurfer Synthmorph" + homepage: "https://martinos.org/malte/synthmorph/" input: @@ -48,7 +48,7 @@ output: - deform_transform: type: file description: Deform transformation - pattern: "*.{m3z}" + pattern: "*.{nii,.nii.gz}" - warped_image: type: file diff --git a/tests/config/nextflow.config b/tests/config/nextflow.config index 633b633b..329b90cd 100755 --- a/tests/config/nextflow.config +++ b/tests/config/nextflow.config @@ -5,8 +5,8 @@ params { } process { - cpus = 4 - memory = 5.GB + cpus = 16 + memory = 20.GB time = 2.h } diff --git a/tests/modules/nf-scil/registration/synthregistration/test.yml b/tests/modules/nf-scil/registration/synthregistration/test.yml index 49c0e31b..c9917296 100644 --- a/tests/modules/nf-scil/registration/synthregistration/test.yml +++ b/tests/modules/nf-scil/registration/synthregistration/test.yml @@ -1,11 +1,22 @@ - name: registration synthregistration test_registration_synthregistration command: nextflow run ./tests/modules/nf-scil/registration/synthregistration -entry test_registration_synthregistration -c ./tests/config/nextflow.config tags: - - "registration" - - "registration/synthregistration" + - registration + - registration/synthregistration files: - - path: "output/registration/test.bam" - md5sum: e667c7caad0bc4b7ac383fd023c654fc - - path: "output/registration/versions.yml" - md5sum: a01fe51bc4c6a3a6226fbf77b2c7cf3b - + - path: output/registration/test__deform_warp.nii.gz + md5sum: e0ed8084afa172668f50579f0585706c + - path: output/registration/test__init_warp.lta + md5sum: 4c5b29a64c8db1f87dd9ecf83a2d9878 + - path: output/registration/test__output_warped.nii.gz + md5sum: 2b0441e95fd48bc269833d05831cfd9e + - path: output/registration/versions.yml + - path: output/testdata/test_data/freesurfer/anat_image.nii.gz + md5sum: ba57c629e9dc29204215dceac36d65ae + - path: output/testdata/test_data/freesurfer/fa.nii.gz + md5sum: 0e76e9378500de64d66ba3d787a147ca + - path: output/testdata/test_data/freesurfer/license.txt + md5sum: 3db0fa4e1860b4774c7855980e406275 + - path: output/testdata/test_data/freesurfer/t1.nii.gz + md5sum: a6ade205420f594737ad67f9fb246f0f + - path: output/testdata/versions.yml From b632962f34b44fdb53f41db57c763b21562d0497 Mon Sep 17 00:00:00 2001 From: anroy1 Date: Sat, 20 Apr 2024 17:51:18 +0000 Subject: [PATCH 15/34] Swith transform format to freesurfer standard --- modules/nf-scil/registration/synthregistration/main.nf | 10 +++++----- .../nf-scil/registration/synthregistration/meta.yml | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/nf-scil/registration/synthregistration/main.nf b/modules/nf-scil/registration/synthregistration/main.nf index 5ceb177e..1131c301 100644 --- a/modules/nf-scil/registration/synthregistration/main.nf +++ b/modules/nf-scil/registration/synthregistration/main.nf @@ -11,7 +11,7 @@ process REGISTRATION_SYNTHREGISTRATION { output: tuple val(meta), path("*__output_warped.nii.gz"), emit: warped_image - tuple val(meta), path("*__deform_warp.nii.gz"), emit: deform_transform + tuple val(meta), path("*__deform_warp.mgz"), emit: deform_transform tuple val (meta), path("*__init_warp.lta"), emit: init_transform path "versions.yml" , emit: versions @@ -36,8 +36,8 @@ process REGISTRATION_SYNTHREGISTRATION { export OMP_NUM_THREADS=1 export OPENBLAS_NUM_THREADS=1 - mri_synthmorph $init -g -t ${prefix}__init_warp.lta $moving $fixed - mri_synthmorph $warp -g -i ${prefix}__init_warp.lta -t ${prefix}__deform_warp.nii.gz -o ${prefix}__output_warped.nii.gz $moving $fixed + mri_synthmorph $init -t ${prefix}__init_warp.lta $moving $fixed + mri_synthmorph $warp $gpu $smooth $extent $weight -i ${prefix}__init_warp.lta -t ${prefix}__deform_warp.mgz -o ${prefix}__output_warped.nii.gz $moving $fixed cat <<-END_VERSIONS > versions.yml "${task.process}": @@ -53,8 +53,8 @@ process REGISTRATION_SYNTHREGISTRATION { mri_synthmorph -h touch ${prefix}__output_warped.nii.gz - touch ${prefix}__deform_warp.nii.gz - touch ${prefix}__init_warp.txt + touch ${prefix}__deform_warp.mgz + touch ${prefix}__init_warp.lta cat <<-END_VERSIONS > versions.yml "${task.process}": diff --git a/modules/nf-scil/registration/synthregistration/meta.yml b/modules/nf-scil/registration/synthregistration/meta.yml index e4ba7545..d51d6208 100644 --- a/modules/nf-scil/registration/synthregistration/meta.yml +++ b/modules/nf-scil/registration/synthregistration/meta.yml @@ -1,6 +1,6 @@ --- name: "registration_synthregistration" -description: Perform registration using SynthMorph from Freesurfer +description: Perform registration using SynthMorph from Freesurfer. Output transforms in Freesurfer format .lta for affine and .mgz for deform, which can be converted for ANTs with respectively lta_convert and mri_warp_convert. keywords: - registration - Brain imaging @@ -43,12 +43,12 @@ output: - init_transform: type: file description: Affine transform for initialization - pattern: "*.{lta}" + pattern: "*.{txt}" - deform_transform: type: file description: Deform transformation - pattern: "*.{nii,.nii.gz}" + pattern: "*.{mgz}" - warped_image: type: file From 077f4207013bfc6e6d8571bccef57504863035a9 Mon Sep 17 00:00:00 2001 From: anroy1 Date: Thu, 25 Apr 2024 19:25:39 +0000 Subject: [PATCH 16/34] run prettier --- modules/nf-scil/registration/synthregistration/meta.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/nf-scil/registration/synthregistration/meta.yml b/modules/nf-scil/registration/synthregistration/meta.yml index d51d6208..5d363197 100644 --- a/modules/nf-scil/registration/synthregistration/meta.yml +++ b/modules/nf-scil/registration/synthregistration/meta.yml @@ -10,7 +10,6 @@ tools: description: "Freesurfer Synthmorph" homepage: "https://martinos.org/malte/synthmorph/" - input: - meta: type: map From 98209d41ee7ee756ab03b49b277fbf664ba51a36 Mon Sep 17 00:00:00 2001 From: anroy1 Date: Thu, 9 May 2024 18:16:20 +0000 Subject: [PATCH 17/34] Remove license as module do not require it and update parameters with newer version --- .../nf-scil/registration/synthregistration/main.nf | 13 +++++++------ .../nf-scil/registration/synthregistration/meta.yml | 5 ----- .../nf-scil/registration/synthregistration/main.nf | 3 +-- .../registration/synthregistration/nextflow.config | 8 ++++++++ .../nf-scil/registration/synthregistration/test.yml | 11 ++++++----- 5 files changed, 22 insertions(+), 18 deletions(-) diff --git a/modules/nf-scil/registration/synthregistration/main.nf b/modules/nf-scil/registration/synthregistration/main.nf index 1131c301..aec53edc 100644 --- a/modules/nf-scil/registration/synthregistration/main.nf +++ b/modules/nf-scil/registration/synthregistration/main.nf @@ -6,7 +6,7 @@ process REGISTRATION_SYNTHREGISTRATION { containerOptions "--entrypoint ''" input: - tuple val(meta), path(moving), path(fixed), path(fs_license) /* optional, value = [] */ + tuple val(meta), path(moving), path(fixed) output: @@ -22,12 +22,13 @@ process REGISTRATION_SYNTHREGISTRATION { def args = task.ext.args ?: '' def prefix = task.ext.prefix ?: "${meta.id}" - def init = task.ext.init ? "-m " + task.est.init : "-m affine" - def warp = task.ext.warp ? "-m " + task.est.warp : "-m deform" + def init = task.ext.init ? "-m " + task.ext.init : "-m affine" + def warp = task.ext.warp ? "-m " + task.ext.warp : "-m deform" def header = task.ext.header ? "-H" : "" def threads = task.ext.threads ? "-j " + task.ext.threads : "" def gpu = task.ext.gpu ? "-g" : "" - def smooth = task.ext.smooth ? "-s " + task.ext.smooth : "" + def lambda = task.ext.lambda ? "-r " + task.ext.lambda : "" + def steps = task.ext.steps ? "-n " + task.ext.steps : "" def extent = task.ext.extent ? "-e " + task.ext.extent : "" def weight = task.ext.weight ? "-w " + task.ext.weight : "" @@ -36,8 +37,8 @@ process REGISTRATION_SYNTHREGISTRATION { export OMP_NUM_THREADS=1 export OPENBLAS_NUM_THREADS=1 - mri_synthmorph $init -t ${prefix}__init_warp.lta $moving $fixed - mri_synthmorph $warp $gpu $smooth $extent $weight -i ${prefix}__init_warp.lta -t ${prefix}__deform_warp.mgz -o ${prefix}__output_warped.nii.gz $moving $fixed + mri_synthmorph ${init} -t ${prefix}__init_warp.lta $moving $fixed + mri_synthmorph ${warp} ${gpu} ${lambda} ${steps} ${extent} ${weight} -i ${prefix}__init_warp.lta -t ${prefix}__deform_warp.mgz -o ${prefix}__output_warped.nii.gz $moving $fixed cat <<-END_VERSIONS > versions.yml "${task.process}": diff --git a/modules/nf-scil/registration/synthregistration/meta.yml b/modules/nf-scil/registration/synthregistration/meta.yml index 5d363197..9a3c2de1 100644 --- a/modules/nf-scil/registration/synthregistration/meta.yml +++ b/modules/nf-scil/registration/synthregistration/meta.yml @@ -27,11 +27,6 @@ input: description: Nifti volume fixed for registration pattern: "*.{nii,nii.gz}" - - fs_license: - type: file - description: The path to your FreeSurfer license. To get one, go to https://surfer.nmr.mgh.harvard.edu/registration.html. Optional. If you have already set your license as prescribed by Freesurfer (copied to a .license file in your $FREESURFER_HOME), this is not required. - pattern: "*.txt" - output: - meta: type: map diff --git a/tests/modules/nf-scil/registration/synthregistration/main.nf b/tests/modules/nf-scil/registration/synthregistration/main.nf index c45a7bd2..89f5d379 100644 --- a/tests/modules/nf-scil/registration/synthregistration/main.nf +++ b/tests/modules/nf-scil/registration/synthregistration/main.nf @@ -15,8 +15,7 @@ workflow test_registration_synthregistration { .map{ test_data_directory -> [ [ id:'test', single_end:false ], // meta map file("${test_data_directory}/t1.nii.gz"), - file("${test_data_directory}/fa.nii.gz"), - file("${test_data_directory}/license.txt") + file("${test_data_directory}/fa.nii.gz") ]} diff --git a/tests/modules/nf-scil/registration/synthregistration/nextflow.config b/tests/modules/nf-scil/registration/synthregistration/nextflow.config index 8730f1c4..2a1c9275 100644 --- a/tests/modules/nf-scil/registration/synthregistration/nextflow.config +++ b/tests/modules/nf-scil/registration/synthregistration/nextflow.config @@ -2,4 +2,12 @@ process { publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } + withName: "test_registration_synthregistration:REGISTRATION_SYNTHREGISTRATION" { + ext.init = "affine" + ext.warp = "deform" + ext.threads = 1 + ext.lambda = 0.5 + ext.steps = 5 + } + } diff --git a/tests/modules/nf-scil/registration/synthregistration/test.yml b/tests/modules/nf-scil/registration/synthregistration/test.yml index c9917296..e19c287b 100644 --- a/tests/modules/nf-scil/registration/synthregistration/test.yml +++ b/tests/modules/nf-scil/registration/synthregistration/test.yml @@ -1,15 +1,16 @@ - name: registration synthregistration test_registration_synthregistration command: nextflow run ./tests/modules/nf-scil/registration/synthregistration -entry test_registration_synthregistration -c ./tests/config/nextflow.config tags: - - registration - registration/synthregistration + - registration files: - - path: output/registration/test__deform_warp.nii.gz - md5sum: e0ed8084afa172668f50579f0585706c + - path: output/registration/test__deform_warp.mgz + contains: + - '# TODO nf-core: file md5sum was variable, please replace this text with a string found in the file instead ' - path: output/registration/test__init_warp.lta - md5sum: 4c5b29a64c8db1f87dd9ecf83a2d9878 + md5sum: 46ad5a5d359b2ec157d1164135e746eb - path: output/registration/test__output_warped.nii.gz - md5sum: 2b0441e95fd48bc269833d05831cfd9e + md5sum: bdc4ff1557093fd25a760e4db48d7d58 - path: output/registration/versions.yml - path: output/testdata/test_data/freesurfer/anat_image.nii.gz md5sum: ba57c629e9dc29204215dceac36d65ae From d47cbed7aae6675dc38466db1926e870efc636af Mon Sep 17 00:00:00 2001 From: anroy1 Date: Tue, 14 May 2024 13:44:19 +0000 Subject: [PATCH 18/34] Switch transform output to fs .nii.gz format --- modules/nf-scil/registration/synthregistration/main.nf | 7 +++---- modules/nf-scil/registration/synthregistration/meta.yml | 2 +- .../nf-scil/registration/synthregistration/test.yml | 5 ++--- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/modules/nf-scil/registration/synthregistration/main.nf b/modules/nf-scil/registration/synthregistration/main.nf index aec53edc..8d130b82 100644 --- a/modules/nf-scil/registration/synthregistration/main.nf +++ b/modules/nf-scil/registration/synthregistration/main.nf @@ -8,10 +8,9 @@ process REGISTRATION_SYNTHREGISTRATION { input: tuple val(meta), path(moving), path(fixed) - output: tuple val(meta), path("*__output_warped.nii.gz"), emit: warped_image - tuple val(meta), path("*__deform_warp.mgz"), emit: deform_transform + tuple val(meta), path("*__deform_warp.nii.gz"), emit: deform_transform tuple val (meta), path("*__init_warp.lta"), emit: init_transform path "versions.yml" , emit: versions @@ -38,7 +37,7 @@ process REGISTRATION_SYNTHREGISTRATION { export OPENBLAS_NUM_THREADS=1 mri_synthmorph ${init} -t ${prefix}__init_warp.lta $moving $fixed - mri_synthmorph ${warp} ${gpu} ${lambda} ${steps} ${extent} ${weight} -i ${prefix}__init_warp.lta -t ${prefix}__deform_warp.mgz -o ${prefix}__output_warped.nii.gz $moving $fixed + mri_synthmorph ${warp} ${gpu} ${lambda} ${steps} ${extent} ${weight} -i ${prefix}__init_warp.lta -t ${prefix}__deform_warp.nii.gz -o ${prefix}__output_warped.nii.gz $moving $fixed cat <<-END_VERSIONS > versions.yml "${task.process}": @@ -54,7 +53,7 @@ process REGISTRATION_SYNTHREGISTRATION { mri_synthmorph -h touch ${prefix}__output_warped.nii.gz - touch ${prefix}__deform_warp.mgz + touch ${prefix}__deform_warp.nii.gz touch ${prefix}__init_warp.lta cat <<-END_VERSIONS > versions.yml diff --git a/modules/nf-scil/registration/synthregistration/meta.yml b/modules/nf-scil/registration/synthregistration/meta.yml index 9a3c2de1..5fe45c45 100644 --- a/modules/nf-scil/registration/synthregistration/meta.yml +++ b/modules/nf-scil/registration/synthregistration/meta.yml @@ -42,7 +42,7 @@ output: - deform_transform: type: file description: Deform transformation - pattern: "*.{mgz}" + pattern: "*.{nii.gz}" - warped_image: type: file diff --git a/tests/modules/nf-scil/registration/synthregistration/test.yml b/tests/modules/nf-scil/registration/synthregistration/test.yml index e19c287b..925c6bdb 100644 --- a/tests/modules/nf-scil/registration/synthregistration/test.yml +++ b/tests/modules/nf-scil/registration/synthregistration/test.yml @@ -4,9 +4,8 @@ - registration/synthregistration - registration files: - - path: output/registration/test__deform_warp.mgz - contains: - - '# TODO nf-core: file md5sum was variable, please replace this text with a string found in the file instead ' + - path: output/registration/test__deform_warp.nii.gz + md5sum: d01c753043af2257908d049ade978981 - path: output/registration/test__init_warp.lta md5sum: 46ad5a5d359b2ec157d1164135e746eb - path: output/registration/test__output_warped.nii.gz From ce493f8874995fff4930693288b0bd61a1c40680 Mon Sep 17 00:00:00 2001 From: anroy1 Date: Sat, 1 Jun 2024 19:27:01 +0000 Subject: [PATCH 19/34] Migrate tests to nf-tests --- .../synthregistration/environment.yml | 7 +++ .../registration/synthregistration/meta.yml | 2 +- .../synthregistration/tests/main.nf.test | 50 +++++++++++++++++++ .../synthregistration/tests/main.nf.test.snap | 37 ++++++++++++++ .../synthregistration/tests/nextflow.config | 10 ++++ .../synthregistration/tests/tags.yml | 2 + 6 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 modules/nf-scil/registration/synthregistration/environment.yml create mode 100644 modules/nf-scil/registration/synthregistration/tests/main.nf.test create mode 100644 modules/nf-scil/registration/synthregistration/tests/main.nf.test.snap create mode 100644 modules/nf-scil/registration/synthregistration/tests/nextflow.config create mode 100644 modules/nf-scil/registration/synthregistration/tests/tags.yml diff --git a/modules/nf-scil/registration/synthregistration/environment.yml b/modules/nf-scil/registration/synthregistration/environment.yml new file mode 100644 index 00000000..52b962fd --- /dev/null +++ b/modules/nf-scil/registration/synthregistration/environment.yml @@ -0,0 +1,7 @@ +--- +name: "registration_synthregistration" +channels: + - Docker + - Apptainer +dependencies: + - "Freesurfer:synthmorph" diff --git a/modules/nf-scil/registration/synthregistration/meta.yml b/modules/nf-scil/registration/synthregistration/meta.yml index 5fe45c45..580f04bb 100644 --- a/modules/nf-scil/registration/synthregistration/meta.yml +++ b/modules/nf-scil/registration/synthregistration/meta.yml @@ -55,4 +55,4 @@ output: pattern: "versions.yml" authors: - - "@scilus" + - "@anroy1" diff --git a/modules/nf-scil/registration/synthregistration/tests/main.nf.test b/modules/nf-scil/registration/synthregistration/tests/main.nf.test new file mode 100644 index 00000000..83148c72 --- /dev/null +++ b/modules/nf-scil/registration/synthregistration/tests/main.nf.test @@ -0,0 +1,50 @@ +// TODO nf-core: Once you have added the required tests, please run the following command to build this file: +// nf-core modules test registration/synthregistration +nextflow_process { + + name "Test Process REGISTRATION_SYNTHREGISTRATION" + script "../main.nf" + process "REGISTRATION_SYNTHREGISTRATION" + + tag "modules" + tag "modules_nfcore" + tag "registration" + tag "registration/synthregistration" + + 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" ] ) + input[1] = "test.load-test-data" + """ + } + } + } + + test("registration - synthregistration") { + config "./nextflow.config" + when { + process { + """ + input[0] = LOAD_DATA.out.test_data_directory + .map{ test_data_directory -> [ + [ id:'test', single_end:false ], + file("\${test_data_directory}/t1.nii.gz"), + file("\${test_data_directory}/fa.nii.gz") + ]} + """ + } + } + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + } +} diff --git a/modules/nf-scil/registration/synthregistration/tests/main.nf.test.snap b/modules/nf-scil/registration/synthregistration/tests/main.nf.test.snap new file mode 100644 index 00000000..d31a7f52 --- /dev/null +++ b/modules/nf-scil/registration/synthregistration/tests/main.nf.test.snap @@ -0,0 +1,37 @@ +{ + "registration - synthregistration": { + "content": [ + { + "0": [ + + ], + "1": [ + + ], + "2": [ + + ], + "3": [ + + ], + "deform_transform": [ + + ], + "init_transform": [ + + ], + "versions": [ + + ], + "warped_image": [ + + ] + } + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "23.10.1" + }, + "timestamp": "2024-06-01T19:08:42.159111" + } +} \ No newline at end of file diff --git a/modules/nf-scil/registration/synthregistration/tests/nextflow.config b/modules/nf-scil/registration/synthregistration/tests/nextflow.config new file mode 100644 index 00000000..1b3a8fe6 --- /dev/null +++ b/modules/nf-scil/registration/synthregistration/tests/nextflow.config @@ -0,0 +1,10 @@ +process { + withName: "REGISTRATION_SYNTHREGISTRATION" { + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } + ext.init = "affine" + ext.warp = "deform" + ext.threads = 1 + ext.lambda = 0.5 + ext.steps = 5 + } +} diff --git a/modules/nf-scil/registration/synthregistration/tests/tags.yml b/modules/nf-scil/registration/synthregistration/tests/tags.yml new file mode 100644 index 00000000..e29e4f02 --- /dev/null +++ b/modules/nf-scil/registration/synthregistration/tests/tags.yml @@ -0,0 +1,2 @@ +registration/synthregistration: + - "modules/nf-scil/registration/synthregistration/**" From 1cfe90d50da6cdcb5f81ec15fc69abf1cbc85ee4 Mon Sep 17 00:00:00 2001 From: anroy1 Date: Wed, 5 Jun 2024 16:33:50 +0000 Subject: [PATCH 20/34] fix nf-tests --- .../synthregistration/tests/main.nf.test.snap | 54 +++++++++++++++---- tests/config/nf-test.config | 4 +- 2 files changed, 47 insertions(+), 11 deletions(-) diff --git a/modules/nf-scil/registration/synthregistration/tests/main.nf.test.snap b/modules/nf-scil/registration/synthregistration/tests/main.nf.test.snap index d31a7f52..1c0e4bbd 100644 --- a/modules/nf-scil/registration/synthregistration/tests/main.nf.test.snap +++ b/modules/nf-scil/registration/synthregistration/tests/main.nf.test.snap @@ -3,28 +3,64 @@ "content": [ { "0": [ - + [ + { + "id": "test", + "single_end": false + }, + "test__output_warped.nii.gz:md5,972f5f538b606379b77b2e1cb92a37ca" + ] ], "1": [ - + [ + { + "id": "test", + "single_end": false + }, + "test__deform_warp.nii.gz:md5,eea6ef9b84915d3475f21b5d2c5ef49d" + ] ], "2": [ - + [ + { + "id": "test", + "single_end": false + }, + "test__init_warp.lta:md5,46ad5a5d359b2ec157d1164135e746eb" + ] ], "3": [ - + "versions.yml:md5,49fb9c85da9f696926d1ab46ef0968fb" ], "deform_transform": [ - + [ + { + "id": "test", + "single_end": false + }, + "test__deform_warp.nii.gz:md5,eea6ef9b84915d3475f21b5d2c5ef49d" + ] ], "init_transform": [ - + [ + { + "id": "test", + "single_end": false + }, + "test__init_warp.lta:md5,46ad5a5d359b2ec157d1164135e746eb" + ] ], "versions": [ - + "versions.yml:md5,49fb9c85da9f696926d1ab46ef0968fb" ], "warped_image": [ - + [ + { + "id": "test", + "single_end": false + }, + "test__output_warped.nii.gz:md5,972f5f538b606379b77b2e1cb92a37ca" + ] ] } ], @@ -32,6 +68,6 @@ "nf-test": "0.8.4", "nextflow": "23.10.1" }, - "timestamp": "2024-06-01T19:08:42.159111" + "timestamp": "2024-06-05T16:31:01.589627" } } \ No newline at end of file diff --git a/tests/config/nf-test.config b/tests/config/nf-test.config index 7e9747fe..7b452af8 100644 --- a/tests/config/nf-test.config +++ b/tests/config/nf-test.config @@ -19,8 +19,8 @@ report { } process { - cpus = 4 - memory = 5.GB + cpus = 16 + memory = 20.GB time = 2.h } From 2aff22f0549ab1a3e094a5996c39fa3229e75404 Mon Sep 17 00:00:00 2001 From: anroy1 Date: Wed, 5 Jun 2024 16:37:50 +0000 Subject: [PATCH 21/34] Remove pytests --- tests/config/pytest_modules.yml | 3 --- .../registration/synthregistration/main.nf | 23 ------------------- .../synthregistration/nextflow.config | 13 ----------- .../registration/synthregistration/test.yml | 22 ------------------ 4 files changed, 61 deletions(-) delete mode 100644 tests/modules/nf-scil/registration/synthregistration/main.nf delete mode 100644 tests/modules/nf-scil/registration/synthregistration/nextflow.config delete mode 100644 tests/modules/nf-scil/registration/synthregistration/test.yml diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index 8fb708a6..e69de29b 100755 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -1,3 +0,0 @@ -registration/synthregistration: - - modules/nf-scil/registration/synthregistration/** - - tests/modules/nf-scil/registration/synthregistration/** diff --git a/tests/modules/nf-scil/registration/synthregistration/main.nf b/tests/modules/nf-scil/registration/synthregistration/main.nf deleted file mode 100644 index 89f5d379..00000000 --- a/tests/modules/nf-scil/registration/synthregistration/main.nf +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env nextflow - -nextflow.enable.dsl = 2 - -include { LOAD_TEST_DATA } from '../../../../../subworkflows/nf-scil/load_test_data/main' -include { REGISTRATION_SYNTHREGISTRATION } from '../../../../../modules/nf-scil/registration/synthregistration/main.nf' - -workflow test_registration_synthregistration { - - input_fetch = Channel.from( [ "freesurfer.zip" ] ) - - LOAD_TEST_DATA ( input_fetch, "test.load-test-data" ) - - input = LOAD_TEST_DATA.out.test_data_directory - .map{ test_data_directory -> [ - [ id:'test', single_end:false ], // meta map - file("${test_data_directory}/t1.nii.gz"), - file("${test_data_directory}/fa.nii.gz") - - ]} - - REGISTRATION_SYNTHREGISTRATION ( input ) -} diff --git a/tests/modules/nf-scil/registration/synthregistration/nextflow.config b/tests/modules/nf-scil/registration/synthregistration/nextflow.config deleted file mode 100644 index 2a1c9275..00000000 --- a/tests/modules/nf-scil/registration/synthregistration/nextflow.config +++ /dev/null @@ -1,13 +0,0 @@ -process { - - publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } - - withName: "test_registration_synthregistration:REGISTRATION_SYNTHREGISTRATION" { - ext.init = "affine" - ext.warp = "deform" - ext.threads = 1 - ext.lambda = 0.5 - ext.steps = 5 - } - -} diff --git a/tests/modules/nf-scil/registration/synthregistration/test.yml b/tests/modules/nf-scil/registration/synthregistration/test.yml deleted file mode 100644 index 925c6bdb..00000000 --- a/tests/modules/nf-scil/registration/synthregistration/test.yml +++ /dev/null @@ -1,22 +0,0 @@ -- name: registration synthregistration test_registration_synthregistration - command: nextflow run ./tests/modules/nf-scil/registration/synthregistration -entry test_registration_synthregistration -c ./tests/config/nextflow.config - tags: - - registration/synthregistration - - registration - files: - - path: output/registration/test__deform_warp.nii.gz - md5sum: d01c753043af2257908d049ade978981 - - path: output/registration/test__init_warp.lta - md5sum: 46ad5a5d359b2ec157d1164135e746eb - - path: output/registration/test__output_warped.nii.gz - md5sum: bdc4ff1557093fd25a760e4db48d7d58 - - path: output/registration/versions.yml - - path: output/testdata/test_data/freesurfer/anat_image.nii.gz - md5sum: ba57c629e9dc29204215dceac36d65ae - - path: output/testdata/test_data/freesurfer/fa.nii.gz - md5sum: 0e76e9378500de64d66ba3d787a147ca - - path: output/testdata/test_data/freesurfer/license.txt - md5sum: 3db0fa4e1860b4774c7855980e406275 - - path: output/testdata/test_data/freesurfer/t1.nii.gz - md5sum: a6ade205420f594737ad67f9fb246f0f - - path: output/testdata/versions.yml From 6df7ba4ddac46d873c2f14da864a92adbb55eb82 Mon Sep 17 00:00:00 2001 From: anroy1 Date: Wed, 5 Jun 2024 18:01:27 +0000 Subject: [PATCH 22/34] Run prettier --- .../nf-scil/registration/synthregistration/tests/main.nf.test | 2 -- tests/config/pytest_modules.yml | 0 2 files changed, 2 deletions(-) delete mode 100755 tests/config/pytest_modules.yml diff --git a/modules/nf-scil/registration/synthregistration/tests/main.nf.test b/modules/nf-scil/registration/synthregistration/tests/main.nf.test index 83148c72..8cbc4853 100644 --- a/modules/nf-scil/registration/synthregistration/tests/main.nf.test +++ b/modules/nf-scil/registration/synthregistration/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/synthregistration nextflow_process { name "Test Process REGISTRATION_SYNTHREGISTRATION" diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml deleted file mode 100755 index e69de29b..00000000 From 2967f20f349dbd2e273092e6056ae8783036dddb Mon Sep 17 00:00:00 2001 From: anroy1 Date: Wed, 5 Jun 2024 18:46:48 +0000 Subject: [PATCH 23/34] Modify tests config for remote tests --- .../synthregistration/tests/main.nf.test.snap | 10 +++++----- .../synthregistration/tests/nextflow.config | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/nf-scil/registration/synthregistration/tests/main.nf.test.snap b/modules/nf-scil/registration/synthregistration/tests/main.nf.test.snap index 1c0e4bbd..d44892c0 100644 --- a/modules/nf-scil/registration/synthregistration/tests/main.nf.test.snap +++ b/modules/nf-scil/registration/synthregistration/tests/main.nf.test.snap @@ -8,7 +8,7 @@ "id": "test", "single_end": false }, - "test__output_warped.nii.gz:md5,972f5f538b606379b77b2e1cb92a37ca" + "test__output_warped.nii.gz:md5,28f54b497cda513feb86b07b0b28ac1d" ] ], "1": [ @@ -17,7 +17,7 @@ "id": "test", "single_end": false }, - "test__deform_warp.nii.gz:md5,eea6ef9b84915d3475f21b5d2c5ef49d" + "test__deform_warp.nii.gz:md5,3cf3d49bc202410b8e6ef64ee394ad84" ] ], "2": [ @@ -38,7 +38,7 @@ "id": "test", "single_end": false }, - "test__deform_warp.nii.gz:md5,eea6ef9b84915d3475f21b5d2c5ef49d" + "test__deform_warp.nii.gz:md5,3cf3d49bc202410b8e6ef64ee394ad84" ] ], "init_transform": [ @@ -59,7 +59,7 @@ "id": "test", "single_end": false }, - "test__output_warped.nii.gz:md5,972f5f538b606379b77b2e1cb92a37ca" + "test__output_warped.nii.gz:md5,28f54b497cda513feb86b07b0b28ac1d" ] ] } @@ -68,6 +68,6 @@ "nf-test": "0.8.4", "nextflow": "23.10.1" }, - "timestamp": "2024-06-05T16:31:01.589627" + "timestamp": "2024-06-05T18:41:40.417146" } } \ No newline at end of file diff --git a/modules/nf-scil/registration/synthregistration/tests/nextflow.config b/modules/nf-scil/registration/synthregistration/tests/nextflow.config index 1b3a8fe6..285352a7 100644 --- a/modules/nf-scil/registration/synthregistration/tests/nextflow.config +++ b/modules/nf-scil/registration/synthregistration/tests/nextflow.config @@ -4,7 +4,7 @@ process { ext.init = "affine" ext.warp = "deform" ext.threads = 1 - ext.lambda = 0.5 - ext.steps = 5 + ext.lambda = 0.9 + ext.steps = 9 } } From d094e653b535c637829cd45461ef2186d984170e Mon Sep 17 00:00:00 2001 From: anroy1 Date: Wed, 5 Jun 2024 21:03:35 +0000 Subject: [PATCH 24/34] Fix test assertion for name only --- .../synthregistration/tests/main.nf.test | 6 +- .../synthregistration/tests/main.nf.test.snap | 67 ++----------------- 2 files changed, 9 insertions(+), 64 deletions(-) diff --git a/modules/nf-scil/registration/synthregistration/tests/main.nf.test b/modules/nf-scil/registration/synthregistration/tests/main.nf.test index 8cbc4853..f4753a05 100644 --- a/modules/nf-scil/registration/synthregistration/tests/main.nf.test +++ b/modules/nf-scil/registration/synthregistration/tests/main.nf.test @@ -41,7 +41,11 @@ nextflow_process { then { assertAll( { assert process.success }, - { assert snapshot(process.out).match() } + { assert snapshot( + file(process.out.warped_image.get(0).get(1)).name, + file(process.out.deform_transform.get(0).get(1)).name, + file(process.out.init_transform.get(0).get(1)).name + ).match() } ) } } diff --git a/modules/nf-scil/registration/synthregistration/tests/main.nf.test.snap b/modules/nf-scil/registration/synthregistration/tests/main.nf.test.snap index d44892c0..71f19060 100644 --- a/modules/nf-scil/registration/synthregistration/tests/main.nf.test.snap +++ b/modules/nf-scil/registration/synthregistration/tests/main.nf.test.snap @@ -1,73 +1,14 @@ { "registration - synthregistration": { "content": [ - { - "0": [ - [ - { - "id": "test", - "single_end": false - }, - "test__output_warped.nii.gz:md5,28f54b497cda513feb86b07b0b28ac1d" - ] - ], - "1": [ - [ - { - "id": "test", - "single_end": false - }, - "test__deform_warp.nii.gz:md5,3cf3d49bc202410b8e6ef64ee394ad84" - ] - ], - "2": [ - [ - { - "id": "test", - "single_end": false - }, - "test__init_warp.lta:md5,46ad5a5d359b2ec157d1164135e746eb" - ] - ], - "3": [ - "versions.yml:md5,49fb9c85da9f696926d1ab46ef0968fb" - ], - "deform_transform": [ - [ - { - "id": "test", - "single_end": false - }, - "test__deform_warp.nii.gz:md5,3cf3d49bc202410b8e6ef64ee394ad84" - ] - ], - "init_transform": [ - [ - { - "id": "test", - "single_end": false - }, - "test__init_warp.lta:md5,46ad5a5d359b2ec157d1164135e746eb" - ] - ], - "versions": [ - "versions.yml:md5,49fb9c85da9f696926d1ab46ef0968fb" - ], - "warped_image": [ - [ - { - "id": "test", - "single_end": false - }, - "test__output_warped.nii.gz:md5,28f54b497cda513feb86b07b0b28ac1d" - ] - ] - } + "test__output_warped.nii.gz", + "test__deform_warp.nii.gz", + "test__init_warp.lta" ], "meta": { "nf-test": "0.8.4", "nextflow": "23.10.1" }, - "timestamp": "2024-06-05T18:41:40.417146" + "timestamp": "2024-06-05T19:55:15.170324" } } \ No newline at end of file From b95c0325cf476497ee6456c8d82364f3a669caf6 Mon Sep 17 00:00:00 2001 From: anroy1 Date: Thu, 6 Jun 2024 13:04:40 +0000 Subject: [PATCH 25/34] Rerun tests and fix linting --- .../registration/synthregistration/tests/main.nf.test | 3 ++- .../registration/synthregistration/tests/main.nf.test.snap | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/modules/nf-scil/registration/synthregistration/tests/main.nf.test b/modules/nf-scil/registration/synthregistration/tests/main.nf.test index f4753a05..67f9cdfc 100644 --- a/modules/nf-scil/registration/synthregistration/tests/main.nf.test +++ b/modules/nf-scil/registration/synthregistration/tests/main.nf.test @@ -44,7 +44,8 @@ nextflow_process { { assert snapshot( file(process.out.warped_image.get(0).get(1)).name, file(process.out.deform_transform.get(0).get(1)).name, - file(process.out.init_transform.get(0).get(1)).name + file(process.out.init_transform.get(0).get(1)).name, + process.out.versions ).match() } ) } diff --git a/modules/nf-scil/registration/synthregistration/tests/main.nf.test.snap b/modules/nf-scil/registration/synthregistration/tests/main.nf.test.snap index 71f19060..0cd56115 100644 --- a/modules/nf-scil/registration/synthregistration/tests/main.nf.test.snap +++ b/modules/nf-scil/registration/synthregistration/tests/main.nf.test.snap @@ -3,12 +3,15 @@ "content": [ "test__output_warped.nii.gz", "test__deform_warp.nii.gz", - "test__init_warp.lta" + "test__init_warp.lta", + [ + "versions.yml:md5,49fb9c85da9f696926d1ab46ef0968fb" + ] ], "meta": { "nf-test": "0.8.4", "nextflow": "23.10.1" }, - "timestamp": "2024-06-05T19:55:15.170324" + "timestamp": "2024-06-06T13:03:51.883573" } } \ No newline at end of file From 3299ec092df0219955910e7be883140288fde52e Mon Sep 17 00:00:00 2001 From: anroy1 Date: Tue, 11 Jun 2024 19:13:44 +0000 Subject: [PATCH 26/34] adjust process parameters for tests locally --- .../registration/synthregistration/tests/nextflow.config | 1 + tests/config/nextflow.config | 4 ++-- tests/config/nf-test.config | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/nf-scil/registration/synthregistration/tests/nextflow.config b/modules/nf-scil/registration/synthregistration/tests/nextflow.config index 285352a7..41fae205 100644 --- a/modules/nf-scil/registration/synthregistration/tests/nextflow.config +++ b/modules/nf-scil/registration/synthregistration/tests/nextflow.config @@ -1,6 +1,7 @@ process { withName: "REGISTRATION_SYNTHREGISTRATION" { publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } + memory = 20 ext.init = "affine" ext.warp = "deform" ext.threads = 1 diff --git a/tests/config/nextflow.config b/tests/config/nextflow.config index 329b90cd..633b633b 100755 --- a/tests/config/nextflow.config +++ b/tests/config/nextflow.config @@ -5,8 +5,8 @@ params { } process { - cpus = 16 - memory = 20.GB + cpus = 4 + memory = 5.GB time = 2.h } diff --git a/tests/config/nf-test.config b/tests/config/nf-test.config index 7b452af8..7e9747fe 100644 --- a/tests/config/nf-test.config +++ b/tests/config/nf-test.config @@ -19,8 +19,8 @@ report { } process { - cpus = 16 - memory = 20.GB + cpus = 4 + memory = 5.GB time = 2.h } From afd5884a188d400e54f3c5c2ae5894f08a25ac6b Mon Sep 17 00:00:00 2001 From: anroy1 Date: Thu, 13 Jun 2024 21:08:47 +0000 Subject: [PATCH 27/34] [wip] fix alex comments 1/2 --- modules/nf-scil/registration/synthregistration/meta.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/nf-scil/registration/synthregistration/meta.yml b/modules/nf-scil/registration/synthregistration/meta.yml index 580f04bb..c603a503 100644 --- a/modules/nf-scil/registration/synthregistration/meta.yml +++ b/modules/nf-scil/registration/synthregistration/meta.yml @@ -37,7 +37,7 @@ output: - init_transform: type: file description: Affine transform for initialization - pattern: "*.{txt}" + pattern: "*.{lta}" - deform_transform: type: file From 6c8468bf97e390a1d3e26b59dfddd17df2adab97 Mon Sep 17 00:00:00 2001 From: anroy1 Date: Fri, 14 Jun 2024 16:18:45 +0000 Subject: [PATCH 28/34] Add precisions regarding convertion on meta.yml --- modules/nf-scil/registration/synthregistration/meta.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/nf-scil/registration/synthregistration/meta.yml b/modules/nf-scil/registration/synthregistration/meta.yml index c603a503..6cbb5563 100644 --- a/modules/nf-scil/registration/synthregistration/meta.yml +++ b/modules/nf-scil/registration/synthregistration/meta.yml @@ -1,6 +1,6 @@ --- name: "registration_synthregistration" -description: Perform registration using SynthMorph from Freesurfer. Output transforms in Freesurfer format .lta for affine and .mgz for deform, which can be converted for ANTs with respectively lta_convert and mri_warp_convert. +description: Perform registration using SynthMorph from Freesurfer. Outputs transforms in Freesurfer format .lta for affine and .nii.gz (synthmorph also supports .mgz) for deform, both in RAS orientation, which can be converted for ANTs with respectively lta_convert and mri_warp_convert, which support a wide range of conversion formats and orientations. Conversion can be processed using the registration/convert module which can be used successively to this one. keywords: - registration - Brain imaging From b46749cad61657d6db30ac0a51ba5ac0c0d41490 Mon Sep 17 00:00:00 2001 From: anroy1 Date: Wed, 7 Aug 2024 03:47:23 +0000 Subject: [PATCH 29/34] Handling threads in script --- modules/nf-scil/registration/synthregistration/main.nf | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/nf-scil/registration/synthregistration/main.nf b/modules/nf-scil/registration/synthregistration/main.nf index 8d130b82..38c48120 100644 --- a/modules/nf-scil/registration/synthregistration/main.nf +++ b/modules/nf-scil/registration/synthregistration/main.nf @@ -24,7 +24,6 @@ process REGISTRATION_SYNTHREGISTRATION { def init = task.ext.init ? "-m " + task.ext.init : "-m affine" def warp = task.ext.warp ? "-m " + task.ext.warp : "-m deform" def header = task.ext.header ? "-H" : "" - def threads = task.ext.threads ? "-j " + task.ext.threads : "" def gpu = task.ext.gpu ? "-g" : "" def lambda = task.ext.lambda ? "-r " + task.ext.lambda : "" def steps = task.ext.steps ? "-n " + task.ext.steps : "" @@ -36,8 +35,8 @@ process REGISTRATION_SYNTHREGISTRATION { export OMP_NUM_THREADS=1 export OPENBLAS_NUM_THREADS=1 - mri_synthmorph ${init} -t ${prefix}__init_warp.lta $moving $fixed - mri_synthmorph ${warp} ${gpu} ${lambda} ${steps} ${extent} ${weight} -i ${prefix}__init_warp.lta -t ${prefix}__deform_warp.nii.gz -o ${prefix}__output_warped.nii.gz $moving $fixed + mri_synthmorph -j $task.cpus ${init} -t ${prefix}__init_warp.lta $moving $fixed + mri_synthmorph -j $task.cpus ${warp} ${gpu} ${lambda} ${steps} ${extent} ${weight} -i ${prefix}__init_warp.lta -t ${prefix}__deform_warp.nii.gz -o ${prefix}__output_warped.nii.gz $moving $fixed cat <<-END_VERSIONS > versions.yml "${task.process}": From 48e5584b3e4c311158745f0d98d4aabef42cdc67 Mon Sep 17 00:00:00 2001 From: anroy1 Date: Thu, 8 Aug 2024 20:10:08 +0000 Subject: [PATCH 30/34] change container version --- modules/nf-scil/registration/synthregistration/main.nf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/nf-scil/registration/synthregistration/main.nf b/modules/nf-scil/registration/synthregistration/main.nf index 38c48120..fb3b8593 100644 --- a/modules/nf-scil/registration/synthregistration/main.nf +++ b/modules/nf-scil/registration/synthregistration/main.nf @@ -2,7 +2,7 @@ process REGISTRATION_SYNTHREGISTRATION { tag "$meta.id" label 'process_single' - container "freesurfer/synthmorph:latest" + container "freesurfer/synthmorph:2" containerOptions "--entrypoint ''" input: From 614dd429be72287100e68bedb6a40c031751c123 Mon Sep 17 00:00:00 2001 From: anroy1 Date: Thu, 15 Aug 2024 17:58:58 +0000 Subject: [PATCH 31/34] Use nifti md5sum assertion --- .../synthregistration/tests/main.nf.test | 6 +++--- .../synthregistration/tests/main.nf.test.snap | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/modules/nf-scil/registration/synthregistration/tests/main.nf.test b/modules/nf-scil/registration/synthregistration/tests/main.nf.test index 67f9cdfc..aecf6ee7 100644 --- a/modules/nf-scil/registration/synthregistration/tests/main.nf.test +++ b/modules/nf-scil/registration/synthregistration/tests/main.nf.test @@ -42,9 +42,9 @@ nextflow_process { assertAll( { assert process.success }, { assert snapshot( - file(process.out.warped_image.get(0).get(1)).name, - file(process.out.deform_transform.get(0).get(1)).name, - file(process.out.init_transform.get(0).get(1)).name, + Nifti_md5sum(process.out.warped_image.get(0).get(1)), + Nifti_md5sum(process.out.deform_transform.get(0).get(1)), + file(process.out.init_transform.get(0).get(1)), process.out.versions ).match() } ) diff --git a/modules/nf-scil/registration/synthregistration/tests/main.nf.test.snap b/modules/nf-scil/registration/synthregistration/tests/main.nf.test.snap index 0cd56115..b1a2fb83 100644 --- a/modules/nf-scil/registration/synthregistration/tests/main.nf.test.snap +++ b/modules/nf-scil/registration/synthregistration/tests/main.nf.test.snap @@ -1,17 +1,17 @@ { "registration - synthregistration": { "content": [ - "test__output_warped.nii.gz", - "test__deform_warp.nii.gz", - "test__init_warp.lta", + "test__output_warped.nii.gz:md5,b8f38768bc1e0860593f3282c41f1551", + "test__deform_warp.nii.gz:md5,a7b8ffcf75af954087b4993717db90c0", + "test__init_warp.lta:md5,8759b302c2609351b3467ef4ceaac0af", [ "versions.yml:md5,49fb9c85da9f696926d1ab46ef0968fb" ] ], "meta": { - "nf-test": "0.8.4", - "nextflow": "23.10.1" + "nf-test": "0.9.0-rc1", + "nextflow": "24.04.4" }, - "timestamp": "2024-06-06T13:03:51.883573" + "timestamp": "2024-08-15T17:53:02.358738" } } \ No newline at end of file From a1f8f2dca5b1dfa3e31e5f6786c956bcc4369aed Mon Sep 17 00:00:00 2001 From: anroy1 Date: Sat, 7 Sep 2024 18:36:50 +0000 Subject: [PATCH 32/34] test with niftiMD5SUM --- modules/nf-scil/registration/synthregistration/main.nf | 2 +- .../registration/synthregistration/tests/main.nf.test | 4 ++-- .../registration/synthregistration/tests/main.nf.test.snap | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/nf-scil/registration/synthregistration/main.nf b/modules/nf-scil/registration/synthregistration/main.nf index fb3b8593..3e168eba 100644 --- a/modules/nf-scil/registration/synthregistration/main.nf +++ b/modules/nf-scil/registration/synthregistration/main.nf @@ -2,7 +2,7 @@ process REGISTRATION_SYNTHREGISTRATION { tag "$meta.id" label 'process_single' - container "freesurfer/synthmorph:2" + container "freesurfer/synthmorph:3" containerOptions "--entrypoint ''" input: diff --git a/modules/nf-scil/registration/synthregistration/tests/main.nf.test b/modules/nf-scil/registration/synthregistration/tests/main.nf.test index aecf6ee7..fa8f9945 100644 --- a/modules/nf-scil/registration/synthregistration/tests/main.nf.test +++ b/modules/nf-scil/registration/synthregistration/tests/main.nf.test @@ -42,8 +42,8 @@ nextflow_process { assertAll( { assert process.success }, { assert snapshot( - Nifti_md5sum(process.out.warped_image.get(0).get(1)), - Nifti_md5sum(process.out.deform_transform.get(0).get(1)), + niftiMD5SUM(process.out.warped_image.get(0).get(1)), + niftiMD5SUM(process.out.deform_transform.get(0).get(1)), file(process.out.init_transform.get(0).get(1)), process.out.versions ).match() } diff --git a/modules/nf-scil/registration/synthregistration/tests/main.nf.test.snap b/modules/nf-scil/registration/synthregistration/tests/main.nf.test.snap index b1a2fb83..2a496d24 100644 --- a/modules/nf-scil/registration/synthregistration/tests/main.nf.test.snap +++ b/modules/nf-scil/registration/synthregistration/tests/main.nf.test.snap @@ -1,8 +1,8 @@ { "registration - synthregistration": { "content": [ - "test__output_warped.nii.gz:md5,b8f38768bc1e0860593f3282c41f1551", - "test__deform_warp.nii.gz:md5,a7b8ffcf75af954087b4993717db90c0", + "test__output_warped.nii.gz:md5:header,7194a6bc4e939bcdcde2eb49dfe86e99,data,bec9bc1da19ef79e3a2b2139605194d1", + "test__deform_warp.nii.gz:md5:header,1c5ab0add89b78f9676438b03a401d7b,data,080fe63c2e7711cb1c1db61523ec4a19", "test__init_warp.lta:md5,8759b302c2609351b3467ef4ceaac0af", [ "versions.yml:md5,49fb9c85da9f696926d1ab46ef0968fb" @@ -12,6 +12,6 @@ "nf-test": "0.9.0-rc1", "nextflow": "24.04.4" }, - "timestamp": "2024-08-15T17:53:02.358738" + "timestamp": "2024-09-07T18:29:01.73367" } } \ No newline at end of file From 6984f7aa6b01dfa8aecb3050220f287ca022c620 Mon Sep 17 00:00:00 2001 From: anroy1 Date: Sat, 7 Sep 2024 19:30:23 +0000 Subject: [PATCH 33/34] Revert "Change org_path" This reverts commit b188fbca21cf1b98036ffad98393baa5fad766e9. --- .nf-core.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.nf-core.yml b/.nf-core.yml index ab4e64f9..86885b8d 100755 --- a/.nf-core.yml +++ b/.nf-core.yml @@ -1,3 +1,3 @@ --- repository_type: modules -org_path: anroy1/nf-scil +org_path: nf-scil From ecc44820a729b1695c7ed2dfc4482c104c74419d Mon Sep 17 00:00:00 2001 From: anroy1 Date: Tue, 17 Sep 2024 20:26:57 +0000 Subject: [PATCH 34/34] fix test --- .../synthregistration/tests/main.nf.test | 2 +- .../synthregistration/tests/main.nf.test.snap | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/modules/nf-scil/registration/synthregistration/tests/main.nf.test b/modules/nf-scil/registration/synthregistration/tests/main.nf.test index fa8f9945..5f2c4761 100644 --- a/modules/nf-scil/registration/synthregistration/tests/main.nf.test +++ b/modules/nf-scil/registration/synthregistration/tests/main.nf.test @@ -44,7 +44,7 @@ nextflow_process { { assert snapshot( niftiMD5SUM(process.out.warped_image.get(0).get(1)), niftiMD5SUM(process.out.deform_transform.get(0).get(1)), - file(process.out.init_transform.get(0).get(1)), + process.out.init_transform, process.out.versions ).match() } ) diff --git a/modules/nf-scil/registration/synthregistration/tests/main.nf.test.snap b/modules/nf-scil/registration/synthregistration/tests/main.nf.test.snap index 2a496d24..6015be41 100644 --- a/modules/nf-scil/registration/synthregistration/tests/main.nf.test.snap +++ b/modules/nf-scil/registration/synthregistration/tests/main.nf.test.snap @@ -1,9 +1,17 @@ { "registration - synthregistration": { "content": [ - "test__output_warped.nii.gz:md5:header,7194a6bc4e939bcdcde2eb49dfe86e99,data,bec9bc1da19ef79e3a2b2139605194d1", - "test__deform_warp.nii.gz:md5:header,1c5ab0add89b78f9676438b03a401d7b,data,080fe63c2e7711cb1c1db61523ec4a19", - "test__init_warp.lta:md5,8759b302c2609351b3467ef4ceaac0af", + "test__output_warped.nii.gz:md5:header,a1c8a7cfd88d5b632700819988507e8b,data,2526d950d4d6786c40faf5285e2f08af", + "test__deform_warp.nii.gz:md5:header,4a9989cf78e087331c587e0d656ee96f,data,3dcaa6acc0ee1a933d8792d9c2fc740d", + [ + [ + { + "id": "test", + "single_end": false + }, + "test__init_warp.lta:md5,eb15bf7f338f1d5bd71227c40b6dbc68" + ] + ], [ "versions.yml:md5,49fb9c85da9f696926d1ab46ef0968fb" ] @@ -12,6 +20,6 @@ "nf-test": "0.9.0-rc1", "nextflow": "24.04.4" }, - "timestamp": "2024-09-07T18:29:01.73367" + "timestamp": "2024-09-17T20:25:42.083995" } } \ No newline at end of file