Skip to content

Commit

Permalink
Merge pull request scilus#137 from gagnonanthony/denoising_2.0
Browse files Browse the repository at this point in the history
Migrate denoising modules to scilpy 2.0.0 + nf-test.
  • Loading branch information
AlexVCaron authored May 1, 2024
2 parents 1ca5733 + 38aba32 commit 48a11f8
Show file tree
Hide file tree
Showing 19 changed files with 283 additions and 105 deletions.
9 changes: 9 additions & 0 deletions modules/nf-scil/denoising/mppca/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: denoising_mppca

channels:
- Docker
- Apptainer

dependencies:
- FSL
- Mrtrix
4 changes: 2 additions & 2 deletions modules/nf-scil/denoising/mppca/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ process DENOISING_MPPCA {
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' }"
'https://scil.usherbrooke.ca/containers/scilus_2.0.0.sif':
'scilus/scilus:2.0.0' }"

input:
tuple val(meta), path(dwi)
Expand Down
52 changes: 52 additions & 0 deletions modules/nf-scil/denoising/mppca/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
nextflow_process {

name "Test Process DENOISING_MPPCA"
script "../main.nf"
process "DENOISING_MPPCA"
config "./nextflow.config"

tag "modules"
tag "modules_nfcore"
tag "denoising"
tag "denoising/mppca"

tag "subworkflows"
tag "subworkflows/load_test_data"

test("denoising - mppca") {

setup {
run("LOAD_TEST_DATA", alias: "LOAD_DATA") {
script "../../../../../subworkflows/nf-scil/load_test_data/main.nf"
process {
"""
input[0] = Channel.from( [ "heavy.zip" ] )
input[1] = "test.load-test-data"
"""
}
}
}

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}/dwi/dwi.nii.gz")
]
}
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}

}

}
37 changes: 37 additions & 0 deletions modules/nf-scil/denoising/mppca/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"denoising - mppca": {
"content": [
{
"0": [
[
{
"id": "test",
"single_end": false
},
"test_dwi_denoised.nii.gz:md5,c949b91d96513cba506975c271e53596"
]
],
"1": [
"versions.yml:md5,fb589ae27eb3edb1cd1a50b0e13d2714"
],
"image": [
[
{
"id": "test",
"single_end": false
},
"test_dwi_denoised.nii.gz:md5,c949b91d96513cba506975c271e53596"
]
],
"versions": [
"versions.yml:md5,fb589ae27eb3edb1cd1a50b0e13d2714"
]
}
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.1"
},
"timestamp": "2024-04-25T11:07:06.152814"
}
}
6 changes: 6 additions & 0 deletions modules/nf-scil/denoising/mppca/tests/nextflow.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
process {
withNAME: "DENOISING_MPPCA" {
publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" }
ext.extent = 3
}
}
2 changes: 2 additions & 0 deletions modules/nf-scil/denoising/mppca/tests/tags.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
denoising/mppca:
- "modules/nf-scil/denoising/mppca/**"
7 changes: 7 additions & 0 deletions modules/nf-scil/denoising/nlmeans/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
name: "denoising_nlmeans"
channels:
- Docker
- Apptainer
dependencies:
- "Scilpy"
12 changes: 6 additions & 6 deletions modules/nf-scil/denoising/nlmeans/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ process DENOISING_NLMEANS {
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' }"
'https://scil.usherbrooke.ca/containers/scilus_2.0.0.sif':
'scilus/scilus:2.0.0' }"

input:
tuple val(meta), path(image), path(mask)
Expand All @@ -27,25 +27,25 @@ process DENOISING_NLMEANS {
export OMP_NUM_THREADS=1
export OPENBLAS_NUM_THREADS=1
scil_run_nlmeans.py $image ${prefix}_denoised.nii.gz 1 ${args.join(" ")}
scil_denoising_nlmeans.py $image ${prefix}_denoised.nii.gz 1 ${args.join(" ")}
cat <<-END_VERSIONS > versions.yml
"${task.process}":
scilpy: 1.6.0
scilpy: 2.0.0
END_VERSIONS
"""

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

"""
scil_run_nlmeans.py -h
scil_denoising_nlmeans.py -h
touch ${prefix}_denoised.nii.gz
cat <<-END_VERSIONS > versions.yml
"${task.process}":
scilpy: 1.6.0
scilpy: 2.0.0
END_VERSIONS
"""
}
78 changes: 78 additions & 0 deletions modules/nf-scil/denoising/nlmeans/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
nextflow_process {

name "Test Process DENOISING_NLMEANS"
script "../main.nf"
process "DENOISING_NLMEANS"
config "./nextflow.config"

tag "modules"
tag "modules_nfcore"
tag "denoising"
tag "denoising/nlmeans"

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( [ "heavy.zip" ] )
input[1] = "test.load-test-data"
"""
}
}
}

test("denoising - nlmeans") {

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}/anat/anat_image.nii.gz"),
[]
]
}
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}

}

test("denoising - nlmeans - withmask") {

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}/anat/anat_image.nii.gz"),
file("\${test_data_directory}/anat/anat_mask.nii.gz")
]
}
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}

}

}
72 changes: 72 additions & 0 deletions modules/nf-scil/denoising/nlmeans/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
"denoising - nlmeans": {
"content": [
{
"0": [
[
{
"id": "test",
"single_end": false
},
"test_denoised.nii.gz:md5,4a4eaa8956682b97589682c62c3226e5"
]
],
"1": [
"versions.yml:md5,e5c9936e9d01b8503f706aecd0a39027"
],
"image": [
[
{
"id": "test",
"single_end": false
},
"test_denoised.nii.gz:md5,4a4eaa8956682b97589682c62c3226e5"
]
],
"versions": [
"versions.yml:md5,e5c9936e9d01b8503f706aecd0a39027"
]
}
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.1"
},
"timestamp": "2024-04-23T21:07:32.369936"
},
"denoising - nlmeans - withmask": {
"content": [
{
"0": [
[
{
"id": "test",
"single_end": false
},
"test_denoised.nii.gz:md5,a4925934f71fc40c2182e8c1d3bc6687"
]
],
"1": [
"versions.yml:md5,e5c9936e9d01b8503f706aecd0a39027"
],
"image": [
[
{
"id": "test",
"single_end": false
},
"test_denoised.nii.gz:md5,a4925934f71fc40c2182e8c1d3bc6687"
]
],
"versions": [
"versions.yml:md5,e5c9936e9d01b8503f706aecd0a39027"
]
}
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.1"
},
"timestamp": "2024-04-23T21:09:03.715606"
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
process {

publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" }

}
2 changes: 2 additions & 0 deletions modules/nf-scil/denoising/nlmeans/tests/tags.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
denoising/nlmeans:
- "modules/nf-scil/denoising/nlmeans/**"
20 changes: 10 additions & 10 deletions subworkflows/nf-scil/preproc_t1/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@
"versions.yml:md5,15044237a18a642d172b2bdb3abcad78",
"versions.yml:md5,209daf2d60de195845dedbdf80c98afd",
"versions.yml:md5,2c0a6f978891003ebdf35c1ba060aa90",
"versions.yml:md5,37327d900785469fe8aba4e90c045be3",
"versions.yml:md5,6aecd5fc2de479eaa81fb30b248c647c",
"versions.yml:md5,792251134d89d9f82a5c75d6d323ae0f"
"versions.yml:md5,792251134d89d9f82a5c75d6d323ae0f",
"versions.yml:md5,97b6b9457caf964b9f20549672f692f0"
],
"crop_box": [
[
Expand Down Expand Up @@ -158,17 +158,17 @@
"versions.yml:md5,15044237a18a642d172b2bdb3abcad78",
"versions.yml:md5,209daf2d60de195845dedbdf80c98afd",
"versions.yml:md5,2c0a6f978891003ebdf35c1ba060aa90",
"versions.yml:md5,37327d900785469fe8aba4e90c045be3",
"versions.yml:md5,6aecd5fc2de479eaa81fb30b248c647c",
"versions.yml:md5,792251134d89d9f82a5c75d6d323ae0f"
"versions.yml:md5,792251134d89d9f82a5c75d6d323ae0f",
"versions.yml:md5,97b6b9457caf964b9f20549672f692f0"
]
}
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.1"
},
"timestamp": "2024-04-23T22:49:49.052741"
"timestamp": "2024-04-30T15:37:59.429278"
},
"preproc_t1_classic": {
"content": [
Expand Down Expand Up @@ -249,9 +249,9 @@
"versions.yml:md5,15044237a18a642d172b2bdb3abcad78",
"versions.yml:md5,209daf2d60de195845dedbdf80c98afd",
"versions.yml:md5,2c0a6f978891003ebdf35c1ba060aa90",
"versions.yml:md5,37327d900785469fe8aba4e90c045be3",
"versions.yml:md5,6aecd5fc2de479eaa81fb30b248c647c",
"versions.yml:md5,792251134d89d9f82a5c75d6d323ae0f"
"versions.yml:md5,792251134d89d9f82a5c75d6d323ae0f",
"versions.yml:md5,97b6b9457caf964b9f20549672f692f0"
],
"crop_box": [
[
Expand Down Expand Up @@ -329,16 +329,16 @@
"versions.yml:md5,15044237a18a642d172b2bdb3abcad78",
"versions.yml:md5,209daf2d60de195845dedbdf80c98afd",
"versions.yml:md5,2c0a6f978891003ebdf35c1ba060aa90",
"versions.yml:md5,37327d900785469fe8aba4e90c045be3",
"versions.yml:md5,6aecd5fc2de479eaa81fb30b248c647c",
"versions.yml:md5,792251134d89d9f82a5c75d6d323ae0f"
"versions.yml:md5,792251134d89d9f82a5c75d6d323ae0f",
"versions.yml:md5,97b6b9457caf964b9f20549672f692f0"
]
}
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.1"
},
"timestamp": "2024-04-23T22:20:50.469644"
"timestamp": "2024-04-30T15:06:27.336343"
}
}
Loading

0 comments on commit 48a11f8

Please sign in to comment.