extract_lungs()
{
- echo "$phase_file -> Extracting lungs..."
- clitkExtractLung -i $phase_file -o $mask_dir_tmp/lungs_$phase_nb.mhd -a $afdb_file --noAutoCrop
+ echo "$phase_file -> Extracting lungs..."
+ clitkExtractLung -i $phase_file -o $mask_dir_tmp/lungs_$phase_nb.mhd -a $afdb_file --noAutoCrop --doNotSeparateLungs
}
+
+
resample()
{
echo "$phase_file -> Resampling..."
clitkResampleImage -i $mask_dir_tmp/patient_$phase_nb.mhd -o $mask_dir_tmp/patient_$phase_nb.mhd --spacing $resample_spacing --interp $resample_algo
+ clitkResampleImage -i $mask_dir_tmp/patient_mask_$phase_nb.mhd -o $mask_dir_tmp/patient_mask_$phase_nb.mhd --spacing $resample_spacing --interp $resample_algo
clitkResampleImage -i $mask_dir_tmp/lungs_$phase_nb.mhd -o $mask_dir_tmp/lungs_$phase_nb.mhd --like $mask_dir_tmp/patient_$phase_nb.mhd
}
FillingLevel=94
fi
- clitkMotionMask -i $mask_dir_tmp/patient_$phase_nb.mh -o $mask_dir_tmp/mm_$phase_nb.mhd --featureLungs $mask_dir_tmp/lungs_$phase_nb.mhd --upperThresholdLungs -400 --fillingLevel $FillingLevel --offsetDetect $MotionMaskOffsetDetect --pad --writeFeature=$mask_dir_tmp/feature_$phase_nb.mhd $MotionMaskExtra
+ clitkMotionMask -i $mask_dir_tmp/patient_$phase_nb.mhd -o $mask_dir_tmp/mm_$phase_nb.mhd --featureLungs $mask_dir_tmp/lungs_$phase_nb.mhd --upperThresholdLungs -400 --fillingLevel $FillingLevel --offsetDetect $MotionMaskOffsetDetect --pad --writeFeature=$mask_dir_tmp/feature_$phase_nb.mhd $MotionMaskExtra
#--monitor=$mask_dir_tmp/monitor_$phase_nb.mhd
}
# extract_bones
extract_lungs
# remove_tmp_masks 1
- resample
+ if [ $resample_spacing -ne 0 ] ; then
+ resample
+ fi
}
mm_postprocessing()
motion_mask()
{
#set cmd line variables
- mhd4d=$1
- resample_spacing=$2
- resample_algo=$3
+ mhd4d=`basename $1`
+ if [ $# -eq 3 ] ; then
+ resample_spacing=$2
+ resample_algo=$3
+ else
+ resample_spacing=0
+ resample_algo=0
+ fi
dir=`dirname $1`
cd $dir
fi
#set other global variables
- mask_dir="MASK-${resample_spacing}mm-$resample_algo"
+ if [ $resample_spacing -ne 0 ] ; then
+ mask_dir="MASK-${resample_spacing}mm-$resample_algo"
+ else
+ mask_dir="MASK"
+ fi
mask_dir_tmp="tmp.$mask_dir"
extract_4d_phases $mhd4d
# main #
#################
-if [ $# != 3 ]; then
- echo "Usage: $0 CT_4D RESAMPLE_SPACING RESAMPLE_ALGORITHM"
+if [ $# -ne 3 -a $# -ne 1 ]; then
+ echo "Usage: $0 CT_4D [RESAMPLE_SPACING RESAMPLE_ALGORITHM]"
exit -1
fi
#
if [ $1 != "using-as-lib" ]; then
- motion_mask $1 $2 $3
+ if [ $# -eq 3 ] ; then
+ motion_mask $1 $2 $3
+ else
+ motion_mask $1
+ fi
fi