-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
[Module] Freesurfer reconall
- Loading branch information
There are no files selected for viewing
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
name: "segmentation_fsreconall" | ||
channels: | ||
- Docker | ||
- Apptainer | ||
dependencies: | ||
- "FreeSurfer" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
process SEGMENTATION_FSRECONALL { | ||
tag "$meta.id" | ||
label 'process_single' | ||
|
||
// Note. Freesurfer is already on Docker. See documentation on | ||
// https://hub.docker.com/r/freesurfer/freesurfer | ||
container "freesurfer/freesurfer:7.4.1" | ||
|
||
input: | ||
tuple val(meta), path(anat), path(fs_license) /* optional, value = [] */ | ||
|
||
output: | ||
tuple val(meta), path("*__recon_all") , emit: recon_all_out_folder | ||
path "versions.yml" , emit: versions | ||
|
||
when: | ||
task.ext.when == null || task.ext.when | ||
|
||
// Note. In dsl1, we used an additional option: -parallel -openmp $params.nb_threads. | ||
// Removed here. | ||
script: | ||
def prefix = task.ext.prefix ?: "${meta.id}" | ||
def dev_debug_test = task.ext.debug ? task.ext.debug : "" // If true, we will only run the help (for unit tests ) | ||
""" | ||
# Manage the license. (Save old one if existed.) | ||
if [[ ! -f "$fs_license" ]] | ||
then | ||
echo "License not given in input, or not found. Will probably fail. " | ||
else | ||
cp "$fs_license" .license | ||
here=`pwd` | ||
export FS_LICENSE=\$here/.license | ||
fi | ||
if [ -z $dev_debug_test ] | ||
then | ||
# Run the main script | ||
export SUBJECTS_DIR=`pwd` | ||
recon-all -i $anat -s ${prefix}__recon_all -all | ||
else | ||
# (for developers: unit tests: skip the long processing. help only.) | ||
export SUBJECTS_DIR=`pwd` | ||
recon-all -i $anat -s ${prefix}__recon_all -autorecon1 -dontrun | ||
fi | ||
# Remove the license | ||
if [ ! $fs_license = [] ]; then | ||
rm .license | ||
fi | ||
# Finish | ||
cat <<-END_VERSIONS > versions.yml | ||
"${task.process}": | ||
freesurfer: \$(recon-all -version) | ||
END_VERSIONS | ||
""" | ||
|
||
stub: | ||
def prefix = task.ext.prefix ?: "${meta.id}" | ||
""" | ||
recon-all --help | ||
mkdir ${prefix}__recon_all | ||
cat <<-END_VERSIONS > versions.yml | ||
"${task.process}": | ||
freesurfer: \$(recon-all -version) | ||
END_VERSIONS | ||
""" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
--- | ||
name: "segmentation_fsreconall" | ||
description: "Performs Freesurfer's recon-all script to segment your anatomy (probably a T1) into labels, surfaces, and much more. See the full documentation here: https://surfer.nmr.mgh.harvard.edu/fswiki/recon-all." | ||
keywords: | ||
- FreeSurfer | ||
- Segmentation | ||
- Tissues | ||
tools: | ||
- "Freesurfer": | ||
description: "An open source neuroimaging toolkit for processing, analyzing, and visualizing human brain MR images." | ||
homepage: "https://surfer.nmr.mgh.harvard.edu/" | ||
|
||
input: | ||
- meta: | ||
type: map | ||
description: | | ||
Groovy Map containing sample information | ||
e.g. `[ id:'test', single_end:false ]` | ||
- anat: | ||
type: file | ||
description: An anatomy (ex, .nii.gz). | ||
pattern: "*.{nii,nii.gz,mgz}" | ||
|
||
- fs_license: | ||
type: file | ||
description: The path to your FreeSurfer license. To get one, go to https://surfer.nmr.mgh.harvard.edu/registration.html. Optional. If you have already set your license as prescribed by Freesurfer (copied to a .license file in your $FREESURFER_HOME), this is not required. | ||
pattern: "*.txt" | ||
|
||
output: | ||
- meta: | ||
type: map | ||
description: | | ||
Groovy Map containing sample information | ||
e.g. `[ id:'test', single_end:false ]` | ||
- recon_all_out_folder: | ||
type: directory | ||
description: Directory containing all recon-all outputs. | ||
pattern: "*.{nii,nii.gz}" | ||
|
||
- versions: | ||
type: file | ||
description: File containing software versions | ||
pattern: "versions.yml" | ||
|
||
authors: | ||
- "@EmmaRenauld" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
nextflow_process { | ||
|
||
name "Test Process SEGMENTATION_FSRECONALL" | ||
script "../main.nf" | ||
process "SEGMENTATION_FSRECONALL" | ||
|
||
tag "modules" | ||
tag "modules_nfcore" | ||
tag "segmentation" | ||
tag "segmentation/fsreconall" | ||
|
||
tag "subworkflows" | ||
tag "subworkflows/load_test_data" | ||
|
||
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" | ||
""" | ||
} | ||
} | ||
} | ||
|
||
test("segmentation - fsreconall") { | ||
|
||
when { | ||
config "./nextflow_debug.config" | ||
|
||
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"), | ||
file("\${test_data_directory}/license.txt") | ||
]} | ||
""" | ||
} | ||
} | ||
|
||
then { | ||
assertAll( | ||
{ assert process.success }, | ||
{ assert snapshot( | ||
file(process.out.recon_all_out_folder.get(0).get(1)).name, | ||
process.out.versions | ||
).match() } | ||
) | ||
} | ||
|
||
} | ||
|
||
|
||
test("segmentation - fsreconall - nolicense") { | ||
|
||
when { | ||
// Not in mode debug + no license = should fail. | ||
config "./nextflow.config" | ||
|
||
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 } | ||
) | ||
} | ||
|
||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"segmentation - fsreconall": { | ||
"content": [ | ||
"test__recon_all", | ||
[ | ||
"versions.yml:md5,12027dd965b94e4d68b7e8a630a04d00" | ||
] | ||
], | ||
"meta": { | ||
"nf-test": "0.8.4", | ||
"nextflow": "23.10.1" | ||
}, | ||
"timestamp": "2024-05-21T18:19:43.835172" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
process { | ||
withName: "SEGMENTATION_FSRECONALL" { | ||
ext.debug = false | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
process { | ||
withName: "SEGMENTATION_FSRECONALL" { | ||
ext.debug = true | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
segmentation/fsreconall: | ||
- "modules/nf-scil/segmentation/fsreconall/**" |