TPCCLIB
Loading...
Searching...
No Matches
ana2ecat.c File Reference

Convert Analyze 7.5 image format to ECAT 6.3 or 7. More...

Go to the source code of this file.

Functions

int imgAnalyzeToEcat (char *dbname, char *ecatfile, int flipping, int scanner_type, float zoom, int verbose)

Detailed Description

Convert Analyze 7.5 image format to ECAT 6.3 or 7.

Author
Vesa Oikonen

Definition in file ana2ecat.c.

Function Documentation

◆ imgAnalyzeToEcat()

int imgAnalyzeToEcat ( char * dbname,
char * ecatfile,
int flipping,
int scanner_type,
float zoom,
int verbose )

Read Analyze database and write ECAT image frame-by-frame

Returns
Returns errstatus, which is STATUS_OK (0) when call was successful, and >0 in case of an error.
Parameters
dbnameAnalyze database name
ecatfileECAT image filename, output extension determines the format
flippingFlipping in Z dimension (usually 1=yes)
scanner_typeScanner type, 0 if not set
zoomrecon_zoom, 0.0 or 1.0, if not known
verboseVerbose level; if <=0 then nothing is printed in stdout

Definition at line 362 of file ana2ecat.c.

375 {
376 IMG img;
377 int zi, fi, ret, file_format=0;
378
379 if(verbose>0) printf("\nimgAnalyzeToEcat(%s, %s)\n", dbname, ecatfile);
380 /* Check the arguments */
381 if(dbname==NULL || ecatfile==NULL) return STATUS_FAULT;
382
383 /* Read the first frame */
384 imgInit(&img); fi=0;
385 ret=imgReadAnalyzeFirstFrame(dbname, &img);
386 if(ret!=STATUS_OK) {imgEmpty(&img); return ret;}
387 do {
388 fi++;
389 if(verbose>1) printf(" frame %d\n", fi);
390 /* Set header information */
391 if(fi==0) // must be saved for reading next frame
392 file_format=img._fileFormat;
393 if(scanner_type>0) imgSetScanner(&img, scanner_type);
394 if(zoom>0.0) img.zoom=zoom;
395 for(zi=0; zi<img.dimz; zi++) img.planeNumber[zi]=zi+1;
396 if(verbose>10) imgInfo(&img);
397 if(flipping!=anaFlipping()) imgFlipPlanes(&img);
398 /* Write the frame in ECAT format */
399 img._fileFormat=0;
400 ret=imgWriteFrame(ecatfile, fi, &img, 0); //printf("ret := %d\n", ret);
401 if(ret!=STATUS_OK) break;
402 if(verbose>2) printf(" frame written.\n");
403 /* Try to read the next frame */
404 img._fileFormat=file_format;
405 ret=imgReadAnalyzeFrame(dbname, fi+1, &img, 0);
406 } while(ret==0);
407 imgEmpty(&img);
408 if(verbose>0 && ret==STATUS_NOMATRIX) {
409 fprintf(stdout, " %d frame(s) processed.\n", fi);
410 }
411 if(ret!=STATUS_OK && ret!=STATUS_NOMATRIX) {
412 remove(ecatfile); return ret;
413 }
414 /*if(verbose>2)
415 fprintf(stdout, " Image saved in ECAT format in %s\n", ecatfile);*/
416 return STATUS_OK;
417}
int anaFlipping()
Definition analyze.c:635
void imgInfo(IMG *image)
Definition img.c:359
void imgEmpty(IMG *image)
Definition img.c:121
void imgInit(IMG *image)
Definition img.c:60
int imgReadAnalyzeFirstFrame(const char *fname, IMG *img)
Definition img_ana.c:592
int imgReadAnalyzeFrame(const char *fname, int frame_to_read, IMG *img, int frame_index)
Definition img_ana.c:639
int imgWriteFrame(const char *fname, int frame_to_write, IMG *img, int frame_index)
Definition imgfile.c:392
void imgFlipPlanes(IMG *img)
Definition imgflips.c:55
int imgSetScanner(IMG *img, int scanner_type)
Definition imgscanner.c:14
int _fileFormat
int * planeNumber
unsigned short int dimz
float zoom

Referenced by imgAnalyzeToEcat().