Functions
ecat63r.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
#include <string.h>
#include <unistd.h>
#include <time.h>
#include "swap.h"
#include "include/ecat63.h"
Include dependency graph for ecat63r.c:

Go to the source code of this file.

Functions

int ecat63ReadMainheader (FILE *fp, ECAT63_mainheader *h)
int ecat63ReadImageheader (FILE *fp, int blk, ECAT63_imageheader *h)
int ecat63ReadAttnheader (FILE *fp, int blk, ECAT63_attnheader *h)
int ecat63ReadScanheader (FILE *fp, int blk, ECAT63_scanheader *h)
int ecat63ReadNormheader (FILE *fp, int blk, ECAT63_normheader *h)
int ecat63ReadMatdata (FILE *fp, int strtblk, int blkNr, char *data, int dtype)
int ecat63ReadImageMatrix (FILE *fp, int first_block, int last_block, ECAT63_imageheader *h, float **fdata)
int ecat63ReadScanMatrix (FILE *fp, int first_block, int last_block, ECAT63_scanheader *h, float **fdata)
float ecat63rFloat (void *bufi, int isvax, int islittle)
int ecat63rInt (void *bufi, int isvax, int islittle)
int ecat63pxlbytes (short int data_type)

Function Documentation

int ecat63pxlbytes ( short int  data_type)

Returns the nr of bytes required for storage of one pixel of specified data_type

Parameters:
data_typedata type code
Returns:
number of bytes

Definition at line 711 of file ecat63r.c.

References BYTE_TYPE, IEEE_R4, SUN_I2, SUN_I4, VAX_I2, VAX_I4, and VAX_R4.

Referenced by ecat63WriteImageMatrix(), and ecat63WriteScanMatrix().

int ecat63ReadAttnheader ( FILE *  fp,
int  blk,
ECAT63_attnheader h 
)

Read ECAT 6.3 attenuation header

Parameters:
fpfile pointer
blkblock number [2..number of blocks]
hEcat 6.3 attenuation header
Returns:
0 if ok, 1 failed to find block, 3 failed to read block, 4 invalid data type, 5 invalid scale factor

Definition at line 238 of file ecat63r.c.

References ecat63_attnheader::attenuation_coeff, ecat63_attnheader::attenuation_type, BYTE_TYPE, ecat63_attnheader::data_type, ecat63_attnheader::dimension_1, ecat63_attnheader::dimension_2, ECAT63_TEST, ecat63rFloat(), MatBLKSIZE, ecat63_attnheader::sample_distance, ecat63_attnheader::scale_factor, SUN_I4, ecat63_attnheader::tilt_angle, ecat63_attnheader::x_origin, ecat63_attnheader::x_radius, ecat63_attnheader::y_origin, and ecat63_attnheader::y_radius.

Referenced by ecat63ReadAllToImg(), ecat63ReadPlaneToImg(), ecat6PrintSubheader(), imgReadEcat63Frame(), and imgReadEcat63Header().

Here is the call graph for this function:

int ecat63ReadImageheader ( FILE *  fp,
int  blk,
ECAT63_imageheader h 
)

Read ECAT 6.3 image header

Parameters:
fpfile pointer
blkblock number [2..number of blocks]
hEcat 6.3 image header
Returns:
0 if ok, 1 invalid input, 2 failed to find block, 3 failed to read block, 4 invalid data type, 5 invalid calibration factor, 6 invalid frame duration

Definition at line 152 of file ecat63r.c.

References ecat63_imageheader::annotation, ecat63_imageheader::atten_cor_mat_num, BYTE_TYPE, ecat63_imageheader::data_type, ecat63_imageheader::decay_corr_fctr, ecat63_imageheader::dimension_1, ecat63_imageheader::dimension_2, ECAT63_TEST, ecat63rFloat(), ecat63rInt(), ecat63_imageheader::ecat_calibration_fctr, ecat63_imageheader::fill1, ecat63_imageheader::fill2, ecat63_imageheader::filter_code, ecat63_imageheader::filter_params, ecat63_imageheader::frame_duration, ecat63_imageheader::frame_start_time, ecat63_imageheader::image_max, ecat63_imageheader::image_min, ecat63_imageheader::image_rotation, ecat63_imageheader::intrinsic_tilt, ecat63_imageheader::loss_corr_fctr, MatBLKSIZE, ecat63_imageheader::norm_matrix_num, ecat63_imageheader::num_dimensions, ecat63_imageheader::pixel_size, ecat63_imageheader::plane_eff_corr_fctr, ecat63_imageheader::processing_code, ecat63_imageheader::quant_scale, ecat63_imageheader::quant_units, ecat63_imageheader::recon_duration, ecat63_imageheader::recon_scale, ecat63_imageheader::recon_start_day, ecat63_imageheader::recon_start_hour, ecat63_imageheader::recon_start_min, ecat63_imageheader::recon_start_month, ecat63_imageheader::recon_start_sec, ecat63_imageheader::recon_start_year, ecat63_imageheader::scan_matrix_num, ecat63_imageheader::slice_location, ecat63_imageheader::slice_width, SUN_I4, ecat63_imageheader::well_counter_cal_fctr, ecat63_imageheader::x_origin, and ecat63_imageheader::y_origin.

Referenced by ecat63ReadAllToImg(), ecat63ReadImageMatrix(), ecat63ReadPlaneToImg(), ecat6PrintSubheader(), imgReadEcat63Frame(), and imgReadEcat63Header().

Here is the call graph for this function:

int ecat63ReadImageMatrix ( FILE *  fp,
int  first_block,
int  last_block,
ECAT63_imageheader h,
float **  fdata 
)

Read ECAT63 image matrix header and data. If only header is to be read, set last_block=first_block. Note: data is not calibrated with factor in main header.

Parameters:
fpECAT file pointer
first_blockSubheader record number
last_blockLast data block number
hPtr to subheader data which is filled
fdataPtr to the address of the matrix data
Returns:
0 if ok, 1 invalid input, 5 failed to read sub header, 6 invalid (x,y,z) dimesions, 8 failed to allocate memory for meta-data, 9 failed to read matrix data, 11 failed to allocate memory for image data

Definition at line 494 of file ecat63r.c.

References BYTE_TYPE, ecat63_imageheader::data_type, ecat63_imageheader::dimension_1, ecat63_imageheader::dimension_2, ECAT63_TEST, ecat63errmsg, ecat63PrintImageheader(), ecat63ReadImageheader(), ecat63ReadMatdata(), ecat63_imageheader::ecat_calibration_fctr, IEEE_R4, MatBLKSIZE, MatFirstDirBlk, ecat63_imageheader::quant_scale, SUN_I2, SUN_I4, VAX_I2, VAX_I4, and VAX_R4.

Here is the call graph for this function:

int ecat63ReadMainheader ( FILE *  fp,
ECAT63_mainheader h 
)

Read ECAT 6.3 main header

Parameters:
fpfile pointer
htarget Ecat 6.3 main header struture
Returns:
0 if ok, 1 invalid input, 2 failed to find subheader block, 3 invalid magic number (should be "ECAT63") at start of file, 5 invalid data type, 6 invalid calibration factor, 7 invalid file type

Definition at line 50 of file ecat63r.c.

References ecat63_mainheader::acquisition_type, ATTN_DATA, ecat63_mainheader::axial_fov, ecat63_mainheader::axial_samp_mode, ecat63_mainheader::bed_elevation, ecat63_mainheader::bed_offset, ecat63_mainheader::bed_type, BYTE_TYPE, ecat63_mainheader::calibration_factor, ecat63_mainheader::calibration_units, ecat63_mainheader::coin_samp_mode, ecat63_mainheader::collimator, ecat63_mainheader::compression_code, ecat63_mainheader::data_type, ECAT63_TEST, ecat63rFloat(), ecat63_mainheader::ecat_format, ecat63_mainheader::facility_name, ecat63_mainheader::file_type, ecat63_mainheader::fill1, ecat63_mainheader::fill2, ecat63_mainheader::gantry_rotation, ecat63_mainheader::gantry_tilt, IMAGE_DATA, ecat63_mainheader::init_bed_position, ecat63_mainheader::isotope_code, ecat63_mainheader::isotope_halflife, ecat63_mainheader::lwr_sctr_thres, ecat63_mainheader::lwr_true_thres, MatBLKSIZE, ecat63_mainheader::node_id, NORM_DATA, ecat63_mainheader::num_bed_pos, ecat63_mainheader::num_frames, ecat63_mainheader::num_gates, ecat63_mainheader::num_planes, ecat63_mainheader::operator_name, ecat63_mainheader::original_file_name, ecat63_mainheader::patient_age, ecat63_mainheader::patient_dexterity, ecat63_mainheader::patient_height, ecat63_mainheader::patient_id, ecat63_mainheader::patient_name, ecat63_mainheader::patient_sex, ecat63_mainheader::patient_weight, ecat63_mainheader::physician_name, ecat63_mainheader::plane_separation, ecat63_mainheader::radiopharmaceutical, RAW_DATA, ecat63_mainheader::rot_source_speed, 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, ecat63_mainheader::septa_type, ecat63_mainheader::study_description, ecat63_mainheader::study_name, SUN_I4, ecat63_mainheader::sw_version, ecat63_mainheader::system_type, ecat63_mainheader::transaxial_fov, ecat63_mainheader::transaxial_samp_mode, ecat63_mainheader::transm_source_type, ecat63_mainheader::upr_true_thres, ecat63_mainheader::user_process_code, and ecat63_mainheader::wobble_speed.

Referenced by ecat63AddImg(), ecat63ReadAllToImg(), ecat63ReadPlaneToImg(), imgRead(), imgReadEcat63Frame(), imgReadEcat63Header(), and imgWriteEcat63Frame().

Here is the call graph for this function:

int ecat63ReadMatdata ( FILE *  fp,
int  strtblk,
int  blkNr,
char *  data,
int  dtype 
)

Read ECAT 6.3 matrix data and convert byte order if necessary Remember to allocate memory for full blocks! There are differences here when compared to ecat7.c

Parameters:
fpfile pointer from where data is read
strtblkstarting block [>= 1]
blkNrnumber of block to be read [>= 0]
datapointer to block where data is read
dtypedata type code
Returns:
0 if ok, 1 invalid input, 2 failed to read data, 9 failed to find starting block from file,

Definition at line 432 of file ecat63r.c.

References BYTE_TYPE, ECAT63_TEST, ecat63rFloat(), ecat63rInt(), IEEE_R4, MatBLKSIZE, SUN_I2, SUN_I4, VAX_I2, VAX_I4, and VAX_R4.

Referenced by ecat63ReadAllToImg(), ecat63ReadImageMatrix(), ecat63ReadPlaneToImg(), ecat63ReadScanMatrix(), and imgReadEcat63Frame().

Here is the call graph for this function:

int ecat63ReadNormheader ( FILE *  fp,
int  blk,
ECAT63_normheader h 
)

Read ECAT 6.3 normalization header

Parameters:
fpfile pointer
blkblock number [2..number of blocks]
hEcat 6.3 normalization header
Returns:
0 if ok, 1 invalid input, 2 failed to find block, 3 failed to read block, 4 invalid data type, 5 invalid scale factor

Definition at line 375 of file ecat63r.c.

References BYTE_TYPE, ecat63_normheader::data_type, ecat63_normheader::dimension_1, ecat63_normheader::dimension_2, ECAT63_TEST, ecat63rFloat(), ecat63_normheader::fov_source_width, MatBLKSIZE, ecat63_normheader::norm_day, ecat63_normheader::norm_hour, ecat63_normheader::norm_minute, ecat63_normheader::norm_month, ecat63_normheader::norm_second, ecat63_normheader::norm_year, ecat63_normheader::scale_factor, and SUN_I4.

Referenced by ecat63ReadAllToImg(), ecat63ReadPlaneToImg(), ecat6PrintSubheader(), imgReadEcat63Frame(), and imgReadEcat63Header().

Here is the call graph for this function:

int ecat63ReadScanheader ( FILE *  fp,
int  blk,
ECAT63_scanheader h 
)
int ecat63ReadScanMatrix ( FILE *  fp,
int  first_block,
int  last_block,
ECAT63_scanheader h,
float **  fdata 
)

Read ECAT63 scan matrix header and data. If only header is to be read, set last_block=first_block. Note: data is not calibrated with factor in main header.

Parameters:
fpECAT file pointer
first_blockSubheader record number
last_blockLast data block number
hPtr to subheader data which is filled
fdataPtr to the address of the matrix data
Returns:
0 if ok, 1 invalid input, 5 failed to read sub header, 6 invalid (x,y,z) dimesions, 8 failed to allocate memory for meta-data, 9 failed to read matrix data, 11 failed to allocate memory for image data

Definition at line 586 of file ecat63r.c.

References BYTE_TYPE, ecat63_scanheader::data_type, ecat63_scanheader::dimension_1, ecat63_scanheader::dimension_2, ECAT63_TEST, ecat63errmsg, ecat63PrintScanheader(), ecat63ReadMatdata(), ecat63ReadScanheader(), IEEE_R4, MatBLKSIZE, MatFirstDirBlk, ecat63_scanheader::scale_factor, SUN_I2, SUN_I4, VAX_I2, VAX_I4, and VAX_R4.

Here is the call graph for this function:

float ecat63rFloat ( void *  bufi,
int  isvax,
int  islittle 
)

Reading ECAT 6.3 floats

Parameters:
bufipointer to 32-bit long data block
isvax1 for VAX format
islittle1 for little endian
Returns:
read float value

Definition at line 671 of file ecat63r.c.

Referenced by ecat63ReadAttnheader(), ecat63ReadImageheader(), ecat63ReadMainheader(), ecat63ReadMatdata(), ecat63ReadNormheader(), and ecat63ReadScanheader().

int ecat63rInt ( void *  bufi,
int  isvax,
int  islittle 
)

Reading and writing ECAT 6.3 32-bit ints. 32-bit int format is same in VAX and i386

Parameters:
bufipointer to 32-bit long data block
isvax1 for VAX format
islittle1 for littel endian
Returns:
read data as interger number

Definition at line 694 of file ecat63r.c.

Referenced by ecat63ReadImageheader(), ecat63ReadMatdata(), and ecat63ReadScanheader().