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

New density map module #30

Merged
merged 8 commits into from
Nov 1, 2024
Merged
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
3 changes: 3 additions & 0 deletions modules/nf-neuro/tractogram/densitymap/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
channels: []
dependencies: []
name: tractogram_densitymap
46 changes: 46 additions & 0 deletions modules/nf-neuro/tractogram/densitymap/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
process TRACTOGRAM_DENSITYMAP {
tag "$meta.id"
label 'process_single'

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' }"

input:
tuple val(meta), path(tractogram)

output:
tuple val(meta), path("*__*.nii.gz"), emit: density_map
path "versions.yml" , emit: versions

when:
task.ext.when == null || task.ext.when

script:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
def binary = task.ext.is_binary ? "--binary" : ""
"""
bname=\$(basename ${tractogram} .trk)
scil_tractogram_compute_density_map.py $tractogram ${prefix}__\${bname}.nii.gz ${binary}

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

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

touch ${prefix}_AF_L.nii.gz

cat <<-END_VERSIONS > versions.yml
"${task.process}":
scilpy: \$(pip list --disable-pip-version-check --no-python-version-warning | grep scilpy | tr -s ' ' | cut -d' ' -f2)
END_VERSIONS
"""
}
45 changes: 45 additions & 0 deletions modules/nf-neuro/tractogram/densitymap/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
name: "tractogram_densitymap"
description: Compute density maps from tractograms
keywords:
- Diffusion MRI
- Tractogram
- Density Map
tools:
- "scilpy":
description: "The Sherbrooke Connectivity Imaging Lab (SCIL) Python dMRI processing toolbox."
homepage: "https://github.com/scilus/scilpy.git"

input:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'test', single_end:false ]`

- tractogram:
type: file
description: Tractogram file for density map computation
pattern: "*.trk"

output:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'test', single_end:false ]`

- density_map:
type: file
description: Computed density map
pattern: "*.nii.gz"

- versions:
type: file
description: File containing software versions
pattern: "versions.yml"

authors:
- "@GuillaumeTh"
maintainers:
- "@GuillaumeTh"
75 changes: 75 additions & 0 deletions modules/nf-neuro/tractogram/densitymap/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
nextflow_process {

name "Test Process TRACTOGRAM_DENSITYMAP"
script "../main.nf"
process "TRACTOGRAM_DENSITYMAP"

tag "modules"
tag "modules_nfcore"
tag "tractogram"
tag "tractogram/densitymap"

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

test("densitymap - map") {

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}/bundle_all_1mm.trk")
]
}
"""
}
}

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

test("densitymap - mask") {

config "./nextflow_mask.config"

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}/bundle_all_1mm.trk")
]
}
"""
}
}

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

}
72 changes: 72 additions & 0 deletions modules/nf-neuro/tractogram/densitymap/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
"densitymap - map": {
"content": [
{
"0": [
[
{
"id": "test",
"single_end": false
},
"test__bundle_all_1mm.nii.gz:md5,a9cc8ba016a680ec8cbac940c45e5464"
]
],
"1": [
"versions.yml:md5,7a2b58d5ff9231cb698c8ca1a279171f"
],
"density_map": [
[
{
"id": "test",
"single_end": false
},
"test__bundle_all_1mm.nii.gz:md5,a9cc8ba016a680ec8cbac940c45e5464"
]
],
"versions": [
"versions.yml:md5,7a2b58d5ff9231cb698c8ca1a279171f"
]
}
],
"meta": {
"nf-test": "0.9.0",
"nextflow": "24.10.0"
},
"timestamp": "2024-10-31T13:26:09.344942322"
},
"densitymap - mask": {
"content": [
{
"0": [
[
{
"id": "test",
"single_end": false
},
"test__bundle_all_1mm.nii.gz:md5,5c682d295c593e132295e21e753a6f4f"
]
],
"1": [
"versions.yml:md5,7a2b58d5ff9231cb698c8ca1a279171f"
],
"density_map": [
[
{
"id": "test",
"single_end": false
},
"test__bundle_all_1mm.nii.gz:md5,5c682d295c593e132295e21e753a6f4f"
]
],
"versions": [
"versions.yml:md5,7a2b58d5ff9231cb698c8ca1a279171f"
]
}
],
"meta": {
"nf-test": "0.9.0",
"nextflow": "24.10.0"
},
"timestamp": "2024-10-31T13:26:15.496099088"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
process {
withName: "TRACTOGRAM_DENSITYMAP" {
publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" }
ext.is_binary = true
}
}
2 changes: 2 additions & 0 deletions modules/nf-neuro/tractogram/densitymap/tests/tags.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
tractogram/densitymap:
- "modules/nf-neuro/tractogram/densitymap/**"