]> Creatis software - FrontAlgorithms.git/blobdiff - appli/CTBronchi/CTBronchi_process.sh
...
[FrontAlgorithms.git] / appli / CTBronchi / CTBronchi_process.sh
index 26257bed106938519023c01fe7ddb6cedbc1829c..f22b699ce9c40efc1e692ed0120ac138bc65d958 100755 (executable)
@@ -1,45 +1,74 @@
 #!/bin/bash
 
 ## Command line arguments
-if [ "$#" -lt 5 ]; then
-    echo "Usage: $0 input_image [index/point] seed_x seed_y seed_z"
+while [[ "$#" -gt 1 ]]; do
+    key="$1"
+    case $key in
+        -input)
+        input="$2"
+        shift
+        ;;
+        -seed)
+        sx="$2"
+        sy="$3"
+        sz="$4"
+        shift
+        ;;
+        -mori)
+        mori="$2"
+        shift
+        ;;
+        -labels)
+        labels="$2"
+        shift
+        ;;
+        -output)
+        output="$2"
+        shift
+        ;;
+        *)
+        # Do nothing
+        ;;
+    esac
+    shift
+done
+if [ -z "$input" ] || [ -z "$sx" ] || [ -z "$sy" ] || [ -z "$sz" ]; then
+    (>&2 echo "Usage: $0 -input input_raw_image -seed x y z [-mori mori_image_dfilename] [-labels labels_image_filename] [-output output_image_filename] [-mori_init_threshold value] [-mori_end_threshold value] [-mori_delta value] [-mori_minimum_threshold value] [-mori_inside_value value] [-mori_outside_value value] [-mori_signal_kernel_size value] [-mori_signal_threshold value] [-mori_signal_influence value] [-label_upper_threshold value] [-label_inside value] [-label_outside value] [-random_walker_beta value]")
     exit 1
 fi
+if [ -z "$mori_init_threshold" ]; then mori_init_threshold="-1024"; fi
+if [ -z "$mori_end_threshold" ]; then mori_end_threshold="0"; fi
+if [ -z "$mori_delta" ]; then mori_delta="1"; fi
+if [ -z "$mori_minimum_threshold" ]; then mori_minimum_threshold="-850"; fi
+if [ -z "$mori_inside_value" ]; then mori_inside_value="255"; fi
+if [ -z "$mori_outside_value" ]; then mori_outside_value="0"; fi
+if [ -z "$mori_signal_kernel_size" ]; then mori_signal_kernel_size="20"; fi
+if [ -z "$mori_signal_threshold" ]; then mori_signal_threshold="500"; fi
+if [ -z "$mori_signal_influence" ]; then mori_signal_influence="0.5"; fi
+if [ -z "$label_upper_threshold" ]; then label_upper_threshold="-600"; fi
+if [ -z "$label_inside" ]; then label_inside="1"; fi
+if [ -z "$label_outside" ]; then label_outside="2"; fi
+if [ -z "$random_walker_beta" ]; then random_walker_beta="20"; fi
+
+base_name=`dirname $input`/`basename $input .mhd`
+if [ -z "$mori" ]; then
+    mori="$base_name"_mori.mhd
+fi
+signal="$mori"_signal.txt
+if [ -z "$labels" ]; then
+    labels="$base_name"_labels.mhd
+fi
+if [ -z "$output" ]; then
+    output="$base_name"_rw.mhd
+fi
 
 exec_dir=`dirname $0`
 mori_seg=`dirname $0`/fpa_CTBronchi_MoriSegmentation
 mori_lab=`dirname $0`/fpa_CTBronchi_MoriLabelling
 random_walker=`dirname $0`/fpa_CTBronchi_RandomWalker
-input_image=$1
-seed_type=$2
-seed_x=$3
-seed_y=$4
-seed_z=$5
-
-base_name=`dirname $input_image`/`basename $input_image .mhd`
-
-mori_output_image="$base_name"_mori.mhd
-mori_output_signal="$base_name"_mori_signal.txt
-mori_init_threshold=-1024
-mori_end_threshold=0
-mori_delta=1
-mori_minimum_threshold=-850
-mori_inside_value=255
-mori_outside_value=0
-mori_signal_kernel_size=20
-mori_signal_threshold=500
-mori_signal_influence=500
-
-labels_output_image="$base_name"_labels.mhd
-label_upper_threshold=-600
-label_inside=1
-label_outside=2
-
-random_walker_output_image="$base_name"_rw.mhd
-random_walker_beta=20
 
 $mori_seg \
-    $input_image $mori_output_image $mori_output_signal \
+    $input $mori $signal \
     $mori_init_threshold \
     $mori_end_threshold \
     $mori_delta \
@@ -49,18 +78,17 @@ $mori_seg \
     $mori_signal_kernel_size \
     $mori_signal_threshold \
     $mori_signal_influence \
-    $seed_type \
-    $seed_x $seed_y $seed_z
+    $sx $sy $sz
 
 $mori_lab \
-    $input_image $mori_output_image $labels_output_image \
+    $input $mori $labels \
     $label_upper_threshold \
     $mori_inside_value \
     $label_inside \
     $label_outside
 
 $random_walker \
-    $input_image $labels_output_image $random_walker_output_image \
+    $input $labels $output \
     $label_inside \
     $random_walker_beta