Commit 34cc7c0d authored by Vesa Oikonen's avatar Vesa Oikonen

simple pve simulation for parametric SRTM computation

parent ec9c6371
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
FIT1 fit_feng 0.7.4 (c) 2019 by Turku PET Centre
Date: 2019-10-31 17:36:43
Data file: rp.dat
Data unit: kBq/ml
Time unit: min
Nr of VOIs: 1
Region Plane Start End dataNr WSS parNr Type Parameters
1 . . 0.000 120.000 100 0.0 9 1314 2.1E+03 -1.21E+01 6.5E+01 -1.8E+00 1.5E+01 -1.16E-01 8.0E+00 -7.9E-03 5.0E-01
#!/bin/bash
#: Title : PVE and SRTM
#: Date : 2019-10-31
#: Author : "Vesa Oikonen" <vesa.oikonen@utu.fi>
#: Options : None
printf "\n=====================================================================\n"
printf " Making or emptying result folder\n"
if [ ! -d sim1 ]; then
mkdir sim1
else
rm -f sim1/*
fi
printf "\n=====================================================================\n"
printf " Set SRTM parameters for two GM TACs \n"
printf "=====================================================================\n"
printf "# model := SRTM\n" > sim1/srtm.par
printf "parameters,R1,k2,BPnd\n" >> sim1/srtm.par
printf "GM1,1.4,0.4,3.0\n" >> sim1/srtm.par
printf "GM2,1.4,0.4,6.0\n" >> sim1/srtm.par
printf "\n=====================================================================\n"
printf " Set image time frames \n"
printf "=====================================================================\n"
printf "01/01/1970 02:00:00 55 2 1 sim1 C-11\n" > sim1/times.sif
printf "0 15\n" >> sim1/times.sif
printf "15 30\n" >> sim1/times.sif
printf "30 45\n" >> sim1/times.sif
printf "45 60\n" >> sim1/times.sif
printf "60 75\n" >> sim1/times.sif
printf "75 90\n" >> sim1/times.sif
printf "90 105\n" >> sim1/times.sif
printf "105 120\n" >> sim1/times.sif
printf "120 135\n" >> sim1/times.sif
printf "135 150\n" >> sim1/times.sif
printf "150 165\n" >> sim1/times.sif
printf "165 180\n" >> sim1/times.sif
printf "180 210\n" >> sim1/times.sif
printf "210 240\n" >> sim1/times.sif
printf "240 270\n" >> sim1/times.sif
printf "270 300\n" >> sim1/times.sif
printf "300 330\n" >> sim1/times.sif
printf "330 360\n" >> sim1/times.sif
printf "360 390\n" >> sim1/times.sif
printf "390 420\n" >> sim1/times.sif
printf "420 450\n" >> sim1/times.sif
printf "450 480\n" >> sim1/times.sif
printf "480 510\n" >> sim1/times.sif
printf "510 540\n" >> sim1/times.sif
printf "540 570\n" >> sim1/times.sif
printf "570 600\n" >> sim1/times.sif
printf "600 660\n" >> sim1/times.sif
printf "660 720\n" >> sim1/times.sif
printf "720 780\n" >> sim1/times.sif
printf "780 840\n" >> sim1/times.sif
printf "840 900\n" >> sim1/times.sif
printf "900 960\n" >> sim1/times.sif
printf "960 1020\n" >> sim1/times.sif
printf "1020 1080\n" >> sim1/times.sif
printf "1080 1140\n" >> sim1/times.sif
printf "1140 1200\n" >> sim1/times.sif
printf "1200 1320\n" >> sim1/times.sif
printf "1320 1440\n" >> sim1/times.sif
printf "1440 1560\n" >> sim1/times.sif
printf "1560 1680\n" >> sim1/times.sif
printf "1680 1800\n" >> sim1/times.sif
printf "1800 2100\n" >> sim1/times.sif
printf "2100 2400\n" >> sim1/times.sif
printf "2400 2700\n" >> sim1/times.sif
printf "2700 3000\n" >> sim1/times.sif
printf "3000 3300\n" >> sim1/times.sif
printf "3300 3600\n" >> sim1/times.sif
printf "3600 3900\n" >> sim1/times.sif
printf "3900 4200\n" >> sim1/times.sif
printf "4200 4500\n" >> sim1/times.sif
printf "4500 4800\n" >> sim1/times.sif
printf "4800 5100\n" >> sim1/times.sif
printf "5100 5400\n" >> sim1/times.sif
printf "5400 5700\n" >> sim1/times.sif
printf "5700 6000\n" >> sim1/times.sif
printf "\n=====================================================================\n"
printf " Compute AIF at 0.1 min sampling times \n"
printf "=====================================================================\n"
fit2dat -c=0,120,0.1 rp.fit sim1/aif.tac
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
tacren --silent sim1/aif.tac 1 AIF
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
printf "\n=====================================================================\n"
printf " Simulate reference TAC \n"
printf "=====================================================================\n"
p2t_3c -nosub sim1/aif.tac 0.11 0.33 0 0 0 0 sim1/ref.tac
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
tacren --silent sim1/ref.tac 1 Refer
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
printf "\n=====================================================================\n"
printf " Simulate WM TAC \n"
printf "=====================================================================\n"
p2t_3c -nosub sim1/aif.tac 0.03 0.04 0 0 0 0 sim1/wm.tac
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
tacren --silent sim1/wm.tac 1 WM
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
printf "\n=====================================================================\n"
printf " Simulate GM TACs using SRTM and reference tissue as input \n"
printf "=====================================================================\n"
sim_rtcm sim1/srtm.par sim1/ref.tac sim1/gm.tac
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
printf "\n=====================================================================\n"
printf " Make mask image \n"
printf "=====================================================================\n"
asc2flat flat_woart.txt sim1/mask.bin
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
flat2img -scanner=HRRT -zoom=4 sim1/mask.bin sim1/mask.v 1 1 256 256
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
img2tif -rb sim1/mask.v sim1/mask.tif
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
printf "\n=====================================================================\n"
printf " Make dynamic image \n"
printf "=====================================================================\n"
tacadd -ovr sim1/temp.tac sim1/wm.tac
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
tacadd sim1/temp.tac sim1/ref.tac
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
tacadd sim1/temp.tac sim1/gm.tac
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
tacadd sim1/temp.tac sim1/aif.tac
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
simframe sim1/temp.tac sim1/times.sif sim1/framed.tac
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
imgcalc sim1/mask.v + 1 sim1/temp.v
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
dft2img -tpl=sim1/temp.v sim1/framed.tac sim1/dynamic.v
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
img2tif -rb -s sim1/dynamic.v
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
img2dft sim1/dynamic.v sim1/temp.v sim1/dynamic.tac
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
tac2svg -mt="TACs from simulated image" sim1/dynamic.svg -s sim1/dynamic.tac -l sim1/framed.tac
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
printf "\n=====================================================================\n"
printf " Gaussian blurring \n"
printf "=====================================================================\n"
imgfiltg sim1/dynamic.v sim1/blurred.v 8px
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
img2tif -rb -s sim1/blurred.v
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
img2dft sim1/blurred.v sim1/temp.v sim1/blurred.tac
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
tac2svg -mt="TACs from blurred image" sim1/blurred.svg -s sim1/framed.tac -l sim1/blurred.tac
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
imginteg -avg sim1/blurred.v 0 0 sim1/sum_blurred.v
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
img2tif -rb -s sim1/sum_blurred.v
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
printf "\n=====================================================================\n"
printf " SRTM for simulated image \n"
printf "=====================================================================\n"
tacadd -ovr sim1/reference.tac sim1/framed.tac Refer
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
imgsrtm -r1=sim1/r1_sharp.v -k2=sim1/k2_sharp.v sim1/dynamic.v sim1/reference.tac sim1/bp_sharp.v
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
img2tif -rb -s sim1/bp_sharp.v
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
img2tif -rb -s sim1/r1_sharp.v
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
img2tif -rb -s sim1/k2_sharp.v
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
imgsrtm -r1=sim1/r1_blurred.v -k2=sim1/k2_blurred.v sim1/blurred.v sim1/reference.tac sim1/bp_blurred.v
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
img2tif -rb -s sim1/bp_blurred.v
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
img2tif -rb -s sim1/r1_blurred.v
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
img2tif -rb -s sim1/k2_blurred.v
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
img2dft sim1/bp_blurred.v sim1/temp.v sim1/bp_blurred.tac
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
img2dft sim1/r1_blurred.v sim1/temp.v sim1/r1_blurred.tac
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
img2dft sim1/k2_blurred.v sim1/temp.v sim1/k2_blurred.tac
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