Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENH] Update preproc modules #31

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions modules/nf-neuro/preproc/eddy/main.nf
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
process PREPROC_EDDY {
tag "$meta.id"
label 'process_single'
label 'process_high'

container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
"https://scil.usherbrooke.ca/containers/scilus_2.0.0.sif":
"scilus/scilus:2.0.0"}"
"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)
Expand Down Expand Up @@ -34,8 +34,8 @@ process PREPROC_EDDY {
def extra_args = task.ext.extra_args ?: ""

"""
export ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS=1
export OMP_NUM_THREADS=1
export ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS=$task.cpus
export OMP_NUM_THREADS=$task.cpus
export OPENBLAS_NUM_THREADS=1
export ANTS_RANDOM_SEED=7468

Expand All @@ -62,7 +62,7 @@ process PREPROC_EDDY {
# If topup has been run before
if [[ -f "$topup_fieldcoef" ]]
then
mrconvert $corrected_b0s b0_corrected.nii.gz -coord 3 0 -axes 0,1,2 -nthreads 1
mrconvert $corrected_b0s b0_corrected.nii.gz -coord 3 0 -axes 0,1,2 -nthreads $task.cpus
bet b0_corrected.nii.gz ${prefix}__b0_bet.nii.gz -m -R\
-f $bet_topup_before_eddy_f

Expand All @@ -80,7 +80,7 @@ process PREPROC_EDDY {
bet ${prefix}__b0.nii.gz ${prefix}__b0_bet.nii.gz -m -R -f $bet_prelim_f
scil_volume_math.py convert ${prefix}__b0_bet_mask.nii.gz ${prefix}__b0_bet_mask.nii.gz --data_type uint8 -f
maskfilter ${prefix}__b0_bet_mask.nii.gz dilate ${prefix}__b0_bet_mask_dilated.nii.gz\
--npass $dilate_b0_mask_prelim_brain_extraction -nthreads 1
--npass $dilate_b0_mask_prelim_brain_extraction -nthreads $task.cpus
scil_volume_math.py multiplication ${prefix}__b0.nii.gz ${prefix}__b0_bet_mask_dilated.nii.gz\
${prefix}__b0_bet.nii.gz --data_type float32 -f

Expand All @@ -93,7 +93,7 @@ process PREPROC_EDDY {

echo "--very_verbose $extra_args" >> eddy.sh
sh eddy.sh
scil_volume_math.py lower_threshold dwi_eddy_corrected.nii.gz 0 ${prefix}__dwi_corrected.nii.gz
scil_volume_math.py lower_clip dwi_eddy_corrected.nii.gz 0 ${prefix}__dwi_corrected.nii.gz

if [[ \$number_rev_dwi -eq 0 ]]
then
Expand All @@ -106,7 +106,7 @@ process PREPROC_EDDY {

cat <<-END_VERSIONS > versions.yml
"${task.process}":
scilpy: 2.0.0
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
Expand Down Expand Up @@ -135,7 +135,7 @@ process PREPROC_EDDY {

cat <<-END_VERSIONS > versions.yml
"${task.process}":
scilpy: 2.0.0
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')

Expand Down
64 changes: 59 additions & 5 deletions modules/nf-neuro/preproc/eddy/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,73 @@ nextflow_process {
script "../../../../../subworkflows/nf-neuro/load_test_data/main.nf"
process {
"""
input[0] = Channel.from( [ "topup_eddy_light.zip" ] )
input[0] = Channel.from( [ "raw_DWIss1000-dir32.zip", "TOPUP.zip", "topup_eddy_light.zip" ] )
input[1] = "test.load-test-data"
"""
}
}
}

test("eddy") {
test("eddy_light") {

config "./nextflow.config"

when {
process {
"""
input[0] = LOAD_DATA.out.test_data_directory
ch_split_test_data = LOAD_DATA.out.test_data_directory
.branch{
raw_dwi: it.simpleName == "raw_DWIss1000-dir32"
topup_results: it.SimpleName == "TOPUP"
rev_dwi: it.simpleName == "topup_eddy_light"
}
ch_raw_dwi = ch_split_test_data.raw_dwi
.map{ test_data_directory -> [
[ id:'test', single_end:false ], // meta map
file("\${test_data_directory}/dwi.nii.gz", checkIfExists: true),
file("\${test_data_directory}/dwi.bval", checkIfExists: true),
file("\${test_data_directory}/dwi.bvec", checkIfExists: true),
[],
[],
[]]}
ch_topup = ch_split_test_data.topup_results
.map{ test_data_directory -> [
[ id:'test', single_end:false ], // meta map
file("\${test_data_directory}/topup_corrected_b0s.nii.gz", checkIfExists: true),
file("\${test_data_directory}/topup_fieldcoef.nii.gz", checkIfExists: true),
file("\${test_data_directory}/topup_movpar.txt", checkIfExists: true)]}
input[0] = ch_raw_dwi.join(ch_topup)
"""
}
}
then {
assertAll(
{ assert process.success },
{ assert snapshot(
file(process.out.dwi_corrected.get(0).get(1)).name,
process.out.bval_corrected,
file(process.out.bvec_corrected.get(0).get(1)).name,
process.out.b0_mask,
process.out.versions
).match() }
)
}
}

test("eddy_full") {

config "./nextflow_full.config"

when {
process {
"""
ch_split_test_data = LOAD_DATA.out.test_data_directory
.branch{
raw_dwi: it.simpleName == "raw_DWIss1000-dir32"
topup_results: it.SimpleName == "TOPUP"
rev_dwi: it.simpleName == "topup_eddy_light"
}
input[0] = ch_split_test_data.rev_dwi
.map{ test_data_directory -> [
[ id:'test', single_end:false ], // meta map
file("\${test_data_directory}/sub-01_dir-AP_dwi.nii.gz", checkIfExists: true),
Expand All @@ -42,10 +97,9 @@ nextflow_process {
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 },
Expand Down
44 changes: 38 additions & 6 deletions modules/nf-neuro/preproc/eddy/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"eddy": {
"eddy_full": {
"content": [
"test__dwi_corrected.nii.gz",
[
Expand All @@ -18,17 +18,49 @@
"id": "test",
"single_end": false
},
"test__b0_bet_mask.nii.gz:md5,fc1f94e2a5e2cf5197d7fdc28a83ca28"
"test__b0_bet_mask.nii.gz:md5,a1e4b4842cbdf57ab34d6803e64f8383"
]
],
[
"versions.yml:md5,2162950d257422ffda17cc7ac676c81d"
"versions.yml:md5,137e3ce0fd25e5b16de2d8cc5a5aefca"
]
],
"meta": {
"nf-test": "0.9.0-rc1",
"nextflow": "24.04.2"
"nf-test": "0.9.0",
"nextflow": "24.04.4"
},
"timestamp": "2024-07-22T03:27:48.011429"
"timestamp": "2024-10-31T18:53:32.412097643"
},
"eddy_light": {
"content": [
"test__dwi_corrected.nii.gz",
[
[
{
"id": "test",
"single_end": false
},
"test__bval_eddy:md5,7995daabbd74fcf7c365a39a779f67e9"
]
],
"test__dwi_eddy_corrected.bvec",
[
[
{
"id": "test",
"single_end": false
},
"test__b0_bet_mask.nii.gz:md5,2dd16e0c664c910f1970b96056866fea"
]
],
[
"versions.yml:md5,137e3ce0fd25e5b16de2d8cc5a5aefca"
]
],
"meta": {
"nf-test": "0.9.0",
"nextflow": "24.04.4"
},
"timestamp": "2024-10-31T13:17:58.524376706"
}
}
2 changes: 1 addition & 1 deletion modules/nf-neuro/preproc/eddy/tests/nextflow.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
process {
withName: "PREPROC_EDDY" {
ext.prefix_topup = "topup_results"
ext.prefix_topup = "topup"
ext.default_config_topup = "b02b0.cnf"
ext.encoding = "y"
ext.readout = 0.062
Expand Down
15 changes: 15 additions & 0 deletions modules/nf-neuro/preproc/eddy/tests/nextflow_full.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
process {
withName: "PREPROC_EDDY" {
ext.prefix_topup = "topup_results"
ext.default_config_topup = "b02b0.cnf"
ext.encoding = "y"
ext.readout = 0.062
ext.b0_thr_extract_b0 = 10
ext.slice_drop_flag = true
ext.bet_topup_before_eddy_f=0.16
ext.eddy_cmd="eddy_cpu"
ext.dilate_b0_mask_prelim_brain_extraction = 5
ext.bet_prelim_f = 0.16
ext.extra_args = "--flm=linear --niter=2"
}
}
7 changes: 4 additions & 3 deletions modules/nf-neuro/preproc/n4/main.nf
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
process PREPROC_N4 {
tag "$meta.id"
label 'process_single'
label 'process_medium'
label "process_high_memory"

container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://scil.usherbrooke.ca/containers/scilus_2.0.2.sif':
Expand Down Expand Up @@ -49,7 +50,7 @@ process PREPROC_N4 {

cat <<-END_VERSIONS > versions.yml
"${task.process}":
scilpy: 2.0.2
scilpy: \$(pip list | grep scilpy | tr -s ' ' | cut -d' ' -f2)
N4BiasFieldCorrection: \$(N4BiasFieldCorrection --version 2>&1 | sed -n 's/ANTs Version: v\\([0-9.]\\+\\)/\\1/p')
END_VERSIONS
"""
Expand All @@ -65,7 +66,7 @@ process PREPROC_N4 {

cat <<-END_VERSIONS > versions.yml
"${task.process}":
scilpy: 2.0.2
scilpy: \$(pip list | grep scilpy | tr -s ' ' | cut -d' ' -f2)
N4BiasFieldCorrection: \$(N4BiasFieldCorrection --version 2>&1 | sed -n 's/ANTs Version: v\\([0-9.]\\+\\)/\\1/p')
END_VERSIONS
"""
Expand Down
2 changes: 1 addition & 1 deletion modules/nf-neuro/preproc/n4/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ keywords:
- N4
- bias field
tools:
- "Scilpy":
- "scilpy":
description: "The Sherbrooke Connectivity Imaging Lab (SCIL) Python dMRI processing toolbox."
homepage: "https://github.com/scilus/scilpy.git"

Expand Down
12 changes: 6 additions & 6 deletions modules/nf-neuro/preproc/n4/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
}
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.1"
"nf-test": "0.9.0",
"nextflow": "24.04.4"
},
"timestamp": "2024-05-10T16:06:45.886061"
"timestamp": "2024-10-30T13:19:29.130623074"
},
"preproc - n4 - anat": {
"content": [
Expand Down Expand Up @@ -64,9 +64,9 @@
}
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.1"
"nf-test": "0.9.0",
"nextflow": "24.04.4"
},
"timestamp": "2024-05-10T16:09:11.896134"
"timestamp": "2024-10-30T13:23:00.282856"
}
}
4 changes: 2 additions & 2 deletions modules/nf-neuro/preproc/normalize/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ process PREPROC_NORMALIZE {

cat <<-END_VERSIONS > versions.yml
"${task.process}":
scilpy: 2.0.2
scilpy: \$(pip list | grep scilpy | tr -s ' ' | cut -d' ' -f2)
mrtrix: \$(dwidenoise -version 2>&1 | sed -n 's/== dwidenoise \\([0-9.]\\+\\).*/\\1/p')
END_VERSIONS
"""
Expand All @@ -63,7 +63,7 @@ process PREPROC_NORMALIZE {

cat <<-END_VERSIONS > versions.yml
"${task.process}":
scilpy: 2.0.2
scilpy: \$(pip list | grep scilpy | tr -s ' ' | cut -d' ' -f2)
mrtrix: \$(dwidenoise -version 2>&1 | sed -n 's/== dwidenoise \\([0-9.]\\+\\).*/\\1/p')
END_VERSIONS
"""
Expand Down
2 changes: 1 addition & 1 deletion modules/nf-neuro/preproc/normalize/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ keywords:
- scilpy
- MRtrix3
tools:
- "Scilpy":
- "scilpy":
description: "The Sherbrooke Connectivity Imaging Lab (SCIL) Python dMRI processing toolbox."
homepage: "https://github.com/scilus/scilpy.git"
- "MRtrix3":
Expand Down
10 changes: 5 additions & 5 deletions modules/nf-neuro/preproc/topup/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ process PREPROC_TOPUP {
label 'process_single'

container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
"https://scil.usherbrooke.ca/containers/scilus_2.0.0.sif":
"scilus/scilus:2.0.0"}"
"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)
path(config_topup)
val(config_topup)

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

cat <<-END_VERSIONS > versions.yml
"${task.process}":
scilpy: 2.0.0
scilpy: \$(pip list | grep scilpy | tr -s ' ' | cut -d' ' -f2)
antsRegistration: 2.4.3
fsl: \$(flirt -version 2>&1 | sed -n 's/FLIRT version \\([0-9.]\\+\\)/\\1/p')

Expand All @@ -91,7 +91,7 @@ process PREPROC_TOPUP {

cat <<-END_VERSIONS > versions.yml
"${task.process}":
scilpy: 2.0.0
scilpy: \$(pip list | grep scilpy | tr -s ' ' | cut -d' ' -f2)
antsRegistration: 2.4.3
fsl: \$(flirt -version 2>&1 | sed -n 's/FLIRT version \\([0-9.]\\+\\)/\\1/p')

Expand Down
2 changes: 1 addition & 1 deletion modules/nf-neuro/preproc/topup/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ tools:
- "FSL":
description: "FSL Toolbox and Scilpy Toolbox"
homepage: "https://fsl.fmrib.ox.ac.uk/fsl/fslwiki"
- "Scilpy":
- "scilpy":
description: "The Sherbrooke Connectivity Imaging Lab (SCIL) Python dMRI processing toolbox."
homepage: "https://github.com/scilus/scilpy.git"

Expand Down
Loading
Loading