10#include "tpcclibConfig.h"
26static char *info[] = {
27 "Constructs a Scan Information File (SIF) from specified dynamic image",
28 "in ECAT, Analyze, or NIfTI format, or sinogram in ECAT format,",
29 "for providing weighting information to modelling software.",
30 "SIF can also be used with Analyze and NIfTI image formats to retain",
31 "the frame time information.",
32 "Note that the count values in the resulting SIF file are not the same as",
33 "the values in SIF file retrieved from the scanner data, but similar",
34 "enough for usual purposes.",
36 "Usage: @P [-Options] petfile sif",
42 " @P ub7761dy1.v ub7761dy1.sif",
44 "See also: eframe, tacweigh, imgthrs, imghead, tacframe, simframe",
46 "Keywords: image, SIF, weighting, time, ECAT, NIfTI, Analyze",
65int main(
int argc,
char **argv)
67 int ai, help=0, version=0, verbose=1;
69 char *cptr, petfile[FILENAME_MAX], siffile[FILENAME_MAX];
74 if(argc==1) {
tpcPrintUsage(argv[0], info, stderr);
return(1);}
75 petfile[0]=siffile[0]=(char)0;
77 for(ai=1; ai<argc; ai++)
if(*argv[ai]==
'-') {
78 cptr=argv[ai]+1;
if(*cptr==
'-') cptr++;
if(cptr==NULL)
continue;
81 fprintf(stderr,
"Error: invalid option '%s'.\n", argv[ai]);
86 if(help==2) {
tpcHtmlUsage(argv[0], info,
"");
return(0);}
91 if(ai<argc) {
strlcpy(petfile, argv[ai], FILENAME_MAX); ai++;}
92 if(ai<argc) {
strlcpy(siffile, argv[ai], FILENAME_MAX); ai++;}
93 if(ai<argc) {fprintf(stderr,
"Error: too many arguments.\n");
return(1);}
97 fprintf(stderr,
"Error: missing command-line argument; use option --help\n");
100 if(strcasecmp(petfile, siffile)==0) {
101 fprintf(stderr,
"Error: check the output filename.\n");
108 printf(
"petfile := %s\n", petfile);
109 printf(
"siffile := %s\n", siffile);
118 if(verbose>0) printf(
"reading PET data\n");
121 fprintf(stderr,
"Error: %s\n",
imgStatus(ret));
125 if(verbose>1) printf(
"frame_nr := %d\n", img.
dimt);
129 fprintf(stderr,
"Error: %s is not an image or scan file.\n", petfile);
136 if(verbose>0) printf(
"computing SIF\n");
137 ret=
img2sif(&img, &sif, 1, 1, 2, 2);
139 fprintf(stderr,
"Error: cannot create SIF from %s.\n", petfile);
150 if(verbose>1) printf(
"writing SIF\n");
152 fprintf(stderr,
"Error in writing '%s': %s\n", siffile,
siferrmsg);
155 if(verbose>0) fprintf(stderr,
"SIF data written in %s\n", siffile);
char * imgStatus(int status_index)
void imgEmpty(IMG *image)
int img2sif(IMG *img, SIF *sif, int copy_header, int copy_frames, int copy_counts, int verbose)
int imgRead(const char *fname, IMG *img)
Header file for libtpcimgio.
int sifWrite(SIF *data, char *filename)
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)