From 97a50b47120a8519b314fbfc9edf85711c05d95c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20K=C3=BCgler?= Date: Thu, 20 Jun 2024 15:13:47 +0200 Subject: [PATCH] run_fastsurfer.sh - Fix for bash-3.2 (|& => 2&>1 |) - Add warning if T2 is passed, but biasfield is skipped --no_biasfield --- HypVINN/run_prediction.py | 2 +- doc/overview/OUTPUT_FILES.md | 2 +- run_fastsurfer.sh | 25 ++++++++++++++----------- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/HypVINN/run_prediction.py b/HypVINN/run_prediction.py index 5a275cfe..ce6736a9 100644 --- a/HypVINN/run_prediction.py +++ b/HypVINN/run_prediction.py @@ -108,7 +108,7 @@ def option_parse() -> argparse.ArgumentParser: # 3. Image processing options parser.add_argument( "--qc_snap", - action='store_true', + default='store_true', dest="qc_snapshots", help="Create qc snapshots in //qc_snapshots.", ) diff --git a/doc/overview/OUTPUT_FILES.md b/doc/overview/OUTPUT_FILES.md index 0ef19454..87416ed3 100644 --- a/doc/overview/OUTPUT_FILES.md +++ b/doc/overview/OUTPUT_FILES.md @@ -27,7 +27,7 @@ The cerebellum module outputs the files in the table shown below. Unless switche ## HypVINN module -The hypothalamus module outputs the files in the table shown below. Unless switched off by the `--no_hypvinn` argument, this module is automatically run whenever the segmentation module is run. It adds three files, an image with the sub-segmentation of the hypothalamus and a text file with summary statistics. +The hypothalamus module outputs the files in the table shown below. Unless switched off by the `--no_hypothal` argument, this module is automatically run whenever the segmentation module is run. It adds three files, an image with the sub-segmentation of the hypothalamus and a text file with summary statistics. | directory | filename | module | description | diff --git a/run_fastsurfer.sh b/run_fastsurfer.sh index 5b1f0e14..d1f8d873 100755 --- a/run_fastsurfer.sh +++ b/run_fastsurfer.sh @@ -193,8 +193,8 @@ SEGMENTATION PIPELINE: statistics. HYPOTHALAMUS MODULE (HypVINN): - --no_hypvinn Skip the hypothalamus segmentation. - --no_biasfield This option implies --no_hypvinn, as the hypothalamus + --no_hypothal Skip the hypothalamus segmentation. + --no_biasfield This option implies --no_hypothal, as the hypothalamus sub-segmentation requires biasfield-corrected images. --t2 *Optional* T2 full head input (does not have to be bias corrected, a mandatory biasfield correction step is @@ -386,10 +386,9 @@ case $key in shift # past argument shift # past value ;; - --qc_snaps) - hypvinn_flags+=(--qc_snapshots "$2") + --qc_snap) + hypvinn_flags+=(--qc_snap) shift # past argument - shift # past value ;; --mask_name) mask_name="$2" @@ -462,7 +461,7 @@ case $key in run_cereb_module="0" shift # past argument ;; - --no_hypvinn) + --no_hypothal) run_hypvinn_module="0" shift # past argument ;; @@ -859,7 +858,7 @@ if [[ "$run_seg_pipeline" == "1" ]] then printf "INFO: Copying T2 file to %s..." "${t2_copy_file}" | tee -a "$seg_log" cmd=("nib-convert" "$t2" "$t2_copy_file") - "${cmd[@]}" |& tee -a "$seg_log" + "${cmd[@]}" 2>&1 | tee -a "$seg_log" echo "Done." | tee -a "$seg_log" fi @@ -918,7 +917,7 @@ if [[ "$run_seg_pipeline" == "1" ]] echo "INFO: Running N4 bias-field correction of the t2" | tee -a "$seg_log" cmd=($python "${reconsurfdir}/N4_bias_correct.py" "--in" "$t2" --out "$norm_name_t2" --threads "$threads" --uchar) - echo "${cmd[@]}" |& tee -a "$seg_log" + echo "${cmd[@]}" | tee -a "$seg_log" "${cmd[@]}" if [[ "${PIPESTATUS[0]}" -ne 0 ]] then @@ -933,7 +932,11 @@ if [[ "$run_seg_pipeline" == "1" ]] echo "INFO: Robustly rescaling $t2 to uchar ($norm_name_t2), which is assumed to already be biasfield corrected." | tee -a "$seg_log" cmd=($python "${fastsurfercnndir}/data_loader/conform.py" --no_force_lia --no_force_vox_size --no_force_img_size "$t2" "$norm_name_t2") - "${cmd[@]}" |& tee -a "$seg_log" + echo "WARNING: --no_biasfield is activated, but FastSurfer does not check, if " + echo " passed T2 image is properly scaled and typed. T2 needs to be uchar and" + echo " robustly scaled (see FastSurferCNN/utils/data_loader/conform.py)!" + # TODO implement/validate no changes to affine parameters for conform + # "${cmd[@]}" 2>&1 | tee -a "$seg_log" fi fi @@ -978,11 +981,11 @@ if [[ "$run_seg_pipeline" == "1" ]] cmd+=("$t1") if [[ -n "$t2" ]] ; then cmd+=(--t2 "$t2"); fi fi - echo "${cmd[@]}" |& tee -a "$seg_log" + echo "${cmd[@]}" 2>&1 | tee -a "$seg_log" "${cmd[@]}" if [[ "${PIPESTATUS[0]}" -ne 0 ]] then - echo "ERROR: Hypothalamus Segmentation failed" |& tee -a "$seg_log" + echo "ERROR: Hypothalamus Segmentation failed" | tee -a "$seg_log" exit 1 fi fi