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 355 of file ana2ecat.c.

368 {
369 IMG img;
370 int zi, fi, ret, file_format=0;
371
372 if(verbose>0) printf("\nimgAnalyzeToEcat(%s, %s)\n", dbname, ecatfile);
373 /* Check the arguments */
374 if(dbname==NULL || ecatfile==NULL) return STATUS_FAULT;
375
376 /* Read the first frame */
377 imgInit(&img); fi=0;
378 ret=imgReadAnalyzeFirstFrame(dbname, &img);
379 if(ret!=STATUS_OK) {imgEmpty(&img); return ret;}
380 do {
381 fi++;
382 if(verbose>1) printf(" frame %d\n", fi);
383 /* Set header information */
384 if(fi==0) // must be saved for reading next frame
385 file_format=img._fileFormat;
386 if(scanner_type>0) imgSetScanner(&img, scanner_type);
387 if(zoom>0.0) img.zoom=zoom;
388 for(zi=0; zi<img.dimz; zi++) img.planeNumber[zi]=zi+1;
389 if(verbose>10) imgInfo(&img);
390 if(flipping!=anaFlipping()) imgFlipPlanes(&img);
391 /* Write the frame in ECAT format */
392 img._fileFormat=0;
393 ret=imgWriteFrame(ecatfile, fi, &img, 0); //printf("ret := %d\n", ret);
394 if(ret!=STATUS_OK) break;
395 if(verbose>2) printf(" frame written.\n");
396 /* Try to read the next frame */
397 img._fileFormat=file_format;
398 ret=imgReadAnalyzeFrame(dbname, fi+1, &img, 0);
399 } while(ret==0);
400 imgEmpty(&img);
401 if(verbose>0 && ret==STATUS_NOMATRIX) {
402 fprintf(stdout, " %d frame(s) processed.\n", fi);
403 }
404 if(ret!=STATUS_OK && ret!=STATUS_NOMATRIX) {
405 remove(ecatfile); return ret;
406 }
407 /*if(verbose>2)
408 fprintf(stdout, " Image saved in ECAT format in %s\n", ecatfile);*/
409 return STATUS_OK;
410}
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