#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/sif.h"#include "include/ecat63.h"#include "include/ecat7.h"#include "include/analyze.h"#include "include/micropet.h"#include "include/interfile.h"#include "include/imgmax.h"#include "include/imgdecay.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) |
| int | imgFormatDetermine (const char *fname, char *basename, char *hdrfile, char *imgfile, char *siffile, int *file_format, int *scanner, int *type, int *modality, int verbose) |
| 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 filename, or basename without extension is accepted. Pathname is not accepted. |
| basename | Pointer to allocated string where image filename without extensions is written (only for Analyze and microPET); enter NULL, if not needed. |
| hdrfile | Pointer to allocated string where header filename without extensions is written (only for Analyze and microPET); enter NULL, if not needed. |
| imgfile | Pointer to allocated string where image data filename without extensions is written (only for Analyze and microPET); enter NULL, if not needed. |
| siffile | Pointer to allocated string where SIF filename 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 663 of file imgfile.c.
References IMG::_fileFormat, anaDatabaseExists(), IMG_ANA, IMG_DICOM, IMG_INTERFILE, IMG_MICROPET, IMG_MODALITY_UNKNOWN, IMG_TYPE_UNKNOWN, IMG_UNKNOWN, imgEmpty(), imgInit(), imgReadAnalyzeHeader(), imgReadEcat63Header(), imgReadEcat7Header(), imgReadMicropetHeader(), interfileExists(), IMG::modality, IMG::scanner, SCANNER_UNKNOWN, STATUS_FAULT, STATUS_NOFILE, STATUS_OK, STATUS_UNKNOWNFORMAT, IMG::type, and upetExists().
| 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. Note that Analyze and microPET files can not be separated by file naming, thus both formats will be identified as Analyze by this function.
| 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 619 of file imgfile.c.
References IMG::_fileFormat, IMG_ANA, IMG_DICOM, IMG_E63, IMG_E7, IMG_INTERFILE, 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 206 of file imgfile.c.
References anaExists(), anaExistsNew(), anaRemoveFNameExtension(), ecat63errmsg, ecat63ReadAllToImg(), ecat63ReadMainheader(), ecat7filetype(), ecat7ReadMainheader(), ECAT7V_MAGICNR, ecat63_mainheader::file_type, ecat7_mainheader::file_type, IMG_STATUS_INITIALIZED, IMG_TEST, imgEcat7Supported(), imgReadAnalyze(), imgReadEcat7(), imgReadMicropet(), imgStatus(), ecat7_mainheader::magic_number, IMG::statmsg, IMG::status, STATUS_FAULT, STATUS_MISSINGMATRIX, STATUS_NOFILE, STATUS_NOSIFDATA, STATUS_OK, STATUS_UNKNOWNFORMAT, STATUS_UNSUPPORTED, STATUS_WRONGSIFDATA, and upetExists().
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 455 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_MICROPET, IMG_POLARMAP, IMG_STATUS_INITIALIZED, IMG_STATUS_OCCUPIED, IMG_TEST, imgAllocate(), imgEmpty(), imgInfo(), imgInit(), imgReadAnalyzeFrame(), imgReadEcat63Frame(), imgReadEcat7Frame(), imgReadHeader(), imgReadMicropetFrame(), 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 379 of file imgfile.c.
References anaDatabaseExists(), IMG_STATUS_INITIALIZED, IMG_TEST, imgReadAnalyzeHeader(), imgReadEcat63Header(), imgReadEcat7Header(), imgReadMicropetHeader(), imgSetStatus(), interfileExists(), IMG::status, STATUS_FAULT, STATUS_OK, STATUS_UNKNOWNFORMAT, STATUS_UNSUPPORTED, and upetExists().
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 327 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 563 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().
1.8.0