Skip to content

Commit

Permalink
added test with multiple subjects + update more modules with patch fi…
Browse files Browse the repository at this point in the history
…les.
  • Loading branch information
gagnonanthony committed Dec 28, 2024
1 parent 7f3df8c commit e779d08
Show file tree
Hide file tree
Showing 20 changed files with 955 additions and 152 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ jobs:
- "connectomics.nf.test"
- "tracking.nf.test"
- "freesurfer.nf.test"
- "multisubjects.nf.test"
isMaster:
- ${{ github.base_ref == 'master' }}
# Exclude conda and singularity on dev
Expand Down
171 changes: 128 additions & 43 deletions modules.json

Large diffs are not rendered by default.

35 changes: 28 additions & 7 deletions modules/nf-neuro/betcrop/synthbet/betcrop-synthbet.diff
Original file line number Diff line number Diff line change
@@ -1,18 +1,39 @@
Changes in module 'nf-neuro/betcrop/synthbet'
Changes in component 'nf-neuro/betcrop/synthbet'
'modules/nf-neuro/betcrop/synthbet/environment.yml' is unchanged
'modules/nf-neuro/betcrop/synthbet/meta.yml' is unchanged
Changes in 'betcrop/synthbet/main.nf':
--- modules/nf-neuro/betcrop/synthbet/main.nf
+++ modules/nf-neuro/betcrop/synthbet/main.nf
@@ -40,7 +40,7 @@
def prefix = task.ext.prefix ?: "${meta.id}"
@@ -2,7 +2,10 @@
tag "$meta.id"
label 'process_single'

- container "freesurfer/freesurfer:7.4.1"
+ container "freesurfer/synthstrip:1.5"
+ containerOptions {
+ (workflow.containerEngine == 'docker') ? '--entrypoint ""': ''
+ }

input:
tuple val(meta), path(image), path(weights) /* optional, input = [] */
@@ -32,7 +35,7 @@

cat <<-END_VERSIONS > versions.yml
"${task.process}":
- Freesurfer: \$(mri_convert -version | grep "freesurfer" | sed -E 's/.* ([0-9]+\\.[0-9]+\\.[0-9]+).*/\\1/')
+ synthstrip: 1.5
END_VERSIONS
"""
- mri_synthstrip -h
+ #mri_synthstrip -h

touch ${prefix}__bet_image.nii.gz
touch ${prefix}__brain_mask.nii.gz
@@ -45,7 +48,7 @@

cat <<-END_VERSIONS > versions.yml
"${task.process}":
- Freesurfer: \$(mri_convert -version | grep "freesurfer" | sed -E 's/.* ([0-9]+\\.[0-9]+\\.[0-9]+).*/\\1/')
+ synthstrip: 1.5
END_VERSIONS

function handle_code () {

'modules/nf-neuro/betcrop/synthbet/tests/main.nf.test.snap' is unchanged
'modules/nf-neuro/betcrop/synthbet/tests/tags.yml' is unchanged
Expand Down
9 changes: 6 additions & 3 deletions modules/nf-neuro/betcrop/synthbet/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ process BETCROP_SYNTHBET {
tag "$meta.id"
label 'process_single'

container "freesurfer/freesurfer:7.4.1"
container "freesurfer/synthstrip:1.5"
containerOptions {
(workflow.containerEngine == 'docker') ? '--entrypoint ""': ''
}

input:
tuple val(meta), path(image), path(weights) /* optional, input = [] */
Expand Down Expand Up @@ -32,7 +35,7 @@ process BETCROP_SYNTHBET {
cat <<-END_VERSIONS > versions.yml
"${task.process}":
Freesurfer: \$(mri_convert -version | grep "freesurfer" | sed -E 's/.* ([0-9]+\\.[0-9]+\\.[0-9]+).*/\\1/')
synthstrip: 1.5
END_VERSIONS
"""

Expand All @@ -45,7 +48,7 @@ process BETCROP_SYNTHBET {
cat <<-END_VERSIONS > versions.yml
"${task.process}":
Freesurfer: \$(mri_convert -version | grep "freesurfer" | sed -E 's/.* ([0-9]+\\.[0-9]+\\.[0-9]+).*/\\1/')
synthstrip: 1.5
END_VERSIONS
function handle_code () {
Expand Down
30 changes: 17 additions & 13 deletions modules/nf-neuro/preproc/eddy/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -114,32 +114,36 @@ process PREPROC_EDDY {
"""

stub:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"

"""
scil_volume_math.py -h
#maskfilter -h
#bet -h
scil_dwi_extract_b0.py -h
scil_gradients_validate_correct_eddy.py -h
scil_dwi_concatenate.py -h
mrconvert -h
scil_dwi_prepare_eddy_command.py -h
scil_header_print_info.py -h
touch ${prefix}__dwi_corrected.nii.gz
touch ${prefix}__dwi_eddy_corrected.bval
touch ${prefix}__dwi_eddy_corrected.bvec
touch ${prefix}__b0_bet_mask.nii.gz
cat <<-END_VERSIONS > versions.yml
"${task.process}":
scilpy: \$(pip list | grep scilpy | tr -s ' ' | cut -d' ' -f2)
mrtrix: \$(dwidenoise -version 2>&1 | sed -n 's/== dwidenoise \\([0-9.]\\+\\).*/\\1/p')
fsl: \$(flirt -version 2>&1 | sed -n 's/FLIRT version \\([0-9.]\\+\\)/\\1/p')
END_VERSIONS
function handle_code () {
local code=\$?
ignore=( 1 )
exit \$([[ " \${ignore[@]} " =~ " \$code " ]] && echo 0 || echo \$code)
}
trap 'handle_code' ERR
scil_volume_math.py -h
maskfilter -h
bet -h
scil_dwi_extract_b0.py -h
scil_gradients_validate_correct_eddy.py -h
scil_dwi_concatenate.py -h
mrconvert -h
scil_dwi_prepare_eddy_command.py -h
scil_header_print_info.py -h
"""
}
22 changes: 11 additions & 11 deletions modules/nf-neuro/preproc/eddy/preproc-eddy.diff
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
Changes in module 'nf-neuro/preproc/eddy'
Changes in component 'nf-neuro/preproc/eddy'
'modules/nf-neuro/preproc/eddy/environment.yml' is unchanged
'modules/nf-neuro/preproc/eddy/meta.yml' is unchanged
Changes in 'preproc/eddy/main.nf':
--- modules/nf-neuro/preproc/eddy/main.nf
+++ modules/nf-neuro/preproc/eddy/main.nf
@@ -119,8 +119,8 @@
@@ -3,8 +3,8 @@
label 'process_high'

"""
scil_volume_math.py -h
- maskfilter -h
- bet -h
+ #maskfilter -h
+ #bet -h
scil_dwi_extract_b0.py -h
scil_gradients_validate_correct_eddy.py -h
scil_dwi_concatenate.py -h
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
- "https://scil.usherbrooke.ca/containers/scilus_2.0.2.sif":
- "scilus/scilus:2.0.2"}"
+ 'https://scil.usherbrooke.ca/containers/scilus_2.0.2.sif':
+ 'scilus/scilus:2.0.2' }"

input:
tuple val(meta), path(dwi), path(bval), path(bvec), path(rev_dwi), path(rev_bval), path(rev_bvec), path(corrected_b0s), path(topup_fieldcoef), path(topup_movpart)

'modules/nf-neuro/preproc/eddy/tests/main.nf.test.snap' is unchanged
'modules/nf-neuro/preproc/eddy/tests/tags.yml' is unchanged
Expand Down
30 changes: 30 additions & 0 deletions modules/nf-neuro/preproc/eddy/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,34 @@ nextflow_process {
)
}
}

test("eddy - stub-run") {
options "-stub-run"
when {
process {
"""
input[0] = LOAD_DATA.out.test_data_directory
.map{ test_data_directory -> [
[ id:'test', single_end:false ], // meta map
file("\${test_data_directory}/sub-01_dir-AP_dwi.nii.gz", checkIfExists: true),
file("\${test_data_directory}/sub-01_dir-AP_dwi.bval", checkIfExists: true),
file("\${test_data_directory}/sub-01_dir-AP_dwi.bvec", checkIfExists: true),
file("\${test_data_directory}/sub-01_dir-PA_dwi.nii.gz", checkIfExists: true),
file("\${test_data_directory}/sub-01_dir-PA_dwi.bval", checkIfExists: true),
file("\${test_data_directory}/sub-01_dir-PA_dwi.bvec", checkIfExists: true),
file("\${test_data_directory}/sub-01__corrected_b0s.nii.gz", checkIfExists: true),
file("\${test_data_directory}/topup_results_fieldcoef.nii.gz", checkIfExists: true),
file("\${test_data_directory}/topup_results_movpar.txt", checkIfExists: true)
]
}
"""
}
}
then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out.versions).match() }
)
}
}
}
12 changes: 12 additions & 0 deletions modules/nf-neuro/preproc/eddy/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,17 @@
"nextflow": "24.04.4"
},
"timestamp": "2024-11-21T19:53:14.315721034"
},
"eddy - stub-run": {
"content": [
[
"versions.yml:md5,137e3ce0fd25e5b16de2d8cc5a5aefca"
]
],
"meta": {
"nf-test": "0.9.0",
"nextflow": "24.10.1"
},
"timestamp": "2024-12-12T12:50:30.654366"
}
}
21 changes: 13 additions & 8 deletions modules/nf-neuro/preproc/topup/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ process PREPROC_TOPUP {

input:
tuple val(meta), path(dwi), path(bval), path(bvec), path(b0), path(rev_dwi), path(rev_bval), path(rev_bvec), path(rev_b0)
val(config_topup)
each config_topup

output:
tuple val(meta), path("*__corrected_b0s.nii.gz"), emit: topup_corrected_b0s
Expand Down Expand Up @@ -73,16 +73,10 @@ process PREPROC_TOPUP {
"""

stub:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
def prefix_topup = task.ext.prefix_topup ? task.ext.prefix_topup : ""

"""
scil_volume_math.py -h
scil_dwi_extract_b0.py -h
#antsRegistrationSyNQuick.sh
scil_dwi_prepare_topup_command.py -h
touch ${prefix}__corrected_b0s.nii.gz
touch ${prefix}__rev_b0_warped.nii.gz
touch ${prefix}__rev_b0_mean.nii.gz
Expand All @@ -95,7 +89,18 @@ process PREPROC_TOPUP {
scilpy: \$(pip list | grep scilpy | tr -s ' ' | cut -d' ' -f2)
antsRegistration: \$(antsRegistration --version | grep "Version" | sed -E 's/.*v([0-9]+\\+\\).*/\\1/')
fsl: \$(flirt -version 2>&1 | sed -n 's/FLIRT version \\([0-9.]\\+\\)/\\1/p')
END_VERSIONS
function handle_code () {
local code=\$?
ignore=( 1 )
exit \$([[ " \${ignore[@]} " =~ " \$code " ]] && echo 0 || echo \$code)
}
trap 'handle_code' ERR
scil_volume_math.py -h
scil_dwi_extract_b0.py -h
antsRegistrationSyNQuick.sh
scil_dwi_prepare_topup_command.py -h
"""
}
25 changes: 16 additions & 9 deletions modules/nf-neuro/preproc/topup/preproc-topup.diff
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
Changes in module 'nf-neuro/preproc/topup'
Changes in component 'nf-neuro/preproc/topup'
'modules/nf-neuro/preproc/topup/environment.yml' is unchanged
'modules/nf-neuro/preproc/topup/meta.yml' is unchanged
Changes in 'preproc/topup/main.nf':
--- modules/nf-neuro/preproc/topup/main.nf
+++ modules/nf-neuro/preproc/topup/main.nf
@@ -80,7 +80,7 @@
"""
scil_volume_math.py -h
scil_dwi_extract_b0.py -h
- antsRegistrationSyNQuick.sh -h
+ #antsRegistrationSyNQuick.sh
scil_dwi_prepare_topup_command.py -h
@@ -3,12 +3,12 @@
label 'process_single'

touch ${prefix}__corrected_b0s.nii.gz
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
- "https://scil.usherbrooke.ca/containers/scilus_2.0.2.sif":
- "scilus/scilus:2.0.2"}"
+ 'https://scil.usherbrooke.ca/containers/scilus_2.0.2.sif':
+ 'scilus/scilus:2.0.2' }"

input:
tuple val(meta), path(dwi), path(bval), path(bvec), path(b0), path(rev_dwi), path(rev_bval), path(rev_bvec), path(rev_b0)
- val(config_topup)
+ each config_topup

output:
tuple val(meta), path("*__corrected_b0s.nii.gz"), emit: topup_corrected_b0s

'modules/nf-neuro/preproc/topup/tests/main.nf.test.snap' is unchanged
'modules/nf-neuro/preproc/topup/tests/tags.yml' is unchanged
Expand Down
28 changes: 28 additions & 0 deletions modules/nf-neuro/preproc/topup/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,32 @@ nextflow_process {
)
}
}

test("topup - stub-run") {
options "-stub-run"
when {
process {
"""
input[0] = LOAD_DATA.out.test_data_directory
.map{ test_data_directory -> [
[ id:'test', single_end:false ], // meta map
file("\${test_data_directory}/sub-01_dir-AP_dwi.nii.gz", checkIfExists: true),
file("\${test_data_directory}/sub-01_dir-AP_dwi.bval", checkIfExists: true),
file("\${test_data_directory}/sub-01_dir-AP_dwi.bvec", checkIfExists: true),
file("\${test_data_directory}/sub-01_dir-AP_sbref.nii.gz", checkIfExists: true),
file("\${test_data_directory}/sub-01_dir-PA_dwi.nii.gz", checkIfExists: true),
file("\${test_data_directory}/sub-01_dir-PA_dwi.bval", checkIfExists: true),
file("\${test_data_directory}/sub-01_dir-PA_dwi.bvec", checkIfExists: true),
file("\${test_data_directory}/sub-01_dir-PA_sbref.nii.gz", checkIfExists: true)]}
input[1] = []
"""
}
}
then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out.versions).match() }
)
}
}
}
12 changes: 12 additions & 0 deletions modules/nf-neuro/preproc/topup/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@
},
"timestamp": "2024-11-01T16:21:18.752887499"
},
"topup - stub-run": {
"content": [
[
"versions.yml:md5,1e46217f093e27a6a26cd479f074296b"
]
],
"meta": {
"nf-test": "0.9.0",
"nextflow": "24.10.1"
},
"timestamp": "2024-12-12T11:56:01.860981"
},
"topup_light": {
"content": [
"test__corrected_b0s.nii.gz",
Expand Down
28 changes: 13 additions & 15 deletions subworkflows/nf-core/utils_nfcore_pipeline/main.nf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e779d08

Please sign in to comment.