Skip to content

Commit

Permalink
run tests and lint
Browse files Browse the repository at this point in the history
  • Loading branch information
anroy1 committed Aug 9, 2024
1 parent 9808e7b commit e051d91
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 27 deletions.
22 changes: 12 additions & 10 deletions subworkflows/nf-scil/preproc_t1/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ workflow PREPROC_T1 {
ch_mask_nlmeans // channel: [ val(meta), [ mask ] ] , optional
ch_ref_n4 // channel: [ val(meta), [ ref, ref_mask ] ] , optional
ch_ref_resample // channel: [ val(meta), [ ref ] ] , optional
val_synth(false) // value: (default: false), , optional
ch_weights // channel: [ val(meta), [ weights ] ] , optional

val_synth(false) // value: (default: false) , optional

main:

Expand All @@ -39,7 +41,7 @@ workflow PREPROC_T1 {

// ** Brain extraction ** //
if ( val_synth ) {
ch_bet = IMAGE_RESAMPLE.out.image
ch_bet = IMAGE_RESAMPLE.out.image.join(ch_weights)
BETCROP_SYNTHBET ( ch_bet )
ch_versions = ch_versions.mix(BETCROP_SYNTHBET.out.versions.first())

Expand Down Expand Up @@ -71,13 +73,13 @@ workflow PREPROC_T1 {
ch_versions = ch_versions.mix(BETCROP_CROPVOLUME_MASK.out.versions.first())

emit:
image_nlmeans = DENOISING_NLMEANS.out.image // channel: [ val(meta), [ image ] ]
image_N4 = PREPROC_N4.out.image // channel: [ val(meta), [ image ] ]
image_resample = IMAGE_RESAMPLE.out.image // channel: [ val(meta), [ image ] ]
image_bet = image_bet // channel: [ val(meta), [ t1 ] ]
mask_bet = mask_bet // channel: [ val(meta), [ mask ] ]
image_nlmeans = DENOISING_NLMEANS.out.image // channel: [ val(meta), [ image ] ]
image_N4 = PREPROC_N4.out.image // channel: [ val(meta), [ image ] ]
image_resample = IMAGE_RESAMPLE.out.image // channel: [ val(meta), [ image ] ]
image_bet = image_bet // channel: [ val(meta), [ t1 ] ]
mask_bet = mask_bet // channel: [ val(meta), [ mask ] ]
crop_box = BETCROP_CROPVOLUME_T1.out.bounding_box // channel: [ val(meta), [ bounding_box ] ]
mask_final = BETCROP_CROPVOLUME_MASK.out.image // channel: [ val(meta), [ mask ] ]
t1_final = BETCROP_CROPVOLUME_T1.out.image // channel: [ val(meta), [ image ] ]
versions = ch_versions // channel: [ versions.yml ]
mask_final = BETCROP_CROPVOLUME_MASK.out.image // channel: [ val(meta), [ mask ] ]
t1_final = BETCROP_CROPVOLUME_T1.out.image // channel: [ val(meta), [ image ] ]
versions = ch_versions // channel: [ versions.yml ]
}
14 changes: 13 additions & 1 deletion subworkflows/nf-scil/preproc_t1/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ description: |
Resamples the T1 to an isotropic spatial resolution. The default is 1mm, a standard in humans which
usually facilitate registration with corrected DWI images.
This spatial resolution is modifiable in the configuration file.
Brain Extraction (bet, ANTs).
Brain Extraction (bet, ANTs, freesurfer).
Isolates the brain tissue voxels from the remaining image. Also creates a binary brain mask.
This brain extraction is required for the T1 to DWI Registration.
Cropping (scil).
Expand All @@ -42,6 +42,7 @@ components:
- preproc/n4
- image/resample
- betcrop/antsbet
- betcrop/synthbet
- betcrop/cropvolume

input:
Expand Down Expand Up @@ -81,6 +82,17 @@ input:
The input channel containing the reference for the resampling. Optional
Structure: [ val(meta), path(ref) ]
pattern: "*.{nii,nii.gz}"
- ch_weights:
type: file
description: |
The input channel containing an alternative model weights for synthbet. Optional
Structure: [ val(meta), path (weights)]
pattern: "*.pt"
- val_synth:
type: boolean
description: |
Boolean input specifying which BET method is employed. Optional: defaults at false (ANTs)
pattern: "true"
output:
- image_nlmeans:
type: file
Expand Down
21 changes: 18 additions & 3 deletions subworkflows/nf-scil/preproc_t1/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,12 @@ nextflow_workflow {
[ id:'test', single_end:false ],
[]
]}
input[6] = false
input[6] = ch_split_test_data.antsbet.map{
test_data_directory -> [
[ id:'test', single_end:false ],
[]
]}
input[7] = false
"""
}
}
Expand Down Expand Up @@ -125,7 +130,12 @@ nextflow_workflow {
[ id:'test', single_end:false ],
file("\${test_data_directory}/t1_unaligned.nii.gz")
]}
input[6] = false
input[6] = ch_split_test_data.antsbet.map{
test_data_directory -> [
[ id:'test', single_end:false ],
[]
]}
input[7] = false
"""
}
}
Expand Down Expand Up @@ -180,7 +190,12 @@ test("preproc_t1_synth") {
[ id:'test', single_end:false ],
[]
]}
input[6] = true
input[6] = ch_split_test_data.antsbet.map{
test_data_directory -> [
[ id:'test', single_end:false ],
[]
]}
input[7] = true
"""
}
}
Expand Down
92 changes: 79 additions & 13 deletions subworkflows/nf-scil/preproc_t1/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@
"nf-test": "0.9.0-rc1",
"nextflow": "24.04.3"
},
"timestamp": "2024-07-26T18:11:30.464682"
"timestamp": "2024-07-30T20:24:23.951944"
},
"preproc_t1_synth": {
"content": [
Expand Down Expand Up @@ -201,27 +201,66 @@
]
],
"3": [

[
{
"id": "test",
"single_end": false
},
"test__bet_image.nii.gz:md5,80bf67681166f331e8495f359461b9d4"
]
],
"4": [

[
{
"id": "test",
"single_end": false
},
"test__brain_mask.nii.gz:md5,df69d549d6919584a0f7b36113994296"
]
],
"5": [

[
{
"id": "test",
"single_end": false
},
"test_t1_cropped_bbox.pkl:md5,fb2114f56d82f5f4465f6b204a8298eb"
]
],
"6": [

[
{
"id": "test",
"single_end": false
},
"test_cropped.nii.gz:md5,8fdb13e81f76139351c7b1056aebf1ed"
]
],
"7": [

[
{
"id": "test",
"single_end": false
},
"test_t1_cropped.nii.gz:md5,6cd92a7c908816a47ae4146bfc6571c7"
]
],
"8": [
"versions.yml:md5,2c0a6f978891003ebdf35c1ba060aa90",
"versions.yml:md5,6aecd5fc2de479eaa81fb30b248c647c",
"versions.yml:md5,97b6b9457caf964b9f20549672f692f0",
"versions.yml:md5,9d515db259af59f33ccd14061fbc45d1",
"versions.yml:md5,b979132991d8f72a3585465533bd5730",
"versions.yml:md5,c6563545d67d7ab20ad849adcaafcb71"
],
"crop_box": [

[
{
"id": "test",
"single_end": false
},
"test_t1_cropped_bbox.pkl:md5,fb2114f56d82f5f4465f6b204a8298eb"
]
],
"image_N4": [
[
Expand All @@ -233,7 +272,13 @@
]
],
"image_bet": [

[
{
"id": "test",
"single_end": false
},
"test__bet_image.nii.gz:md5,80bf67681166f331e8495f359461b9d4"
]
],
"image_nlmeans": [
[
Expand All @@ -254,16 +299,37 @@
]
],
"mask_bet": [

[
{
"id": "test",
"single_end": false
},
"test__brain_mask.nii.gz:md5,df69d549d6919584a0f7b36113994296"
]
],
"mask_final": [

[
{
"id": "test",
"single_end": false
},
"test_cropped.nii.gz:md5,8fdb13e81f76139351c7b1056aebf1ed"
]
],
"t1_final": [

[
{
"id": "test",
"single_end": false
},
"test_t1_cropped.nii.gz:md5,6cd92a7c908816a47ae4146bfc6571c7"
]
],
"versions": [
"versions.yml:md5,2c0a6f978891003ebdf35c1ba060aa90",
"versions.yml:md5,6aecd5fc2de479eaa81fb30b248c647c",
"versions.yml:md5,97b6b9457caf964b9f20549672f692f0",
"versions.yml:md5,9d515db259af59f33ccd14061fbc45d1",
"versions.yml:md5,b979132991d8f72a3585465533bd5730",
"versions.yml:md5,c6563545d67d7ab20ad849adcaafcb71"
]
Expand All @@ -273,7 +339,7 @@
"nf-test": "0.9.0-rc1",
"nextflow": "24.04.3"
},
"timestamp": "2024-07-26T17:13:02.031243"
"timestamp": "2024-07-30T19:21:50.686836"
},
"preproc_t1_classic": {
"content": [
Expand Down Expand Up @@ -444,6 +510,6 @@
"nf-test": "0.9.0-rc1",
"nextflow": "24.04.3"
},
"timestamp": "2024-07-26T17:51:34.909311"
"timestamp": "2024-07-30T20:05:33.018053"
}
}
3 changes: 3 additions & 0 deletions subworkflows/nf-scil/preproc_t1/tests/nextflow_synth.config
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ process {
ext.output_bbox = true
ext.first_suffix = "t1"
}
withName: "BETCROP_SYNTHBET" {
memory = 8.GB
}
}

0 comments on commit e051d91

Please sign in to comment.