Functions
img_e7.c File Reference
#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 "include/img.h"
#include "include/ecat7.h"
#include "include/imgmax.h"
#include "include/imgdecay.h"
#include "include/imgfile.h"
Include dependency graph for img_e7.c:

Go to the source code of this file.

Functions

int imgReadEcat7 (const char *fname, IMG *img)
int imgWriteEcat7 (const char *fname, IMG *img)
int imgWrite2DEcat7 (const char *fname, IMG *img)
int imgWritePolarmap (const char *fname, IMG *img)
void imgGetEcat7MHeader (IMG *img, ECAT7_mainheader *h)
void imgSetEcat7MHeader (IMG *img, ECAT7_mainheader *h)
int imgGetEcat7Fileformat (ECAT7_mainheader *h)
int imgReadEcat7Header (const char *fname, IMG *img)
int imgEcat7Supported (ECAT7_mainheader *h)
int imgReadEcat7FirstFrame (const char *fname, IMG *img)
int imgReadEcat7Frame (const char *fname, int frame_to_read, IMG *img, int frame_index)
int imgWriteEcat7Frame (const char *fname, int frame_to_write, IMG *img, int frame_index)
void imgSetEcat7SHeader (IMG *img, void *h)

Function Documentation

Check whether read functions in IMG library support this ECAT 7.x file_type.

Parameters:
hEcat7 main header
Returns:
1 if supported, 0 if not.

Definition at line 984 of file img_e7.c.

References ECAT7_2DSCAN, ECAT7_3DSCAN, ECAT7_3DSCAN8, ECAT7_3DSCANFIT, ECAT7_IMAGE16, ECAT7_IMAGE8, ECAT7_POLARMAP, ECAT7_VOLUME16, ECAT7_VOLUME8, and ecat7_mainheader::file_type.

Referenced by imgRead(), imgReadEcat7(), imgReadEcat7Frame(), and imgReadEcat7Header().

Return the IMG fileformat based on ECAT7 file_type.

Parameters:
hEcat7 main header
Returns:
IMG._fileFormat code value

Definition at line 794 of file img_e7.c.

References ECAT7_2DSCAN, ECAT7_3DSCAN, ECAT7_3DSCAN8, ECAT7_3DSCANFIT, ECAT7_IMAGE16, ECAT7_IMAGE8, ECAT7_POLARMAP, ECAT7_VOLUME16, ECAT7_VOLUME8, ecat7_mainheader::file_type, IMG_E7, IMG_E7_2D, IMG_POLARMAP, and IMG_UNKNOWN.

Referenced by imgReadEcat7Header().

void imgGetEcat7MHeader ( IMG img,
ECAT7_mainheader h 
)
int imgReadEcat7 ( const char *  fname,
IMG img 
)

Read ECAT 7 image, volume or 2D sinogram.

Parameters:
fnameinput filename
imginitialized IMG structure
Returns:
0 if ok, 1 invalid input, 2 image status is not 'initialized', 3 failed to open file fiel for reading, 4 recognize file, 5 file type not supported, 6 invalid matrix list, 7 invalid number of matrixes/frames, 8 variable matrix size, 9 failed to read header, 11 failed to allocate memory for data, 13 failed to read data

Definition at line 83 of file img_e7.c.

References IMG::_dataType, IMG::_fileFormat, ecat7_mainheader::bin_size, ecat7_imageheader::data_type, ecat7_scanheader::data_type, ecat7_2Dscanheader::data_type, ecat7_polmapheader::data_type, ecat7_scanheader::deadtime_correction_factor, ecat7_2Dscanheader::deadtime_correction_factor, ecat7_imageheader::decay_corr_fctr, IMG::decayCorrected, IMG::decayCorrFactor, ecat7_scanheader::delayed, IMG::dimt, IMG::dimx, IMG::dimy, IMG::dimz, ECAT7_2DSCAN, ECAT7_3DSCAN, ECAT7_3DSCAN8, ECAT7_3DSCANFIT, ecat7_id_to_val(), ECAT7_IMAGE16, ECAT7_IMAGE8, ECAT7_POLARMAP, ECAT7_VOLUME16, ECAT7_VOLUME8, ecat7CheckMatlist(), ecat7EmptyMatlist(), ecat7errmsg, ecat7InitMatlist(), ecat7PrintMatlist(), ecat7Read2DScanheader(), ecat7Read2DScanMatrix(), ecat7ReadImageheader(), ecat7ReadImageMatrix(), ecat7ReadMainheader(), ecat7ReadMatlist(), ecat7ReadPolarmapMatrix(), ecat7ReadPolmapheader(), ecat7ReadScanheader(), ecat7ReadScanMatrix(), ecat7SortMatlistByPlane(), ECAT7V_MAGICNR, ecat7_mainheader::ecat_calibration_factor, IMG::end, ECAT7_MatDir::endblk, ecat7_mainheader::file_type, ECAT7_Matval::frame, ecat7_imageheader::frame_duration, ecat7_2Dscanheader::frame_duration, ecat7_polmapheader::frame_duration, ecat7_imageheader::frame_start_time, ecat7_scanheader::frame_start_time, ecat7_2Dscanheader::frame_start_time, ecat7_polmapheader::frame_start_time, ECAT7_Matval::gate, ECAT7_MatDir::id, IMG_E7, IMG_E7_2D, IMG_POLARMAP, IMG_STATUS_INITIALIZED, IMG_TEST, IMG_TYPE_IMAGE, IMG_TYPE_POLARMAP, IMG_TYPE_RAW, IMG_UNKNOWN, imgAllocate(), imgEcat7Supported(), imgGetEcat7MHeader(), imgSetStatus(), IMG::m, ecat7_mainheader::magic_number, ECAT7_MATRIXLIST::matdir, ECAT7_MATRIXLIST::matrixNr, IMG::mid, ecat7_scanheader::num_angles, ecat7_2Dscanheader::num_angles, ecat7_imageheader::num_dimensions, ecat7_2Dscanheader::num_dimensions, ecat7_mainheader::num_frames, ecat7_mainheader::num_gates, ecat7_scanheader::num_r_elements, ecat7_2Dscanheader::num_r_elements, ecat7_polmapheader::num_rings, ecat7_scanheader::num_z_elements, ecat7_2Dscanheader::num_z_elements, ecat7_polmapheader::pixel_size, ECAT7_Matval::plane, IMG::planeNumber, IMG::prompts, ecat7_scanheader::prompts, IMG::randoms, ecat7_imageheader::recon_zoom, IMG::resolutionx, IMG::resolutiony, IMG::resolutionz, IMG::sampleDistance, ecat7_polmapheader::sectors_per_ring, IMG::sizex, IMG::sizey, IMG::sizez, IMG::start, IMG::status, STATUS_FAULT, STATUS_INVALIDMATLIST, STATUS_MISSINGMATRIX, STATUS_NOFILE, STATUS_NOMATRIX, STATUS_NOMEMORY, STATUS_NOSUBHEADER, STATUS_OK, STATUS_UNKNOWNFORMAT, STATUS_UNSUPPORTED, STATUS_VARMATSIZE, ECAT7_MatDir::strtblk, IMG::type, ecat7_imageheader::x_dimension, ecat7_imageheader::x_pixel_size, ecat7_imageheader::x_resolution, ecat7_scanheader::x_resolution, ecat7_imageheader::y_dimension, ecat7_imageheader::y_pixel_size, ecat7_imageheader::y_resolution, ecat7_imageheader::z_dimension, ecat7_imageheader::z_pixel_size, ecat7_imageheader::z_resolution, and IMG::zoom.

Referenced by imgRead().

Here is the call graph for this function:

int imgReadEcat7FirstFrame ( const char *  fname,
IMG img 
)

Read the first frame from an ECAT 7 file into IMG data structure.

Parameters:
fnamename of file from which IMG contents will be read
imgpointer to the initiated but not preallocated IMG data
Returns:
errstatus, which is STATUS_OK (0) when call was successful, and >0 in case of an error.

Definition at line 1008 of file img_e7.c.

References IMG::dimt, IMG::dimx, IMG::dimy, IMG::dimz, IMG_STATUS_INITIALIZED, IMG_TEST, imgAllocate(), imgInfo(), imgReadEcat7Frame(), imgReadEcat7Header(), imgSetStatus(), IMG::status, STATUS_FAULT, STATUS_NOMEMORY, and STATUS_OK.

Here is the call graph for this function:

int imgReadEcat7Frame ( const char *  fname,
int  frame_to_read,
IMG img,
int  frame_index 
)

Read a specified frame from an ECAT 7 file into preallocated IMG data structure. IMG header is assumed to be filled correctly before calling this function, except for information concerning separate planes and this frame, which is filled here. If frame does not exist, then and only then STATUS_NOMATRIX is returned.

Parameters:
fnamename of file from which IMG contents will be read
frame_to_readframe which will be read [1..frameNr]
imgpointer to the IMG data. Place for the frame must be preallocated
frame_indexIMG frame index [0..dimt-1] where data will be placed
Returns:
errstatus, which is STATUS_OK (0) when call was successful, and >0 in case of an error.

Definition at line 1051 of file img_e7.c.

References IMG::_fileFormat, ecat7_scanheader::deadtime_correction_factor, ecat7_2Dscanheader::deadtime_correction_factor, ecat7_imageheader::decay_corr_fctr, IMG::decayCorrFactor, ecat7_scanheader::delayed, ecat7_2Dscanheader::delayed, IMG::dimt, IMG::dimx, IMG::dimy, IMG::dimz, ecat7_id_to_val(), ecat7CheckMatlist(), ecat7EmptyMatlist(), ecat7GatherMatlist(), ecat7InitMatlist(), ecat7Read2DScanMatrix(), ecat7ReadImageMatrix(), ecat7ReadMainheader(), ecat7ReadMatlist(), ecat7ReadPolarmapMatrix(), ecat7ReadScanMatrix(), ecat7SortMatlistByFrame(), ECAT7V_MAGICNR, ecat7_mainheader::ecat_calibration_factor, IMG::end, ECAT7_MatDir::endblk, ECAT7_Matval::frame, ecat7_imageheader::frame_duration, ecat7_2Dscanheader::frame_duration, ecat7_polmapheader::frame_duration, ecat7_imageheader::frame_start_time, ecat7_scanheader::frame_start_time, ecat7_2Dscanheader::frame_start_time, ecat7_polmapheader::frame_start_time, ECAT7_Matval::gate, ECAT7_MatDir::id, IMG_E7_2D, IMG_STATUS_OCCUPIED, IMG_TEST, IMG_TYPE_IMAGE, IMG_TYPE_POLARMAP, imgEcat7Supported(), imgSetStatus(), IMG::m, ecat7_mainheader::magic_number, ECAT7_MATRIXLIST::matdir, ECAT7_MATRIXLIST::matrixNr, IMG::mid, ecat7_mainheader::num_frames, ecat7_mainheader::num_gates, ECAT7_Matval::plane, IMG::planeNumber, IMG::prompts, ecat7_scanheader::prompts, ecat7_2Dscanheader::prompts, IMG::randoms, IMG::start, IMG::status, STATUS_FAULT, STATUS_INVALIDMATLIST, STATUS_MISSINGMATRIX, STATUS_NOFILE, STATUS_NOMAINHEADER, STATUS_NOMATLIST, STATUS_NOMATRIX, STATUS_OK, STATUS_UNKNOWNFORMAT, STATUS_UNSUPPORTED, ECAT7_MatDir::strtblk, and IMG::type.

Referenced by imgReadEcat7FirstFrame(), and imgReadFrame().

Here is the call graph for this function:

int imgReadEcat7Header ( const char *  fname,
IMG img 
)

Fill IMG struct header information from an image or sinogram file in ECAT 7 format. Information concerning separate frames or planes is not filled.

Parameters:
fnameimage or sinogram filename
imgpointer to initialized IMG structure
Returns:
errstatus, which is STATUS_OK (0) when call was successful, and >0 in case of an error.

Definition at line 827 of file img_e7.c.

References IMG::_dataType, IMG::_fileFormat, ecat7_mainheader::bin_size, ecat7_imageheader::data_type, ecat7_scanheader::data_type, ecat7_2Dscanheader::data_type, ecat7_imageheader::decay_corr_fctr, IMG::decayCorrected, IMG::dimt, IMG::dimx, IMG::dimy, IMG::dimz, ECAT7_2DSCAN, ECAT7_3DSCAN, ECAT7_3DSCAN8, ECAT7_3DSCANFIT, ECAT7_IMAGE16, ECAT7_IMAGE8, ECAT7_POLARMAP, ECAT7_VOLUME16, ECAT7_VOLUME8, ecat7CheckMatlist(), ecat7EmptyMatlist(), ecat7GatherMatlist(), ecat7GetMatrixBlockSize(), ecat7GetPlaneAndFrameNr(), ecat7InitMatlist(), ecat7Read2DScanheader(), ecat7ReadImageheader(), ecat7ReadMainheader(), ecat7ReadMatlist(), ecat7ReadPolmapheader(), ecat7ReadScanheader(), ECAT7V_MAGICNR, ecat7_mainheader::file_type, IMG_STATUS_INITIALIZED, IMG_TEST, IMG_UNKNOWN, imgEcat7Supported(), imgGetEcat7Fileformat(), imgGetEcat7MHeader(), imgSetStatus(), ecat7_mainheader::magic_number, ECAT7_MATRIXLIST::matdir, ECAT7_MATRIXLIST::matrixNr, MAX_POLARMAP_NUM_RINGS, ecat7_scanheader::num_angles, ecat7_2Dscanheader::num_angles, ecat7_imageheader::num_dimensions, ecat7_2Dscanheader::num_dimensions, ecat7_scanheader::num_r_elements, ecat7_2Dscanheader::num_r_elements, ecat7_polmapheader::num_rings, ecat7_scanheader::num_z_elements, ecat7_2Dscanheader::num_z_elements, ecat7_polmapheader::pixel_size, IMG::polarmap_num_rings, IMG::polarmap_ring_angle, IMG::polarmap_ring_position, IMG::polarmap_sectors_per_ring, IMG::polarmap_start_angle, ecat7_imageheader::recon_zoom, IMG::resolutionx, IMG::resolutiony, IMG::resolutionz, ecat7_polmapheader::ring_angle, ecat7_polmapheader::ring_position, IMG::sampleDistance, ecat7_polmapheader::sectors_per_ring, IMG::sizex, IMG::sizey, IMG::sizez, ecat7_polmapheader::start_angle, IMG::status, STATUS_FAULT, STATUS_INVALIDMATLIST, STATUS_INVALIDPOLARMAP, STATUS_NOFILE, STATUS_NOMAINHEADER, STATUS_NOSUBHEADER, STATUS_OK, STATUS_UNKNOWNFORMAT, STATUS_UNSUPPORTED, ECAT7_MatDir::strtblk, IMG::type, ecat7_imageheader::x_dimension, ecat7_imageheader::x_pixel_size, ecat7_imageheader::x_resolution, ecat7_scanheader::x_resolution, ecat7_2Dscanheader::x_resolution, ecat7_imageheader::y_dimension, ecat7_imageheader::y_pixel_size, ecat7_imageheader::y_resolution, ecat7_imageheader::z_dimension, ecat7_imageheader::z_pixel_size, ecat7_imageheader::z_resolution, and IMG::zoom.

Referenced by imgReadEcat7FirstFrame(), imgReadHeader(), and imgWriteEcat7Frame().

Here is the call graph for this function:

void imgSetEcat7MHeader ( IMG img,
ECAT7_mainheader h 
)

Copy information from IMG to ECAT 7 main header

Parameters:
imgsource structure
htarget structure

Definition at line 734 of file img_e7.c.

References IMG::_fileFormat, IMG::axialFOV, IMG::dimt, IMG::dimz, ecat7_mainheader::distance_scanned, ECAT7_2DSCAN, ECAT7_3DSCAN, ECAT7_IMAGE16, ECAT7_POLARMAP, ECAT7_VOLUME16, ECAT7S_MAGICNR, ECAT7V_MAGICNR, ecat7_mainheader::ecat_calibration_factor, ecat7_mainheader::file_type, IMG_E7_2D, IMG_TYPE_POLARMAP, IMG_TYPE_RAW, imgIsotope(), imgUnitToEcat7(), ecat7_mainheader::isotope_halflife, ecat7_mainheader::isotope_name, IMG::isotopeHalflife, ecat7_mainheader::magic_number, ecat7_mainheader::num_bed_pos, ecat7_mainheader::num_frames, ecat7_mainheader::num_gates, ecat7_mainheader::num_planes, IMG::orientation, ecat7_mainheader::patient_id, ecat7_mainheader::patient_name, ecat7_mainheader::patient_orientation, IMG::patientID, IMG::patientName, ecat7_mainheader::plane_separation, ecat7_mainheader::radiopharmaceutical, IMG::radiopharmaceutical, ecat7_mainheader::scan_start_time, IMG::scanner, IMG::scanStart, IMG::sizez, ecat7_mainheader::study_description, ecat7_mainheader::study_type, IMG::studyDescription, IMG::studyNr, ecat7_mainheader::sw_version, ecat7_mainheader::system_type, ecat7_mainheader::transaxial_fov, IMG::transaxialFOV, IMG::type, ecat7_mainheader::user_process_code, and IMG::userProcessCode.

Referenced by imgWrite2DEcat7(), imgWriteEcat7(), imgWriteEcat7Frame(), and imgWritePolarmap().

Here is the call graph for this function:

void imgSetEcat7SHeader ( IMG img,
void *  h 
)

Set ECAT7 subheader based on IMG contents

Parameters:
imgimage structure
hEcat7 image, scan, 2D scan or polar map header

Definition at line 1391 of file img_e7.c.

References IMG::_fileFormat, ecat7_imageheader::data_type, ecat7_scanheader::data_type, ecat7_2Dscanheader::data_type, ecat7_polmapheader::data_type, IMG::dimx, IMG::dimy, IMG::dimz, ECAT7_SUNI2, ecat7_imageheader::fill_user, IMG_E7_2D, IMG_TYPE_POLARMAP, IMG_TYPE_RAW, ecat7_scanheader::num_angles, ecat7_2Dscanheader::num_angles, ecat7_imageheader::num_dimensions, ecat7_scanheader::num_dimensions, ecat7_2Dscanheader::num_dimensions, ecat7_scanheader::num_r_elements, ecat7_2Dscanheader::num_r_elements, ecat7_polmapheader::num_rings, ecat7_scanheader::num_z_elements, ecat7_2Dscanheader::num_z_elements, ecat7_polmapheader::pixel_size, IMG::polarmap_num_rings, IMG::polarmap_ring_angle, IMG::polarmap_ring_position, IMG::polarmap_sectors_per_ring, ecat7_polmapheader::quant_units, ecat7_imageheader::recon_zoom, IMG::resolutionx, IMG::resolutiony, IMG::resolutionz, ecat7_polmapheader::ring_angle, ecat7_polmapheader::ring_position, IMG::sampleDistance, ecat7_polmapheader::sectors_per_ring, IMG::sizex, IMG::sizey, IMG::sizez, ecat7_polmapheader::start_angle, ecat7_scanheader::storage_order, IMG::type, ecat7_imageheader::x_dimension, ecat7_imageheader::x_pixel_size, ecat7_imageheader::x_resolution, ecat7_scanheader::x_resolution, ecat7_imageheader::y_dimension, ecat7_imageheader::y_pixel_size, ecat7_imageheader::y_resolution, ecat7_imageheader::z_dimension, ecat7_imageheader::z_pixel_size, ecat7_imageheader::z_resolution, and IMG::zoom.

Referenced by imgWriteEcat7Frame(), and imgWritePolarmap().

int imgWrite2DEcat7 ( const char *  fname,
IMG img 
)

Write ECAT 7 2D image or 2D sinogram.

Parameters:
fnameoutput filename
imgpointer to image structure
Returns:
0 if ok, 1 invalid input, 2 image status is not 'occupied', 3 failed to allocate memory for data, 6 faield to create file, 7 failed to write data, 8 image type not supported, sets IMG->statmsg in case of error

Definition at line 498 of file img_e7.c.

References ecat7_mainheader::bin_size, ecat7_imageheader::data_type, ecat7_2Dscanheader::data_type, ecat7_imageheader::decay_corr_fctr, IMG::decayCorrFactor, ecat7_2Dscanheader::delayed, IMG::dimt, IMG::dimx, IMG::dimy, IMG::dimz, ECAT7_2DSCAN, ECAT7_IMAGE16, ECAT7_SUNI2, ECAT7_TEST, ecat7_val_to_id(), ecat7Create(), ecat7Write2DScanMatrix(), ecat7WriteImageMatrix(), IMG::end, ecat7_mainheader::file_type, ecat7_imageheader::frame_duration, ecat7_2Dscanheader::frame_duration, ecat7_imageheader::frame_start_time, ecat7_2Dscanheader::frame_start_time, IMG_STATUS_OCCUPIED, IMG_TEST, IMG_TYPE_IMAGE, IMG_TYPE_RAW, imgSetEcat7MHeader(), imgSetStatus(), IMG::m, ecat7_2Dscanheader::num_angles, ecat7_imageheader::num_dimensions, ecat7_2Dscanheader::num_dimensions, ecat7_mainheader::num_planes, ecat7_2Dscanheader::num_r_elements, ecat7_2Dscanheader::num_z_elements, IMG::planeNumber, IMG::prompts, ecat7_2Dscanheader::prompts, IMG::randoms, ecat7_imageheader::recon_zoom, IMG::resolutionx, IMG::resolutiony, IMG::resolutionz, IMG::sampleDistance, IMG::sizex, IMG::sizey, IMG::sizez, IMG::start, IMG::status, STATUS_DISKFULL, STATUS_FAULT, STATUS_NOMEMORY, STATUS_NOWRITEPERM, STATUS_OK, STATUS_UNSUPPORTED, IMG::type, ecat7_imageheader::x_dimension, ecat7_imageheader::x_pixel_size, ecat7_imageheader::x_resolution, ecat7_imageheader::y_dimension, ecat7_imageheader::y_pixel_size, ecat7_imageheader::y_resolution, ecat7_imageheader::z_dimension, ecat7_imageheader::z_pixel_size, ecat7_imageheader::z_resolution, and IMG::zoom.

Referenced by imgWrite().

Here is the call graph for this function:

int imgWriteEcat7 ( const char *  fname,
IMG img 
)

Write ECAT 7 3D image volume or 3D sinogram.

Parameters:
fnameoutput filename
imgpointer to IMG data
Returns:
0 if ok, 1 invalid input, 2 image status is not 'occupied', 3 failed to allocate memory for data, 6 failed to create file, 7 failed to write data, 8 unsupported image type sets IMG->statmsg in case of error

Definition at line 380 of file img_e7.c.

References ecat7_mainheader::bin_size, ecat7_imageheader::data_type, ecat7_scanheader::data_type, ecat7_imageheader::decay_corr_fctr, IMG::decayCorrFactor, ecat7_scanheader::delayed, IMG::dimt, IMG::dimx, IMG::dimy, IMG::dimz, ECAT7_SUNI2, ECAT7_TEST, ecat7_val_to_id(), ecat7Create(), ecat7WriteImageMatrix(), ecat7WriteScanMatrix(), IMG::end, ecat7_imageheader::frame_duration, ecat7_scanheader::frame_duration, ecat7_imageheader::frame_start_time, ecat7_scanheader::frame_start_time, IMG_STATUS_OCCUPIED, IMG_TEST, IMG_TYPE_IMAGE, IMG_TYPE_RAW, imgSetEcat7MHeader(), imgSetStatus(), IMG::m, ecat7_scanheader::num_angles, ecat7_imageheader::num_dimensions, ecat7_scanheader::num_dimensions, ecat7_scanheader::num_r_elements, ecat7_scanheader::num_z_elements, IMG::prompts, ecat7_scanheader::prompts, IMG::randoms, ecat7_imageheader::recon_zoom, IMG::resolutionx, IMG::resolutiony, IMG::resolutionz, IMG::sampleDistance, IMG::sizex, IMG::sizey, IMG::sizez, IMG::start, IMG::status, STATUS_DISKFULL, STATUS_FAULT, STATUS_NOMEMORY, STATUS_NOWRITEPERM, STATUS_OK, STATUS_UNSUPPORTED, ecat7_scanheader::storage_order, IMG::type, ecat7_imageheader::x_dimension, ecat7_imageheader::x_pixel_size, ecat7_imageheader::x_resolution, ecat7_scanheader::x_resolution, ecat7_imageheader::y_dimension, ecat7_imageheader::y_pixel_size, ecat7_imageheader::y_resolution, ecat7_imageheader::z_dimension, ecat7_imageheader::z_pixel_size, ecat7_imageheader::z_resolution, and IMG::zoom.

Referenced by imgWrite().

Here is the call graph for this function:

int imgWriteEcat7Frame ( const char *  fname,
int  frame_to_write,
IMG img,
int  frame_index 
)

Write one PET frame from IMG data struct into ECAT 7 image or sinogram file; format is specified in IMG struct. This function can be called repeatedly to write all frames one at a time to conserve memory. However, file with just mainheader and matrix list without any previous frame is not accepted.

Parameters:
fnamename of file where IMG contents will be written. If file does not exist, it is created. Make sure to delete existing file, unless you want to add data
frame_to_writePET 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
imgpointer to the IMG data struct
frame_indexIMG frame index (0..dimt-1) which will be written
Returns:
errstatus, which is STATUS_OK (0) when call was successful, and >0 in case of an error.

Definition at line 1222 of file img_e7.c.

References IMG::_fileFormat, ecat7_mainheader::bin_size, ecat7_imageheader::decay_corr_fctr, IMG::decayCorrFactor, ecat7_scanheader::delayed, ecat7_2Dscanheader::delayed, IMG::dimt, IMG::dimx, IMG::dimy, IMG::dimz, ecat7_val_to_id(), ecat7Create(), ecat7ReadMainheader(), ecat7Write2DScanMatrix(), ecat7WriteImageMatrix(), ecat7WriteMainheader(), ecat7WritePolarmapMatrix(), ecat7WriteScanMatrix(), IMG::end, ecat7_imageheader::frame_duration, ecat7_scanheader::frame_duration, ecat7_2Dscanheader::frame_duration, ecat7_polmapheader::frame_duration, ecat7_imageheader::frame_start_time, ecat7_scanheader::frame_start_time, ecat7_2Dscanheader::frame_start_time, ecat7_polmapheader::frame_start_time, IMG_E7, IMG_E7_2D, IMG_POLARMAP, IMG_STATUS_OCCUPIED, IMG_TEST, IMG_TYPE_RAW, imgEmpty(), imgInit(), imgReadEcat7Header(), imgSetEcat7MHeader(), imgSetEcat7SHeader(), IMG::m, ecat7_mainheader::num_frames, IMG::planeNumber, IMG::prompts, ecat7_scanheader::prompts, ecat7_2Dscanheader::prompts, IMG::randoms, IMG::sampleDistance, IMG::start, IMG::status, STATUS_DISKFULL, STATUS_FAULT, STATUS_NOMAINHEADER, STATUS_NOMEMORY, STATUS_NOWRITEPERM, STATUS_OK, STATUS_VARMATSIZE, STATUS_WRONGFILETYPE, and IMG::type.

Referenced by imgWriteFrame().

Here is the call graph for this function:

int imgWritePolarmap ( const char *  fname,
IMG img 
)

Write ECAT 7 polar map.

Parameters:
fnameoutput filename
imgpointer to image structure
Returns:
0 if ok, 1 invalid input, 2 image status is not 'occupied', 3 failed to allocate memory for data, 6 faield to create file, 7 failed to write data, 8 image type not supported, sets IMG->statmsg in case of error

Definition at line 606 of file img_e7.c.

References ecat7_mainheader::bin_size, IMG::dimt, IMG::dimx, IMG::dimy, IMG::dimz, ECAT7_TEST, ecat7_val_to_id(), ecat7Create(), ecat7WritePolarmapMatrix(), IMG::end, ecat7_polmapheader::frame_duration, ecat7_polmapheader::frame_start_time, IMG_STATUS_OCCUPIED, IMG_TEST, IMG_TYPE_POLARMAP, imgSetEcat7MHeader(), imgSetEcat7SHeader(), imgSetStatus(), IMG::m, IMG::sampleDistance, IMG::start, IMG::status, STATUS_DISKFULL, STATUS_FAULT, STATUS_NOMEMORY, STATUS_NOWRITEPERM, STATUS_OK, and IMG::type.

Referenced by imgWrite().

Here is the call graph for this function: