8#include "tpcclibConfig.h"
23static char *info[] = {
24 "Convert PET image data in filename1 into filename2",
25 "in specified file format.",
26 "Data can be written only in a few formats (listed below), but more",
27 "file formats can be read.",
29 "Usage: @P [options] filename1 [filename2]",
33 " Accepted format-id's:",
34 " FLAT - Pixel values are written to binary flat file as 32-bit",
35 " floating point values in order t,z,y,x.",
36 " NIFTI1 - NIfTI-1 single file format.",
37 " Without this option, only the format of the given image is shown.",
40 "See also: tacformat, img2flat, e63to7, ecat2ana, ecat2nii",
42 "Keywords: image, tool, format",
61int main(
int argc,
char **argv)
63 int ai, help=0, version=0, verbose=1;
66 char imgfile1[FILENAME_MAX], imgfile2[FILENAME_MAX];
72 if(argc==1) {
tpcPrintUsage(argv[0], info, stderr);
return(1);}
73 imgfile1[0]=imgfile2[0]=(char)0;
75 for(ai=1; ai<argc; ai++)
if(*argv[ai]==
'-') {
77 char *cptr=argv[ai]+1;
if(*cptr==
'-') cptr++;
if(!*cptr)
continue;
78 if(strncasecmp(cptr,
"F=", 2)==0) {
81 }
else if(strncasecmp(cptr,
"FORMAT=", 7)==0) {
85 fprintf(stderr,
"Error: invalid option '%s'.\n", argv[ai]);
90 if(help==2) {
tpcHtmlUsage(argv[0], info,
"");
return(0);}
95 if(ai<argc)
strlcpy(imgfile1, argv[ai++], FILENAME_MAX);
96 if(ai<argc)
strlcpy(imgfile2, argv[ai++], FILENAME_MAX);
97 if(ai<argc) {fprintf(stderr,
"Error: too many arguments: '%s'.\n", argv[ai]);
return(1);}
99 if(!imgfile1[0]) {
tpcPrintUsage(argv[0], info, stdout);
return(1);}
104 printf(
"imgfile1 := %s\n", imgfile1);
105 if(imgfile2[0]) printf(
"imgfile2 := %s\n", imgfile2);
116 if(verbose>1) {printf(
"reading %s\n", imgfile1); fflush(stdout);}
118 ret=
imgRead(&img, imgfile1, &status);
123 fprintf(stderr,
"Error: %s (%s)\n",
errorMsg(status.
error), imgfile1); fflush(stderr);
129 fprintf(stderr,
"Error: %s (%s)\n",
errorMsg(status.
error), imgfile1); fflush(stderr);
146 strcpy(imgfile2, imgfile1);
150 printf(
"imgfile2 := %s\n", imgfile2);
156 if(verbose>1) {printf(
"writing %s\n", imgfile2); fflush(stdout);}
158 ret=
imgWrite(&img, imgfile2, &status);
160 fprintf(stderr,
"Error: writing format %s is not supported.\n",
tacFormattxt(new_format));
164 fprintf(stderr,
"Error: %s\n",
errorMsg(status.
error)); fflush(stderr);
167 if(verbose>0) {printf(
" %s written.\n", imgfile2); fflush(stdout);}
void filenameRmPath(char *s)
int filenameRmExtension(char *s)
void imgContents(IMG *img, FILE *fp)
imgformat imgFormatFromFName(const char *fname, TPCSTATUS *status)
int imgRead(IMG *img, const char *fname, TPCSTATUS *status)
imgformat imgFormatIdentify(const char *s)
int imgWrite(IMG *img, const char *fname, TPCSTATUS *status)
char * imgFormatDescr(imgformat c)
char * imgDefaultExtension(imgformat c)
int tpcProcessStdOptions(const char *s, int *print_usage, int *print_version, int *verbose_level)
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)
void statusInit(TPCSTATUS *s)
char * errorMsg(tpcerror e)
void statusSet(TPCSTATUS *s, const char *func, const char *srcfile, int srcline, tpcerror error)
size_t strlcpy(char *dst, const char *src, size_t dstsize)
int verbose
Verbose level, used by statusPrint() etc.
tpcerror error
Error code.
char * tacFormattxt(tacformat c)
Header file for library libtpccsv.
Header file for library libtpcextensions.
@ TPCERROR_UNSUPPORTED
Unsupported file type.
Header file for library libtpcift.
Header file for libtpcimage.
@ IMG_FORMAT_UNKNOWN
Unknown format.
Header file for library libtpctac.