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 reconst modules #33

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
14 changes: 7 additions & 7 deletions modules/nf-neuro/reconst/fodf/main.nf
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@

process RECONST_FODF {
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(mask), path(fa), path(md), path(wm_frf), path(gm_frf), path(csf_frf)
Expand Down Expand Up @@ -40,7 +40,7 @@ process RECONST_FODF {
def sh_order = task.ext.sh_order ? "--sh_order " + task.ext.sh_order : ""
def sh_basis = task.ext.sh_basis ? "--sh_basis " + task.ext.sh_basis : ""
def set_method = task.ext.method ? task.ext.method : "ssst"
def processes = task.ext.processes ? "--processes " + task.ext.processes : ""
def processes = task.cpus > 1 ? "--processes " + task.cpus : ""
def set_mask = mask ? "--mask $mask" : ""
def relative_threshold = task.ext.relative_threshold ? "--rt " + task.ext.relative_threshold : ""
def fodf_metrics_a_factor = task.ext.fodf_metrics_a_factor ? task.ext.fodf_metrics_a_factor : 2.0
Expand Down Expand Up @@ -122,13 +122,13 @@ process RECONST_FODF {
$set_mask $sh_basis $absolute_peaks \
$peaks $peak_values $peak_indices \
$afd_max $afd_total \
$afd_sum $nufo \
$afd_sum $nufo $processes \
$relative_threshold --not_all --at \${a_threshold}
fi

cat <<-END_VERSIONS > versions.yml
"${task.process}":
scilpy: 2.0.0
scilpy: \$(pip list | grep scilpy | tr -s ' ' | cut -d' ' -f2)
END_VERSIONS
"""

Expand Down Expand Up @@ -159,7 +159,7 @@ process RECONST_FODF {

cat <<-END_VERSIONS > versions.yml
"${task.process}":
scilpy: 2.0.0
scilpy: \$(pip list | grep scilpy | tr -s ' ' | cut -d' ' -f2)
END_VERSIONS
"""
}
7 changes: 6 additions & 1 deletion modules/nf-neuro/reconst/fodf/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ keywords:
- Local Model
- Reconst
tools:
- "Scilpy":
- "scilpy":
description: "The Sherbrooke Connectivity Imaging Lab (SCIL) Python dMRI processing toolbox."
homepage: "https://github.com/scilus/scilpy.git"

Expand Down Expand Up @@ -146,6 +146,11 @@ output:
description: Number of Fiber Orientation (NuFO) map.
pattern: "*nufo.nii.gz"

- vent_mask:
type: file
description: Ventricule mask estimated from an MD and FA threshold.
pattern: "*ventricles_mask.nii.gz"

- versions:
type: file
description: File containing software versions
Expand Down
223 changes: 136 additions & 87 deletions modules/nf-neuro/reconst/fodf/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,22 @@ nextflow_process {
tag "subworkflows/load_test_data"

setup {
run("LOAD_TEST_DATA", alias: "LOAD_DATA") {
script "../../../../../subworkflows/nf-neuro/load_test_data/main.nf"
process {
"""
input[0] = Channel.from( [ "processing.zip" , "commit_amico.zip" ] )
input[1] = "test.load-test-data"
"""
}
run("LOAD_TEST_DATA", alias: "LOAD_DATA") {
script "../../../../../subworkflows/nf-neuro/load_test_data/main.nf"
process {
"""
input[0] = Channel.from( [
"DWIss2000-dir60.zip",
"DWIms1000-2000-dir32-60.zip" ,
"segmentation.zip",
"dti.zip",
"responses.zip"
] )
input[1] = "test.load-test-data"
"""
}
}
}

test("reconst - fodf") {

Expand All @@ -33,23 +39,43 @@ nextflow_process {
"""
ch_split_test_data = LOAD_DATA.out.test_data_directory
.branch{
ssst: it.simpleName == "processing"
msmt: it.simpleName == "commit_amico"
ssst: it.simpleName == "DWIss2000-dir60"
segmentation: it.simpleName == "segmentation"
dti: it.simpleName == "dti"
responses: it.simpleName == "responses"
}
input[0] = ch_split_test_data.ssst.map{
ch_dwi = ch_split_test_data.ssst.map{
test_data_directory -> [
[ id:'test', single_end:false ],
[ id:'test' ],
file("\${test_data_directory}/dwi.nii.gz"),
file("\${test_data_directory}/dwi.bval"),
file("\${test_data_directory}/dwi.bvec"),
file("\${test_data_directory}/cc.nii.gz"),
file("\${test_data_directory}/dwi.bvec")
]
}
ch_mask = ch_split_test_data.segmentation.map{
test_data_directory -> [
[ id:'test' ],
file("\${test_data_directory}/brainmask/brainmask.nii.gz")
]
}
ch_metrics = ch_split_test_data.dti.map{
test_data_directory -> [
[ id:'test' ],
file("\${test_data_directory}/fa.nii.gz"),
file("\${test_data_directory}/md.nii.gz"),
file("\${test_data_directory}/frf.txt"),
[],
[]
file("\${test_data_directory}/md.nii.gz")
]
}
ch_response = ch_split_test_data.responses.map{
test_data_directory -> [
[ id:'test' ],
file("\${test_data_directory}/DWIss1000-dir32.txt")
]
}
input[0] = ch_dwi
.join(ch_mask)
.join(ch_metrics)
.join(ch_response)
.map{ it + [[], []] }
"""
}
}
Expand All @@ -72,62 +98,43 @@ nextflow_process {
"""
ch_split_test_data = LOAD_DATA.out.test_data_directory
.branch{
ssst: it.simpleName == "processing"
msmt: it.simpleName == "commit_amico"
msmt: it.simpleName == "DWIms1000-2000-dir32-60"
segmentation: it.simpleName == "segmentation"
dti: it.simpleName == "dti"
responses: it.simpleName == "responses"
}
input[0] = ch_split_test_data.ssst.map{
ch_dwi = ch_split_test_data.msmt.map{
test_data_directory -> [
[ id:'test', single_end:false ],
[ id:'test' ],
file("\${test_data_directory}/dwi.nii.gz"),
file("\${test_data_directory}/dwi.bval"),
file("\${test_data_directory}/dwi.bvec"),
file("\${test_data_directory}/cc.nii.gz"),
file("\${test_data_directory}/fa.nii.gz"),
file("\${test_data_directory}/md.nii.gz"),
file("\${test_data_directory}/frf.txt"),
[],
[]
file("\${test_data_directory}/dwi.bvec")
]
}
"""
}
}

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

}

test("reconst - fodf_no_mask") {

config "./nextflow.config"

when {
process {
"""
ch_split_test_data = LOAD_DATA.out.test_data_directory
.branch{
ssst: it.simpleName == "processing"
msmt: it.simpleName == "commit_amico"
}
input[0] = ch_split_test_data.ssst.map{
ch_mask = ch_split_test_data.segmentation.map{
test_data_directory -> [
[ id:'test', single_end:false ],
file("\${test_data_directory}/dwi.nii.gz"),
file("\${test_data_directory}/dwi.bval"),
file("\${test_data_directory}/dwi.bvec"),
[],
[ id:'test' ],
file("\${test_data_directory}/brainmask/brainmask.nii.gz")
]
}
ch_metrics = ch_split_test_data.dti.map{
test_data_directory -> [
[ id:'test' ],
file("\${test_data_directory}/fa.nii.gz"),
file("\${test_data_directory}/md.nii.gz"),
file("\${test_data_directory}/frf.txt"),
[],
[]
file("\${test_data_directory}/md.nii.gz")
]
}
ch_response = ch_split_test_data.responses.map{
test_data_directory -> [
[ id:'test' ],
file("\${test_data_directory}/DWIss1000-dir32.txt")
]
}
input[0] = ch_dwi
.join(ch_mask)
.join(ch_metrics)
.join(ch_response)
.map{ it + [[], []] }
"""
}
}
Expand All @@ -150,23 +157,43 @@ nextflow_process {
"""
ch_split_test_data = LOAD_DATA.out.test_data_directory
.branch{
ssst: it.simpleName == "processing"
msmt: it.simpleName == "commit_amico"
ssst: it.simpleName == "DWIss2000-dir60"
segmentation: it.simpleName == "segmentation"
dti: it.simpleName == "dti"
responses: it.simpleName == "responses"
}
input[0] = ch_split_test_data.ssst.map{
ch_dwi = ch_split_test_data.ssst.map{
test_data_directory -> [
[ id:'test', single_end:false ],
[ id:'test' ],
file("\${test_data_directory}/dwi.nii.gz"),
file("\${test_data_directory}/dwi.bval"),
file("\${test_data_directory}/dwi.bvec"),
file("\${test_data_directory}/cc.nii.gz"),
file("\${test_data_directory}/dwi.bvec")
]
}
ch_mask = ch_split_test_data.segmentation.map{
test_data_directory -> [
[ id:'test' ],
file("\${test_data_directory}/brainmask/brainmask.nii.gz")
]
}
ch_metrics = ch_split_test_data.dti.map{
test_data_directory -> [
[ id:'test' ],
file("\${test_data_directory}/fa.nii.gz"),
file("\${test_data_directory}/md.nii.gz"),
file("\${test_data_directory}/frf.txt"),
[],
[]
file("\${test_data_directory}/md.nii.gz")
]
}
ch_response = ch_split_test_data.responses.map{
test_data_directory -> [
[ id:'test' ],
file("\${test_data_directory}/DWIss1000-dir32.txt")
]
}
input[0] = ch_dwi
.join(ch_mask)
.join(ch_metrics)
.join(ch_response)
.map{ it + [[], []] }
"""
}
}
Expand All @@ -189,32 +216,52 @@ nextflow_process {
"""
ch_split_test_data = LOAD_DATA.out.test_data_directory
.branch{
ssst: it.simpleName == "processing"
msmt: it.simpleName == "commit_amico"
msmt: it.simpleName == "DWIms1000-2000-dir32-60"
segmentation: it.simpleName == "segmentation"
dti: it.simpleName == "dti"
responses: it.simpleName == "responses"
}
input[0] = ch_split_test_data.msmt.map{
ch_dwi = ch_split_test_data.msmt.map{
test_data_directory -> [
[ id:'test', single_end:false ],
[ id:'test' ],
file("\${test_data_directory}/dwi.nii.gz"),
file("\${test_data_directory}/dwi.bval"),
file("\${test_data_directory}/dwi.bvec"),
file("\${test_data_directory}/mask.nii.gz"),
file("\${test_data_directory}/dwi.bvec")
]
}
ch_mask = ch_split_test_data.segmentation.map{
test_data_directory -> [
[ id:'test' ],
file("\${test_data_directory}/brainmask/brainmask.nii.gz")
]
}
ch_metrics = ch_split_test_data.dti.map{
test_data_directory -> [
[ id:'test' ],
file("\${test_data_directory}/fa.nii.gz"),
file("\${test_data_directory}/md.nii.gz"),
file("\${test_data_directory}/wm_frf.txt"),
file("\${test_data_directory}/gm_frf.txt"),
file("\${test_data_directory}/csf_frf.txt")

file("\${test_data_directory}/md.nii.gz")
]
}
ch_response = ch_split_test_data.responses.map{
test_data_directory -> [
[ id:'test' ],
file("\${test_data_directory}/DWIms1000-2000-dir32-60_wm.txt"),
file("\${test_data_directory}/DWIms1000-2000-dir32-60_gm.txt"),
file("\${test_data_directory}/DWIms1000-2000-dir32-60_csf.txt")
]
}
input[0] = ch_dwi
.join(ch_mask)
.join(ch_metrics)
.join(ch_response)
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(
file(process.out.fodf.get(0).get(1)).name,
file(process.out.wm_fodf.get(0).get(1)).name,
file(process.out.gm_fodf.get(0).get(1)).name,
file(process.out.csf_fodf.get(0).get(1)).name,
Expand All @@ -226,7 +273,9 @@ nextflow_process {
file(process.out.afd_max.get(0).get(1)).name,
file(process.out.afd_total.get(0).get(1)).name,
file(process.out.afd_sum.get(0).get(1)).name,
file(process.out.nufo.get(0).get(1)).name).match() }
file(process.out.nufo.get(0).get(1)).name,
file(process.out.vent_mask.get(0).get(1)).name,
file(process.out.versions.get(0).get(1)).name).match() }
)
}

Expand Down
Loading
Loading