3 source `dirname $0`/midp_common.sh
8 if echo $* | grep "\-h"; then
9 echo Usage: calculate_motion_amplitude.sh { REFERENCE_IMAGE RTSTRUCT_FILE [ RTSTRUCT_ROI | --gui ] } | --gui
10 echo " RTSTRUCT_REF_IMAGE: mhd of the reference image used in the contour delineation"
11 echo " RTSTRUCT_FILE: dicom with contours"
12 echo " RTSTRUCT_ROI: number of the contour whose motion to analyze"
13 echo " --gui: use GUI to select files"
20 if echo $* | grep "\-\-gui" > /dev/null 2>&1; then
23 rtstruct_ref_image=`zenity --file-selection --title="Select Reference Image."`
24 rtstruct_file=`zenity --file-selection --title="Select RT Struct file."`
31 echo Invalid arguments. Type \'`basename $0` -h\' for help
43 rtstruct_roi_name=$rtstruct_roi
45 echo Invalid arguments. Type \'`basename $0` -h\' for help
52 #echo "Processing \"${rtstruct_roi_list[$roi_struct]}\"..."
53 # create ROI mask from rtstruct
54 roi_mask=roi_${rtstruct_roi_name}.mhd
55 clitkDicomRTStruct2Image -i ${rtstruct_file} -o ${roi_mask} -j ${rtstruct_ref_image} -r ${rtstruct_roi} 2> /tmp/err.txt
56 if cat /tmp/err.txt | grep -q "No ROI"; then
57 echo Invalid contour number.
61 # guarantees the same sampling for roi mask and vector image
62 roi_mask2=resampled_${roi_mask}
63 clitkResampleImage -i ${roi_mask} -o ${roi_mask2} --like ${rtstruct_ref_image}
66 clitkImageStatistics -i ${rtstruct_ref_image} -m ${roi_mask2} --verbose 2> /dev/null | tail -n 8 > /tmp/result.txt
68 if [ $gui_mode = 1 ]; then
69 cat /tmp/result.txt | zenity --text-info --title "Restuls for \"${rtstruct_roi_name}\""
71 echo "Restuls for \"${rtstruct_roi_name}\""
75 rm `basename $roi_mask .mhd`.{mhd,raw}
76 rm `basename $roi_mask2 .mhd`.{mhd,raw}