diff --git a/modules/nf-neuro/reconst/noddi/main.nf b/modules/nf-neuro/reconst/noddi/main.nf index 56bcbd8d..d64d1898 100644 --- a/modules/nf-neuro/reconst/noddi/main.nf +++ b/modules/nf-neuro/reconst/noddi/main.nf @@ -31,14 +31,8 @@ process RECONST_NODDI { def set_kernels = kernels ? "--load_kernels $kernels" : "--save_kernels kernels/" def set_mask = mask ? "--mask $mask" : "" def compute_only = task.ext.compute_only && !kernels ? "--compute_only" : "" - def ignore_single_shell = task.ext.ignore_single_shell ?: false """ - # Set home directory. This is problematic if the container is run - # with non-root user which does not create a home directory, whilst - # AMICO attempts to write in the home directory, raising an error. - export HOME=/tmp - # Check if data are multi-shell based on b-values and set number of clusters accordingly # Set tolerance threshold (default 40 if not specified) b_threshold=${task.ext.b_thr ?: 40} @@ -58,27 +52,29 @@ process RECONST_NODDI { if [ \$clusters -lt 3 ]; then echo "Error: NODDI reconstruction requires multi-shell data (at least 2 non-zero b-value shells). Detected only \$clusters shell(s) with b-values: \${uniq_bvals[@]}" - if [ "$ignore_single_shell" = "false" ]; then - exit 1 - fi + exit 1 else echo "Detected \$clusters unique b-value shells: \${uniq_bvals[@]}" + fi + # Set home directory. This is problematic if the container is run + # with non-root user which does not create a home directory, whilst + # AMICO attempts to write in the home directory, raising an error. + export HOME=/tmp - scil_NODDI_maps $dwi $bval $bvec $para_diff_str $iso_diff_str $lambda1 \ - $lambda2 $nb_threads $b_thr $set_mask $set_kernels --skip_b0_check $compute_only + scil_NODDI_maps $dwi $bval $bvec $para_diff_str $iso_diff_str $lambda1 \ + $lambda2 $nb_threads $b_thr $set_mask $set_kernels --skip_b0_check $compute_only - if [ -z "${compute_only}" ]; - then - mv results/fit_dir.nii.gz ${prefix}__dir.nii.gz - mv results/fit_NDI.nii.gz ${prefix}__icvf.nii.gz # ICVF -> NDI - mv results/fit_FWF.nii.gz ${prefix}__isovf.nii.gz # ISOVF -> FWF - mv results/fit_ODI.nii.gz ${prefix}__odi.nii.gz # ODI -> OD + if [ -z "${compute_only}" ]; + then + mv results/fit_dir.nii.gz ${prefix}__dir.nii.gz + mv results/fit_NDI.nii.gz ${prefix}__icvf.nii.gz # ICVF -> NDI + mv results/fit_FWF.nii.gz ${prefix}__isovf.nii.gz # ISOVF -> FWF + mv results/fit_ODI.nii.gz ${prefix}__odi.nii.gz # ODI -> OD - scil_volume_math subtraction 1 ${prefix}__isovf.nii.gz ${prefix}__ecvf.nii.gz + scil_volume_math subtraction 1 ${prefix}__isovf.nii.gz ${prefix}__ecvf.nii.gz - rm -rf results - fi + rm -rf results fi cat <<-END_VERSIONS > versions.yml diff --git a/modules/nf-neuro/reconst/noddi/meta.yml b/modules/nf-neuro/reconst/noddi/meta.yml index 061a8e70..7fe53609 100644 --- a/modules/nf-neuro/reconst/noddi/meta.yml +++ b/modules/nf-neuro/reconst/noddi/meta.yml @@ -79,9 +79,7 @@ args: - compute_only: type: boolean description: Compute kernels only. - - ignore_single_shell: - type: boolean - description: Ignore single shell data instead of raising an error. With this flag enabled, simply no output will be produced for single shell data. + output: dir: - - meta: diff --git a/subworkflows/nf-neuro/reconst_fw_noddi/main.nf b/subworkflows/nf-neuro/reconst_fw_noddi/main.nf index 05cc8483..85d77930 100644 --- a/subworkflows/nf-neuro/reconst_fw_noddi/main.nf +++ b/subworkflows/nf-neuro/reconst_fw_noddi/main.nf @@ -197,6 +197,13 @@ workflow RECONST_FW_NODDI { ch_noddi_input = ch_noddi_custom_subj .mix( ch_noddi_custom ) .mix( ch_noddi_computed ) + .filter{ _meta, _dwi, bval, _bvec, _b0_mask, _para, _iso -> + def is_multi_shell = bval.text.tokenize().unique().size() > 2 + if (!is_multi_shell && !options.silence_single_shell_warnings){ + log.warn "Subject ${_meta.id} has single-shell data. Skipping NODDI reconstruction." + } + return is_multi_shell + } .map{ meta, dwi, bval, bvec, b0_mask, para, iso -> [meta, dwi, bval, bvec, b0_mask, [], para, iso] } diff --git a/subworkflows/nf-neuro/reconst_fw_noddi/meta.yml b/subworkflows/nf-neuro/reconst_fw_noddi/meta.yml index a1d1e8f0..f90439b6 100644 --- a/subworkflows/nf-neuro/reconst_fw_noddi/meta.yml +++ b/subworkflows/nf-neuro/reconst_fw_noddi/meta.yml @@ -113,6 +113,10 @@ input: type: boolean description: If 'true', the diffusivity priors computed from the RECONST/DIFFUSIVITYPRIORS module will be averaged across all subjects. (Recommended) default: false + silence_single_shell_warnings: + type: boolean + description: If 'true', the workflow will silence warnings about single-shell data (e.g. when filtering subjects for NODDI). + default: false mandatory: false output: - noddi_dir: