Functions
imgfile.h File Reference
#include "img.h"
#include "ecat7.h"
#include "ecat63.h"
#include "analyze.h"
#include "imgunit.h"
Include dependency graph for imgfile.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int imgRead (const char *fname, IMG *img)
 
int imgReadMainHeader (const char *fname, IMG *img)
 
int imgWrite (const char *fname, IMG *img)
 
int imgReadHeader (const char *fname, IMG *img)
 
int imgReadNextFrame (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 ecat63ReadAllToImg (const char *fname, IMG *img)
 
int ecat63WriteAllImg (const char *fname, IMG *img)
 
int ecat63ReadPlaneToImg (const char *fname, IMG *img)
 
int ecat63AddImg (const char *fname, IMG *img)
 
void imgGetEcat63MHeader (IMG *img, ECAT63_mainheader *h)
 
void imgSetEcat63MHeader (IMG *img, ECAT63_mainheader *h)
 
int imgEcat63Supported (ECAT63_mainheader *h)
 
int imgGetEcat63Fileformat (ECAT63_mainheader *h)
 
int imgReadEcat63Header (const char *fname, IMG *img)
 
int imgReadEcat63FirstFrame (const char *fname, IMG *img)
 
int imgReadEcat63Frame (const char *fname, int frame_to_read, IMG *img, int frame_index)
 
int imgWriteEcat63Frame (const char *fname, int frame_to_write, IMG *img, int frame_index)
 
void imgSetEcat63SHeader (IMG *img, void *h)
 
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 imgReadEcat7Header (const char *fname, IMG *img)
 
int imgEcat7Supported (ECAT7_mainheader *h)
 
int imgReadEcat7Frame (const char *fname, int frame_to_read, IMG *img, int frame_index)
 
int imgReadEcat7FirstFrame (const char *fname, IMG *img)
 
int imgGetEcat7Fileformat (ECAT7_mainheader *h)
 
int imgWriteEcat7Frame (const char *fname, int frame_to_write, IMG *img, int frame_index)
 
void imgSetEcat7SHeader (IMG *img, void *h)
 
int imgReadAnalyze (const char *dbname, IMG *img)
 
int imgWriteAnalyze (const char *dbname, IMG *img)
 
int imgReadAnalyzeHeader (const char *dbname, IMG *img)
 
int imgGetAnalyzeHeader (IMG *img, ANALYZE_DSR *h)
 
int imgSetAnalyzeHeader (IMG *img, const char *dbname, ANALYZE_DSR *h, float fmin, float fmax)
 
int imgReadAnalyzeFrame (const char *dbname, int frame_to_read, IMG *img, int frame_index)
 
int imgReadAnalyzeFirstFrame (const char *fname, IMG *img)
 
int imgWriteAnalyzeFrame (const char *fname, int frame_to_write, IMG *img, int frame_index, float fmin, float fmax)
 

Function Documentation

int ecat63AddImg ( const char *  fname,
IMG img 
)

Adds all matrices in memory to the ECAT file. If ECAT file does not exist, it is created. Please note that existing ECAT file is NOT saved as fname%

Parameters
fnamename of the output ECAT 6.3 file
imgdata structure from which the data is written
Returns
0 if ok, 1 invalid input, 2 image status is not 'occupied', 3 failed to open file for reading, 4 failed to allocate memory for data, 9 failed to write data, 21 invalid matrix list, 22 failed to write main header

Definition at line 886 of file img_e63.c.

References IMG::_dataType, ecat63_mainheader::axial_fov, IMG::axialFOV, ecat63_mainheader::calibration_factor, ecat63_mainheader::calibration_units, ecat63_mainheader::data_type, ecat63_imageheader::data_type, ecat63_scanheader::data_type, ecat63_imageheader::decay_corr_fctr, IMG::decayCorrected, IMG::decayCorrFactor, ecat63_scanheader::delayed, ecat63_imageheader::dimension_1, ecat63_scanheader::dimension_1, ecat63_imageheader::dimension_2, ecat63_scanheader::dimension_2, IMG::dimt, IMG::dimx, IMG::dimy, IMG::dimz, ECAT63_SYSTEM_TYPE_DEFAULT, ecat63Create(), ecat63EmptyMatlist(), ecat63errmsg, ecat63InitMatlist(), ecat63PrintMainheader(), ecat63ReadMainheader(), ecat63ReadMatlist(), ecat63WriteImage(), ecat63WriteMainheader(), ecat63WriteScan(), ecat63_imageheader::ecat_calibration_fctr, IMG::end, ecat63_mainheader::file_type, Matval::frame, ecat63_imageheader::frame_duration, ecat63_scanheader::frame_duration, ecat63_scanheader::frame_duration_sec, ecat63_imageheader::frame_start_time, ecat63_scanheader::frame_start_time, IMAGE_DATA, ecat63_imageheader::image_max, ecat63_imageheader::image_min, IMG_STATUS_OCCUPIED, IMG_TEST, IMG_TYPE_IMAGE, IMG_TYPE_RAW, imgInfo(), imgIsotope(), imgUnitToEcat6(), ecat63_mainheader::isotope_code, ecat63_mainheader::isotope_halflife, IMG::isotopeHalflife, ecat63_imageheader::loss_corr_fctr, ecat63_scanheader::loss_correction_fctr, IMG::m, mat_numcod(), mat_numdoc(), MATRIXLIST::matdir, MatDir::matnum, MATRIXLIST::matrixNr, ecat63_mainheader::num_bed_pos, ecat63_imageheader::num_dimensions, ecat63_mainheader::num_frames, ecat63_mainheader::num_gates, ecat63_mainheader::num_planes, ecat63_mainheader::patient_id, ecat63_mainheader::patient_name, IMG::patientID, IMG::patientName, ecat63_imageheader::pixel_size, Matval::plane, ecat63_imageheader::plane_eff_corr_fctr, ecat63_mainheader::plane_separation, IMG::planeNumber, ecat63_scanheader::prompts, IMG::prompts, ecat63_imageheader::quant_scale, ecat63_imageheader::quant_units, ecat63_mainheader::radiopharmaceutical, IMG::radiopharmaceutical, IMG::randoms, RAW_DATA, ecat63_imageheader::recon_scale, ecat63_scanheader::sample_distance, IMG::sampleDistance, ecat63_scanheader::scale_factor, ecat63_scanheader::scan_max, ecat63_scanheader::scan_min, ecat63_mainheader::scan_start_day, ecat63_mainheader::scan_start_hour, ecat63_mainheader::scan_start_minute, ecat63_mainheader::scan_start_month, ecat63_mainheader::scan_start_second, ecat63_mainheader::scan_start_year, IMG::scanner, IMG::scanStart, IMG::sizex, IMG::sizez, ecat63_imageheader::slice_width, IMG::start, IMG::status, ecat63_mainheader::study_description, ecat63_mainheader::study_name, IMG::studyDescription, IMG::studyNr, ecat63_mainheader::sw_version, ecat63_mainheader::system_type, ecat63_mainheader::transaxial_fov, IMG::transaxialFOV, IMG::type, ecat63_mainheader::user_process_code, IMG::userProcessCode, VAX_I2, ecat63_imageheader::well_counter_cal_fctr, and IMG::zoom.

Here is the call graph for this function:

int ecat63ReadAllToImg ( const char *  fname,
IMG img 
)

Read all matrices in ECAT file to memory. Img data must be initialized before this procedure.

Parameters
fnamename of the input ECAT 6.3 file
imgdata structure in which the file is read
Returns
0 if ok, 1 invalid input, 3 failed to open file for reading, 4 failed to read main header, 5 failed to read matrix list, 6 matrix not found, 7 variable matrix sizes, 8 failed to read matrix sub header, 9 failed to allocate memory for data, 10 failed to read sub header, 11 failed to read matrix data

Definition at line 77 of file img_e63.c.

References IMG::_dataType, IMG::_fileFormat, ATTN_DATA, ecat63_mainheader::axial_fov, IMG::axialFOV, BYTE_TYPE, ecat63_mainheader::calibration_factor, ecat63_mainheader::calibration_units, ecat63_imageheader::data_type, ecat63_scanheader::data_type, ecat63_normheader::data_type, ecat63_attnheader::data_type, ecat63_imageheader::decay_corr_fctr, IMG::decayCorrected, IMG::decayCorrFactor, ecat63_scanheader::delayed, ecat63_imageheader::dimension_1, ecat63_scanheader::dimension_1, ecat63_normheader::dimension_1, ecat63_attnheader::dimension_1, ecat63_imageheader::dimension_2, ecat63_scanheader::dimension_2, ecat63_normheader::dimension_2, ecat63_attnheader::dimension_2, ecat63DeleteLateFrames(), ecat63EmptyMatlist(), ecat63errmsg, ecat63InitMatlist(), ecat63PrintMainheader(), ecat63PrintMatlist(), ecat63ReadAttnheader(), ecat63ReadImageheader(), ecat63ReadMainheader(), ecat63ReadMatdata(), ecat63ReadMatlist(), ecat63ReadNormheader(), ecat63ReadScanheader(), ecat63_imageheader::ecat_calibration_fctr, IMG::end, MatDir::endblk, ecat63_mainheader::file_type, Matval::frame, ecat63_imageheader::frame_duration, ecat63_scanheader::frame_duration, ecat63_imageheader::frame_start_time, ecat63_scanheader::frame_start_time, Matval::gate, IEEE_R4, IMAGE_DATA, IMG_E63, IMG_STATUS_INITIALIZED, IMG_TEST, IMG_TYPE_IMAGE, IMG_TYPE_RAW, imgAllocate(), imgSetStatus(), imgUnitFromEcat(), ecat63_mainheader::isotope_halflife, IMG::isotopeHalflife, ecat63_scanheader::loss_correction_fctr, IMG::m, mat_numdoc(), MatBLKSIZE, MATRIXLIST::matdir, MatDir::matnum, MATRIXLIST::matrixNr, MatDir::matstat, IMG::mid, NORM_DATA, ecat63_mainheader::num_frames, ecat63_mainheader::num_gates, ecat63_mainheader::patient_id, ecat63_mainheader::patient_name, IMG::patientID, IMG::patientName, ecat63_imageheader::pixel_size, Matval::plane, ecat63_mainheader::plane_separation, IMG::planeNumber, ecat63_scanheader::prompts, IMG::prompts, ecat63_imageheader::quant_scale, ecat63_imageheader::quant_units, ecat63_mainheader::radiopharmaceutical, IMG::radiopharmaceutical, IMG::randoms, RAW_DATA, ecat63_imageheader::recon_scale, ecat63_scanheader::sample_distance, IMG::sampleDistance, ecat63_scanheader::scale_factor, ecat63_normheader::scale_factor, ecat63_attnheader::scale_factor, ecat63_mainheader::scan_start_day, ecat63_mainheader::scan_start_hour, ecat63_mainheader::scan_start_minute, ecat63_mainheader::scan_start_month, ecat63_mainheader::scan_start_second, ecat63_mainheader::scan_start_year, IMG::scanner, IMG::scanStart, IMG::sizex, IMG::sizey, IMG::sizez, ecat63_imageheader::slice_width, IMG::start, IMG::status, STATUS_FAULT, STATUS_NOFILE, STATUS_NOMAINHEADER, STATUS_NOMATLIST, MatDir::strtblk, ecat63_mainheader::study_description, ecat63_mainheader::study_name, IMG::studyDescription, IMG::studyNr, SUN_I2, SUN_I4, ecat63_mainheader::system_type, ecat63_mainheader::transaxial_fov, IMG::transaxialFOV, IMG::type, IMG::unit, ecat63_mainheader::user_process_code, IMG::userProcessCode, VAX_I2, VAX_I4, VAX_R4, and IMG::zoom.

Referenced by imgRead().

Here is the call graph for this function:

int ecat63ReadPlaneToImg ( const char *  fname,
IMG img 
)

Reads one CTI ECAT 6.3 plane (all frames or gates) at a time to memory. Img data must be initialized before this procedure. Existing img->_dataType is not changed. If img data structure is empty, reads the first plane. If img data structure contains data, reads the next plane. Any existing data in img is cleared and replaced by the new plane.

Parameters
fnamename of the input ECAT 6.3 file
imgdata structure in which the file is read
Returns
0 if ok, 1 next plane was requested but not found anymore, 2 invalid input data, 3 failed to open file, 4 failed to read main header, 5 failed to read matrix list, 6 invalid matrix data, 7 failed to read matrix sub header, 8 failed to allocate memory, 9 failed to read matrix data

Definition at line 568 of file img_e63.c.

References IMG::_dataType, IMG::_fileFormat, ATTN_DATA, ecat63_mainheader::axial_fov, IMG::axialFOV, BYTE_TYPE, ecat63_mainheader::calibration_factor, ecat63_mainheader::calibration_units, ecat63_imageheader::data_type, ecat63_scanheader::data_type, ecat63_normheader::data_type, ecat63_attnheader::data_type, ecat63_imageheader::decay_corr_fctr, IMG::decayCorrected, IMG::decayCorrFactor, ecat63_scanheader::delayed, ecat63_imageheader::dimension_1, ecat63_scanheader::dimension_1, ecat63_normheader::dimension_1, ecat63_attnheader::dimension_1, ecat63_imageheader::dimension_2, ecat63_scanheader::dimension_2, ecat63_normheader::dimension_2, ecat63_attnheader::dimension_2, IMG::dimt, IMG::dimz, ecat63DeleteLateFrames(), ecat63EmptyMatlist(), ecat63errmsg, ecat63InitMatlist(), ecat63PrintMainheader(), ecat63ReadAttnheader(), ecat63ReadImageheader(), ecat63ReadMainheader(), ecat63ReadMatdata(), ecat63ReadMatlist(), ecat63ReadNormheader(), ecat63ReadScanheader(), ecat63_imageheader::ecat_calibration_fctr, IMG::end, MatDir::endblk, ecat63_mainheader::file_type, Matval::frame, ecat63_imageheader::frame_duration, ecat63_scanheader::frame_duration, ecat63_imageheader::frame_start_time, ecat63_scanheader::frame_start_time, Matval::gate, IEEE_R4, IMAGE_DATA, IMG_E63, IMG_STATUS_OCCUPIED, IMG_STATUS_UNINITIALIZED, IMG_TEST, IMG_TYPE_IMAGE, IMG_TYPE_RAW, imgAllocate(), imgEmpty(), imgUnitFromEcat(), ecat63_mainheader::isotope_halflife, IMG::isotopeHalflife, ecat63_scanheader::loss_correction_fctr, IMG::m, mat_numdoc(), MatBLKSIZE, MATRIXLIST::matdir, MatDir::matnum, MATRIXLIST::matrixNr, MatDir::matstat, IMG::mid, NORM_DATA, ecat63_mainheader::num_frames, ecat63_mainheader::num_gates, ecat63_mainheader::patient_id, ecat63_mainheader::patient_name, IMG::patientID, IMG::patientName, ecat63_imageheader::pixel_size, Matval::plane, ecat63_mainheader::plane_separation, IMG::planeNumber, ecat63_scanheader::prompts, IMG::prompts, ecat63_imageheader::quant_scale, ecat63_imageheader::quant_units, ecat63_mainheader::radiopharmaceutical, IMG::radiopharmaceutical, IMG::randoms, RAW_DATA, ecat63_imageheader::recon_scale, ecat63_scanheader::sample_distance, IMG::sampleDistance, ecat63_scanheader::scale_factor, ecat63_normheader::scale_factor, ecat63_attnheader::scale_factor, ecat63_mainheader::scan_start_day, ecat63_mainheader::scan_start_hour, ecat63_mainheader::scan_start_minute, ecat63_mainheader::scan_start_month, ecat63_mainheader::scan_start_second, ecat63_mainheader::scan_start_year, IMG::scanner, IMG::scanStart, IMG::sizex, IMG::sizey, IMG::sizez, ecat63_imageheader::slice_width, IMG::start, IMG::status, MatDir::strtblk, ecat63_mainheader::study_description, ecat63_mainheader::study_name, IMG::studyDescription, IMG::studyNr, SUN_I2, SUN_I4, ecat63_mainheader::system_type, ecat63_mainheader::transaxial_fov, IMG::transaxialFOV, IMG::type, IMG::unit, ecat63_mainheader::user_process_code, IMG::userProcessCode, VAX_I2, VAX_I4, VAX_R4, and IMG::zoom.

Here is the call graph for this function:

int ecat63WriteAllImg ( const char *  fname,
IMG img 
)

Write all matrices in memory to the ECAT file.

Parameters
fnamename of the output ECAT 6.3 file, If ECAT file exists, it is renamed as filename%
imgdata structure from which the data is written
Returns
0 if ok, 1 invalid data, 2 image status is not 'oocupied', 3 failed to create file, 4 failed to allocate memory for data, 9 failed to write data

Definition at line 374 of file img_e63.c.

References IMG::_dataType, ecat63_mainheader::axial_fov, IMG::axialFOV, ecat63_mainheader::calibration_factor, ecat63_mainheader::calibration_units, ecat63_mainheader::data_type, ecat63_imageheader::data_type, ecat63_scanheader::data_type, ecat63_imageheader::decay_corr_fctr, IMG::decayCorrected, IMG::decayCorrFactor, ecat63_scanheader::delayed, ecat63_imageheader::dimension_1, ecat63_scanheader::dimension_1, ecat63_imageheader::dimension_2, ecat63_scanheader::dimension_2, IMG::dimt, IMG::dimx, IMG::dimy, IMG::dimz, ECAT63_SYSTEM_TYPE_DEFAULT, ecat63Create(), ecat63errmsg, ecat63PrintImageheader(), ecat63PrintMainheader(), ecat63PrintScanheader(), ecat63WriteImage(), ecat63WriteScan(), ecat63_imageheader::ecat_calibration_fctr, IMG::end, ecat63_mainheader::file_type, ecat63_imageheader::frame_duration, ecat63_scanheader::frame_duration, ecat63_scanheader::frame_duration_sec, ecat63_imageheader::frame_start_time, ecat63_scanheader::frame_start_time, IMAGE_DATA, ecat63_imageheader::image_max, ecat63_imageheader::image_min, IMG_STATUS_OCCUPIED, IMG_TEST, IMG_TYPE_IMAGE, imgIsotope(), imgUnitToEcat6(), ecat63_mainheader::isotope_code, ecat63_mainheader::isotope_halflife, IMG::isotopeHalflife, ecat63_imageheader::loss_corr_fctr, ecat63_scanheader::loss_correction_fctr, IMG::m, mat_numcod(), ecat63_mainheader::num_bed_pos, ecat63_imageheader::num_dimensions, ecat63_mainheader::num_frames, ecat63_mainheader::num_gates, ecat63_mainheader::num_planes, ecat63_mainheader::patient_id, ecat63_mainheader::patient_name, IMG::patientID, IMG::patientName, ecat63_imageheader::pixel_size, ecat63_imageheader::plane_eff_corr_fctr, ecat63_mainheader::plane_separation, IMG::planeNumber, ecat63_scanheader::prompts, IMG::prompts, ecat63_imageheader::quant_scale, ecat63_imageheader::quant_units, ecat63_mainheader::radiopharmaceutical, IMG::radiopharmaceutical, IMG::randoms, RAW_DATA, ecat63_imageheader::recon_scale, ecat63_scanheader::sample_distance, IMG::sampleDistance, ecat63_scanheader::scale_factor, ecat63_scanheader::scan_max, ecat63_scanheader::scan_min, ecat63_mainheader::scan_start_day, ecat63_mainheader::scan_start_hour, ecat63_mainheader::scan_start_minute, ecat63_mainheader::scan_start_month, ecat63_mainheader::scan_start_second, ecat63_mainheader::scan_start_year, IMG::scanner, IMG::scanStart, IMG::sizex, IMG::sizez, ecat63_imageheader::slice_width, IMG::start, IMG::status, ecat63_mainheader::study_description, ecat63_mainheader::study_name, IMG::studyDescription, IMG::studyNr, ecat63_mainheader::sw_version, ecat63_mainheader::system_type, ecat63_mainheader::transaxial_fov, IMG::transaxialFOV, IMG::type, ecat63_mainheader::user_process_code, IMG::userProcessCode, VAX_I2, ecat63_imageheader::well_counter_cal_fctr, and IMG::zoom.

Referenced by imgWrite().

Here is the call graph for this function:

int imgEcat63Supported ( ECAT63_mainheader h)

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

Parameters
hEcat 6.3 main header
Returns
1 if supported, 0 if not.

Definition at line 1140 of file img_e63.c.

References ATTN_DATA, ecat63_mainheader::file_type, IMAGE_DATA, NORM_DATA, and RAW_DATA.

Referenced by imgReadEcat63Header().

int imgEcat7Supported ( ECAT7_mainheader h)

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().

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.

Parameters
imgtarget image struture where fileformat is saved, should have IMG_UNKNOWN as file type
fnamename 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(), imgWriteFrame(), and test_modules().

int imgGetAnalyzeHeader ( IMG img,
ANALYZE_DSR h 
)
int imgGetEcat63Fileformat ( ECAT63_mainheader h)

Return the IMG fileformat based on ECAT 6.3 file_type.

Parameters
hEcat 6.3 main header
Returns
IMG._fileFormat value.

Definition at line 1260 of file img_e63.c.

References ATTN_DATA, ecat63_mainheader::file_type, IMAGE_DATA, IMG_E63, IMG_UNKNOWN, NORM_DATA, and RAW_DATA.

Referenced by imgReadEcat63Header().

void imgGetEcat63MHeader ( IMG img,
ECAT63_mainheader h 
)
int imgGetEcat7Fileformat ( ECAT7_mainheader h)

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 imgRead ( const char *  fname,
IMG img 
)

Read an image or sinogram file in ECAT 6.3, ECAT 7.x or Analyze 7.5 format.

Parameters
fnameinput filename
imgpointer to initialized IMG structure
Returns
0 if ok, 1 invalid input, 2 image status is not 'initialized', 4 unrecognized format, 5 unsupported Ecat7 type, sets IMG->statmsg in case of error

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().

Here is the call graph for this function:

int imgReadAnalyze ( const char *  dbname,
IMG img 
)

Read Analyze 7.5 image. Analyze database name must be given with path. Image and header files with .img and .hdr extensions must exist. Also SIF file with .sif extension is used, if it exists. anaFlipping() determines whether image is flipped in z-direction; image is always flipped in x,y-directions.

Parameters
dbnameAnalyze database name with path, with or without extension
imgPointer to initialized IMG strucure
Returns
0 if ok, 1 invalid input, 2 invalid image status (not initialized), 3 no header file found, 4 invalid header, 7 failed to read image data, 11 failed to allocate memory for header data, 12 failed to allocate memory for image data, 21 failed to rad sif data, 22 invalid sif data, sets IMG->statmsg in case of error

Definition at line 83 of file img_ana.c.

References IMG::_fileFormat, anaExists(), anaFlipping(), anaPrintHeader(), anaReadHeader(), anaReadImagedata(), IMG::decayCorrected, ANALYZE_HEADER_HISTORY::descrip, ANALYZE_HEADER_IMGDIM::dim, ANALYZE_DSR::dime, IMG::dimt, IMG::dimz, IMG::end, SIF::frameNr, ANALYZE_HEADER_IMGDIM::funused3, ANALYZE_DSR::hist, IMG_ANA, IMG_ANA_L, IMG_STATUS_INITIALIZED, IMG_TEST, IMG_TYPE_IMAGE, imgAllocate(), imgSetStatus(), SIF::isotope_name, IMG::isotopeHalflife, ANALYZE_DSR::little, IMG::m, IMG::mid, ANALYZE_HEADER_HISTORY::patient_id, IMG::patientName, ANALYZE_HEADER_IMGDIM::pixdim, IMG::planeNumber, SIF::prompts, IMG::prompts, SIF::randoms, IMG::randoms, IMG::scanStart, SIF::scantime, sifEmpty(), sifInit(), sifRead(), IMG::sizex, IMG::sizey, IMG::sizez, IMG::start, IMG::status, STATUS_FAULT, STATUS_INVALIDHEADER, STATUS_NOHEADERFILE, STATUS_NOIMGDATA, STATUS_NOMEMORY, STATUS_NOSIFDATA, STATUS_OK, STATUS_UNSUPPORTED, STATUS_WRONGSIFDATA, IMG::studyNr, IMG::type, SIF::x1, and SIF::x2.

Referenced by imgRead().

Here is the call graph for this function:

int imgReadAnalyzeFirstFrame ( const char *  fname,
IMG img 
)

Read the first frame from an Analyze 7.5 database into IMG data structure.

Parameters
fnameName of Analyze database 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 629 of file img_ana.c.

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

Here is the call graph for this function:

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

Read a specified frame from an Analyze 7.5 database into preallocated IMG data structure. Analyze database consists of two or three files in the same directory: fname.hdr, fname.img, and optionally fname.sif. 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 Analyze database 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 674 of file img_ana.c.

References anaDatabaseExists(), anaFlipping(), anaReadHeader(), anaReadImagedata(), IMG::dimt, IMG::dimx, IMG::dimy, IMG::dimz, IMG::end, SIF::frameNr, IMG_STATUS_OCCUPIED, IMG_TEST, imgSetStatus(), IMG::m, IMG::mid, SIF::prompts, IMG::prompts, SIF::randoms, IMG::randoms, sifEmpty(), sifInit(), sifRead(), IMG::start, IMG::status, STATUS_FAULT, STATUS_NOFILE, STATUS_NOHEADERFILE, STATUS_NOIMGDATA, STATUS_NOMATRIX, STATUS_NOMEMORY, STATUS_OK, STATUS_UNSUPPORTED, SIF::x1, and SIF::x2.

Referenced by imgReadAnalyzeFirstFrame(), and imgReadFrame().

Here is the call graph for this function:

int imgReadAnalyzeHeader ( const char *  dbname,
IMG img 
)

Fill IMG struct header information from Analyze 7.5 database files. SIF file is read if available. Information concerning separate frames or planes is not filled though.

Parameters
dbnamename of Analyze database, may contain filename extension
imgpointer to the initiated IMG data
Returns
errstatus, which is STATUS_OK (0) when call was successful, and >0 in case of an error.

Definition at line 414 of file img_ana.c.

References anaDatabaseExists(), anaReadHeader(), IMG_STATUS_INITIALIZED, IMG_TEST, imgGetAnalyzeHeader(), imgSetStatus(), SIF::isotope_name, IMG::isotopeHalflife, IMG::scanStart, SIF::scantime, sifEmpty(), sifInit(), sifRead(), IMG::status, STATUS_FAULT, STATUS_NOFILE, STATUS_NOHEADERFILE, STATUS_OK, STATUS_UNSUPPORTED, SIF::studynr, and IMG::studyNr.

Referenced by imgReadAnalyzeFirstFrame(), imgReadHeader(), and imgWriteAnalyzeFrame().

Here is the call graph for this function:

int imgReadEcat63FirstFrame ( const char *  fname,
IMG img 
)

Read the first frame from an ECAT 6.3 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 1422 of file img_e63.c.

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

Here is the call graph for this function:

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

Read a specified frame from an ECAT 6.3 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.

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. If frame does not exist, then and only then STATUS_NOMATRIX is returned.

Definition at line 1464 of file img_e63.c.

References IMG::_dataType, ATTN_DATA, BYTE_TYPE, ecat63_mainheader::calibration_factor, ecat63_imageheader::data_type, ecat63_scanheader::data_type, ecat63_normheader::data_type, ecat63_attnheader::data_type, ecat63_imageheader::decay_corr_fctr, IMG::decayCorrFactor, ecat63_scanheader::delayed, IMG::dimt, IMG::dimx, IMG::dimy, IMG::dimz, ecat63EmptyMatlist(), ecat63GatherMatlist(), ecat63GetMatrixBlockSize(), ecat63InitMatlist(), ecat63ReadAttnheader(), ecat63ReadImageheader(), ecat63ReadMainheader(), ecat63ReadMatdata(), ecat63ReadMatlist(), ecat63ReadNormheader(), ecat63ReadScanheader(), ecat63SortMatlistByFrame(), ecat63_imageheader::ecat_calibration_fctr, IMG::end, MatDir::endblk, ecat63_mainheader::file_type, Matval::frame, ecat63_imageheader::frame_duration, ecat63_scanheader::frame_duration, ecat63_imageheader::frame_start_time, ecat63_scanheader::frame_start_time, Matval::gate, IEEE_R4, IMAGE_DATA, IMG_STATUS_OCCUPIED, IMG_TEST, imgSetStatus(), ecat63_scanheader::loss_correction_fctr, IMG::m, mat_numdoc(), MatBLKSIZE, MATRIXLIST::matdir, MatDir::matnum, MATRIXLIST::matrixNr, MatDir::matstat, IMG::mid, NORM_DATA, ecat63_mainheader::num_frames, ecat63_mainheader::num_gates, Matval::plane, IMG::planeNumber, ecat63_scanheader::prompts, IMG::prompts, ecat63_imageheader::quant_scale, IMG::randoms, RAW_DATA, ecat63_scanheader::sample_distance, IMG::sampleDistance, ecat63_scanheader::scale_factor, ecat63_normheader::scale_factor, ecat63_attnheader::scale_factor, IMG::start, IMG::status, STATUS_FAULT, STATUS_INVALIDMATLIST, STATUS_MISSINGMATRIX, STATUS_NOFILE, STATUS_NOMAINHEADER, STATUS_NOMATLIST, STATUS_NOMATRIX, STATUS_NOMEMORY, STATUS_NOSUBHEADER, STATUS_OK, MatDir::strtblk, SUN_I2, SUN_I4, VAX_I2, VAX_I4, and VAX_R4.

Referenced by imgReadEcat63FirstFrame(), and imgReadFrame().

Here is the call graph for this function:

int imgReadEcat63Header ( const char *  fname,
IMG img 
)

Fill IMG struct header information from an image or sinogram file in ECAT 6.3 format. Information concerning separate frames or planes is not filled. Please note: ECAT 6.3 files do not have a magic number, therefore, do not use this function to determine if your file is in this format, at least test all other possible formats before calling this.

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 1289 of file img_e63.c.

References IMG::_dataType, IMG::_fileFormat, ATTN_DATA, ecat63_imageheader::data_type, ecat63_scanheader::data_type, ecat63_normheader::data_type, ecat63_attnheader::data_type, ecat63_imageheader::decay_corr_fctr, IMG::decayCorrected, ecat63_imageheader::dimension_1, ecat63_scanheader::dimension_1, ecat63_normheader::dimension_1, ecat63_attnheader::dimension_1, ecat63_imageheader::dimension_2, ecat63_scanheader::dimension_2, ecat63_normheader::dimension_2, ecat63_attnheader::dimension_2, IMG::dimt, IMG::dimx, IMG::dimy, IMG::dimz, ecat63DeleteLateFrames(), ecat63EmptyMatlist(), ecat63GatherMatlist(), ecat63GetMatrixBlockSize(), ecat63GetPlaneAndFrameNr(), ecat63InitMatlist(), ecat63ReadAttnheader(), ecat63ReadImageheader(), ecat63ReadMainheader(), ecat63ReadMatlist(), ecat63ReadNormheader(), ecat63ReadScanheader(), ecat63SortMatlistByPlane(), ecat63_mainheader::file_type, IMAGE_DATA, IMG_STATUS_INITIALIZED, IMG_TEST, IMG_TYPE_RAW, IMG_UNKNOWN, imgEcat63Supported(), imgGetEcat63Fileformat(), imgGetEcat63MHeader(), imgSetStatus(), imgUnitFromEcat(), MATRIXLIST::matdir, MATRIXLIST::matrixNr, NORM_DATA, ecat63_mainheader::num_frames, ecat63_imageheader::pixel_size, ecat63_imageheader::quant_units, RAW_DATA, ecat63_imageheader::recon_scale, ecat63_scanheader::sample_distance, IMG::sampleDistance, IMG::sizex, IMG::sizey, IMG::sizez, ecat63_imageheader::slice_width, IMG::status, STATUS_FAULT, STATUS_INVALIDMATLIST, STATUS_NOFILE, STATUS_NOMAINHEADER, STATUS_NOMATLIST, STATUS_NOSUBHEADER, STATUS_OK, STATUS_UNSUPPORTED, MatDir::strtblk, IMG::type, IMG::unit, VAX_I2, VAX_I4, VAX_R4, and IMG::zoom.

Referenced by imgReadEcat63FirstFrame(), imgReadHeader(), and imgWriteEcat63Frame().

Here is the call graph for this function:

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:

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.

Parameters
fnamename 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_readframe which will be read [1..frameNr]
imgpointer 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_indexIMG 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.
Returns
errstatus, which is STATUS_OK (0) when call was successful, and >0 in case of an error. Specifically, return value STATUS_NOMATRIX signals that frame does not exist, i.e. all frames have been read. IMG.statmsg can be set using ERROR_STATUS.

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().

Here is the call graph for this function:

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.

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

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().

Here is the call graph for this function:

int imgReadMainHeader ( const char *  fname,
IMG img 
)
int imgReadNextFrame ( char *  fname,
IMG img 
)
int imgSetAnalyzeHeader ( IMG img,
const char *  dbname,
ANALYZE_DSR dsr,
float  fmin,
float  fmax 
)

Copy header information in IMG struct into Analyze 7.5 header struct. Min, max, and scale factor are set here and they apply to all frames.

Parameters
imgpointer to IMG struct
dbnameAnalyze 7.5 database name
dsrpointer to Analyze header struct to be filled
fminminimum pixel value in all frames that will be written
fmaxmaximum pixel value in all frames that will be written
Returns
errstatus, which is STATUS_OK (0) when call was successful, and >0 in case of an error.

Definition at line 542 of file img_ana.c.

References IMG::_fileFormat, ANALYZE_DT_SIGNED_SHORT, ANALYZE_HEADER_IMGDIM::bitpix, ANALYZE_HEADER_IMGDIM::cal_max, ANALYZE_HEADER_IMGDIM::cal_min, ANALYZE_HEADER_KEY::data_type, ANALYZE_HEADER_IMGDIM::datatype, ANALYZE_HEADER_KEY::db_name, IMG::decayCorrected, ANALYZE_HEADER_HISTORY::descrip, ANALYZE_HEADER_IMGDIM::dim, ANALYZE_DSR::dime, IMG::dimt, IMG::dimx, IMG::dimy, IMG::dimz, ANALYZE_HEADER_HISTORY::exp_date, ANALYZE_HEADER_HISTORY::exp_time, ANALYZE_HEADER_KEY::extents, ANALYZE_HEADER_IMGDIM::funused1, ANALYZE_HEADER_IMGDIM::funused3, ANALYZE_HEADER_IMGDIM::glmax, ANALYZE_HEADER_IMGDIM::glmin, ANALYZE_DSR::hist, ANALYZE_DSR::hk, IMG_ANA_L, IMG_STATUS_INITIALIZED, IMG_STATUS_OCCUPIED, IMG_TEST, imgMinMax(), imgSetStatus(), IMG::isotopeHalflife, ANALYZE_DSR::little, ANALYZE_HEADER_IMGDIM::pixdim, ANALYZE_HEADER_KEY::regular, ANALYZE_HEADER_HISTORY::scannum, IMG::scanStart, ANALYZE_HEADER_KEY::sizeof_hdr, IMG::sizex, IMG::sizey, IMG::sizez, IMG::status, STATUS_FAULT, STATUS_OK, and IMG::studyNr.

Referenced by imgWriteAnalyzeFrame().

Here is the call graph for this function:

void imgSetEcat63MHeader ( IMG img,
ECAT63_mainheader h 
)

Copy information from IMG struct into ECAT 6.3 main header

Parameters
imgsource image structure
htarget Ecat 6.3 main header

Definition at line 1208 of file img_e63.c.

References ecat63_mainheader::axial_fov, IMG::axialFOV, ecat63_mainheader::calibration_factor, ecat63_mainheader::calibration_units, ecat63_mainheader::data_type, IMG::dimt, IMG::dimz, ECAT63_SYSTEM_TYPE_DEFAULT, ecat63_mainheader::file_type, IMAGE_DATA, IMG_TYPE_IMAGE, imgIsotope(), imgUnitToEcat6(), ecat63_mainheader::isotope_code, ecat63_mainheader::isotope_halflife, IMG::isotopeHalflife, ecat63_mainheader::num_bed_pos, ecat63_mainheader::num_frames, ecat63_mainheader::num_gates, ecat63_mainheader::num_planes, ecat63_mainheader::patient_id, ecat63_mainheader::patient_name, IMG::patientID, IMG::patientName, ecat63_mainheader::plane_separation, ecat63_mainheader::radiopharmaceutical, IMG::radiopharmaceutical, RAW_DATA, ecat63_mainheader::scan_start_day, ecat63_mainheader::scan_start_hour, ecat63_mainheader::scan_start_minute, ecat63_mainheader::scan_start_month, ecat63_mainheader::scan_start_second, ecat63_mainheader::scan_start_year, IMG::scanner, IMG::scanStart, IMG::sizez, ecat63_mainheader::study_description, ecat63_mainheader::study_name, IMG::studyDescription, IMG::studyNr, ecat63_mainheader::sw_version, ecat63_mainheader::system_type, ecat63_mainheader::transaxial_fov, IMG::transaxialFOV, IMG::type, ecat63_mainheader::user_process_code, IMG::userProcessCode, and VAX_I2.

Referenced by imgWriteEcat63Frame().

Here is the call graph for this function:

void imgSetEcat63SHeader ( IMG img,
void *  h 
)
void imgSetEcat7MHeader ( IMG img,
ECAT7_mainheader h 
)
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 imgWrite ( const char *  fname,
IMG img 
)

Write an image or sinogram file. Format depends on _fileFormat or filename extension.

Parameters
fnameoutput filename
imgpointer to IMG data
Returns
0 if ok, 1 invalid input, 2 invalid image type or status, 5 failed to write file, sets IMG->statmsg in case of error

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().

Here is the call graph for this function:

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 imgWriteAnalyze ( const char *  dbname,
IMG img 
)

Write Analyze 7.5 image. Analyze database name must be given with path. Path must exist. Image and header files with .img and .hdr extensions are created. Existing files are overwritten. anaFlipping() determines whether image is flipped in z-direction; image is always flipped in x,y-directions. Byte order is determined based on _fileFormat field.

Parameters
dbnameanalyze database name with path, without extension
imgpointer to IMG data
Returns
0 if ok, 1 invalid input, 2 invalid image status (image not occupied), 3 failed to resolve extreme values (min and max), 12 failed to allocate temp memory, 14 failed to open file for writing, 15 failed to write data, 21 failed to write header, sets IMG->statmsg in case of error

Definition at line 253 of file img_ana.c.

References IMG::_fileFormat, anaFlipping(), ANALYZE_DT_SIGNED_SHORT, anaWriteHeader(), ANALYZE_HEADER_IMGDIM::bitpix, ANALYZE_HEADER_IMGDIM::cal_max, ANALYZE_HEADER_IMGDIM::cal_min, ANALYZE_HEADER_KEY::data_type, ANALYZE_HEADER_IMGDIM::datatype, ANALYZE_HEADER_KEY::db_name, IMG::decayCorrected, ANALYZE_HEADER_HISTORY::descrip, ANALYZE_HEADER_IMGDIM::dim, ANALYZE_DSR::dime, IMG::dimt, IMG::dimx, IMG::dimy, IMG::dimz, ANALYZE_HEADER_HISTORY::exp_date, ANALYZE_HEADER_HISTORY::exp_time, ANALYZE_HEADER_KEY::extents, ANALYZE_HEADER_IMGDIM::funused1, ANALYZE_HEADER_IMGDIM::funused3, ANALYZE_HEADER_IMGDIM::glmax, ANALYZE_HEADER_IMGDIM::glmin, ANALYZE_DSR::hist, ANALYZE_DSR::hk, IMG_ANA_L, IMG_STATUS_OCCUPIED, IMG_TEST, imgMinMax(), imgSetStatus(), IMG::isotopeHalflife, ANALYZE_DSR::little, IMG::m, ANALYZE_HEADER_IMGDIM::pixdim, ANALYZE_HEADER_KEY::regular, ANALYZE_HEADER_HISTORY::scannum, IMG::scanStart, ANALYZE_HEADER_KEY::sizeof_hdr, IMG::sizex, IMG::sizey, IMG::sizez, IMG::status, STATUS_CANTWRITEHEADERFILE, STATUS_CANTWRITEIMGFILE, STATUS_FAULT, STATUS_NOMEMORY, STATUS_OK, and IMG::studyNr.

Referenced by imgWrite().

Here is the call graph for this function:

int imgWriteAnalyzeFrame ( const char *  dbname,
int  frame_to_write,
IMG img,
int  frame_index,
float  fmin,
float  fmax 
)

Write one PET frame from IMG data struct into Analyze 7.5 database file. This function can be called repeatedly to write all frames one at a time to conserve memory.

Parameters
dbnamename 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
fminminimum pixel value in all frames that will be written; used only when writing the first frame
fmaxmaximum pixel value in all frames that will be written; used only when writing the first frame
Returns
errstatus, which is STATUS_OK (0) when call was successful, and >0 in case of an error.

Definition at line 781 of file img_ana.c.

References IMG::_fileFormat, anaDatabaseExists(), anaFlipping(), anaReadHeader(), anaWriteHeader(), ANALYZE_HEADER_IMGDIM::dim, ANALYZE_DSR::dime, IMG::dimt, IMG::dimx, IMG::dimy, IMG::dimz, ANALYZE_HEADER_IMGDIM::funused1, IMG_ANA, IMG_ANA_L, IMG_STATUS_OCCUPIED, IMG_TEST, imgEmpty(), imgInit(), imgReadAnalyzeHeader(), imgSetAnalyzeHeader(), ANALYZE_DSR::little, IMG::m, IMG::status, STATUS_CANTWRITEHEADERFILE, STATUS_CANTWRITEIMGFILE, STATUS_FAULT, STATUS_MISSINGMATRIX, STATUS_NOMAINHEADER, STATUS_NOMEMORY, STATUS_NOWRITEPERM, STATUS_OK, STATUS_VARMATSIZE, STATUS_WRONGFILETYPE, and IMG::type.

Here is the call graph for this function:

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

Write one PET frame from IMG data struct into ECAT 6.3 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 1656 of file img_e63.c.

References IMG::_fileFormat, ecat63_imageheader::decay_corr_fctr, IMG::decayCorrected, IMG::decayCorrFactor, ecat63_scanheader::delayed, IMG::dimt, IMG::dimx, IMG::dimy, IMG::dimz, ECAT63_TEST, ecat63Create(), ecat63PrintMainheader(), ecat63ReadMainheader(), ecat63WriteImageMatrix(), ecat63WriteMainheader(), ecat63WriteScanMatrix(), IMG::end, ecat63_imageheader::frame_duration, ecat63_scanheader::frame_duration, ecat63_imageheader::frame_start_time, ecat63_scanheader::frame_start_time, IMG_E63, IMG_STATUS_OCCUPIED, IMG_TEST, IMG_TYPE_IMAGE, IMG_TYPE_RAW, imgEmpty(), imgInit(), imgReadEcat63Header(), imgSetEcat63MHeader(), imgSetEcat63SHeader(), IMG::m, mat_numcod(), ecat63_mainheader::num_frames, IMG::planeNumber, ecat63_scanheader::prompts, IMG::prompts, IMG::randoms, 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 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 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.

Parameters
fnamename 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_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 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().

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: