Skip to content

Commit

Permalink
Add parcellation optional output and adjust tests
Browse files Browse the repository at this point in the history
  • Loading branch information
anroy1 committed Sep 22, 2024
1 parent 4c75a34 commit 3916335
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 20 deletions.
18 changes: 14 additions & 4 deletions modules/nf-scil/segmentation/synthseg/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ process SEGMENTATION_SYNTHSEG {
tuple val(meta), path("*__mask_wm.nii.gz") , emit: wm_mask
tuple val(meta), path("*__mask_gm.nii.gz") , emit: gm_mask
tuple val(meta), path("*__mask_csf.nii.gz") , emit: csf_mask
tuple val(meta), path("*__parc.nii.gz") , emit: parc, optional: true
tuple val(meta), path("*__resampled_image.nii.gz") , emit: resample, optional: true
tuple val(meta), path("*__vol.csv") , emit: vol, optional: true
tuple val(meta), path("*__qc.csv") , emit: qc, optional: true
Expand Down Expand Up @@ -41,20 +42,27 @@ process SEGMENTATION_SYNTHSEG {
cp $fs_license \$FREESURFER_HOME/license.txt
mri_synthseg --i $image --threads $task.cpus --o t1.nii.gz $gpu $parc $robust $fast $ct $output_resample $output_vol $output_qc $crop
mri_synthseg --i $image --o seg.nii.gz --threads $task.cpus $gpu $robust $fast $ct $output_resample $output_vol $output_qc $crop
if [[ $task.parc ]];
then
# Cortical parcellation
mri_synthseg --i $image --o ${prefix}__parc.nii.gz --threads $task.cpus $gpu $parc $robust $fast $crop
mri_convert -i ${prefix}__parc.nii.gz --out_data_type uchar -o ${prefix}__parc.nii.gz
fi
# WM Mask
mri_binarize --i t1.nii.gz \
mri_binarize --i seg.nii.gz \
--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 \
mri_binarize --i seg.nii.gz \
--match 3 8 11 17 18 26 42 47 50 52 53 54 58 \
--o ${prefix}__mask_gm.nii.gz
# CSF Mask
mri_binarize --i t1.nii.gz \
mri_binarize --i seg.nii.gz \
--match 4 5 14 15 24 43 44 \
--o ${prefix}__mask_csf.nii.gz
Expand All @@ -66,6 +74,7 @@ process SEGMENTATION_SYNTHSEG {
mri_convert -i ${prefix}__mask_wm.nii.gz --out_data_type uchar -o ${prefix}__mask_wm.nii.gz
mri_convert -i ${prefix}__mask_gm.nii.gz --out_data_type uchar -o ${prefix}__mask_gm.nii.gz
mri_convert -i ${prefix}__mask_csf.nii.gz --out_data_type uchar -o ${prefix}__mask_csf.nii.gz
mri_convert -i ${prefix}__parc.nii.gz --out_data_type uchar ${prefix}__parc.nii.gz
rm \$FREESURFER_HOME/license.txt
Expand All @@ -87,6 +96,7 @@ process SEGMENTATION_SYNTHSEG {
touch ${prefix}__mask_wm.nii.gz
touch ${prefix}__mask_gm.nii.gz
touch ${prefix}__mask_csf.nii.gz
touch ${prefix}__parc.nii.gz
touch ${prefix}__resampled_image.nii.gz
touch ${prefix}__vol.csv
touch ${prefix}__qc.csv
Expand Down
5 changes: 5 additions & 0 deletions modules/nf-scil/segmentation/synthseg/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ output:
description: Nifti CSF mask volume.
pattern: "*.{nii,nii.gz}"

- parc:
type: file
description: Nifti cortical parcellation volume.
pattern: "*.{nii,nii.gz}"

- vol:
type: file
description: (optional) Output CSV file with volumes for all structures and subjects.
Expand Down
1 change: 1 addition & 0 deletions modules/nf-scil/segmentation/synthseg/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ nextflow_process {
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)),
niftiMD5SUM(process.out.parc.get(0).get(1)),
process.out.resample,
process.out.vol,
process.out.qc,
Expand Down
27 changes: 14 additions & 13 deletions modules/nf-scil/segmentation/synthseg/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"segmentation - synthseg - options": {
"content": [
"test__mask_wm.nii.gz:md5:header,a0430ca63ccc3bb2b925694cb7568388,data,a7ad690eb017c4146332b0bdeb135aa8",
"test__mask_gm.nii.gz:md5:header,a0430ca63ccc3bb2b925694cb7568388,data,370281fcda8be302cd72060e761121d2",
"test__mask_csf.nii.gz:md5:header,a0430ca63ccc3bb2b925694cb7568388,data,3d227c46c2d58cf80284a6f48d13d792",
"test__mask_wm.nii.gz:md5:header,a0430ca63ccc3bb2b925694cb7568388,data,95946cf22f6adf539b65c72b49eb3b32",
"test__mask_gm.nii.gz:md5:header,a0430ca63ccc3bb2b925694cb7568388,data,a54f8c03a17a16d9271534c387434720",
"test__mask_csf.nii.gz:md5:header,a0430ca63ccc3bb2b925694cb7568388,data,3895c471bc8b06446a8adbba9fe235f7",
"test__parc.nii.gz:md5:header,a0430ca63ccc3bb2b925694cb7568388,data,cb9a481316ae64dceb229879bd0c6619",
[

],
Expand All @@ -12,15 +13,15 @@
{
"id": "test"
},
"test__vol.csv:md5,d0a69e3e2fbd7184dfcdf8bc2c35d673"
"test__vol.csv:md5,c5c29a038e4f43abcce1845bc429952c"
]
],
[
[
{
"id": "test"
},
"test__qc.csv:md5,4627c87c018fe1e5f2b0803e78aff306"
"test__qc.csv:md5,333de3d7b60916596f0460c808b598f5"
]
],
[
Expand All @@ -31,13 +32,13 @@
"nf-test": "0.9.0-rc1",
"nextflow": "24.04.4"
},
"timestamp": "2024-09-17T17:33:59.710663"
"timestamp": "2024-09-20T14:42:35.40267"
},
"segmentation - synthseg - basic": {
"content": [
"test__mask_wm.nii.gz:md5:header,a0430ca63ccc3bb2b925694cb7568388,data,10191bbea81929574adf7cf9b9122a07",
"test__mask_gm.nii.gz:md5:header,a0430ca63ccc3bb2b925694cb7568388,data,eb6e177ec5ede4102fec41163d0c612a",
"test__mask_csf.nii.gz:md5:header,a0430ca63ccc3bb2b925694cb7568388,data,27060f0edda8db50469061177e085d76",
"test__mask_wm.nii.gz:md5:header,a0430ca63ccc3bb2b925694cb7568388,data,1b5a4d63ae2b56d9d6936313b5225b55",
"test__mask_gm.nii.gz:md5:header,a0430ca63ccc3bb2b925694cb7568388,data,c093a4b4c8c5804342b7ea8eea6164fb",
"test__mask_csf.nii.gz:md5:header,a0430ca63ccc3bb2b925694cb7568388,data,c9abaab9c5e047fadf928a6520929d5e",
[
"versions.yml:md5,b65418e9ce2ab1cce590b1f659e18c1d"
]
Expand All @@ -46,13 +47,13 @@
"nf-test": "0.9.0-rc1",
"nextflow": "24.04.4"
},
"timestamp": "2024-09-17T17:33:11.109853"
"timestamp": "2024-09-20T14:40:33.985446"
},
"segmentation - synthseg - lesion": {
"content": [
"test__mask_wm.nii.gz:md5:header,a0430ca63ccc3bb2b925694cb7568388,data,6d99d71cff4a2f9d147c45b1ee36dce0",
"test__mask_gm.nii.gz:md5:header,a0430ca63ccc3bb2b925694cb7568388,data,eb6e177ec5ede4102fec41163d0c612a",
"test__mask_csf.nii.gz:md5:header,a0430ca63ccc3bb2b925694cb7568388,data,27060f0edda8db50469061177e085d76",
"test__mask_gm.nii.gz:md5:header,a0430ca63ccc3bb2b925694cb7568388,data,c093a4b4c8c5804342b7ea8eea6164fb",
"test__mask_csf.nii.gz:md5:header,a0430ca63ccc3bb2b925694cb7568388,data,c9abaab9c5e047fadf928a6520929d5e",
[
"versions.yml:md5,b65418e9ce2ab1cce590b1f659e18c1d"
]
Expand All @@ -61,6 +62,6 @@
"nf-test": "0.9.0-rc1",
"nextflow": "24.04.4"
},
"timestamp": "2024-09-17T17:36:18.384824"
"timestamp": "2024-09-20T14:44:24.290916"
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
process {
memory = '14G'
memory = "8G"
publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" }
ext.fast = true
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
process {
memory = "8G"
publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" }
ext.robust = true
ext.fast = true
ext.output_resample = true
ext.output_vol = true
ext.output_qc = true
ext.crop = 64
ext.crop = 150
ext.parc = true
}

0 comments on commit 3916335

Please sign in to comment.