diff --git a/PK11195_input.bat b/PK11195_input.bat new file mode 100644 index 0000000000000000000000000000000000000000..3cef1f811b16d7a0509b306edcad19ff3c28b3c4 --- /dev/null +++ b/PK11195_input.bat @@ -0,0 +1,173 @@ +@echo off +setLocal EnableDelayedExpansion + +REM Script name, version and copyright +set PROGRAM=PK11195_input 1.0.1 (c) 2013 Turku PET Centre + +REM ABSS calibration file +set CALFILE=S:\Lab\plasma\bsampler_calibration\pump_cal.dat + + +REM Check user input +if "%1" == "" goto USER_INFO +if "%1" == "-help" goto USER_INFO +if "%1" == "-h" goto USER_INFO +if "%1" == "-v" goto VERSION_INFO +if "%1" == "-version" goto VERSION_INFO +if "%8" == "" ( + @echo Invalid command-line parameters; get instructions with option -help + exit /b 0 +) + +REM Get and check input files +set ABSSFILE=%1 +if not exist %ABSSFILE% ( + @echo Error: file does not exist: %ABSSFILE% + exit /b 1 +) +set MPLFILE=%2 +if not exist %MPLFILE% ( + @echo Error: file does not exist: %MPLFILE% + exit /b 1 +) +set CRFILE=%3 +if not exist %CRFILE% ( + @echo Error: file does not exist: %CRFILE% + exit /b 1 +) +set RATFILE=%4 +if not exist %RATFILE% ( + @echo Error: file does not exist: %RATFILE% + exit /b 1 +) +set HCT=%5 + +REM Get output filenames +set APCFILE=%6 +set APMFILE=%7 +set ABFILE=%8 + +@echo Preprocessing count rate data +tocr_0_2_0 -min -format=dft -copy %CRFILE% C-11 %CRFILE%.tmp +if not %errorlevel%==0 exit /b 1 +addtimes_2_1_3 -m %CRFILE%.tmp +if not %errorlevel%==0 exit /b 1 +@echo. + +@echo Preprocessing and calibrating ABSS data +blo2kbq_3_8_0 -min -i=C-11 -d=C-11 -c=%CALFILE% -o=%ABSSFILE%.tmp %ABSSFILE% +if not %errorlevel%==0 exit /b 1 +@echo. + +@echo Converting ABSS blood TAC to plasma +b2plasma_1_7_4 PK11195 %ABSSFILE%.tmp %HCT% %ABSSFILE%.tmp2 +if not %errorlevel%==0 exit /b 1 +dftren_1_3_3 --silent %ABSSFILE%.tmp2 0 Plasma . . +if not %errorlevel%==0 exit /b 1 +@echo. + +@echo Combining ABSS and manual TACs +dftcat_1_4_1 -both %ABSSFILE%.tmp2 %MPLFILE% %ABSSFILE%.tmp3 +if not %errorlevel%==0 exit /b 1 +@echo. + +@echo Converting combined plasma TAC to blood +p2blood_1_7_4 PK11195 %ABSSFILE%.tmp3 %HCT% %ABSSFILE%.tmp4 +if not %errorlevel%==0 exit /b 1 +dftren_1_3_3 -silent %ABSSFILE%.tmp4 0 Blood . . +if not %errorlevel%==0 exit /b 1 +@echo. + +@echo Metabolite correction +fit_ppf_2_0_10 -model=hill -d=1 -e=0 %RATFILE% %RATFILE%.fit +if not %errorlevel%==0 exit /b 1 +fit2dat_2_5_2 -a=70 %RATFILE%.fit %RATFILE%.fit.tmp +if not %errorlevel%==0 exit /b 1 +dft2svg_0_3_5 -y1=0 -y2=1 %RATFILE%.svg -s %RATFILE% -l %RATFILE%.fit.tmp +if not %errorlevel%==0 exit /b 1 +call svg2png %RATFILE%.svg +metabcor_1_3_6 -fnpure=%ABSSFILE%.tmp5 -fnmet=%ABSSFILE%.tmp6 %ABSSFILE%.tmp3 %RATFILE%.fit +if not %errorlevel%==0 exit /b 1 +@echo. + +@echo Delay correction +fitdelay_2_0_3 -timeunit=min -L -o=%APCFILE% -o2=%APMFILE% -o3=%ABFILE% %ABSSFILE%.tmp5 %CRFILE%.tmp 300 %ABSSFILE%.tmp6 %ABSSFILE%.tmp4 +if not %errorlevel%==0 exit /b 1 +dftscale_0_3_1 -x2=2 %APCFILE% %CRFILE%.tmp %CRFILE%.tmp2 +if not %errorlevel%==0 exit /b 1 +dft2svg_0_3_5 -x2=4 %APCFILE%.delay.svg -l %APCFILE% %CRFILE%.tmp2 %ABSSFILE%.tmp5 +if not %errorlevel%==0 exit /b 1 +call svg2png %APCFILE%.delay.svg +@echo. + +@echo Plot result TACs +dft2svg_0_3_5 %APCFILE%.svg -l %APCFILE% %APMFILE% %ABFILE% +if not %errorlevel%==0 exit /b 1 +call svg2png %APCFILE%.svg +@echo. + +goto PASSED + + +:VERSION_INFO +@echo %PROGRAM% +goto END + +REM Information for user +:USER_INFO +@echo. +@echo %PROGRAM% +@echo. +@echo Input data preprocessing for [C-11]PK11195 PET studies. +@echo Resulting data is calibrated and corrected for physical decay +@echo and time delay. +@echo. +@echo Command-line arguments: +@echo 1. ABSS file (*.blo, *.lis, *.txt) +@echo 2. Manual plasma sample file (*ap.kbq) +@echo 3. Count-rate file (*.hc, *.cr, *.head) +@echo 4. Plasma parent fraction file (*.rat) +@echo 5. Haematocrit (e.g. 0.40) +@echo 6. Filename for parent plasma TAC (*apc.kbq) +@echo 7. Filename for metabolite plasma TAC (*apm.kbq) +@echo 8. Filename for blood TAC (*ab.kbq) +@echo. +@echo Keywords: blood, input, ABSS, PK11195 +@echo. +goto END + +:VERSION_HISTORY +@echo Version history: +@echo 1.0.0 2010-11-26 Vesa Oikonen +@echo First created, based on PK11195_input.vbs 1.1.3. +@echo 1.0.1 2013-05-31 Jarkko Johansson +@echo fit_ppf_1_0_1 changed to fit_ppf_2_0_8 +@echo dft2svg_0_2_3 changed to dft2svg_0_3_4 +@echo. +goto END + + +:DEL_TEMP +if exist %CRFILE%.tmp del %CRFILE%.tmp +if exist %CRFILE%.tmp2 del %CRFILE%.tmp2 +if exist %ABSSFILE%.tmp del %ABSSFILE%.tmp +if exist %ABSSFILE%.tmp2 del %ABSSFILE%.tmp2 +if exist %ABSSFILE%.tmp3 del %ABSSFILE%.tmp3 +if exist %ABSSFILE%.tmp4 del %ABSSFILE%.tmp4 +if exist %ABSSFILE%.tmp5 del %ABSSFILE%.tmp5 +if exist %ABSSFILE%.tmp6 del %ABSSFILE%.tmp6 +if exist %RATFILE%.fit.tmp del %RATFILE%.fit.tmp +goto END + + +:PASSED +@echo. +@echo Preprocessing done. +@echo Please check the plots in created *.svg or *.png files. +@echo. +goto DEL_TEMP +goto END +:FAILED +exit /b 1 +:END +exit /b 0