9#include "tpcclibConfig.h"
23static char *info[] = {
24 "List the matrices of a PET image in DICOM format.",
26 "NOT for production use!",
28 "Usage: @P [-Options] dicomfile",
32 " List (y, default) or do not list (n) the plane (slice) number.",
34 " List (y, default) or do not list (n) the frame number.",
36 " List (y, default) or do not list (n) the frame start time.",
38 " List (y, default) or do not list (n) the frame duration.",
40 " List (y) or do not list (n, default) the acquisition date.",
42 " List (y, default) or do not list (n) the acquisition time.",
44 " List (y, default) or do not list (n) the file name.",
47 "See also: dcmlhdr, dcmframe",
49 "Keywords: image, DICOM",
68int main(
int argc,
char **argv)
70 int ai, help=0, version=0, verbose=1;
71 char dcmfile[FILENAME_MAX];
85 if(argc==1) {
tpcPrintUsage(argv[0], info, stderr);
return(1);}
88 for(ai=1; ai<argc; ai++)
if(*argv[ai]==
'-') {
90 char *cptr; cptr=argv[ai]+1;
if(*cptr==
'-') cptr++;
if(!*cptr)
continue;
91 if(strncasecmp(cptr,
"PLANE=", 6)==0) {
92 if((listPlane=
tpcYesNo(cptr+6))>=0)
continue;
93 }
else if(strncasecmp(cptr,
"FRAME=", 6)==0) {
94 if((listFrame=
tpcYesNo(cptr+6))>=0)
continue;
95 }
else if(strncasecmp(cptr,
"FRAMESTART=", 11)==0) {
96 if((listFrameStart=
tpcYesNo(cptr+11))>=0)
continue;
97 }
else if(strncasecmp(cptr,
"FRAMEDUR=", 9)==0) {
98 if((listFrameDur=
tpcYesNo(cptr+9))>=0)
continue;
99 }
else if(strncasecmp(cptr,
"ACQDATE=", 8)==0) {
100 if((listAcqDate=
tpcYesNo(cptr+8))>=0)
continue;
101 }
else if(strncasecmp(cptr,
"ACQTIME=", 8)==0) {
102 if((listAcqTime=
tpcYesNo(cptr+8))>=0)
continue;
103 }
else if(strncasecmp(cptr,
"FILENAME=", 9)==0) {
104 if((listFilename=
tpcYesNo(cptr+9))>=0)
continue;
106 fprintf(stderr,
"Error: invalid option '%s'.\n", argv[ai]);
115 if(help==2) {
tpcHtmlUsage(argv[0], info,
"");
return(0);}
120 if(ai<argc)
strlcpy(dcmfile, argv[ai++], FILENAME_MAX);
122 fprintf(stderr,
"Error: invalid argument '%s'.\n", argv[ai]);
127 fprintf(stderr,
"Error: missing command-line argument; use option --help\n");
133 printf(
"dcmfile := %s\n", dcmfile);
134 printf(
"listPlane := %d\n", listPlane);
135 printf(
"listFrame := %d\n", listFrame);
136 printf(
"listFrameStart := %d\n", listFrameStart);
137 printf(
"listFrameDur := %d\n", listFrameDur);
138 printf(
"listAcqDate := %d\n", listAcqDate);
139 printf(
"listAcqTime := %d\n", listAcqTime);
140 printf(
"listFilename := %d\n", listFilename);
152 if(verbose>1) {printf(
"fileNr := %d\n", fl.
keyNr); fflush(stdout);}
153 if(verbose>6)
iftWrite(&fl, stdout, NULL);
176 if(listPlane) {
if(col>0) {printf(
"\t");} printf(
"Plane"); col++;}
177 if(listFrame) {
if(col>0) {printf(
"\t");} printf(
"Frame"); col++;}
178 if(listFrameStart) {
if(col>0) {printf(
"\t");} printf(
"Start"); col++;}
179 if(listFrameDur) {
if(col>0) {printf(
"\t");} printf(
"Dur"); col++;}
180 if(listAcqDate) {
if(col>0) {printf(
"\t");} printf(
"AcqDate"); col++;}
181 if(listAcqTime) {
if(col>0) {printf(
"\t");} printf(
"AcqTime"); col++;}
182 if(listFilename) {
if(col>0) {printf(
"\t");} printf(
"File"); col++;}
184 fprintf(stderr,
"Error: all prints turned off by user.\n");
188 for(
unsigned int i=0; i<ml.
nr; i++) {
190 if(listPlane) {
if(col>0) {printf(
"\t");} printf(
"%u", ml.
m[i].
plane); col++;}
191 if(listFrame) {
if(col>0) {printf(
"\t");} printf(
"%u", ml.
m[i].
frame); col++;}
192 if(listFrameStart) {
if(col>0) {printf(
"\t");} printf(
"%g", ml.
m[i].
frameStart); col++;}
193 if(listFrameDur) {
if(col>0) {printf(
"\t");} printf(
"%g", ml.
m[i].
frameDur); col++;}
194 if(listAcqDate) {
if(col>0) {printf(
"\t");} printf(
"%s", ml.
m[i].
acqDate); col++;}
195 if(listAcqTime) {
if(col>0) {printf(
"\t");} printf(
"%s", ml.
m[i].
acqTime); col++;}
196 if(listFilename) {
if(col>0) {printf(
"\t");} printf(
"%s", ml.
m[i].
filename); col++;}
int dcmFileList(const char *filename, IFT *ift, TPCSTATUS *status)
List DICOM files belonging to one image.
int dcmMListRead(IFT *ift, DCMML *ml, TPCSTATUS *status)
int dcmmlSortByPlane(DCMML *d, TPCSTATUS *status)
int iftWrite(IFT *ift, FILE *fp, TPCSTATUS *status)
int tpcProcessStdOptions(const char *s, int *print_usage, int *print_version, int *verbose_level)
int tpcYesNo(const char *s)
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.
Header file for libtpcdcm.
Header file for library libtpcextensions.
Header file for library libtpctac.