Skip to content
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
6 changes: 6 additions & 0 deletions modules/nf-neuro/tensor/ratio/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json
name: "tensor_ratio"
channels: []
dependencies: []

48 changes: 48 additions & 0 deletions modules/nf-neuro/tensor/ratio/main.nf
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think the ratio of y on z could be interesting for someone ? If so, please add it to the module.

Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
process TENSOR_RATIO {
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:latest' }"

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

output:
tuple val(meta), path("*_Dxx_to_Dyy.nii.gz") , emit: tensor_x_to_y
tuple val(meta), path("*_Dxx_to_Dzz.nii.gz") , emit: tensor_x_to_z
Comment on lines +13 to +14
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel the names ratio_x_on_y or eval_x_on_y (same for x on z) would convey a better meaning. If you agree, please adjust, here and in the meta.

path "versions.yml" , emit: versions

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

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

"""
fslsplit $image
fslmaths ${image}_0000.nii.gz -div ${image}_0003.nii.gz ${prefix}_Dxx_to_Dyy.nii.gz
fslmaths ${image}_0000.nii.gz -div ${image}_0005.nii.gz ${prefix}_Dxx_to_Dzz.nii.gz

cat <<-END_VERSIONS > versions.yml
"${task.process}":
fsl: \$(fslsplit -version 2>&1 | sed -n 's/FSLSPLIT version \\([0-9.]\\+\\)/\\1/p')
END_VERSIONS
"""

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

"""
touch ${prefix}_Dxx_to_Dyy.nii.gz
touch ${prefix}_Dxx_to_Dzz.nii.gz
fslsplit
fslmaths

cat <<-END_VERSIONS > versions.yml
"${task.process}":
fsl: \$(fslsplit -version 2>&1 | sed -n 's/FSLSPLIT version \\([0-9.]\\+\\)/\\1/p')
END_VERSIONS
"""
}
51 changes: 51 additions & 0 deletions modules/nf-neuro/tensor/ratio/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json
name: "tensor_ratio"
description: Split the tensor image and compute the ratio of Dxx to Dyy and Dxx to Dzz for ALPS.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specify to which convention the tensor image must abide to (I assume it's FSL). Something like :

The tensor elements must be ordered following convention, that is : Dxx, Dxy, Dxz, Dyy, Dyz, Dzz.

keywords:
- DWI
- tensor
- DTI-ALPS
tools:
- "FSL":
description: "FSL Toolbox"
homepage: "https://fsl.fmrib.ox.ac.uk/fsl/fslwiki"

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

- image:
type: file
description: Nifti tensor image volume to extract Dx to Dy and Dx to Dz.
pattern: "*.{nii,nii.gz}"

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

- tensor_x_to_y:
type: file
description: Nifti volume ratio of Dxx to Dyy.
pattern: "*_Dxx_to_Dyy.{nii,nii.gz}"

- tensor_x_to_z:
type: file
description: Nifti volume ratio of Dxx to Dzz.
pattern: "*_Dxx_to_Dzz.{nii,nii.gz}"

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

authors:
- "@atsuch"
maintainers:
- "@atsuch"
78 changes: 78 additions & 0 deletions modules/nf-neuro/tensor/ratio/tests/main.nf.test
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the TODO comments in this file.

Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// TODO nf-core: Once you have added the required tests, please run the following command to build this file:
// nf-core modules test tensor/ratio
nextflow_process {

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

tag "modules"
tag "modules_nfcore"
tag "tensor"
tag "tensor/ratio"

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( [ "dti.zip" ] )
input[1] = "test.load-test-data"
"""
}
}
}
test("tensorratio - classic") {
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}/dti/tensor.nii.gz")
]
}
"""
}
}

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

}

// TODO nf-core: Change the test name preferably indicating the test-data and file-format used but keep the " - stub" suffix.
test("tensorratio - stub") {

options "-stub"

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

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

}

}
60 changes: 60 additions & 0 deletions modules/nf-neuro/tensor/ratio/tests/main.nf.test.snap
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This snapshot will have to be updated

Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"tensorratio - classic": {
"content": [
{
"0": [

],
"1": [

],
"2": [

],
"tensor_x_to_y": [

],
"tensor_x_to_z": [

],
"versions": [

]
}
],
"meta": {
"nf-test": "0.9.0",
"nextflow": "24.10.4"
},
"timestamp": "2025-02-27T14:05:10.553221131"
},
"tensorratio - stub": {
"content": [
{
"0": [

],
"1": [

],
"2": [

],
"tensor_x_to_y": [

],
"tensor_x_to_z": [

],
"versions": [

]
}
],
"meta": {
"nf-test": "0.9.0",
"nextflow": "24.10.4"
},
"timestamp": "2025-02-27T14:05:28.311339916"
}
}
2 changes: 2 additions & 0 deletions modules/nf-neuro/tensor/ratio/tests/tags.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
tensor/ratio:
- "modules/nf-neuro/tensor/ratio/**"
Loading