Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
anroy1 committed Sep 7, 2024
1 parent e69bd07 commit 48d0cfc
Show file tree
Hide file tree
Showing 4 changed files with 141 additions and 226 deletions.
6 changes: 3 additions & 3 deletions modules/nf-scil/segmentation/synthseg/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ process SEGMENTATION_SYNTHSEG {
# WM Mask
mri_binarize --i t1.nii.gz \
--match 2 7 12 16 28 41 46 49 51 60 \
--match 2 7 10 12 13 16 28 41 46 49 51 52 60 \
--o ${prefix}__mask_wm.nii.gz
# GM Mask
mri_binarize --i t1.nii.gz \
--match 3 8 11 17 18 26 42 47 50 \
--match 3 8 11 17 18 26 42 47 50 52 53 54 58 \
--o ${prefix}__mask_gm.nii.gz
# CSF Mask
Expand All @@ -64,7 +64,7 @@ process SEGMENTATION_SYNTHSEG {
if [[ -f "$lesion" ]];
then
mri_binarize --i ${prefix}__mask_wm.nii.gz --union $lesion --o ${prefix}__mask_wm.nii.gz
mri_binarize --i ${prefix}__mask_wm.nii.gz --merge $lesion --min 0.5 --o ${prefix}__mask_wm.nii.gz
fi
mri_convert -i ${prefix}__mask_wm.nii.gz --out_data_type uchar -o ${prefix}__mask_wm.nii.gz
Expand Down
128 changes: 90 additions & 38 deletions modules/nf-scil/segmentation/synthseg/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ nextflow_process {
script "../../../../../subworkflows/nf-scil/load_test_data/main.nf"
process {
"""
input[0] = Channel.from( [ "freesurfer.zip" ] )
input[0] = Channel.from( [ "heavy.zip", "freesurfer.zip" ] )
input[1] = "test.load-test-data"
"""
}
Expand All @@ -29,22 +29,39 @@ nextflow_process {
when {
process {
"""
input[0] = LOAD_DATA.out.test_data_directory.map{
ch_split_test_data = LOAD_DATA.out.test_data_directory
.branch{
heavy: it.simpleName == "heavy"
freesurfer: it.simpleName == "freesurfer"
}
ch_anat = ch_split_test_data.heavy.map{
test_data_directory -> [
[ id:'test', single_end:false ], // meta map
file("\${test_data_directory}/t1.nii.gz", checkIfExists: true,),
[],
file("\${test_data_directory}/license.txt", checkIfExists: true,)
[ id:'test' ],
file("\${test_data_directory}/anat/anat_image.nii.gz"),
[]
]
}
ch_license = ch_split_test_data.freesurfer.map{
test_data_directory -> [
[ id:'test' ],
file("\${test_data_directory}/license.txt")
]
}
input[0] = ch_anat
.join(ch_license)
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
{ assert snapshot(
niftiMD5SUM(process.out.wm_mask.get(0).get(1)),
niftiMD5SUM(process.out.gm_mask.get(0).get(1)),
niftiMD5SUM(process.out.csf_mask.get(0).get(1)),
process.out.versions
).match() }
)
}
}
Expand All @@ -54,50 +71,85 @@ nextflow_process {
when {
process {
"""
input[0] = LOAD_DATA.out.test_data_directory.map{
ch_split_test_data = LOAD_DATA.out.test_data_directory
.branch{
heavy: it.simpleName == "heavy"
freesurfer: it.simpleName == "freesurfer"
}
ch_anat = ch_split_test_data.heavy.map{
test_data_directory -> [
[ id:'test', single_end:false ], // meta map
file("\${test_data_directory}/t1.nii.gz", checkIfExists: true,),
[],
file("\${test_data_directory}/license.txt", checkIfExists: true,)
[ id:'test' ],
file("\${test_data_directory}/anat/anat_image.nii.gz"),
[]
]
}
ch_license = ch_split_test_data.freesurfer.map{
test_data_directory -> [
[ id:'test' ],
file("\${test_data_directory}/license.txt")
]
}
input[0] = ch_anat
.join(ch_license)
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
{ assert snapshot(
niftiMD5SUM(process.out.wm_mask.get(0).get(1)),
niftiMD5SUM(process.out.gm_mask.get(0).get(1)),
niftiMD5SUM(process.out.csf_mask.get(0).get(1)),
process.out.resample,
process.out.vol,
process.out.qc,
process.out.versions
).match() }
)
}
}

// test("segmentation - synthseg - lesion") {
// config "./nextflow_lesion.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}/t1.nii.gz", checkIfExists: true,),
// file("\${test_data_directory}/lesion.nii.gz", checkIfExists: true,),
// file("\${test_data_directory}/license.txt", checkIfExists: true,)

// ]
// }
// """
// }
// }

// then {
// assertAll(
// { assert process.success },
// { assert snapshot(process.out).match() }
// )
// }
// }
test("segmentation - synthseg - lesion") {
config "./nextflow_basic.config"
when {
process {
"""
ch_split_test_data = LOAD_DATA.out.test_data_directory
.branch{
heavy: it.simpleName == "heavy"
freesurfer: it.simpleName == "freesurfer"
}
ch_anat = ch_split_test_data.heavy.map{
test_data_directory -> [
[ id:'test' ],
file("\${test_data_directory}/anat/anat_image.nii.gz"),
file("\${test_data_directory}/anat/anat_mask.nii.gz")
]
}
ch_license = ch_split_test_data.freesurfer.map{
test_data_directory -> [
[ id:'test' ],
file("\${test_data_directory}/license.txt")
]
}
input[0] = ch_anat
.join(ch_license)
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(
niftiMD5SUM(process.out.wm_mask.get(0).get(1)),
niftiMD5SUM(process.out.gm_mask.get(0).get(1)),
niftiMD5SUM(process.out.csf_mask.get(0).get(1)),
process.out.versions
).match() }
)
}
}
}
Loading

0 comments on commit 48d0cfc

Please sign in to comment.