Skip to content
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
5 changes: 3 additions & 2 deletions subworkflows/nf-neuro/preproc_dwi/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ include { IMAGE_RESAMPLE as RESAMPLE_DWI } from '../../../modules/nf-neuro/image
include { IMAGE_RESAMPLE as RESAMPLE_MASK } from '../../../modules/nf-neuro/image/resample/main'
include { UTILS_EXTRACTB0 } from '../../../modules/nf-neuro/utils/extractb0/main'
include { TOPUP_EDDY } from '../topup_eddy/main'
include { getOptionsWithDefaults } from '../utils_options/main'


workflow PREPROC_DWI {
Expand All @@ -30,8 +31,8 @@ workflow PREPROC_DWI {

main:

// Check to ensure options is a list of options,
assert options instanceof Map : "Options must be a Map, got ${options.getClass().getName()}"
// Merge options with defaults from meta.yml
options = getOptionsWithDefaults(options, "${moduleDir}/meta.yml")

ch_versions = channel.empty()
ch_multiqc_files = channel.empty()
Expand Down
13 changes: 12 additions & 1 deletion subworkflows/nf-neuro/preproc_dwi/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ components:
- utils/extractb0
- preproc/gibbs
- topup_eddy
- getoptionswithdefaults

input:
- ch_dwi:
type: file
Expand Down Expand Up @@ -147,7 +149,16 @@ input:
- preproc_dwi_run_normalize (bool): If 'true', the DWI will be normalized to have a mean value in the WM of approximately 1000 using MRtrix3's dwinormalise.
- preproc_dwi_run_resampling (bool): If 'true', the DWI will be resampled to 1 mm isotropic spatial resolution using DIPY's resample.
mandatory: true
default: {}
default:
preproc_dwi_run_denoising: true
preproc_dwi_run_degibbs: true
topup_eddy_run_topup: true
topup_eddy_run_eddy: true
preproc_dwi_run_synthstrip: false
preproc_dwi_keep_dwi_with_skull: false
preproc_dwi_run_N4: true
preproc_dwi_run_normalize: true
preproc_dwi_run_resampling: true
output:
- dwi_resample:
type: file
Expand Down
82 changes: 4 additions & 78 deletions subworkflows/nf-neuro/preproc_dwi/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ nextflow_workflow {
tag "preproc/normalize"
tag "utils/extractb0"
tag "topup_eddy"
tag "subworkflows/utils_options"

tag "load_test_data"

Expand All @@ -41,7 +42,6 @@ nextflow_workflow {
}

test("preproc_dwi - AP DWI | skip steps") {
config "./nextflow_skipsteps.config"
when {
workflow {
"""
Expand All @@ -62,15 +62,12 @@ nextflow_workflow {
"topup_eddy_run_eddy": false,
"preproc_dwi_run_denoising": false,
"preproc_dwi_run_degibbs": false,
"preproc_dwi_run_N4": true,
"preproc_dwi_run_normalize": false,
"preproc_dwi_run_resampling": true,
"preproc_dwi_keep_dwi_with_skull": true
]
"""
}
}

then {
assertAll(
{ assert workflow.success },
Expand All @@ -92,7 +89,6 @@ nextflow_workflow {
}

test("preproc_dwi - AP DWI | PA sbref") {
config "./nextflow_synthstrip.config"
when {
workflow {
"""
Expand All @@ -113,20 +109,11 @@ nextflow_workflow {
input[4] = channel.empty()
input[5] = channel.from( [] )
input[6] = [
"topup_eddy_run_topup": true,
"topup_eddy_run_eddy": true,
"preproc_dwi_run_denoising": true,
"preproc_dwi_run_degibbs": true,
"preproc_dwi_run_N4": true,
"preproc_dwi_run_normalize": true,
"preproc_dwi_run_resampling": true,
"preproc_dwi_run_synthstrip": true,
"preproc_dwi_keep_dwi_with_skull": false
"preproc_dwi_run_synthstrip": true
]
"""
}
}

then {
assertAll(
{ assert workflow.success },
Expand All @@ -148,7 +135,6 @@ nextflow_workflow {
}

test("preproc_dwi - AP DWI | PA DWI") {
config "./nextflow_synthstrip.config"
when {
workflow {
"""
Expand All @@ -171,20 +157,11 @@ nextflow_workflow {
input[4] = channel.from("https://surfer.nmr.mgh.harvard.edu/docs/synthstrip/requirements/synthstrip.1.pt")
input[5] = channel.from( [] )
input[6] = [
"topup_eddy_run_topup": true,
"topup_eddy_run_eddy": true,
"preproc_dwi_run_denoising": true,
"preproc_dwi_run_degibbs": true,
"preproc_dwi_run_N4": true,
"preproc_dwi_run_normalize": true,
"preproc_dwi_run_resampling": true,
"preproc_dwi_run_synthstrip": true,
"preproc_dwi_keep_dwi_with_skull": false
"preproc_dwi_run_synthstrip": true
]
"""
}
}

then {
assertAll(
{ assert workflow.success },
Expand All @@ -206,7 +183,6 @@ nextflow_workflow {
}

test("preproc_dwi - AP DWI+sbref | PA DWI+sbref") {
config "./nextflow_synthstrip.config"
when {
workflow {
"""
Expand Down Expand Up @@ -237,21 +213,10 @@ nextflow_workflow {
input[4] = channel.from("https://surfer.nmr.mgh.harvard.edu/docs/synthstrip/requirements/synthstrip.1.pt")
.map{ weights -> [ [ id:'test' ], weights ] }
input[5] = channel.from( [] )
input[6] = [
"topup_eddy_run_topup": true,
"topup_eddy_run_eddy": true,
"preproc_dwi_run_denoising": true,
"preproc_dwi_run_degibbs": true,
"preproc_dwi_run_N4": true,
"preproc_dwi_run_normalize": true,
"preproc_dwi_run_resampling": true,
"preproc_dwi_run_synthstrip": true,
"preproc_dwi_keep_dwi_with_skull": false
]
input[6] = [:]
"""
}
}

then {
assertAll(
{ assert workflow.success },
Expand All @@ -271,43 +236,4 @@ nextflow_workflow {
)
}
}

test("preproc_dwi - wrong options format - should fail") {
config "./nextflow_skipsteps.config"
when {
workflow {
"""
input[0] = LOAD_DATA.out.test_data_directory.map{
test_data_directory -> [
[ id:'test' ],
file("\${test_data_directory}/sub-01_dir-AP_dwi.nii.gz"),
file("\${test_data_directory}/sub-01_dir-AP_dwi.bval"),
file("\${test_data_directory}/sub-01_dir-AP_dwi.bvec")
]}
input[1] = channel.from( [] )
input[2] = channel.from( [] )
input[3] = channel.from( [] )
input[4] = channel.empty()
input[5] = channel.from( [] )
input[6] = channel.of([
"topup_eddy_run_topup": false,
"topup_eddy_run_eddy": false,
"preproc_dwi_run_denoising": false,
"preproc_dwi_run_degibbs": false,
"preproc_dwi_run_N4": true,
"preproc_dwi_run_normalize": false,
"preproc_dwi_run_resampling": true,
"preproc_dwi_keep_dwi_with_skull": true
])
"""
}
}

then {
assertAll(
{ assert workflow.failed },
{ assert workflow.stdout.contains("ERROR ~ Options must be a Map, got groovyx.gpars.dataflow.DataflowBroadcast. Expression: (options instanceof java.util.Map). Values: options = DataflowBroadcast around DataflowStream[?]") }
)
}
}
}
27 changes: 7 additions & 20 deletions subworkflows/nf-neuro/preproc_dwi/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
{
"id": "test"
},
"test_dwi_cropped_bbox.pkl"
"test__image_boundingBox.pkl"
]
],
"mqc": [
Expand Down Expand Up @@ -77,29 +77,16 @@
"test__rev_dwi_eddy_mqc.gif"
]
],
"pwd_avg": [
[
{
"id": "test"
},
"test_pwd_avg.nii.gz"
]
],
"versions": [
"versions.yml:md5,00c3e8560e74fb87cacb736eb5658fcb",
"versions.yml:md5,034b6d262d1e0e45c673d3ac1756e22f",
"versions.yml:md5,218c08543fae3d1e7dd9b1527aa67a21",
"versions.yml:md5,2b1e0ce850286655d4510ff462e0f57b",
"versions.yml:md5,3efc92963bc72284def5a9aeff469919",
"versions.yml:md5,4f645295735c7f79182fd589063e11a5",
"versions.yml:md5,6775dffbd2264e526ccdfde32db655b9",
"versions.yml:md5,73b36e0fa7fa782add714cca892bf09c",
"versions.yml:md5,76b89b06b38b2148b5af5d388d333763",
"versions.yml:md5,83bb1f168d146ca8d303c24584044f9f",
"versions.yml:md5,a585ae0f02b31e59f3f641836f5cb608",
"versions.yml:md5,c6674ec69abd660014fba145790ec070",
"versions.yml:md5,c7da6834a9868efe7d6878ae023a6782",
"versions.yml:md5,c9f89e6a31f3d2add46a0350e9ff799b",
"versions.yml:md5,d1da6ec93d46e17eff56d0e7f9dc085d",
"versions.yml:md5,dd4515fa7d32a40e94927fddf215ef18",
"versions.yml:md5,fcf20744f2d2ea2b1a57d549d53c8ee6"
]
Expand All @@ -109,7 +96,7 @@
"nf-test": "0.9.3",
"nextflow": "25.10.2"
},
"timestamp": "2026-02-05T22:18:20.502502877"
"timestamp": "2026-02-13T11:04:27.678692921"
},
"preproc_dwi - AP DWI | PA sbref": {
"content": [
Expand Down Expand Up @@ -217,9 +204,9 @@
],
"meta": {
"nf-test": "0.9.3",
"nextflow": "25.04.8"
"nextflow": "25.10.2"
},
"timestamp": "2026-02-11T13:35:27.137234"
"timestamp": "2026-02-12T23:28:25.597720297"
},
"preproc_dwi - AP DWI | PA DWI": {
"content": [
Expand Down Expand Up @@ -331,7 +318,7 @@
"nf-test": "0.9.3",
"nextflow": "25.10.2"
},
"timestamp": "2026-02-05T22:16:59.844303539"
"timestamp": "2026-02-12T23:29:35.247048959"
},
"preproc_dwi - AP DWI | skip steps": {
"content": [
Expand Down Expand Up @@ -397,6 +384,6 @@
"nf-test": "0.9.3",
"nextflow": "25.10.2"
},
"timestamp": "2026-02-05T23:33:51.782441298"
"timestamp": "2026-02-13T10:59:51.74610525"
}
}
14 changes: 14 additions & 0 deletions subworkflows/nf-neuro/preproc_dwi/tests/nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,20 @@ process {
ext.readout = 0.062
ext.extra_args = "--flm=linear --niter=2"
}
withName: "IMAGE_POWDERAVERAGE" {
ext.b0_thr = 10
}
withName: "CROPDWI" {
ext.output_bbox = true
ext.first_suffix = "dwi"
}
withName: "CROPMASK" {
ext.first_suffix = "mask"
}
withName: "CONVERT" {
ext.first_suffix = "mask"
ext.datatype = "uint8"
}
withName: "BETCROP_FSLBETCROP" {
ext.bet_f = 0.16
ext.b0_thr = 10
Expand Down
52 changes: 0 additions & 52 deletions subworkflows/nf-neuro/preproc_dwi/tests/nextflow_skipsteps.config

This file was deleted.

Loading
Loading