Skip to content

Commit

Permalink
Merge pull request #74 from gagnonanthony/eddytopupexiterror
Browse files Browse the repository at this point in the history
#40 - Catch error in stub for `preproc/eddy` and `preproc/topup` + add stub test
  • Loading branch information
arnaudbore authored Dec 18, 2024
2 parents 68cde77 + e112b57 commit 3429ec3
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 20 deletions.
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
"""
}
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"
}
}
19 changes: 12 additions & 7 deletions modules/nf-neuro/preproc/topup/main.nf
Original file line number Diff line number Diff line change
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 -h
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
"""
}
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

0 comments on commit 3429ec3

Please sign in to comment.