]> Creatis software - clitk.git/blobdiff - scripts/create_midP_masks.sh
Merge branch 'master' of git.creatis.insa-lyon.fr:clitk
[clitk.git] / scripts / create_midP_masks.sh
index 8e4af7aeddbfb2d13117d895c9276d8d62b7a472..845237d6a31dd3a4923fdc7acd4786b262b073c1 100755 (executable)
@@ -1,14 +1,6 @@
 #! /bin/bash -x
 
-MAX_THREADS=2
-
-check_threads()
-{
-    while [[ $(jobs -p | wc -l) -ge $1 ]]; do
-        jobs
-        sleep 10
-    done
-}
+source `dirname $0`/midp_common.sh
 
 extract_patient()
 {
@@ -23,10 +15,13 @@ extract_bones()
   if [ x = x$ExtractBonesLower1 ]; then
     ExtractBonesLower1=120
   fi
+  if [ x = x$ExtractBonesLower2 ]; then
+    ExtractBonesLower2=80
+  fi
   echo "$image_name -> Extracting bones..."
   clitkImageConvert -i $image_name -o $mask_dir_tmp/float_$image_name -t float
   #clitkExtractBones -i $mask_dir_tmp/float_$image_name -o $mask_dir_tmp/bones_$image_name --lower1 120 --upper1 2000 --lower2 70 --upper2 2000 --smooth --time 0.0625 --noAutoCrop
-  clitkExtractBones -i $mask_dir_tmp/float_$image_name -o $mask_dir_tmp/bones_$image_name -a $afdb_name --lower1 $ExtractBonesLower1 --upper1 2000 --lower2 80 --upper2 2000 --smooth --time 0.0625 --noAutoCrop
+  clitkExtractBones -i $mask_dir_tmp/float_$image_name -o $mask_dir_tmp/bones_$image_name -a $afdb_name --lower1 $ExtractBonesLower1 --upper1 2000 --lower2 $ExtractBonesLower2 --upper2 2000 --smooth --time 0.0625 --noAutoCrop
   #clitkMorphoMath -i $mask_dir_tmp/bones_$image_name -o $mask_dir_tmp/bones_$image_name --type 2 --radius 4,4,2
 }
 
@@ -50,7 +45,10 @@ compute_motion_mask()
   if [ x = x$MotionMaskOffsetDetect ]; then
     MotionMaskOffsetDetect="0,-5,0"
   fi
-  clitkMotionMask -i $mask_dir_tmp/patient_only_$image_name -o $mask_dir_tmp/mm_$image_name --featureBones=$mask_dir_tmp/bones_$image_name --featureLungs=$mask_dir_tmp/lungs_$image_name --upperThresholdLungs -400 --fillingLevel 94 --offsetDetect 0,-5,0 --pad --writeFeature=$mask_dir_tmp/feature_$image_name $MotionMaskExtra --monitor=$mask_dir_tmp/monitor_$image_name
+  if [ x = x$FillingLevel ]; then
+    FillingLevel=94
+  fi
+  clitkMotionMask -i $mask_dir_tmp/patient_only_$image_name -o $mask_dir_tmp/mm_$image_name --featureBones=$mask_dir_tmp/bones_$image_name --featureLungs=$mask_dir_tmp/lungs_$image_name --upperThresholdLungs -400 --fillingLevel $FillingLevel --offsetDetect 0,-5,0 --pad --writeFeature=$mask_dir_tmp/feature_$image_name $MotionMaskExtra --monitor=$mask_dir_tmp/monitor_$image_name
 }
 
 set_background()
@@ -126,6 +124,9 @@ motion_mask()
   dir=`dirname $1`
   cd $dir
 
+  # import variables specific to each patient
+  source variables
+
   resample_spacing=$2
   resample_algo=$3
 
@@ -240,16 +241,13 @@ fi
 #
 # variables exported in this scope
 #
-# mask_dir: directory where all mask are kept
+# mask_dir: directory where all masks are kept
 # regmask_in_list: list of registration mask files (inside lungs)
 # regmask_out_list: list of registration mask files (outised lungs)
 # reg_in_list: list of registration image files (inside lungs)
 # reg_out_list: list of registration image files (outside lungs)
 #
 
-# import variables specific to each patient
-source variables
-
 if [ $1 != "using-as-lib" ]; then
   motion_mask $1 $2 $3
 fi