Commit 7225794f authored by Vesa Oikonen's avatar Vesa Oikonen

more detailed PVE simulation

parent 8e7b4854
#!/bin/bash
#: Title : Simple simulation on the effect of PVE on radiowater PET
#: Date : 2019-03-22
#: Author : "Vesa Oikonen" <vesa.oikonen@utu.fi>
#: Options : None
printf "\n=====================================================================\n"
printf " Making or emptying result folder\n"
if [ ! -d sim2 ]; then
mkdir sim2
else
rm -f sim2/*
fi
printf "\n=====================================================================\n"
printf " Compute BTAC at 0.5 s sampling times \n"
printf "=====================================================================\n"
fit2dat -c=0,480,0.5 blend_lvcav.fit sim2/blood.tac
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
tacren --silent sim2/blood.tac 1 blood_artery
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
tacstudy --force sim2/blood.tac sim2
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
printf "\n=====================================================================\n"
printf " Simulate GM TTACs \n"
printf "=====================================================================\n"
b2t_h2o -fpt -voiname="GM70" sim2/blood.tac 70 1.03 1.0 5.2 30 sim2/gm.tac
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
b2t_h2o -add -fpt -voiname="GM60" sim2/blood.tac 60 1.03 1.0 5.2 30 sim2/gm.tac
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
b2t_h2o -add -fpt -voiname="GM50" sim2/blood.tac 50 1.03 1.0 5.2 30 sim2/gm.tac
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
b2t_h2o -add -fpt -voiname="GM40" sim2/blood.tac 40 1.03 1.0 5.2 30 sim2/gm.tac
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
b2t_h2o -add -fpt -voiname="GM30" sim2/blood.tac 30 1.03 1.0 5.2 30 sim2/gm.tac
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
tacstudy --force sim2/gm.tac sim2
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
printf "\n=====================================================================\n"
printf " Simulate GM and WM TTACs \n"
printf "=====================================================================\n"
b2t_h2o -fpt -voiname="WM" sim2/blood.tac 20 0.86 1.0 2.7 30 sim2/wm.tac
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
tacstudy --force sim2/wm.tac sim2
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
printf "\n=====================================================================\n"
printf " Simulate PVE by mixing GM and WM TTACs \n"
printf "=====================================================================\n"
printf "\n 80-to-20 \n"
taccalc sim2/gm.tac x 0.80 sim2/temp1.tac
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
taccalc sim2/wm.tac x 0.20 sim2/temp2.tac
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
taccalc sim2/temp1.tac + sim2/temp2.tac sim2/mixed80.tac
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
tacren sim2/mixed80.tac 0 @_W20_@
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
printf "\n 60-to-40 \n"
taccalc sim2/gm.tac x 0.60 sim2/temp1.tac
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
taccalc sim2/wm.tac x 0.40 sim2/temp2.tac
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
taccalc sim2/temp1.tac + sim2/temp2.tac sim2/mixed60.tac
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
tacren sim2/mixed60.tac 0 @_W40_@
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
printf "\n 40-to-60 \n"
taccalc sim2/gm.tac x 0.40 sim2/temp1.tac
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
taccalc sim2/wm.tac x 0.60 sim2/temp2.tac
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
taccalc sim2/temp1.tac + sim2/temp2.tac sim2/mixed40.tac
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
tacren sim2/mixed40.tac 0 @_W60_@
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
printf "\n 20-to-40 \n"
taccalc sim2/gm.tac x 0.20 sim2/temp1.tac
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
taccalc sim2/wm.tac x 0.80 sim2/temp2.tac
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
taccalc sim2/temp1.tac + sim2/temp2.tac sim2/mixed20.tac
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
tacren sim2/mixed20.tac 0 @_W80_@
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
tacadd -ovr sim2/ttacs.tac sim2/gm.tac sim2/mixed80.tac sim2/mixed60.tac sim2/mixed40.tac sim2/mixed20.tac sim2/wm.tac
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
printf "\n=====================================================================\n"
printf " Simulate frames \n"
printf "=====================================================================\n"
printf "3/17/2019 17:05:23 22 2 1 sim2 O-15\n" > sim2/frames.sif
printf "0 5\n" >> sim2/frames.sif
printf "5 10\n" >> sim2/frames.sif
printf "10 15\n" >> sim2/frames.sif
printf "15 20\n" >> sim2/frames.sif
printf "20 25\n" >> sim2/frames.sif
printf "25 30\n" >> sim2/frames.sif
printf "30 40\n" >> sim2/frames.sif
printf "40 50\n" >> sim2/frames.sif
printf "50 60\n" >> sim2/frames.sif
printf "60 80\n" >> sim2/frames.sif
printf "80 100\n" >> sim2/frames.sif
printf "100 120\n" >> sim2/frames.sif
printf "120 140\n" >> sim2/frames.sif
printf "140 160\n" >> sim2/frames.sif
printf "160 180\n" >> sim2/frames.sif
printf "180 210\n" >> sim2/frames.sif
printf "210 240\n" >> sim2/frames.sif
printf "240 270\n" >> sim2/frames.sif
printf "270 300\n" >> sim2/frames.sif
printf "300 330\n" >> sim2/frames.sif
printf "330 360\n" >> sim2/frames.sif
printf "360 420\n" >> sim2/frames.sif
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
simframe sim2/ttacs.tac sim2/frames.sif sim2/ttacsf.tac
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
printf "\n=====================================================================\n"
printf " Calculate perfusion \n"
printf "=====================================================================\n"
printf "K1_lower := 0\n" > sim2/fit_h2o.lim
printf "K1_upper := 100\n" >> sim2/fit_h2o.lim
printf "K1k2_lower := 0.3\n" >> sim2/fit_h2o.lim
printf "K1k2_upper := 1.1\n" >> sim2/fit_h2o.lim
printf "Va_lower := 0\n" >> sim2/fit_h2o.lim
printf "Va_upper := 6\n" >> sim2/fit_h2o.lim
printf "Delay_lower := 0\n" >> sim2/fit_h2o.lim
printf "Delay_upper := 0\n" >> sim2/fit_h2o.lim
fit_h2o -fpt -ml -k2 -lim=sim2/fit_h2o.lim -fit=sim2/cbf_sim2_fit_h2o.tac sim2/blood.tac sim2/ttacsf.tac 999 sim2/fit_h2o.par
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
tac2svg -mt="" -legend=y sim2/cbf_sim2_fit_h2o.svg -s sim2/ttacsf.tac -l sim2/cbf_sim2_fit_h2o.tac
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
printf "\n=====================================================================\n"
printf " Calculate perfusion ratio \n"
printf "=====================================================================\n"
perfrat -fr sim2/ttacsf.tac GM70 sim2/perfrat_refGM70W0.par
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
perfrat -fr sim2/ttacsf.tac GM50_W20 sim2/perfrat_refGM50W20.par
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
printf "\n=====================================================================\n"
printf " ARG method \n"
printf "=====================================================================\n"
dftinteg sim2/ttacsf.tac 0 100 sim2/integral.tac
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
arlkup -nr=10000 sim2/blood.tac 0.8 500 0 100 sim2/arg.lkup
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
taclkup sim2/integral.tac sim2/arg.lkup sim2/arg.tac
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
dft2res sim2/arg.tac
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
parformat -f=TSV-UK sim2/arg.res sim2/arg.tsv
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
printf "\n===================================================================\n"
printf " All done! \n"
printf "===================================================================\n"
exit 0
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment