6 roi=`zenity --list --title="Available Contours" --column="Please choose a contour:" $roi_list`
11 zenity --warning --text="You must choose one contour."
12 select_contour $roi_list
14 rtstruct_roi_name=$roi
17 if zenity --question --text="Do you really wish to quit?"
21 select_contour $roi_list
24 zenity --error --text="Unexpected error. Please relaunch the application."
31 rtstruct_roi_name_list=( `clitkDicomInfo ${rtstruct_file} | grep "3006|0026" | cut -d '[' -f 4 | sed 's/| V 3006|0026[LO] [ROI Name] \|]//'` )
32 rtstruct_roi_number_list=( `clitkDicomInfo ${rtstruct_file} | grep "3006|0022" | cut -d '[' -f 4 | sed 's/| V 3006|0026[LO] [ROI Number] \|]//'` )
34 for i in $(seq 0 1 $(( ${#rtstruct_roi_name_list[@]} - 1 ))); do
35 rtstruct_roi_list[$i]=${rtstruct_roi_number_list[$i]}:${rtstruct_roi_name_list[$i]}
38 select_contour ${rtstruct_roi_list[@]}
39 rtstruct_roi=`echo ${rtstruct_roi_name} | cut -d ':' -f 1`
44 if echo $* | grep "\-h"; then
45 echo Usage: calculate_motion_amplitude.sh { RTSTRUCT_FILE REFERENCE_IMAGE | --gui }
53 if echo $* | grep "\-\-gui" > /dev/null 2>&1; then
55 echo Invalid arguments. Type \'`basename $0` -h\' for help
59 rtstruct_file=`zenity --file-selection --title="Select RT Struct file."`
61 rtstruct_ref_image=`zenity --file-selection --title="Select Reference Image."`
64 echo Invalid arguments. Type \'`basename $0` -h\' for help
74 #echo "Processing \"${rtstruct_roi_list[$roi_struct]}\"..."
75 # create ROI mask from rtstruct
76 roi_mask=roi_${rtstruct_roi_name}.mhd
77 clitkDicomRTStruct2Image -i ${rtstruct_file} -o ${roi_mask} -j ${rtstruct_ref_image} -r ${rtstruct_roi} 2> /tmp/err.txt
78 if cat /tmp/err.txt | grep -q "No ROI"; then
79 echo Invalid contour number.
83 # guarantees the same sampling for roi mask and vector image
84 roi_mask2=resampled_${roi_mask}
85 clitkResampleImage -i ${roi_mask} -o ${roi_mask2} --like ${rtstruct_ref_image}
88 clitkImageStatistics -i ${rtstruct_ref_image} -m ${roi_mask2} --verbose 2> /dev/null | tail -n 8 | zenity --text-info --title "Restuls for \"${rtstruct_roi_name}\""
90 rm `basename $roi_mask .mhd`.{mhd,raw}
91 rm `basename $roi_mask2 .mhd`.{mhd,raw}