-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #122 from anroy1/synthbet
[Module] Freesurfer BET
- Loading branch information
Showing
7 changed files
with
230 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
name: betcrop_synthbet | ||
|
||
channels: | ||
- Docker | ||
- Apptainer | ||
|
||
dependencies: | ||
- "Freesurfer:synthstrip" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
process BETCROP_SYNTHBET { | ||
tag "$meta.id" | ||
label 'process_single' | ||
|
||
container "freesurfer/synthstrip:latest" | ||
containerOptions "--entrypoint ''" | ||
|
||
input: | ||
tuple val(meta), path(image), path(weights) /* optional, input = [] */ | ||
|
||
output: | ||
tuple val(meta), path("*__bet_image.nii.gz"), emit: bet_image | ||
tuple val(meta), path("*__brain_mask.nii.gz"), emit: brain_mask | ||
path "versions.yml" , emit: versions | ||
|
||
when: | ||
task.ext.when == null || task.ext.when | ||
|
||
script: | ||
def prefix = task.ext.prefix ?: "${meta.id}" | ||
|
||
def gpu = task.ext.gpu ? "--gpu" : "" | ||
def border = task.ext.border ? "-b " + task.ext.border : "" | ||
def nocsf = task.ext.nocsf ? "--no-csf" : "" | ||
def model = "$weights" ? "--model $weights" : "" | ||
|
||
""" | ||
export ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS=$task.cpus | ||
export OMP_NUM_THREADS=1 | ||
export OPENBLAS_NUM_THREADS=1 | ||
mri_synthstrip -i $image --out ${prefix}__bet_image.nii.gz --mask ${prefix}__brain_mask.nii.gz $gpu $border $nocsf $model | ||
cat <<-END_VERSIONS > versions.yml | ||
"${task.process}": | ||
freesurfer: 7.4 | ||
END_VERSIONS | ||
""" | ||
|
||
stub: | ||
def prefix = task.ext.prefix ?: "${meta.id}" | ||
|
||
""" | ||
mri_synthstrip -h | ||
touch ${prefix}__bet_image.nii.gz | ||
touch ${prefix}__brain_mask.nii.gz | ||
cat <<-END_VERSIONS > versions.yml | ||
"${task.process}": | ||
freesurfer: 7.4 | ||
END_VERSIONS | ||
""" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
--- | ||
name: "betcrop_synthbet" | ||
description: Perform brain extraction using synthstrip on image | ||
keywords: | ||
- anatomical image | ||
- BET | ||
- freesurfer | ||
tools: | ||
- "Freesurfer": | ||
description: "Software package for the analysis and visualization of structural and functional neuroimaging data." | ||
homepage: "https://surfer.nmr.mgh.harvard.edu/fswiki" | ||
|
||
input: | ||
- meta: | ||
type: map | ||
description: | | ||
Groovy Map containing sample information | ||
e.g. `[ id:'test', single_end:false ]` | ||
- image: | ||
type: file | ||
description: Nifti image volume to perform BET. | ||
pattern: "*.{nii,nii.gz}" | ||
|
||
- weights: | ||
type: file | ||
description: Alternative model weights | ||
pattern: "*.pt" | ||
|
||
output: | ||
- meta: | ||
type: map | ||
description: | | ||
Groovy Map containing sample information | ||
e.g. `[ id:'test', single_end:false ]` | ||
- bet_image: | ||
type: file | ||
description: Nifti brain-extracted volume. | ||
pattern: "*__bet_image.{nii,nii.gz}" | ||
|
||
- brain_mask: | ||
type: file | ||
description: Brain-extracted image mask . | ||
pattern: "*__brain_mask.{nii,nii.gz}" | ||
|
||
- versions: | ||
type: file | ||
description: File containing software versions | ||
pattern: "versions.yml" | ||
|
||
authors: | ||
- "@anroy1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
nextflow_process { | ||
|
||
name "Test Process BETCROP_SYNTHBET" | ||
script "../main.nf" | ||
process "BETCROP_SYNTHBET" | ||
config "./nextflow.config" | ||
|
||
tag "modules" | ||
tag "modules_nfcore" | ||
tag "betcrop" | ||
tag "betcrop/synthbet" | ||
|
||
tag "subworkflows" | ||
tag "subworkflows/load_test_data" | ||
|
||
test("betcrop - synthbet") { | ||
|
||
setup { | ||
run("LOAD_TEST_DATA", alias: "LOAD_DATA") { | ||
script "../../../../../subworkflows/nf-scil/load_test_data/main.nf" | ||
process { | ||
""" | ||
input[0] = Channel.from( [ "freesurfer.zip" ] ) | ||
input[1] = "test.load-test-data" | ||
""" | ||
} | ||
} | ||
} | ||
|
||
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}/anat_image.nii.gz"), | ||
[] | ||
] | ||
} | ||
""" | ||
} | ||
} | ||
|
||
then { | ||
assertAll( | ||
{ assert process.success }, | ||
{ assert snapshot(process.out).match() } | ||
) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{ | ||
"betcrop - synthbet": { | ||
"content": [ | ||
{ | ||
"0": [ | ||
[ | ||
{ | ||
"id": "test", | ||
"single_end": false | ||
}, | ||
"test__bet_image.nii.gz:md5,6f5eb365a11dfc52b8c80cd7bcee7b9d" | ||
] | ||
], | ||
"1": [ | ||
[ | ||
{ | ||
"id": "test", | ||
"single_end": false | ||
}, | ||
"test__brain_mask.nii.gz:md5,52871114b59d09dca864cb0ea4f12832" | ||
] | ||
], | ||
"2": [ | ||
"versions.yml:md5,f0a96d8fd7ca9d9935818dceaf91f457" | ||
], | ||
"bet_image": [ | ||
[ | ||
{ | ||
"id": "test", | ||
"single_end": false | ||
}, | ||
"test__bet_image.nii.gz:md5,6f5eb365a11dfc52b8c80cd7bcee7b9d" | ||
] | ||
], | ||
"brain_mask": [ | ||
[ | ||
{ | ||
"id": "test", | ||
"single_end": false | ||
}, | ||
"test__brain_mask.nii.gz:md5,52871114b59d09dca864cb0ea4f12832" | ||
] | ||
], | ||
"versions": [ | ||
"versions.yml:md5,f0a96d8fd7ca9d9935818dceaf91f457" | ||
] | ||
} | ||
], | ||
"meta": { | ||
"nf-test": "0.8.4", | ||
"nextflow": "23.10.1" | ||
}, | ||
"timestamp": "2024-06-11T14:52:54.970673" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
process { | ||
withName: "BETCROP_SYNTHBET" { | ||
publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } | ||
memory = 8.GB | ||
ext.nocsf = true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
betcrop/synthbet: | ||
- "modules/nf-scil/betcrop/synthbet/**" |