8#include "tpcclibConfig.h"
23static char *info[] = {
24 "Conversion of Siemens Inveon/MicroPET CT or PET image to ECAT 7",
25 "image volume format.",
26 "MicroPET image consists of two files with extension .img and img.hdr;",
27 "both are required in conversion.",
28 "Note that also Analyze and dual file format NIfTI images consist",
29 "of equally named two files.",
31 "Usage: @P [Options] <MicroPET image> [ECAT filename]",
37 " @P ae72.pet.img ae72.v",
39 "See also: upet2sif, nii2ecat, ana2ecat, flat2img, img2flat",
41 "Keywords: image, format conversion, MicroPET, Inveon",
60int main(
int argc,
char *argv[])
62 int ai, help=0, version=0, verbose=1;
64 char ecatfile[FILENAME_MAX], upetname[FILENAME_MAX];
71 if(argc==1) {
tpcPrintUsage(argv[0], info, stderr);
return(1);}
72 upetname[0]=ecatfile[0]=(char)0;
74 for(ai=1; ai<argc; ai++)
if(*argv[ai]==
'-') {
75 cptr=argv[ai]+1;
if(*cptr==
'-') cptr++;
if(cptr==NULL)
continue;
77 fprintf(stderr,
"Error: invalid option '%s'\n", argv[ai]);
82 if(help==2) {
tpcHtmlUsage(argv[0], info,
"");
return(0);}
87 if(ai<argc) {
strlcpy(upetname, argv[ai++], FILENAME_MAX);}
88 if(ai<argc) {
strlcpy(ecatfile, argv[ai++], FILENAME_MAX);}
89 if(ai<argc) {fprintf(stderr,
"Error: too many arguments.\n");
return(1);}
93 fprintf(stderr,
"Error: missing command-line argument; use option --help\n");
99 printf(
"upetname := %s\n", upetname);
100 if(ecatfile[0]) printf(
"ecatfile := %s\n", ecatfile);
107 char upetheader[FILENAME_MAX], upetimage[FILENAME_MAX];
108 ret=
upetExists(upetname, upetheader, upetimage, verbose-1);
110 fprintf(stderr,
"Error: %s does not exist or is not Inveon/MicroPET image.\n",
114 fprintf(stderr,
"Error: Inveon/MicroPET image %s not found.\n",
119 printf(
"upetheader := %s\n", upetheader);
120 printf(
"upetimage := %s\n", upetimage);
125 strcpy(ecatfile, upetimage);
126 cptr=strrchr(ecatfile,
'.');
128 if(strncasecmp(cptr,
".IMG", 4)==0) *cptr=(char)0;
130 strcat(ecatfile,
".v");
131 if(verbose>1) printf(
"ecatfile := %s\n", ecatfile);
138 fprintf(stdout,
" converting %s ...\n", upetname);
143 fprintf(stderr,
"Error: %s\n",
imgStatus(ret));
147 fprintf(stdout,
" Image saved in ECAT format in %s\n", ecatfile);
char * imgStatus(int status_index)
int imgMicropetToEcat7(char *upetname, char *ecatfile, int verbose)
Header file for libtpcimgio.
int upetExists(const char *upetname, char *hdrfile, char *imgfile, int verbose)
Header file for libtpcimgp.
Header file for libtpcmisc.
int tpcProcessStdOptions(const char *s, int *print_usage, int *print_version, int *verbose_level)
size_t strlcpy(char *dst, const char *src, size_t dstsize)
int tpcHtmlUsage(const char *program, char *text[], const char *path)
void tpcPrintBuild(const char *program, FILE *fp)
void tpcPrintUsage(const char *program, char *text[], FILE *fp)