Commit b4d6db0d authored by Vesa Oikonen's avatar Vesa Oikonen
Browse files

started app fit2auc

parent 46d5a9f6
......@@ -4,7 +4,7 @@ cmake_minimum_required (VERSION 3.12.1 FATAL_ERROR)
# Name and language of the project
project(tpcclib LANGUAGES C VERSION 0.7.7)
# Set copyright owner for all executables
set(tpcclib_COPYRIGHT "(c) 2020 by Turku PET Centre")
set(tpcclib_COPYRIGHT "(c) 2021 by Turku PET Centre")
message(STATUS "")
message(STATUS "${PROJECT_NAME} ${tpcclib_COPYRIGHT}")
......@@ -307,6 +307,7 @@ add_subdirectory (v2/llsq)
add_subdirectory (v2/misc)
add_subdirectory (v2/mtga)
add_subdirectory (v2/parutils)
add_subdirectory (v2/pk)
add_subdirectory (v2/sifutils)
add_subdirectory (v2/simulation)
add_subdirectory (v2/suv)
......
......@@ -4,9 +4,11 @@ Changes in tpcclib
This is a concise list of changes; commit messages can be found in the
[Git repository](https://gitlab.utu.fi/vesoik/tpcclib.git).
## version 0.7.7 (2020-06-30, in development)
## version 0.7.7 (2021-02-03, in development)
- Bug fix in application fit_dexp with option -1BL.
- Started writing apps taccat and fit2auc.
- libtpcfunc in v2 supports more functions, and added mfEvalIntToInf.
## version 0.7.6 (2020-06-28)
......
# Make sure the compiler can find include files from our libraries.
include_directories (${CMAKE_SOURCE_DIR}/v2/libtpcextensions)
include_directories (${CMAKE_SOURCE_DIR}/v2/libtpcisotope)
include_directories (${CMAKE_SOURCE_DIR}/v2/libtpcbfm)
include_directories (${CMAKE_SOURCE_DIR}/v2/libtpcfileutil)
include_directories (${CMAKE_SOURCE_DIR}/v2/libtpctac)
include_directories (${CMAKE_SOURCE_DIR}/v2/libtpcli)
include_directories (${CMAKE_SOURCE_DIR}/v2/libtpcmodels)
include_directories (${CMAKE_SOURCE_DIR}/v2/libtpcfunc)
include_directories (${CMAKE_SOURCE_DIR}/v2/libtpccm)
include_directories (${CMAKE_SOURCE_DIR}/v2/libtpclinopt)
include_directories (${CMAKE_SOURCE_DIR}/v2/libtpcrand)
include_directories (${CMAKE_SOURCE_DIR}/v2/libtpcnlopt)
include_directories (${CMAKE_SOURCE_DIR}/v2/libtpctacmod)
include_directories (${CMAKE_SOURCE_DIR}/v2/libtpcfunc)
include_directories (${CMAKE_SOURCE_DIR}/v2/libtpcpar)
include_directories (${CMAKE_SOURCE_DIR}/v2/libtpccsv)
include_directories (${CMAKE_SOURCE_DIR}/v2/libtpcift)
# Make sure the linker can find the libraries once they are built.
link_directories (${CMAKE_BINARY_DIR}/v2/libtpcextensions)
link_directories (${CMAKE_BINARY_DIR}/v2/libtpcisotope)
link_directories (${CMAKE_BINARY_DIR}/v2/libtpcbfm)
link_directories (${CMAKE_BINARY_DIR}/v2/libtpcfileutil)
link_directories (${CMAKE_BINARY_DIR}/v2/libtpctac)
link_directories (${CMAKE_BINARY_DIR}/v2/libtpcli)
link_directories (${CMAKE_BINARY_DIR}/v2/libtpcmodels)
link_directories (${CMAKE_BINARY_DIR}/v2/libtpcfunc)
link_directories (${CMAKE_BINARY_DIR}/v2/libtpclinopt)
link_directories (${CMAKE_BINARY_DIR}/v2/libtpcrand)
link_directories (${CMAKE_BINARY_DIR}/v2/libtpcnlopt)
link_directories (${CMAKE_BINARY_DIR}/v2/libtpccm)
link_directories (${CMAKE_BINARY_DIR}/v2/libtpctacmod)
link_directories (${CMAKE_BINARY_DIR}/v2/libtpcpar)
link_directories (${CMAKE_BINARY_DIR}/v2/libtpccsv)
link_directories (${CMAKE_BINARY_DIR}/v2/libtpcift)
# Add executable that is built from the source file(s)
# The extensions are automatically found.
add_executable (fit2auc fit2auc.c)
# Link the executable to the libraries.
target_link_libraries (fit2auc tpctacmod tpcfunc tpcmodels tpcfileutil tpctac tpcpar tpccsv tpcift tpcextensions m)
# Install the executable(s)
#install (
# PROGRAMS
# ${CMAKE_CURRENT_BINARY_DIR}/fit2auc${CMAKE_EXECUTABLE_SUFFIX}
# DESTINATION bin
# COMPONENT applications
#)
# Copy test data folder
add_custom_target(pktests ALL
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/test
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/test ${CMAKE_CURRENT_BINARY_DIR}/test/
)
# And delete test data folder with clean
set_property(DIRECTORY PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${CMAKE_CURRENT_BINARY_DIR}/test")
#
# Simple tests
#
add_test(fit2aucUsage fit2auc "--help")
set_tests_properties(
fit2aucUsage
PROPERTIES PASS_REGULAR_EXPRESSION "Usage: *"
)
#
# Run test scripts
#
add_test (
NAME fit2aucTests
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/test/fit2auc
COMMAND bash "./test_fit2auc.sh"
)
/** @file fit2auc.c
@brief Calculation of PTAC AUC from specified time to infinity.
@copyright (c) Turku PET Centre
@author Vesa Oikonen
@note Work-in-progress.
*/
/// @cond
/*****************************************************************************/
#include "tpcclibConfig.h"
/*****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
/*****************************************************************************/
#include "tpcextensions.h"
#include "tpcift.h"
#include "tpctac.h"
#include "tpcpar.h"
#include "tpctacmod.h"
/*****************************************************************************/
/*****************************************************************************/
static char *info[] = {
"Calculation of PTAC AUC from specified time to infinity, based on parameters",
"of decaying sum of exponentials.",
" ",
"Usage: @P [Options] parfile starttime [aucfile]",
" ",
"Options:",
" -stdoptions", // List standard options like --help, -v, etc
" ",
"See also: fit_dexp, fit2dat, extrapol, paucinf, tacln, parcoll",
" ",
"Keywords: AUC, input, pharmacokinetics, clearance, elimination rate",
0};
/*****************************************************************************/
/*****************************************************************************/
/* Turn on the globbing of the command line, since it is disabled by default in
mingw-w64 (_dowildcard=0); in MinGW32 define _CRT_glob instead, if necessary;
In Unix&Linux wildcard command line processing is enabled by default. */
/*
#undef _CRT_glob
#define _CRT_glob -1
*/
int _dowildcard = -1;
/*****************************************************************************/
/*****************************************************************************/
/**
* Main
*/
int main(int argc, char **argv)
{
int ai, help=0, version=0, verbose=1;
char parfile[FILENAME_MAX], aucfile[FILENAME_MAX];
double starttime=nan("");
/*
* Get arguments
*/
if(argc==1) {tpcPrintUsage(argv[0], info, stderr); return(1);}
parfile[0]=aucfile[0]=(char)0;
/* Options */
for(ai=1; ai<argc; ai++) if(*argv[ai]=='-') {
if(tpcProcessStdOptions(argv[ai], &help, &version, &verbose)==0) continue;
char *cptr=argv[ai]+1; if(*cptr=='-') cptr++; if(!*cptr) continue;
fprintf(stderr, "Error: invalid option '%s'.\n", argv[ai]);
return(1);
} else break;
TPCSTATUS status; statusInit(&status);
statusSet(&status, __func__, __FILE__, __LINE__, TPCERROR_OK);
status.verbose=verbose-3;
/* Print help or version? */
if(help==2) {tpcHtmlUsage(argv[0], info, ""); return(0);}
if(help) {tpcPrintUsage(argv[0], info, stdout); return(0);}
if(version) {tpcPrintBuild(argv[0], stdout); return(0);}
/* Process other arguments, starting from the first non-option */
if(ai<argc) strlcpy(parfile, argv[ai++], FILENAME_MAX);
if(ai<argc) {
starttime=atofVerified(argv[ai]);
if(starttime>=0.0) {ai++;}
else {fprintf(stderr, "Error: invalid start time '%s'.\n", argv[ai]); return(1);}
}
if(ai<argc) strlcpy(aucfile, argv[ai++], FILENAME_MAX);
if(ai<argc) {
fprintf(stderr, "Error: invalid argument '%s'.\n", argv[ai]);
return(1);
}
/* Did we get all the information that we need? */
if(!(starttime>=0.0)) {
fprintf(stderr, "Error: missing command-line argument; use option --help\n");
return(1);
}
/* In verbose mode print arguments and options */
if(verbose>1) {
printf("parfile := %s\n", parfile);
printf("starttime := %g\n", starttime);
if(aucfile[0]) printf("aucfile := %s\n", aucfile);
fflush(stdout);
}
return(0);
}
/*****************************************************************************/
/*****************************************************************************/
/// @endcond
# Injection time: 05.05.2004 11:10:32
# Isotope: F-18
# Radiopharmaceutical: FDG
# Calibration coefficient: 0.002870
# Activity units: kBq/mL
# Time units: min
0.250 0.001
0.500 0.001
0.667 2.212
1.000 14.487
1.167 18.996
1.417 19.889
1.750 22.802
2.250 23.141
2.583 20.601
2.917 18.749
3.000 17.612
4.000 15.197
5.250 12.703
7.083 11.007
7.700 8.005
12.133 5.538
18.833 3.387
30.250 2.025
45.750 1.092
48.467 0.776
65.433 0.688
73.983 0.382
85.133 0.378
95.667 0.312
#!/bin/bash
#: Title : test_fit2auc
#: Date : 2021-02-03
#: Author : "Vesa Oikonen" <vesa.oikonen@utu.fi>
#: Options : None
# Set the name of executable to test
if [ -n "${OS+1}" ] && [ "$OS" = "Windows_NT" ]; then
EXT=.exe;
else
EXT=;
fi
PROGRAM=../../fit2auc$EXT;
if [ ! -f $PROGRAM ]; then
printf "Failed: executable does not exist.\n"
exit 1
fi
printf "=====================================================================\n"
printf "creating test data for %s\n" $PROGRAM
printf "=====================================================================\n"
printf "\n verifying that required data exists \n"
if [ ! -f s6910vp.kbq ]; then
printf "Failed: missing test data file.\n"
exit 1
fi
printf "\n fit bi-exponential function to late part of venous FDG PTAC \n"
taccut s6910vp.kbq 10 120 s6910vp_cut.kbq
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
fit_dexp -2 -w1 s6910vp_cut.kbq s6910vp.fit
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
fit2dat -a=100 s6910vp.fit s6910vp_fit.kbq
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
tac2svg -x1=0 -y1=0 -legend=no s6910vp.svg -s s6910vp.kbq -l s6910vp_fit.kbq
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
printf "\n\n"
printf "=====================================================================\n"
printf "testing %s\n" $PROGRAM
printf "=====================================================================\n"
printf "\n 1.0.0 \n"
printf " Test case: Actual plasma TAC, fitted with bi-exponential. \n"
printf " Expected result: close to correct AUC is obtained. \n\n"
printf "\n Start time: 0 \n"
rm -f output0.par
$PROGRAM s6910vp.fit 0 output0.par
if [ $? -ne 0 ] ; then printf "Failed!\n" ; exit 1 ; fi
printf "\n ok \n"
printf "\n passed. \n\n"
printf "\n===================================================================\n"
printf " All passed! \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