TPCCLIB
|
I/O routines for IMG data. More...
#include "libtpcimgio.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 format) |
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) |
int | imgFormatDetermine (const char *fname, char *basename, char *hdrfile, char *imgfile, char *siffile, int *file_format, int *scanner, int *type, int *modality, int verbose) |
I/O routines for IMG data.
Currently supported file formats:
Definition in file imgfile.c.
int imgFormatDetermine | ( | const char * | fname, |
char * | basename, | ||
char * | hdrfile, | ||
char * | imgfile, | ||
char * | siffile, | ||
int * | file_format, | ||
int * | scanner, | ||
int * | type, | ||
int * | modality, | ||
int | verbose ) |
Determine the file format and type of an existing PET image data.
Note that this function only identifies those formats and types that were needed in TPC at the time of writing this function. Note also that this function does not care whether the format is fully or not at all supported by other library functions.
fname | Full name of image file. In case of Analyze or microPET image, hdr or img file name, or basename without extension is accepted. Pathname is not accepted. |
basename | Pointer to allocated string where image file name without extensions is written (only for Analyze and microPET); enter NULL, if not needed. |
hdrfile | Pointer to allocated string where header file name without extensions is written (only for Analyze and microPET); enter NULL, if not needed. |
imgfile | Pointer to allocated string where image data file name without extensions is written (only for Analyze and microPET); enter NULL, if not needed. |
siffile | Pointer to allocated string where SIF file name without extensions is written (only for Analyze), if available; enter NULL, if not needed. |
file_format | Pointer to int where image format ID is written; 0=unknown, for other formats see definitions in img.h |
scanner | Pointer to int where scanner ID is written; 0=unknown, for other formats see definitions in img.h |
type | Pointer to int where image type is written; 0=unknown, 1=image, 2=sinogram, 3=polarmap, please check definitions in img.h |
modality | Pointer to int where modality is written; 0=unknown, 1=PET, 2=MRI, 3=CT, ..., please check definitions in img.h |
verbose | Verbose level; if zero, then nothing is printed into stdout or stderr |
Definition at line 536 of file imgfile.c.
Referenced by imgReadHeader().
void imgFormatFromFName | ( | IMG * | img, |
const char * | fname ) |
Determine IMG _fileFormat from file name extension, if not already defined. Default is ECAT 7 image volume, if nothing else can be guessed.
Note that NIfTI dual file format, Analyze, and microPET files can not be separated by file naming, thus all of these formats will be identified as Analyze by this function (default may be changed to NIfTI in future).
img | Target image structure where file format is saved; should have IMG_UNKNOWN as file type. |
fname | Name of file that is used to determine format. |
Definition at line 483 of file imgfile.c.
Referenced by imgWrite(), and imgWriteFrame().
int imgRead | ( | const char * | fname, |
IMG * | img ) |
Read an image or sinogram file in ECAT 6.3 or ECAT 7.x format, or image in NIfTI-1, Analyze 7.5, or microPET format.
fname | Input filename. |
img | Pointer to initialized IMG structure. |
Definition at line 26 of file imgfile.c.
Referenced by imgReadModelingData().
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 NIfTI-1, Analyze 7.5, and microPET 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 269 of file imgfile.c.
Referenced by imgReadMinMax().
int imgReadHeader | ( | const char * | fname, |
IMG * | img, | ||
int | format ) |
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 file name |
img | Pointer to initialized but not allocated IMG structure. |
format | Image file format, if known (IMG_E63, IMG_E7, ...); if not known, set to IMG_UNKNOWN or 0. |
Definition at line 199 of file imgfile.c.
Referenced by imgReadFrame().
int imgWrite | ( | const char * | fname, |
IMG * | img ) |
Write an image or sinogram file.
Format depends on _fileFormat or file name extension.
fname | File name for output image. |
img | Pointer to IMG data. |
Definition at line 136 of file imgfile.c.
Referenced by imgMicropetCTToEcat7().
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.
Currently supported file formats are ECAT 6.3 images and sinograms, and ECAT 7.x 2D and 3D images and sinograms, and NIfTI-1 images. Analyze 7.5 images are NOT supported (because global min and max would be needed). SIF for NIfTI-1 files is not written by this function.
fname | Name of file where IMG contents will be written. 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 structure. |
frame_index | IMG frame index (0..dimt-1) which will be written. |
Definition at line 392 of file imgfile.c.
Referenced by imgAnalyzeToEcat(), imgMicropetPETToEcat7(), and imgNiftiToEcat().