Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions modules/nf-neuro/image/applymask/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ process IMAGE_APPLYMASK {

script:
def prefix = task.ext.prefix ?: "${meta.id}"
def suffix = task.ext.first_suffix ? task.ext.first_suffix + "_masked" : "masked"
def nthreads_mrtrix = task.ext.single_thread ? "-nthreads 0" : "-nthreads ${task.cpus}"
def data_type = task.ext.data_type ? "-datatype ${task.ext.data_type}" : " -datatype float32"

"""
export OMP_NUM_THREADS=${task.ext.single_thread ? 1 : task.cpus}

mrcalc $image $mask -mult ${prefix}_masked.nii.gz -force -quiet ${nthreads_mrtrix}
mrcalc $image $mask -mult ${prefix}_${suffix}.nii.gz -force -quiet ${nthreads_mrtrix} ${data_type}

cat <<-END_VERSIONS > versions.yml
"${task.process}":
Expand All @@ -31,9 +33,9 @@ process IMAGE_APPLYMASK {

stub:
def prefix = task.ext.prefix ?: "${meta.id}"

def suffix = task.ext.first_suffix ? task.ext.first_suffix + "_masked" : "masked"
"""
touch ${prefix}_masked.nii.gz
touch ${prefix}_${suffix}.nii.gz

mrcalc -h

Expand Down
10 changes: 10 additions & 0 deletions modules/nf-neuro/image/applymask/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,20 @@ input:
ontologies:
- edam: http://edamontology.org/format_3989 # GZIP format
args:
- first_suffix:
type: string
description: Suffix for the output image file. This will be used as the first part of the suffix, followed by "_masked".
default: ""
- single_thread:
type: boolean
description: If true, the command will be run in single-threaded mode. By default, the command will use multiple threads based on the number of CPUs allocated to the task.
default: false
- data_type:
type: string
description: |
Data type for the output image. Use the following format:
uint8, int16, int32, int64, float16, float32 or float64.
default: "float32"
output:
image:
- - meta:
Expand Down
12 changes: 4 additions & 8 deletions modules/nf-neuro/registration/ants/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ process REGISTRATION_ANTS {
container "scilus/scilus:2.2.2"

input:
tuple val(meta), path(fixed_image), path(moving_image), path(fixed_mask), path(moving_mask) //** optional, input = [] **//
tuple val(meta), path(fixed_image), path(moving_image)

output:
tuple val(meta), path("*_warped.nii.gz") , emit: image_warped
tuple val(meta), path("*_warped.nii.gz") , emit: image_warped
tuple val(meta), path("*_forward1_affine.mat") , emit: forward_affine, optional: true
tuple val(meta), path("*_forward0_warp.nii.gz") , emit: forward_warp, optional: true
tuple val(meta), path("*_backward1_warp.nii.gz") , emit: backward_warp, optional: true
Expand All @@ -18,8 +18,8 @@ process REGISTRATION_ANTS {
tuple val(meta), path("*_backward*.{nii.gz,mat}", arity: '1..2') , emit: backward_image_transform
tuple val(meta), path("*_backward*.{nii.gz,mat}", arity: '1..2') , emit: forward_tractogram_transform
tuple val(meta), path("*_forward*.{nii.gz,mat}", arity: '1..2') , emit: backward_tractogram_transform
tuple val(meta), path("*_registration_ants_mqc.gif") , emit: mqc, optional: true
path "versions.yml" , emit: versions
tuple val(meta), path("*_registration_ants_mqc.gif") , emit: mqc, optional: true
path "versions.yml" , emit: versions

when:
task.ext.when == null || task.ext.when
Expand All @@ -36,10 +36,6 @@ process REGISTRATION_ANTS {
def nthreads = task.ext.single_thread ? 1 : task.cpus
args += " -n $nthreads"

if ( fixed_mask || moving_mask ) {
args += " -x \"${fixed_mask ?: 'NULL'},${moving_mask ?: 'NULL'}\""
}

if ( task.ext.initial_transform ) args += " -i [$fixed_image,$moving_image,${initialization_types[task.ext.initial_transform]}]"
if ( task.ext.histogram_bins ) args += " -r $task.ext.histogram_bins"
if ( task.ext.spline_distance ) args += " -s $task.ext.spline_distance"
Expand Down
14 changes: 0 additions & 14 deletions modules/nf-neuro/registration/ants/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,20 +145,6 @@ input:
mandatory: true
ontologies:
- edam: http://edamontology.org/format_4001 # NIFTI format
- fixed_mask:
type: file
description: Mask(s) for the fixed image space
pattern: "*.{nii,nii.gz}"
mandatory: false
ontologies:
- edam: http://edamontology.org/format_4001 # NIFTI format
- moving_mask:
type: file
description: Mask(s) for the moving image space
pattern: "*.{nii,nii.gz}"
mandatory: false
ontologies:
- edam: http://edamontology.org/format_4001 # NIFTI format
output:
image_warped:
- - meta:
Expand Down
32 changes: 0 additions & 32 deletions modules/nf-neuro/registration/ants/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,8 @@ nextflow_process {
file("\${test_data_directory}/t1.nii.gz")
]
}
ch_T1w_mask = ch_split_test_data.T1w.map{
test_data_directory -> [
[ id:'test' ],
file("\${test_data_directory}/T1w_mask.nii.gz")
]
}
input[0] = ch_T1w
.join(ch_moving)
.join(ch_T1w_mask)
.map{ meta, T1w, t1, T1w_mask -> [meta, T1w, t1, T1w_mask, []] }
"""
}
}
Expand Down Expand Up @@ -89,16 +81,8 @@ nextflow_process {
file("\${test_data_directory}/t1.nii.gz")
]
}
ch_T1w_mask = ch_split_test_data.T1w.map{
test_data_directory -> [
[ id:'test' ],
file("\${test_data_directory}/T1w_mask.nii.gz")
]
}
input[0] = ch_T1w
.join(ch_moving)
.join(ch_T1w_mask)
.map{ meta, T1w, t1, T1w_mask -> [meta, T1w, t1, T1w_mask, []] }
"""
}
}
Expand Down Expand Up @@ -132,16 +116,8 @@ nextflow_process {
file("\${test_data_directory}/t1.nii.gz")
]
}
ch_T1w_mask = ch_split_test_data.T1w.map{
test_data_directory -> [
[ id:'test' ],
file("\${test_data_directory}/T1w_mask.nii.gz")
]
}
input[0] = ch_T1w
.join(ch_moving)
.join(ch_T1w_mask)
.map{ meta, T1w, t1, T1w_mask -> [meta, T1w, t1, T1w_mask, []] }
"""
}
}
Expand Down Expand Up @@ -176,16 +152,8 @@ nextflow_process {
file("\${test_data_directory}/t1.nii.gz")
]
}
ch_T1w_mask = ch_split_test_data.T1w.map{
test_data_directory -> [
[ id:'test' ],
file("\${test_data_directory}/T1w_mask.nii.gz")
]
}
input[0] = ch_T1w
.join(ch_moving)
.join(ch_T1w_mask)
.map{ meta, T1w, t1, T1w_mask -> [meta, T1w, t1, T1w_mask, []] }
"""
}
}
Expand Down
Loading
Loading