#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include "petc99.h"
#include "swap.h"
#include "halflife.h"
#include "substitutions.h"
#include "include/img.h"
#include "include/ecat63.h"
#include "include/ecat7.h"
#include "include/analyze.h"
#include "include/imgmax.h"
#include "include/imgdecay.h"
#include "include/sif.h"
#include "include/imgfile.h"
Go to the source code of this file.
Functions | |
int | imgRead (const char *fname, IMG *img) |
int | imgWrite (const char *fname, IMG *img) |
int | imgReadHeader (const char *fname, IMG *img) |
int | imgReadFrame (const char *fname, int frame_to_read, IMG *img, int frame_index) |
int | imgWriteFrame (const char *fname, int frame_to_write, IMG *img, int frame_index) |
void | imgFormatFromFName (IMG *img, const char *fname) |
void imgFormatFromFName | ( | IMG * | img, |
const char * | fname | ||
) |
Determine IMG _fileFormat from filename extension, if not already defined. Default if ECAT 7 image volume, if nothing else can be guessed.
img | target image struture where fileformat is saved, should have IMG_UNKNOWN as file type |
fname | name of file that is detemined |
Definition at line 547 of file imgfile.c.
References IMG::_fileFormat, IMG_ANA, IMG_E63, IMG_E7, IMG_POLARMAP, and IMG_UNKNOWN.
Referenced by imgWrite(), and imgWriteFrame().
Read an image or sinogram file in ECAT 6.3, ECAT 7.x or Analyze 7.5 format.
fname | input filename |
img | pointer to initialized IMG structure |
Definition at line 190 of file imgfile.c.
References anaExists(), ecat63errmsg, ecat63ReadAllToImg(), ecat63ReadMainheader(), ecat7filetype(), ecat7ReadMainheader(), ECAT7V_MAGICNR, ecat63_mainheader::file_type, ecat7_mainheader::file_type, IMG_STATUS_INITIALIZED, IMG_TEST, imgEcat7Supported(), imgReadAnalyze(), imgReadEcat7(), imgStatus(), ecat7_mainheader::magic_number, IMG::statmsg, IMG::status, STATUS_FAULT, STATUS_MISSINGMATRIX, STATUS_NOFILE, STATUS_OK, STATUS_UNKNOWNFORMAT, and STATUS_UNSUPPORTED.
Referenced by test_img_io(), and test_polarmap_io().
int imgReadFrame | ( | const char * | fname, |
int | frame_to_read, | ||
IMG * | img, | ||
int | frame_index | ||
) |
Read one time frame from a supported PET image or sinogram file into IMG data structure. This functions can be called repeatedly to read all the frames one at a time to conserve memory.
fname | name of file from which IMG contents will be read. Currently supported file formats are ECAT 6.3 images and sinograms, ECAT 7.x 2D and 3D images and sinograms, and Analyze 7.5 3D and 4D images. |
frame_to_read | frame which will be read [1..frameNr] |
img | pointer to initiated or occupied IMG data. If occupied, then new frame is tested to match the previous file type, dimensions, and other fundamental information contained in the IMG. If not occupied, then memory is allocated here. |
frame_index | IMG frame index (0..dimt-1) where data will be placed. If index is >0, then the memory for that frame must be allocated before calling this function. |
Definition at line 389 of file imgfile.c.
References IMG::_fileFormat, IMG::dimt, IMG::dimx, IMG::dimy, IMG::dimz, IMG_ANA, IMG_ANA_L, IMG_E63, IMG_E7, IMG_E7_2D, IMG_POLARMAP, IMG_STATUS_INITIALIZED, IMG_STATUS_OCCUPIED, IMG_TEST, imgAllocate(), imgEmpty(), imgInfo(), imgInit(), imgReadAnalyzeFrame(), imgReadEcat63Frame(), imgReadEcat7Frame(), imgReadHeader(), imgSetStatus(), IMG::statmsg, IMG::status, STATUS_FAULT, STATUS_INVALIDHEADER, STATUS_NOMEMORY, STATUS_UNSUPPORTED, and IMG::type.
Referenced by imgReadMinMax().
int imgReadHeader | ( | const char * | fname, |
IMG * | img | ||
) |
Fill IMG struct header information from an image or sinogram file in ECAT 6.3, ECAT 7.x or Analyze 7.5 format. Information concerning separate frames or planes is not filled.
fname | image or sinogram filename |
img | pointer to initialized but not allocated IMG structure |
Definition at line 329 of file imgfile.c.
References anaDatabaseExists(), IMG_STATUS_INITIALIZED, IMG_TEST, imgReadAnalyzeHeader(), imgReadEcat63Header(), imgReadEcat7Header(), imgSetStatus(), IMG::status, STATUS_FAULT, STATUS_OK, and STATUS_UNKNOWNFORMAT.
Referenced by imgReadFrame().
Write an image or sinogram file. Format depends on _fileFormat or filename extension.
fname | output filename |
img | pointer to IMG data |
Definition at line 277 of file imgfile.c.
References IMG::_fileFormat, ecat63WriteAllImg(), IMG_ANA, IMG_ANA_L, IMG_E63, IMG_E7_2D, IMG_POLARMAP, IMG_STATUS_OCCUPIED, IMG_TEST, IMG_TYPE_IMAGE, IMG_TYPE_POLARMAP, IMG_TYPE_RAW, IMG_UNKNOWN, imgFormatFromFName(), imgSetStatus(), imgWrite2DEcat7(), imgWriteAnalyze(), imgWriteEcat7(), imgWritePolarmap(), IMG::status, STATUS_DISKFULL, STATUS_FAULT, STATUS_NOMEMORY, STATUS_NOWRITEPERM, STATUS_OK, and IMG::type.
Referenced by imgMicropetCTToEcat7(), test_img_io(), and test_polarmap_io().
int imgWriteFrame | ( | const char * | fname, |
int | frame_to_write, | ||
IMG * | img, | ||
int | frame_index | ||
) |
Write one PET frame from IMG data struct into a supported PET image or sinogram file. This function can be called repeatedly to write all frames one at a time to conserve memory.
fname | name of file where IMG contents will be written. Currently supported file formats are ECAT 6.3 images and sinograms, and ECAT 7.x 2D and 3D images and sinograms. Analyze 7.5 images are NOT supported. If file exists, data is either overwritten or catenated as a new frame, depending on the following arguments. If file does not exist, it is created. |
frame_to_write | PET frame number (1..frameNr) which will be written: If set to 0, frame data will be written to an existing or new PET file as a new frame, never overwriting existing data. If >0, then frame data is written as specified frame number, overwriting any data existing with the same frame number |
img | pointer to the IMG data struct |
frame_index | IMG frame index (0..dimt-1) which will be written. |
Definition at line 493 of file imgfile.c.
References IMG::_fileFormat, IMG::dimt, IMG_ANA, IMG_ANA_L, IMG_E63, IMG_E7, IMG_E7_2D, IMG_POLARMAP, IMG_STATUS_OCCUPIED, IMG_TEST, imgFormatFromFName(), imgSetStatus(), imgWriteEcat63Frame(), imgWriteEcat7Frame(), IMG::status, STATUS_FAULT, and STATUS_UNSUPPORTED.
Referenced by imgMicropetPETToEcat7().