Skip to content

Commit

Permalink
fix test data, freesurfer license
Browse files Browse the repository at this point in the history
  • Loading branch information
anroy1 committed Apr 9, 2024
1 parent 7e6991f commit 00fc10f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 33 deletions.
29 changes: 7 additions & 22 deletions modules/nf-scil/registration/synthregistration/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ process REGISTRATION_SYNTHREGISTRATION {
tag "$meta.id"
label 'process_single'

container "freesurfer/synthmorph:latest"
container "freesurfer/freesurfer:7.4.1"
containerOptions "--entrypoint ''"

input:
tuple val(meta), path(moving), path(fixed), path(fs_license) /* optional, value = [] */


output:
tuple val(meta), path("*__*_output_warped.nii.gz"), emit: warped_image
tuple val(meta), path("*__output_warped.nii.gz"), emit: warped_image
tuple val(meta), path("*__deform_warp.nii.gz"), emit: deform_transform
tuple val (meta), path("*__init_warp.txt"), emit: init_transform
path "versions.yml" , emit: versions
Expand All @@ -20,13 +21,12 @@ process REGISTRATION_SYNTHREGISTRATION {
script:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
def suffix = task.ext.suffix ?: "${meta.id}"

def init = task.ext.init ? "-m " + task.est.init : "-m affine"
def warp = task.ext.warp ? "-m " + task.est.warp : "-m deform"
def header = task.ext.header ? "-H " + task.ext.header : ""
def header = task.ext.header ? "-H" : ""
def threads = task.ext.threads ? "-j " + task.ext.threads : ""
def gpu = task.ext.gpu ? "-g " + task.ext.gpu : ""
def gpu = task.ext.gpu ? "-g" : ""
def smooth = task.ext.smooth ? "-s " + task.ext.smooth : ""
def extent = task.ext.extent ? "-e " + task.ext.extent : ""
def weight = task.ext.weight ? "-w " + task.ext.weight : ""
Expand All @@ -35,29 +35,15 @@ process REGISTRATION_SYNTHREGISTRATION {
def out_format = task.ext.out_format ? "--out" + task.ext.out_format : "--outlps"

"""
# Manage the license. (Save old one if existed.)
if [ $fs_license = [] ]; then
echo "License not given in input. Using default environment. "
else
cp $fs_license .license
here=`pwd`
export FS_LICENSE=\$here/.license
fi
export ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS=1
export OMP_NUM_THREADS=1
export OPENBLAS_NUM_THREADS=1
mri_synthmorph $init -t ${prefix}__init_warp.txt $moving $fixed
mri_synthmorph $warp -i ${prefix}__init_warp.txt -t temp.mgz -o ${prefix}__${suffix}_output_warped.nii.gz $moving $fixed
mri_synthmorph $warp -i ${prefix}__init_warp.txt -t temp.mgz -o ${prefix}__output_warped.nii.gz $moving $fixed
mri_warp_convert -g $moving --inras temp.mgz $out_format ${prefix}__deform_warp.nii.gz
# Remove the license
if [ ! $fs_license = [] ]; then
rm .license
fi
cat <<-END_VERSIONS > versions.yml
"${task.process}":
Freesurfer: 7.4
Expand All @@ -67,14 +53,13 @@ process REGISTRATION_SYNTHREGISTRATION {
stub:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
def suffix = task.ext.suffix ?: ""

"""
mri_synthmorph -h
mri_warp_convert -h
touch ${prefix}__${suffix}_output_warped.nii.gz
touch ${prefix}__output_warped.nii.gz
touch ${prefix}__deform_warp.nii.gz
touch ${prefix}__init_warp.txt
Expand Down
6 changes: 0 additions & 6 deletions tests/config/test_data.config
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,6 @@ params {
frf = "${params.test_data_base}/reconst/frf.txt"
}
}
"registration" {
"synthregistration"{
t1 = "${params.test_data_base}/heavy/anat/anat_image.nii.gz"
fa = "${params.test_data_base}/heavy/dwi/dwi.nii.gz"
fs_license = "${params.test_data_base}/heavy/freesurfer/license.txt"
}
"segmentation" {
"freesurferseg" {
aparc_aseg = "${params.test_data_base}/heavy/freesurfer/aparc_aseg.nii.gz"
Expand Down
17 changes: 12 additions & 5 deletions tests/modules/nf-scil/registration/synthregistration/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,23 @@

nextflow.enable.dsl = 2

include { LOAD_TEST_DATA } from '../../../../../subworkflows/nf-scil/load_test_data/main'
include { REGISTRATION_SYNTHREGISTRATION } from '../../../../../modules/nf-scil/registration/synthregistration/main.nf'

workflow test_registration_synthregistration {

input = [
input_fetch = Channel.from( [ "freesurfer.zip" ] )

LOAD_TEST_DATA ( input_fetch, "test.load-test-data" )

input = LOAD_TEST_DATA.out.test_data_directory
.map{ test_data_directory -> [
[ id:'test', single_end:false ], // meta map
file(params.test_data['registration']['synthregistration']['t1'], checkIfExists: true),
file(params.test_data['registration']['synthregistration']['fa'], checkIfExists: true),
file(params.test_data['registration']['synthregistration']['fs_license'], checkIfExists: true)
]
file("${test_data_directory}/t1.nii.gz"),
file("${test_data_directory}/fa.nii.gz"),
[]

]}

REGISTRATION_SYNTHREGISTRATION ( input )
}

0 comments on commit 00fc10f

Please sign in to comment.