forked from scilus/nf-scil
-
Notifications
You must be signed in to change notification settings - Fork 0
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 scilus#69 from ThoumyreStanislas/ants_bet_crop
[Module][WIP] Antsbet
- Loading branch information
Showing
9 changed files
with
183 additions
and
0 deletions.
There are no files selected for viewing
Git LFS file not shown
Git LFS file not shown
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,62 @@ | ||
|
||
process BETCROP_ANTSBET { | ||
tag "$meta.id" | ||
label 'process_single' | ||
|
||
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? | ||
'https://scil.usherbrooke.ca/containers/scilus_1.6.0.sif': | ||
'scilus/scilus:1.6.0' }" | ||
|
||
input: | ||
tuple val(meta), path(t1), path(template), path(tissues_probabilities) | ||
|
||
output: | ||
tuple val(meta), path("*t1_bet.nii.gz") , emit: t1 | ||
tuple val(meta), path("*t1_bet_mask.nii.gz"), emit: mask | ||
path "versions.yml" , emit: versions | ||
|
||
when: | ||
task.ext.when == null || task.ext.when | ||
|
||
script: | ||
def args = task.ext.args ?: '' | ||
def prefix = task.ext.prefix ?: "${meta.id}" | ||
|
||
""" | ||
export ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS=1 | ||
export OMP_NUM_THREADS=1 | ||
export OPENBLAS_NUM_THREADS=1 | ||
export ANTS_RANDOM_SEED=1234 | ||
antsBrainExtraction.sh -d 3 -a $t1 -e $template -o bet/ -m $tissues_probabilities -u 0 | ||
scil_image_math.py convert bet/BrainExtractionMask.nii.gz ${prefix}__t1_bet_mask.nii.gz --data_type uint8 | ||
mrcalc $t1 ${prefix}__t1_bet_mask.nii.gz -mult ${prefix}__t1_bet.nii.gz -nthreads 1 | ||
cat <<-END_VERSIONS > versions.yml | ||
"${task.process}": | ||
scilpy: 1.6.0 | ||
mrtrix: \$(mrcalc -version 2>&1 | sed -n 's/== mrcalc \\([0-9.]\\+\\).*/\\1/p') | ||
ants: 2.4.3 | ||
END_VERSIONS | ||
""" | ||
|
||
stub: | ||
def args = task.ext.args ?: '' | ||
def prefix = task.ext.prefix ?: "${meta.id}" | ||
|
||
""" | ||
antsBrainExtraction.sh -h | ||
scil_image_math.py -h | ||
mrcalc -h | ||
touch ${prefix}__t1_bet.nii.gz | ||
touch ${prefix}__t1_bet_mask.nii.gz | ||
cat <<-END_VERSIONS > versions.yml | ||
"${task.process}": | ||
scilpy: 1.6.0 | ||
mrtrix: \$(mrcalc -version 2>&1 | sed -n 's/== mrcalc \\([0-9.]\\+\\).*/\\1/p') | ||
ants: 2.4.3 | ||
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,65 @@ | ||
--- | ||
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/yaml-schema.json | ||
name: "betcrop_antsbet" | ||
description: Perform Brain extraction using antsBrainExtraction.sh on T1 image. | ||
keywords: | ||
- T1 | ||
- BET | ||
- ants | ||
tools: | ||
- "Scilpy": | ||
description: "The Sherbrooke Connectivity Imaging Lab (SCIL) Python dMRI processing toolbox." | ||
homepage: "https://github.com/scilus/scilpy.git" | ||
- "MRtrix3": | ||
description: "Toolbox for image processing, analysis and visualisation of dMRI." | ||
homepage: "https://mrtrix.readthedocs.io/en/latest/" | ||
- "ants": | ||
description: "Advanced Normalization Tools." | ||
homepage: "https://github.com/ANTsX/ANTs" | ||
|
||
input: | ||
- meta: | ||
type: map | ||
description: | | ||
Groovy Map containing sample information | ||
e.g. `[ id:'test', single_end:false ]` | ||
- t1: | ||
type: file | ||
description: Nifti t1 volume to perform BET. | ||
pattern: "*.{nii,nii.gz}" | ||
|
||
- template: | ||
type: file | ||
description: Nifti Anatomical template to perform BET. | ||
pattern: "*.{nii,nii.gz}" | ||
|
||
- tissues_probabilities: | ||
type: file | ||
description: Brain probability mask, with intensity range 1 (definitely brain) to 0 (definitely background). | ||
pattern: "*.{nii,nii.gz}" | ||
|
||
output: | ||
- meta: | ||
type: map | ||
description: | | ||
Groovy Map containing sample information | ||
e.g. `[ id:'test', single_end:false ]` | ||
- t1: | ||
type: file | ||
description: Nifti T1 volume brain-extracted. | ||
pattern: "*t1_bet.{nii,nii.gz}" | ||
|
||
- mask: | ||
type: file | ||
description: T1 mask brain-extracted and cropped. | ||
pattern: "*t1_bet_mask.{nii,nii.gz}" | ||
|
||
- versions: | ||
type: file | ||
description: File containing software versions | ||
pattern: "versions.yml" | ||
|
||
authors: | ||
- "@ThoumyreStanislas" |
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
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
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,24 @@ | ||
#!/usr/bin/env nextflow | ||
|
||
nextflow.enable.dsl = 2 | ||
|
||
include { BETCROP_ANTSBET } from '../../../../../modules/nf-scil/betcrop/antsbet/main.nf' | ||
include { LOAD_TEST_DATA } from '../../../../../subworkflows/nf-scil/load_test_data/main' | ||
|
||
workflow test_betcrop_antsbet { | ||
|
||
input_fetch = Channel.from( [ "antsbet.zip" ] ) | ||
|
||
LOAD_TEST_DATA ( input_fetch, "test.test_betcrop_antsbet" ) | ||
|
||
input = LOAD_TEST_DATA.out.test_data_directory | ||
.map{ test_data_directory -> [ | ||
[ id:'test', single_end:false ], // meta map | ||
file("${test_data_directory}/t1_unaligned.nii.gz"), | ||
file("${test_data_directory}/t1_template.nii.gz"), | ||
file("${test_data_directory}/t1_brain_probability_map.nii.gz") | ||
|
||
]} | ||
|
||
BETCROP_ANTSBET ( input ) | ||
} |
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,6 @@ | ||
process { | ||
|
||
withName: "BETCROP_ANTSBET" { | ||
publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } | ||
} | ||
} |
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,11 @@ | ||
- name: betcrop antsbet test_betcrop_antsbet | ||
command: nextflow run ./tests/modules/nf-scil/betcrop/antsbet -entry test_betcrop_antsbet -c ./tests/config/nextflow.config | ||
tags: | ||
- betcrop/antsbet | ||
- betcrop | ||
files: | ||
- path: output/betcrop/test__t1_bet.nii.gz | ||
md5sum: e88c7e63cf220562a97f16c92be0d87b | ||
- path: output/betcrop/test__t1_bet_mask.nii.gz | ||
md5sum: 846bd8fc8a212dcffcd728a0846a711c | ||
- path: output/betcrop/versions.yml |