Data Structures | Macros | Typedefs | Functions | Variables
ecat7.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ecat7_mainheader
 
struct  ecat7_imageheader
 
struct  ecat7_scanheader
 
struct  ecat7_2Dscanheader
 
struct  ecat7_2Dnormheader
 
struct  ecat7_attenheader
 
struct  ecat7_normheader
 
struct  ecat7_polmapheader
 
struct  ECAT7_MatDir
 
struct  ECAT7_MATRIXLIST
 
struct  ECAT7_Matval
 

Macros

#define MatBLKSIZE   512
 
#define MatFirstDirBlk   2
 
#define ECAT7V_MAGICNR   "MATRIX72v"
 
#define ECAT7S_MAGICNR   "MATRIX7011"
 
#define ECAT7_SW_VERSION   72
 
#define ECAT7_BYTE   1
 
#define ECAT7_VAXI2   2
 
#define ECAT7_VAXI4   3
 
#define ECAT7_VAXR4   4
 
#define ECAT7_IEEER4   5
 
#define ECAT7_SUNI2   6
 
#define ECAT7_SUNI4   7
 
#define ECAT7_UNKNOWN   0
 
#define ECAT7_2DSCAN   1
 
#define ECAT7_IMAGE16   2
 
#define ECAT7_ATTEN   3
 
#define ECAT7_2DNORM   4
 
#define ECAT7_POLARMAP   5
 
#define ECAT7_VOLUME8   6
 
#define ECAT7_VOLUME16   7
 
#define ECAT7_PROJ   8
 
#define ECAT7_PROJ16   9
 
#define ECAT7_IMAGE8   10
 
#define ECAT7_3DSCAN   11
 
#define ECAT7_3DSCAN8   12
 
#define ECAT7_3DNORM   13
 
#define ECAT7_3DSCANFIT   14
 
#define ECAT7_Feet_First_Prone   0
 
#define ECAT7_Head_First_Prone   1
 
#define ECAT7_Feet_First_Supine   2
 
#define ECAT7_Head_First_Supine   3
 
#define ECAT7_Feet_First_Decubitus_Right   4
 
#define ECAT7_Head_First_Decubitus_Right   5
 
#define ECAT7_Feet_First_Decubitus_Left   6
 
#define ECAT7_Head_First_Decubitus_Left   7
 
#define ECAT7_Unknown_Orientation   8
 
#define BACKUP_EXTENSION   ".bak"
 

Typedefs

typedef struct ecat7_mainheader ECAT7_mainheader
 
typedef struct ecat7_imageheader ECAT7_imageheader
 
typedef struct ecat7_scanheader ECAT7_scanheader
 
typedef struct ecat7_2Dscanheader ECAT7_2Dscanheader
 
typedef struct ecat7_2Dnormheader ECAT7_2Dnormheader
 
typedef struct ecat7_attenheader ECAT7_attenheader
 
typedef struct ecat7_normheader ECAT7_normheader
 
typedef struct ecat7_polmapheader ECAT7_polmapheader
 

Functions

int ecat7ReadMainheader (FILE *fp, ECAT7_mainheader *h)
 
int ecat7ReadImageheader (FILE *fp, int blk, ECAT7_imageheader *h)
 
int ecat7ReadAttenheader (FILE *fp, int blk, ECAT7_attenheader *h)
 
int ecat7ReadPolmapheader (FILE *fp, int blk, ECAT7_polmapheader *h)
 
int ecat7ReadNormheader (FILE *fp, int blk, ECAT7_normheader *h)
 
int ecat7ReadScanheader (FILE *fp, int blk, ECAT7_scanheader *h)
 
int ecat7Read2DScanheader (FILE *fp, int blk, ECAT7_2Dscanheader *h)
 
int ecat7Read2DNormheader (FILE *fp, int blk, ECAT7_2Dnormheader *h)
 
int ecat7ReadMatrixdata (FILE *fp, int start_block, int block_nr, char *data, int dtype)
 
float ecat7rFloat (void *bufi, int isvax, int islittle)
 
int ecat7rInt (void *bufi, int isvax, int islittle)
 
int ecat7ReadImageMatrix (FILE *fp, int first_block, int last_block, ECAT7_imageheader *h, float **fdata)
 
int ecat7Read2DScanMatrix (FILE *fp, int first_block, int last_block, ECAT7_2Dscanheader *h, float **fdata)
 
int ecat7ReadScanMatrix (FILE *fp, int first_block, int last_block, ECAT7_scanheader *h, float **fdata)
 
int ecat7ReadPolarmapMatrix (FILE *fp, int first_block, int last_block, ECAT7_polmapheader *h, float **fdata)
 
int ecat7pxlbytes (short int data_type)
 
void ecat7InitMatlist (ECAT7_MATRIXLIST *mlist)
 
void ecat7EmptyMatlist (ECAT7_MATRIXLIST *mlist)
 
int ecat7ReadMatlist (FILE *fp, ECAT7_MATRIXLIST *ml)
 
void ecat7PrintMatlist (ECAT7_MATRIXLIST *ml)
 
int ecat7EnterMatrix (FILE *fp, int matrix_id, int block_nr)
 
int ecat7_val_to_id (int frame, int plane, int gate, int data, int bed)
 
void ecat7_id_to_val (int matrix_id, ECAT7_Matval *matval)
 
void ecat7SortMatlistByPlane (ECAT7_MATRIXLIST *ml)
 
void ecat7SortMatlistByFrame (ECAT7_MATRIXLIST *ml)
 
int ecat7CheckMatlist (ECAT7_MATRIXLIST *ml)
 
int ecat7DeleteLateFrames (ECAT7_MATRIXLIST *ml, int frame_nr)
 
int ecat7GetPlaneAndFrameNr (ECAT7_MATRIXLIST *mlist, ECAT7_mainheader *h, int *plane_nr, int *frame_nr)
 
int ecat7GetMatrixBlockSize (ECAT7_MATRIXLIST *mlist, int *blk_nr)
 
int ecat7GetNums (ECAT7_MATRIXLIST *ml, ECAT7_mainheader *mh, FILE *fp, short int *num_planes, short int *num_frames, short int *num_gates, short int *num_bed_pos)
 
int ecat7GatherMatlist (ECAT7_MATRIXLIST *ml, short int do_planes, short int do_frames, short int do_gates, short int do_beds)
 
int ecat7WriteMainheader (FILE *fp, ECAT7_mainheader *h)
 
int ecat7WriteImageheader (FILE *fp, int blk, ECAT7_imageheader *h)
 
int ecat7WriteAttenheader (FILE *fp, int blk, ECAT7_attenheader *h)
 
int ecat7WritePolmapheader (FILE *fp, int blk, ECAT7_polmapheader *h)
 
int ecat7WriteNormheader (FILE *fp, int blk, ECAT7_normheader *h)
 
int ecat7WriteScanheader (FILE *fp, int blk, ECAT7_scanheader *h)
 
int ecat7Write2DScanheader (FILE *fp, int blk, ECAT7_2Dscanheader *h)
 
int ecat7Write2DNormheader (FILE *fp, int blk, ECAT7_2Dnormheader *h)
 
int ecat7WritePolarmapMatrix (FILE *fp, int matrix_id, ECAT7_polmapheader *h, float *fdata)
 
int ecat7WriteMatrixdata (FILE *fp, int start_block, char *data, int pxl_nr, int pxl_size)
 
FILE * ecat7Create (const char *fname, ECAT7_mainheader *h)
 
int ecat7WriteImageMatrix (FILE *fp, int matrix_id, ECAT7_imageheader *h, float *fdata)
 
int ecat7Write2DScanMatrix (FILE *fp, int matrix_id, ECAT7_2Dscanheader *h, float *fdata)
 
int ecat7WriteScanMatrix (FILE *fp, int matrix_id, ECAT7_scanheader *h, float *fdata)
 
int ecat7_is_scaling_needed (float amax, float *data, int nr)
 
void ecat7PrintMainheader (ECAT7_mainheader *h, FILE *fp)
 
void ecat7PrintImageheader (ECAT7_imageheader *h, FILE *fp)
 
void ecat7PrintScanheader (ECAT7_scanheader *h, FILE *fp)
 
void ecat7PrintAttenheader (ECAT7_attenheader *h, FILE *fp)
 
void ecat7PrintPolmapheader (ECAT7_polmapheader *h, FILE *fp)
 
void ecat7PrintNormheader (ECAT7_normheader *h, FILE *fp)
 
void ecat7Print2DScanheader (ECAT7_2Dscanheader *h, FILE *fp)
 
void ecat7Print2DNormheader (ECAT7_2Dnormheader *h, FILE *fp)
 
int ecat7PrintSubheader (ECAT7_mainheader mh, FILE *fp, int plane, int frame, FILE *ofp)
 
char * ecat7filetype (short int file_type)
 
char * ecat7acquisitiontype (short int acquisition_type)
 
char * ecat7datatype (short int data_type)
 
int ecat7EditMHeader (ECAT7_mainheader *h, char *field, char *value)
 
int ecat7EditSHeader (ECAT7_scanheader *h, char *field, char *value)
 
int ecat7EditVHeader (ECAT7_imageheader *h, char *field, char *value)
 

Variables

char ecat7errmsg [128]
 
int ECAT7_TEST
 

Macro Definition Documentation

#define BACKUP_EXTENSION   ".bak"

Definition at line 96 of file ecat7.h.

#define ECAT7_2DNORM   4

Definition at line 71 of file ecat7.h.

Referenced by ecat7PrintSubheader().

#define ECAT7_2DSCAN   1
#define ECAT7_3DNORM   13

Definition at line 80 of file ecat7.h.

Referenced by ecat7PrintSubheader().

#define ECAT7_3DSCAN   11
#define ECAT7_3DSCAN8   12
#define ECAT7_3DSCANFIT   14
#define ECAT7_ATTEN   3

Definition at line 70 of file ecat7.h.

Referenced by ecat7PrintSubheader().

#define ECAT7_BYTE   1
#define ECAT7_Feet_First_Decubitus_Left   6

Definition at line 90 of file ecat7.h.

#define ECAT7_Feet_First_Decubitus_Right   4

Definition at line 88 of file ecat7.h.

#define ECAT7_Feet_First_Prone   0

Patient orientation

Definition at line 84 of file ecat7.h.

#define ECAT7_Feet_First_Supine   2

Definition at line 86 of file ecat7.h.

#define ECAT7_Head_First_Decubitus_Left   7

Definition at line 91 of file ecat7.h.

#define ECAT7_Head_First_Decubitus_Right   5

Definition at line 89 of file ecat7.h.

#define ECAT7_Head_First_Prone   1

Definition at line 85 of file ecat7.h.

#define ECAT7_Head_First_Supine   3

Definition at line 87 of file ecat7.h.

#define ECAT7_IEEER4   5
#define ECAT7_IMAGE16   2
#define ECAT7_IMAGE8   10
#define ECAT7_POLARMAP   5
#define ECAT7_PROJ   8

Definition at line 75 of file ecat7.h.

#define ECAT7_PROJ16   9

Definition at line 76 of file ecat7.h.

#define ECAT7_SUNI2   6
#define ECAT7_SUNI4   7
#define ECAT7_SW_VERSION   72

Definition at line 55 of file ecat7.h.

#define ECAT7_UNKNOWN   0

Matrix filetypes

Definition at line 67 of file ecat7.h.

#define ECAT7_Unknown_Orientation   8

Definition at line 92 of file ecat7.h.

#define ECAT7_VAXI2   2
#define ECAT7_VAXI4   3
#define ECAT7_VAXR4   4
#define ECAT7_VOLUME16   7
#define ECAT7_VOLUME8   6
#define ECAT7S_MAGICNR   "MATRIX7011"

Definition at line 54 of file ecat7.h.

Referenced by imgSetEcat7MHeader().

#define ECAT7V_MAGICNR   "MATRIX72v"
#define MatBLKSIZE   512

Definition at line 47 of file ecat7.h.

#define MatFirstDirBlk   2

Definition at line 50 of file ecat7.h.

Typedef Documentation

Function Documentation

void ecat7_id_to_val ( int  matrix_id,
ECAT7_Matval matval 
)

Conversion of matrix identifier to numerical values

Parameters
matrix_idmatrix identifire coding
matvalmatrix values structure

Definition at line 299 of file ecat7ml.c.

References ECAT7_Matval::bed, ECAT7_Matval::data, ECAT7_Matval::frame, ECAT7_Matval::gate, and ECAT7_Matval::plane.

Referenced by ecat7DeleteLateFrames(), ecat7GatherMatlist(), ecat7GetNums(), ecat7GetPlaneAndFrameNr(), ecat7PrintMatlist(), ecat7PrintSubheader(), ecat7SortMatlistByFrame(), ecat7SortMatlistByPlane(), imgReadEcat7(), and imgReadEcat7Frame().

int ecat7_is_scaling_needed ( float  amax,
float *  data,
int  nr 
)

Check if pixel float values need to be scaled to be saved as short ints, or if they are already all very close to integers.

Parameters
amaxabsolute maximum value
datafloat array
nrfloat array size
Returns
1, if scaling is necessary, and 0 if not.

Definition at line 657 of file ecat7w.c.

Referenced by ecat7Write2DScanMatrix(), ecat7WriteImageMatrix(), ecat7WritePolarmapMatrix(), and ecat7WriteScanMatrix().

int ecat7_val_to_id ( int  frame,
int  plane,
int  gate,
int  data,
int  bed 
)

Returns the matrix identifier.

Parameters
frameframe number [0..65536]
planeplane number [0..65536]
gategate number [0..64]
datadata [0..1]
bedbed position [0..16]
Returns
matrix identifier coding

Definition at line 282 of file ecat7ml.c.

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

char* ecat7acquisitiontype ( short int  acquisition_type)

Returns pointer to a string describing the ECAT7 acquisition_type

Parameters
acquisition_typeacquisition type code
Returns
pointer to static string

Definition at line 498 of file ecat7p.c.

Referenced by ecat7PrintMainheader().

int ecat7CheckMatlist ( ECAT7_MATRIXLIST ml)

Checks that all matrixlist entries have read/write status.

Parameters
mlchecked matrix list
Returns
0 if ok, or 1 if an entry is marked as deleted or unfinished

Definition at line 366 of file ecat7ml.c.

References ECAT7_MATRIXLIST::matdir, ECAT7_MATRIXLIST::matrixNr, and ECAT7_MatDir::status.

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

FILE* ecat7Create ( const char *  fname,
ECAT7_mainheader h 
)

Create a new ECAT 7.x file. If file exists, it is renamed as fname% if possible. Directory list is written in big endian byte order.

Parameters
fnamefilename
hEcat7 main header
Returns
file pointer or NULL in case of an error.

Definition at line 616 of file ecat7w.c.

References BACKUP_EXTENSION, ECAT7_TEST, ecat7WriteMainheader(), MatBLKSIZE, and MatFirstDirBlk.

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

Here is the call graph for this function:

char* ecat7datatype ( short int  data_type)

Returns pointer to a string describing the ECAT7 data_type

Parameters
data_typedata type code
Returns
pointer to static string

Definition at line 517 of file ecat7p.c.

Referenced by ecat7Print2DNormheader(), ecat7Print2DScanheader(), ecat7PrintAttenheader(), ecat7PrintImageheader(), ecat7PrintNormheader(), ecat7PrintPolmapheader(), and ecat7PrintScanheader().

int ecat7DeleteLateFrames ( ECAT7_MATRIXLIST ml,
int  frame_nr 
)

Mark deleted the frames after the specified frame number.

Parameters
mltarget matrix list
frame_nrfirst index to be marked as deleted [1..number of frames]
Returns
Returns the number of deleted matrices.

Definition at line 383 of file ecat7ml.c.

References ecat7_id_to_val(), ECAT7_Matval::frame, ECAT7_MatDir::id, ECAT7_MATRIXLIST::matdir, ECAT7_MATRIXLIST::matrixNr, and ECAT7_MatDir::status.

Here is the call graph for this function:

int ecat7EditMHeader ( ECAT7_mainheader h,
char *  field,
char *  value 
)

Edit ECAT 7 main header.

Returns
Returns 0, if ok, and 1 or 2, if field name or or value is invalid.
Parameters
hPointer to ECAT 7 mainheader structure
fieldField name to be changed
valueNew value for the field

Definition at line 30 of file ecat7h.c.

References ecat7_mainheader::acquisition_mode, ecat7_mainheader::acquisition_type, ecat7_mainheader::angular_compression, ecat7_mainheader::axial_samp_mode, ecat7_mainheader::bed_elevation, ecat7_mainheader::bed_position, ecat7_mainheader::bin_size, ecat7_mainheader::branching_fraction, ecat7_mainheader::calibration_units, ecat7_mainheader::calibration_units_label, ecat7_mainheader::coin_samp_mode, ecat7_mainheader::compression_code, ecat7_mainheader::data_units, ecat7_mainheader::distance_scanned, ecat7_mainheader::dosage, ecat7_mainheader::dose_start_time, ecat7_mainheader::ecat_calibration_factor, ecat7_mainheader::facility_name, ecat7_mainheader::file_type, ecat7_mainheader::gantry_rotation, ecat7_mainheader::gantry_tilt, ecat7_mainheader::init_bed_position, ecat7_mainheader::intrinsic_tilt, ecat7_mainheader::isotope_halflife, ecat7_mainheader::isotope_name, ecat7_mainheader::lwr_sctr_thres, ecat7_mainheader::lwr_true_thres, ecat7_mainheader::magic_number, ecat7_mainheader::num_bed_pos, ecat7_mainheader::num_frames, ecat7_mainheader::num_gates, ecat7_mainheader::num_planes, ecat7_mainheader::operator_name, ecat7_mainheader::original_file_name, ecat7_mainheader::patient_age, ecat7_mainheader::patient_birth_date, ecat7_mainheader::patient_dexterity, ecat7_mainheader::patient_height, ecat7_mainheader::patient_id, ecat7_mainheader::patient_name, ecat7_mainheader::patient_orientation, ecat7_mainheader::patient_sex, ecat7_mainheader::patient_weight, ecat7_mainheader::physician_name, ecat7_mainheader::plane_separation, ecat7_mainheader::radiopharmaceutical, ecat7_mainheader::scan_start_time, ecat7_mainheader::septa_state, ecat7_mainheader::serial_number, ecat7_mainheader::study_description, ecat7_mainheader::study_type, ecat7_mainheader::sw_version, ecat7_mainheader::system_type, ecat7_mainheader::transaxial_fov, ecat7_mainheader::transm_source_type, ecat7_mainheader::upr_true_thres, ecat7_mainheader::user_process_code, ecat7_mainheader::well_counter_corr_factor, and ecat7_mainheader::wobble_speed.

int ecat7EditSHeader ( ECAT7_scanheader h,
char *  field,
char *  value 
)
int ecat7EditVHeader ( ECAT7_imageheader h,
char *  field,
char *  value 
)

Edit ECAT 7 image volume header.

Returns
Returns 0, if ok, and 1 or 2, if field name or or value is invalid.
Parameters
hPointer to ECAT 7 image volume header structure
fieldField name to be changed
valueNew value for the field

Definition at line 312 of file ecat7h.c.

References ecat7_imageheader::annotation, ecat7_imageheader::data_type, ecat7_imageheader::decay_corr_fctr, ecat7_imageheader::filter_code, ecat7_imageheader::filter_cutoff_frequency, ecat7_imageheader::filter_order, ecat7_imageheader::filter_ramp_slope, ecat7_imageheader::filter_resolution, ecat7_imageheader::filter_scatter_fraction, ecat7_imageheader::filter_scatter_slope, ecat7_imageheader::frame_duration, ecat7_imageheader::frame_start_time, ecat7_imageheader::gate_duration, ecat7_imageheader::image_max, ecat7_imageheader::image_min, ecat7_imageheader::mt_1_1, ecat7_imageheader::mt_1_2, ecat7_imageheader::mt_1_3, ecat7_imageheader::mt_1_4, ecat7_imageheader::mt_2_1, ecat7_imageheader::mt_2_2, ecat7_imageheader::mt_2_3, ecat7_imageheader::mt_2_4, ecat7_imageheader::mt_3_1, ecat7_imageheader::mt_3_2, ecat7_imageheader::mt_3_3, ecat7_imageheader::mt_3_4, ecat7_imageheader::num_accepted_beats, ecat7_imageheader::num_angles, ecat7_imageheader::num_dimensions, ecat7_imageheader::num_r_elements, ecat7_imageheader::processing_code, ecat7_imageheader::r_wave_offset, ecat7_imageheader::recon_type, ecat7_imageheader::recon_views, ecat7_imageheader::recon_zoom, ecat7_imageheader::rfilter_code, ecat7_imageheader::rfilter_cutoff, ecat7_imageheader::rfilter_order, ecat7_imageheader::rfilter_resolution, ecat7_imageheader::scale_factor, ecat7_imageheader::scatter_type, ecat7_imageheader::x_dimension, ecat7_imageheader::x_offset, ecat7_imageheader::x_pixel_size, ecat7_imageheader::x_resolution, ecat7_imageheader::y_dimension, ecat7_imageheader::y_offset, ecat7_imageheader::y_pixel_size, ecat7_imageheader::y_resolution, ecat7_imageheader::z_dimension, ecat7_imageheader::z_offset, ecat7_imageheader::z_pixel_size, ecat7_imageheader::z_resolution, ecat7_imageheader::z_rotation_angle, ecat7_imageheader::zfilter_code, ecat7_imageheader::zfilter_cutoff, ecat7_imageheader::zfilter_order, and ecat7_imageheader::zfilter_resolution.

void ecat7EmptyMatlist ( ECAT7_MATRIXLIST mlist)

Free memory allocated for ECAT matrix list.

Parameters
mlisttarget matrix list that has allocated memory

Definition at line 70 of file ecat7ml.c.

References ECAT7_MATRIXLIST::matdir, ECAT7_MATRIXLIST::matrixNr, and ECAT7_MATRIXLIST::matrixSpace.

Referenced by ecat7PrintSubheader(), ecat7ReadMatlist(), imgReadEcat7(), imgReadEcat7Frame(), and imgReadEcat7Header().

int ecat7EnterMatrix ( FILE *  fp,
int  matrix_id,
int  block_nr 
)

Prepare matrix list for additional matrix data and return block number for matrix header. Directory records are written in big endian byte order. Set block_nr to the number of data blocks + (nr of header blocks - 1)

Parameters
fpfile pointer
matrix_idmatrix identifier coding
block_nrmatrix number [1..number of matrixes]
Returns
returns the block number for matrix header, -1 if invalid input, -2 if first directory block is not found, -3 if failed to read first block, -9 if other directory block is not found, -10 if failed to read other block, -11 if place for new directory block is not found, -12 if failed clear new block, -15 if place for new directory block is not found, -16 if failed to write into new block

Definition at line 184 of file ecat7ml.c.

References ECAT7_TEST, MatBLKSIZE, and MatFirstDirBlk.

Referenced by ecat7Write2DScanMatrix(), ecat7WriteImageMatrix(), ecat7WritePolarmapMatrix(), and ecat7WriteScanMatrix().

char* ecat7filetype ( short int  file_type)

Returns pointer to a string describing the ECAT7 file_type

Parameters
file_typefile type code
Returns
pointer to static string

Definition at line 479 of file ecat7p.c.

Referenced by ecat7PrintMainheader(), and imgRead().

int ecat7GatherMatlist ( ECAT7_MATRIXLIST ml,
short int  do_planes,
short int  do_frames,
short int  do_gates,
short int  do_beds 
)

Matrix numbers in ECAT 7 matrix list are edited, when necessary, so that plane, frame, gate and/or bed numbers are continuous, starting from one (planes, frames and gates) or from zero (beds). List order is not changed.

Parameters
mlECAT 7 matrix list, where the matrix numbers will be edited
do_planesPlane numbers are gathered together (1) or not (0)
do_framesFrame numbers are gathered together (1) or not (0)
do_gatesGate numbers are gathered together (1) or not (0)
do_bedsBed numbers are gathered together (1) or not (0)
Returns
0 if successful, 1 if invalid input, 3 failed to allocate memory

Definition at line 572 of file ecat7ml.c.

References ECAT7_Matval::bed, ecat7_id_to_val(), ecat7_val_to_id(), ECAT7_Matval::frame, ECAT7_Matval::gate, ECAT7_MatDir::id, ECAT7_MATRIXLIST::matdir, ECAT7_MATRIXLIST::matrixNr, and ECAT7_Matval::plane.

Referenced by imgReadEcat7Frame(), and imgReadEcat7Header().

Here is the call graph for this function:

int ecat7GetMatrixBlockSize ( ECAT7_MATRIXLIST mlist,
int *  blk_nr 
)

Calculate the size of one data matrix in ECAT7 file matrix list, and check that the size is same in all matrices.

Parameters
mlistEcat7 matrix list; note that this list is here sorted by planes
blk_nrnumber of blocks will be put here; NULL if not needed
Returns
errstatus, which is STATUS_OK (0) when call was successful, and >0 in case of an error.

Definition at line 455 of file ecat7ml.c.

References ECAT7_MatDir::endblk, ECAT7_MATRIXLIST::matdir, ECAT7_MATRIXLIST::matrixNr, STATUS_FAULT, STATUS_OK, STATUS_VARMATSIZE, and ECAT7_MatDir::strtblk.

Referenced by imgReadEcat7Header().

int ecat7GetNums ( ECAT7_MATRIXLIST ml,
ECAT7_mainheader mh,
FILE *  fp,
short int *  num_planes,
short int *  num_frames,
short int *  num_gates,
short int *  num_bed_pos 
)

Read the maximum plane, frame, gate and bed number from matrixlist. In case of 3D formats, num_planes is checked from the first subheader.

Parameters
mlPointer to matrixlist
mhPointer to mainheader
fpFile pointer to ECAT7 file opened in binary mode
num_planesnum_planes will be put here; NULL if not needed to be read
num_framesnum_planes will be put here; NULL if not needed to be read
num_gatesnum_planes will be put here; NULL if not needed to be read
num_bed_posnum_planes will be put here; NULL if not needed to be read
Returns
0 if successful, 1 if invalid input, 2 if no matrixes, 3 failed to allocate memory, 5 if failed to read image/scan header information

Definition at line 489 of file ecat7ml.c.

References ECAT7_Matval::bed, ECAT7_3DSCAN, ECAT7_3DSCAN8, ECAT7_3DSCANFIT, ecat7_id_to_val(), ECAT7_VOLUME16, ECAT7_VOLUME8, ecat7ReadImageheader(), ecat7ReadScanheader(), ecat7_mainheader::file_type, ECAT7_Matval::frame, ECAT7_Matval::gate, ECAT7_MatDir::id, ECAT7_MATRIXLIST::matdir, ECAT7_MATRIXLIST::matrixNr, ecat7_imageheader::num_dimensions, ecat7_scanheader::num_z_elements, ECAT7_Matval::plane, ECAT7_MatDir::strtblk, and ecat7_imageheader::z_dimension.

Here is the call graph for this function:

int ecat7GetPlaneAndFrameNr ( ECAT7_MATRIXLIST mlist,
ECAT7_mainheader h,
int *  plane_nr,
int *  frame_nr 
)

Calculate the number of planes and frames/gates from ECAT7 matrix list. Check that all planes have equal nr of frames/gates, that frames/gates are sequentally numbered.

Parameters
mlistEcat7 matrix list; note that this list is here sorted by planes
hEcat7 main header structure
plane_nrNumber of planes will be put here; NULL if not needed [1..number of planes, or NULL]
frame_nrNumber of frames/gates will be put here; NULL if not needed [1..number of frames, or NULL]
Returns
errstatus, which is STATUS_OK (0) when call was successful, and >0 in case of an error. Note that if this is 3D image volume or sinogram, then the returned plane_nr will be one, and the actual Z dim must be read from subheader.

Definition at line 409 of file ecat7ml.c.

References ecat7_id_to_val(), ecat7SortMatlistByPlane(), ECAT7_Matval::frame, ECAT7_Matval::gate, ECAT7_MatDir::id, ECAT7_MATRIXLIST::matdir, ECAT7_MATRIXLIST::matrixNr, ecat7_mainheader::num_frames, ecat7_mainheader::num_gates, ECAT7_Matval::plane, STATUS_FAULT, STATUS_MISSINGMATRIX, and STATUS_OK.

Referenced by imgReadEcat7Header().

Here is the call graph for this function:

void ecat7InitMatlist ( ECAT7_MATRIXLIST mlist)

Initiate ECAT matrix list. Call this once before first use.

Parameters
mlisttarget matrix list

Definition at line 59 of file ecat7ml.c.

References ECAT7_MATRIXLIST::matdir, ECAT7_MATRIXLIST::matrixNr, and ECAT7_MATRIXLIST::matrixSpace.

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

void ecat7Print2DNormheader ( ECAT7_2Dnormheader h,
FILE *  fp 
)
void ecat7Print2DScanheader ( ECAT7_2Dscanheader h,
FILE *  fp 
)
void ecat7PrintAttenheader ( ECAT7_attenheader h,
FILE *  fp 
)
void ecat7PrintImageheader ( ECAT7_imageheader h,
FILE *  fp 
)

Print ECAT 7.x image header contents to specified file pointer.

Parameters
hEcat7 image header
fptarget file pointer

Definition at line 137 of file ecat7p.c.

References ecat7_imageheader::annotation, ecat7_imageheader::data_type, ecat7_imageheader::decay_corr_fctr, ECAT7_TEST, ecat7datatype(), ecat7_imageheader::fill_cti, ecat7_imageheader::fill_user, ecat7_imageheader::filter_code, ecat7_imageheader::filter_cutoff_frequency, ecat7_imageheader::filter_order, ecat7_imageheader::filter_ramp_slope, ecat7_imageheader::filter_resolution, ecat7_imageheader::filter_scatter_fraction, ecat7_imageheader::filter_scatter_slope, ecat7_imageheader::frame_duration, ecat7_imageheader::frame_start_time, ecat7_imageheader::gate_duration, ecat7_imageheader::image_max, ecat7_imageheader::image_min, ecat7_imageheader::mt_1_1, ecat7_imageheader::mt_1_2, ecat7_imageheader::mt_1_3, ecat7_imageheader::mt_1_4, ecat7_imageheader::mt_2_1, ecat7_imageheader::mt_2_2, ecat7_imageheader::mt_2_3, ecat7_imageheader::mt_2_4, ecat7_imageheader::mt_3_1, ecat7_imageheader::mt_3_2, ecat7_imageheader::mt_3_3, ecat7_imageheader::mt_3_4, ecat7_imageheader::num_accepted_beats, ecat7_imageheader::num_angles, ecat7_imageheader::num_dimensions, ecat7_imageheader::num_r_elements, ecat7_imageheader::processing_code, ecat7_imageheader::r_wave_offset, ecat7_imageheader::recon_type, ecat7_imageheader::recon_views, ecat7_imageheader::recon_zoom, ecat7_imageheader::rfilter_code, ecat7_imageheader::rfilter_cutoff, ecat7_imageheader::rfilter_order, ecat7_imageheader::rfilter_resolution, ecat7_imageheader::scale_factor, ecat7_imageheader::scatter_type, ecat7_imageheader::x_dimension, ecat7_imageheader::x_offset, ecat7_imageheader::x_pixel_size, ecat7_imageheader::x_resolution, ecat7_imageheader::y_dimension, ecat7_imageheader::y_offset, ecat7_imageheader::y_pixel_size, ecat7_imageheader::y_resolution, ecat7_imageheader::z_dimension, ecat7_imageheader::z_offset, ecat7_imageheader::z_pixel_size, ecat7_imageheader::z_resolution, ecat7_imageheader::z_rotation_angle, ecat7_imageheader::zfilter_code, ecat7_imageheader::zfilter_cutoff, ecat7_imageheader::zfilter_order, and ecat7_imageheader::zfilter_resolution.

Referenced by ecat7PrintSubheader(), and ecat7ReadImageMatrix().

Here is the call graph for this function:

void ecat7PrintMainheader ( ECAT7_mainheader h,
FILE *  fp 
)

Print ECAT 7.x main header contents to specified file pointer

Parameters
hEcat7 main header
fptarget file pointer

Definition at line 49 of file ecat7p.c.

References ecat7_mainheader::acquisition_mode, ecat7_mainheader::acquisition_type, ecat7_mainheader::angular_compression, ecat7_mainheader::axial_samp_mode, ecat7_mainheader::bed_elevation, ecat7_mainheader::bed_position, ecat7_mainheader::bin_size, ecat7_mainheader::branching_fraction, ecat7_mainheader::calibration_units, ecat7_mainheader::calibration_units_label, ecat7_mainheader::coin_samp_mode, ecat7_mainheader::compression_code, ecat7_mainheader::data_units, ecat7_mainheader::distance_scanned, ecat7_mainheader::dosage, ecat7_mainheader::dose_start_time, ECAT7_TEST, ecat7acquisitiontype(), ecat7filetype(), ecat7_mainheader::ecat_calibration_factor, ecat7_mainheader::facility_name, ecat7_mainheader::file_type, ecat7_mainheader::fill_cti, ecat7_mainheader::gantry_rotation, ecat7_mainheader::gantry_tilt, ecat7_mainheader::init_bed_position, ecat7_mainheader::intrinsic_tilt, ecat7_mainheader::isotope_halflife, ecat7_mainheader::isotope_name, ecat7_mainheader::lwr_sctr_thres, ecat7_mainheader::lwr_true_thres, ecat7_mainheader::magic_number, ecat7_mainheader::num_bed_pos, ecat7_mainheader::num_frames, ecat7_mainheader::num_gates, ecat7_mainheader::num_planes, ecat7_mainheader::operator_name, ecat7_mainheader::original_file_name, ecat7_mainheader::patient_age, ecat7_mainheader::patient_birth_date, ecat7_mainheader::patient_dexterity, ecat7_mainheader::patient_height, ecat7_mainheader::patient_id, ecat7_mainheader::patient_name, ecat7_mainheader::patient_orientation, ecat7_mainheader::patient_sex, ecat7_mainheader::patient_weight, ecat7_mainheader::physician_name, ecat7_mainheader::plane_separation, ecat7_mainheader::radiopharmaceutical, ecat7_mainheader::scan_start_time, ecat7_mainheader::septa_state, ecat7_mainheader::serial_number, ecat7_mainheader::study_description, ecat7_mainheader::study_type, ecat7_mainheader::sw_version, ecat7_mainheader::system_type, ecat7_mainheader::transaxial_fov, ecat7_mainheader::transm_source_type, ecat7_mainheader::upr_true_thres, ecat7_mainheader::user_process_code, ecat7_mainheader::well_counter_corr_factor, and ecat7_mainheader::wobble_speed.

Here is the call graph for this function:

void ecat7PrintMatlist ( ECAT7_MATRIXLIST ml)

Print ECAT matrix list on stdout.

Parameters
mlmatrix list for Ecat7 file

Definition at line 149 of file ecat7ml.c.

References ECAT7_Matval::bed, ecat7_id_to_val(), ECAT7_MatDir::endblk, ECAT7_Matval::frame, ECAT7_Matval::gate, ECAT7_MatDir::id, ECAT7_MATRIXLIST::matdir, ECAT7_MATRIXLIST::matrixNr, ECAT7_Matval::plane, ECAT7_MatDir::status, and ECAT7_MatDir::strtblk.

Referenced by ecat7PrintSubheader(), and imgReadEcat7().

Here is the call graph for this function:

void ecat7PrintNormheader ( ECAT7_normheader h,
FILE *  fp 
)
void ecat7PrintPolmapheader ( ECAT7_polmapheader h,
FILE *  fp 
)
void ecat7PrintScanheader ( ECAT7_scanheader h,
FILE *  fp 
)
int ecat7PrintSubheader ( ECAT7_mainheader  mh,
FILE *  fp,
int  plane,
int  frame,
FILE *  ofp 
)
int ecat7pxlbytes ( short int  data_type)

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

Parameters
data_typedefined value for data type
Returns
number of bytes (1,2 or 4) or 0 if type not recognized

Definition at line 1055 of file ecat7r.c.

References ECAT7_BYTE, ECAT7_IEEER4, ECAT7_SUNI2, ECAT7_SUNI4, ECAT7_VAXI2, ECAT7_VAXI4, and ECAT7_VAXR4.

Referenced by ecat7ReadScanMatrix(), ecat7Write2DScanMatrix(), ecat7WriteImageMatrix(), ecat7WritePolarmapMatrix(), and ecat7WriteScanMatrix().

int ecat7Read2DNormheader ( FILE *  fp,
int  blk,
ECAT7_2Dnormheader h 
)
int ecat7Read2DScanheader ( FILE *  fp,
int  blk,
ECAT7_2Dscanheader h 
)

Read ECAT 7.x 2D scan header

Parameters
fpinput file pointer
blkblock number [1..number of blocks]
hEcat7 2D scan header
Returns
0 if ok, 1 == invalid parameters, 2 == first header block not found, 3 == header block not read properly

Definition at line 485 of file ecat7r.c.

References ecat7_2Dscanheader::cor_singles, ecat7_2Dscanheader::corrections_applied, ecat7_2Dscanheader::data_type, ecat7_2Dscanheader::deadtime_correction_factor, ecat7_2Dscanheader::delayed, ECAT7_TEST, ecat7_2Dscanheader::fill_cti, ecat7_2Dscanheader::fill_gate, ecat7_2Dscanheader::fill_user, ecat7_2Dscanheader::frame_duration, ecat7_2Dscanheader::frame_start_time, ecat7_2Dscanheader::gate_duration, MatBLKSIZE, ecat7_2Dscanheader::multiples, ecat7_2Dscanheader::net_trues, ecat7_2Dscanheader::num_accepted_beats, ecat7_2Dscanheader::num_angles, ecat7_2Dscanheader::num_dimensions, ecat7_2Dscanheader::num_r_elements, ecat7_2Dscanheader::num_z_elements, ecat7_2Dscanheader::physical_planes, ecat7_2Dscanheader::prompts, ecat7_2Dscanheader::r_wave_offset, ecat7_2Dscanheader::ring_difference, ecat7_2Dscanheader::scale_factor, ecat7_2Dscanheader::scan_max, ecat7_2Dscanheader::scan_min, ecat7_2Dscanheader::tot_avg_cor, ecat7_2Dscanheader::tot_avg_uncor, ecat7_2Dscanheader::total_coin_rate, ecat7_2Dscanheader::uncor_singles, ecat7_2Dscanheader::w_resolution, ecat7_2Dscanheader::x_resolution, ecat7_2Dscanheader::y_resolution, and ecat7_2Dscanheader::z_resolution.

Referenced by ecat7PrintSubheader(), ecat7Read2DScanMatrix(), imgReadEcat7(), and imgReadEcat7Header().

int ecat7Read2DScanMatrix ( FILE *  fp,
int  first_block,
int  last_block,
ECAT7_2Dscanheader h,
float **  fdata 
)

Read ECAT7 2D sinogram matrix header and data Memory for fdata[] is allocated here, remember to free memory after usage. Note: data is not calibrated with factor in main header. Note: data is not multiplied with deadtime_correction_factor.

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 scan header, 6 invalid image (x,y,z) dimensions, 8 failed to allocate memory for meta-data, 9 failed to read matrix data, 11 failed to allocate memory for voxel data

Definition at line 749 of file ecat7r.c.

References ecat7_2Dscanheader::data_type, ECAT7_BYTE, ECAT7_IEEER4, ECAT7_SUNI2, ECAT7_SUNI4, ECAT7_TEST, ECAT7_VAXI2, ECAT7_VAXI4, ECAT7_VAXR4, ecat7errmsg, ecat7Print2DScanheader(), ecat7Read2DScanheader(), ecat7ReadMatrixdata(), MatBLKSIZE, MatFirstDirBlk, ecat7_2Dscanheader::num_angles, ecat7_2Dscanheader::num_dimensions, ecat7_2Dscanheader::num_r_elements, ecat7_2Dscanheader::num_z_elements, and ecat7_2Dscanheader::scale_factor.

Referenced by imgReadEcat7(), and imgReadEcat7Frame().

Here is the call graph for this function:

int ecat7ReadAttenheader ( FILE *  fp,
int  blk,
ECAT7_attenheader h 
)
int ecat7ReadImageheader ( FILE *  fp,
int  blk,
ECAT7_imageheader h 
)

Read ECAT 7.x image header

Parameters
fpinput file pointer
blkblock number [1..number of blocks]
hEcat7 image header
Returns
0 if ok, 1 == invalid parameters, 2 == first header block not found, 3 == header block not read properly

Definition at line 177 of file ecat7r.c.

References ecat7_imageheader::annotation, ecat7_imageheader::data_type, ecat7_imageheader::decay_corr_fctr, ECAT7_TEST, ecat7_imageheader::fill_cti, ecat7_imageheader::fill_user, ecat7_imageheader::filter_code, ecat7_imageheader::filter_cutoff_frequency, ecat7_imageheader::filter_order, ecat7_imageheader::filter_ramp_slope, ecat7_imageheader::filter_resolution, ecat7_imageheader::filter_scatter_fraction, ecat7_imageheader::filter_scatter_slope, ecat7_imageheader::frame_duration, ecat7_imageheader::frame_start_time, ecat7_imageheader::gate_duration, ecat7_imageheader::image_max, ecat7_imageheader::image_min, MatBLKSIZE, ecat7_imageheader::mt_1_1, ecat7_imageheader::mt_1_2, ecat7_imageheader::mt_1_3, ecat7_imageheader::mt_1_4, ecat7_imageheader::mt_2_1, ecat7_imageheader::mt_2_2, ecat7_imageheader::mt_2_3, ecat7_imageheader::mt_2_4, ecat7_imageheader::mt_3_1, ecat7_imageheader::mt_3_2, ecat7_imageheader::mt_3_3, ecat7_imageheader::mt_3_4, ecat7_imageheader::num_accepted_beats, ecat7_imageheader::num_angles, ecat7_imageheader::num_dimensions, ecat7_imageheader::num_r_elements, ecat7_imageheader::processing_code, ecat7_imageheader::r_wave_offset, ecat7_imageheader::recon_type, ecat7_imageheader::recon_views, ecat7_imageheader::recon_zoom, ecat7_imageheader::rfilter_code, ecat7_imageheader::rfilter_cutoff, ecat7_imageheader::rfilter_order, ecat7_imageheader::rfilter_resolution, ecat7_imageheader::scale_factor, ecat7_imageheader::scatter_type, ecat7_imageheader::x_dimension, ecat7_imageheader::x_offset, ecat7_imageheader::x_pixel_size, ecat7_imageheader::x_resolution, ecat7_imageheader::y_dimension, ecat7_imageheader::y_offset, ecat7_imageheader::y_pixel_size, ecat7_imageheader::y_resolution, ecat7_imageheader::z_dimension, ecat7_imageheader::z_offset, ecat7_imageheader::z_pixel_size, ecat7_imageheader::z_resolution, ecat7_imageheader::z_rotation_angle, ecat7_imageheader::zfilter_code, ecat7_imageheader::zfilter_cutoff, ecat7_imageheader::zfilter_order, and ecat7_imageheader::zfilter_resolution.

Referenced by ecat7GetNums(), ecat7PrintSubheader(), ecat7ReadImageMatrix(), imgReadEcat7(), and imgReadEcat7Header().

int ecat7ReadImageMatrix ( FILE *  fp,
int  first_block,
int  last_block,
ECAT7_imageheader h,
float **  fdata 
)

Read ECAT7 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 subheader, 6 invalid image (x,y,z) dimensions, 8 failed to allocate memory for meta-data, 9 failed to read matrix data, 11 failed to allocate memory for voxel data

Definition at line 656 of file ecat7r.c.

References ecat7_imageheader::data_type, ECAT7_BYTE, ECAT7_IEEER4, ECAT7_SUNI2, ECAT7_SUNI4, ECAT7_TEST, ECAT7_VAXI2, ECAT7_VAXI4, ECAT7_VAXR4, ecat7errmsg, ecat7PrintImageheader(), ecat7ReadImageheader(), ecat7ReadMatrixdata(), MatBLKSIZE, MatFirstDirBlk, ecat7_imageheader::num_dimensions, ecat7_imageheader::scale_factor, ecat7_imageheader::x_dimension, ecat7_imageheader::y_dimension, and ecat7_imageheader::z_dimension.

Referenced by imgReadEcat7(), and imgReadEcat7Frame().

Here is the call graph for this function:

int ecat7ReadMainheader ( FILE *  fp,
ECAT7_mainheader h 
)

Read ECAT 7.x main header

Parameters
fpinput file pointer
hEcat7 main header
Returns
0 if ok, 1 == invalid parameters, 2 == first header block not found, 3 == header block not read properly

Definition at line 78 of file ecat7r.c.

References ecat7_mainheader::acquisition_mode, ecat7_mainheader::acquisition_type, ecat7_mainheader::angular_compression, ecat7_mainheader::axial_samp_mode, ecat7_mainheader::bed_elevation, ecat7_mainheader::bed_position, ecat7_mainheader::bin_size, ecat7_mainheader::branching_fraction, ecat7_mainheader::calibration_units, ecat7_mainheader::calibration_units_label, ecat7_mainheader::coin_samp_mode, ecat7_mainheader::compression_code, ecat7_mainheader::data_units, ecat7_mainheader::distance_scanned, ecat7_mainheader::dosage, ecat7_mainheader::dose_start_time, ECAT7_TEST, ecat7_mainheader::ecat_calibration_factor, ecat7_mainheader::facility_name, ecat7_mainheader::file_type, ecat7_mainheader::fill_cti, ecat7_mainheader::gantry_rotation, ecat7_mainheader::gantry_tilt, ecat7_mainheader::init_bed_position, ecat7_mainheader::intrinsic_tilt, ecat7_mainheader::isotope_halflife, ecat7_mainheader::isotope_name, ecat7_mainheader::lwr_sctr_thres, ecat7_mainheader::lwr_true_thres, ecat7_mainheader::magic_number, MatBLKSIZE, ecat7_mainheader::num_bed_pos, ecat7_mainheader::num_frames, ecat7_mainheader::num_gates, ecat7_mainheader::num_planes, ecat7_mainheader::operator_name, ecat7_mainheader::original_file_name, ecat7_mainheader::patient_age, ecat7_mainheader::patient_birth_date, ecat7_mainheader::patient_dexterity, ecat7_mainheader::patient_height, ecat7_mainheader::patient_id, ecat7_mainheader::patient_name, ecat7_mainheader::patient_orientation, ecat7_mainheader::patient_sex, ecat7_mainheader::patient_weight, ecat7_mainheader::physician_name, ecat7_mainheader::plane_separation, ecat7_mainheader::radiopharmaceutical, ecat7_mainheader::scan_start_time, ecat7_mainheader::septa_state, ecat7_mainheader::serial_number, ecat7_mainheader::study_description, ecat7_mainheader::study_type, ecat7_mainheader::sw_version, ecat7_mainheader::system_type, ecat7_mainheader::transaxial_fov, ecat7_mainheader::transm_source_type, ecat7_mainheader::upr_true_thres, ecat7_mainheader::user_process_code, ecat7_mainheader::well_counter_corr_factor, and ecat7_mainheader::wobble_speed.

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

int ecat7ReadMatlist ( FILE *  fp,
ECAT7_MATRIXLIST ml 
)

Read ECAT matrix list. Matrix list must be initiated (once) before calling this.

Parameters
fpfile pointer
mlmatrix list structure for Ecat7
Returns
returns 0 if ok, 1 if invalid input, 2 if first matrix is not found, 3 if failed to read matrix, 4 if data allocation failed for matrix, 5 if other error occurred.

Definition at line 86 of file ecat7ml.c.

References ECAT7_TEST, ecat7EmptyMatlist(), ECAT7_MatDir::endblk, ECAT7_MatDir::id, MatBLKSIZE, ECAT7_MATRIXLIST::matdir, MatFirstDirBlk, ECAT7_MATRIXLIST::matrixNr, ECAT7_MATRIXLIST::matrixSpace, ECAT7_MatDir::status, and ECAT7_MatDir::strtblk.

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

Here is the call graph for this function:

int ecat7ReadMatrixdata ( FILE *  fp,
int  start_block,
int  block_nr,
char *  data,
int  dtype 
)

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

Parameters
fpinput file pointer
start_blockstarting block index
block_nrnumber of blocks to be read
datatarget buffer
dtypedata type of target buffer
Returns
0 if ok, 1 == invalid parameters, 9 == start block not found, 2 == data blocks read properly

Definition at line 595 of file ecat7r.c.

References ECAT7_BYTE, ECAT7_IEEER4, ECAT7_SUNI2, ECAT7_SUNI4, ECAT7_TEST, ECAT7_VAXI2, ECAT7_VAXI4, ECAT7_VAXR4, ecat7rFloat(), ecat7rInt(), and MatBLKSIZE.

Referenced by ecat7Read2DScanMatrix(), ecat7ReadImageMatrix(), ecat7ReadPolarmapMatrix(), and ecat7ReadScanMatrix().

Here is the call graph for this function:

int ecat7ReadNormheader ( FILE *  fp,
int  blk,
ECAT7_normheader h 
)
int ecat7ReadPolarmapMatrix ( FILE *  fp,
int  first_block,
int  last_block,
ECAT7_polmapheader h,
float **  fdata 
)

Read ECAT7 polar map 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 scan header, 6 invalid image (x,y,z) dimensions, 8 failed to allocate memory for meta-data, 9 failed to read matrix data, 11 failed to allocate memory for voxel data

Definition at line 939 of file ecat7r.c.

References ecat7_polmapheader::data_type, ECAT7_BYTE, ECAT7_IEEER4, ECAT7_SUNI2, ECAT7_SUNI4, ECAT7_TEST, ECAT7_VAXI2, ECAT7_VAXI4, ECAT7_VAXR4, ecat7errmsg, ecat7PrintPolmapheader(), ecat7ReadMatrixdata(), ecat7ReadPolmapheader(), MatBLKSIZE, MatFirstDirBlk, ecat7_polmapheader::num_rings, ecat7_polmapheader::scale_factor, and ecat7_polmapheader::sectors_per_ring.

Referenced by imgReadEcat7(), and imgReadEcat7Frame().

Here is the call graph for this function:

int ecat7ReadPolmapheader ( FILE *  fp,
int  blk,
ECAT7_polmapheader h 
)
int ecat7ReadScanheader ( FILE *  fp,
int  blk,
ECAT7_scanheader h 
)

Read ECAT 7.x 3D scan header (512 bytes)

Parameters
fpinput file pointer
blkblock number [1..number of blocks]
hEcat7 scan header
Returns
0 if ok, 1 == invalid parameters, 2 == first header block not found, 3 == header block not read properly

Definition at line 424 of file ecat7r.c.

References ecat7_scanheader::axial_compression, ecat7_scanheader::corrections_applied, ecat7_scanheader::data_type, ecat7_scanheader::deadtime_correction_factor, ecat7_scanheader::delayed, ECAT7_TEST, ecat7_scanheader::fill_cti, ecat7_scanheader::fill_gate, ecat7_scanheader::fill_user, ecat7_scanheader::frame_duration, ecat7_scanheader::frame_start_time, ecat7_scanheader::gate_duration, MatBLKSIZE, ecat7_scanheader::multiples, ecat7_scanheader::net_trues, ecat7_scanheader::num_accepted_beats, ecat7_scanheader::num_angles, ecat7_scanheader::num_dimensions, ecat7_scanheader::num_r_elements, ecat7_scanheader::num_z_elements, ecat7_scanheader::prompts, ecat7_scanheader::r_wave_offset, ecat7_scanheader::ring_difference, ecat7_scanheader::scale_factor, ecat7_scanheader::scan_max, ecat7_scanheader::scan_min, ecat7_scanheader::storage_order, ecat7_scanheader::tot_avg_cor, ecat7_scanheader::tot_avg_uncor, ecat7_scanheader::total_coin_rate, ecat7_scanheader::uncor_singles, ecat7_scanheader::v_resolution, ecat7_scanheader::w_resolution, ecat7_scanheader::x_resolution, and ecat7_scanheader::z_resolution.

Referenced by ecat7GetNums(), ecat7PrintSubheader(), ecat7ReadScanMatrix(), imgReadEcat7(), and imgReadEcat7Header().

int ecat7ReadScanMatrix ( FILE *  fp,
int  first_block,
int  last_block,
ECAT7_scanheader h,
float **  fdata 
)

Read ECAT7 3D sinogram matrix header and data. Memory for fdata[] is allocated here, remember to free memory after usage. Note: data is converted to floats with scale_factor in the scan matrix header. Note: data is not calibrated with ecat_calibration_factor in main header. Note: data is not multiplied with deadtime_correction_factor.

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 scan header, 6 invalid image (x,y,z) dimensions, 8 failed to allocate memory for meta-data, 9 failed to read matrix data, 11 failed to allocate memory for voxel data

Definition at line 844 of file ecat7r.c.

References ecat7_scanheader::data_type, ECAT7_BYTE, ECAT7_IEEER4, ECAT7_SUNI2, ECAT7_SUNI4, ECAT7_TEST, ECAT7_VAXI2, ECAT7_VAXI4, ECAT7_VAXR4, ecat7errmsg, ecat7PrintScanheader(), ecat7pxlbytes(), ecat7ReadMatrixdata(), ecat7ReadScanheader(), MatBLKSIZE, MatFirstDirBlk, ecat7_scanheader::num_angles, ecat7_scanheader::num_r_elements, ecat7_scanheader::num_z_elements, and ecat7_scanheader::scale_factor.

Referenced by imgReadEcat7(), and imgReadEcat7Frame().

Here is the call graph for this function:

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

Read ECAT7 floats

Parameters
bufipointer to 32-bit data block
isvax!= 0 for VAX format
islittle!= 0 for little endian conversion
Returns
data in bufi as float value

Definition at line 1015 of file ecat7r.c.

Referenced by ecat7ReadMatrixdata().

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

Reading and writing ECAT7 32-bit ints 32-bit int format is same in VAX and i386

Parameters
bufipointer to one 32-bit data block
isvaxignored
islittle!= 0 for little endian conversion
Returns
converted 32-bit integer

Definition at line 1038 of file ecat7r.c.

Referenced by ecat7ReadMatrixdata().

void ecat7SortMatlistByFrame ( ECAT7_MATRIXLIST ml)

Sort matrixlist by frame and plane. Bubble sorting algorithm.

Parameters
mltarget matrix list

Definition at line 340 of file ecat7ml.c.

References ecat7_id_to_val(), ECAT7_Matval::frame, ECAT7_MatDir::id, ECAT7_MATRIXLIST::matdir, ECAT7_MATRIXLIST::matrixNr, and ECAT7_Matval::plane.

Referenced by imgReadEcat7Frame().

Here is the call graph for this function:

void ecat7SortMatlistByPlane ( ECAT7_MATRIXLIST ml)

Sort matrixlist by plane and frame. Bubble sorting algorithm.

Parameters
mltarget matrix list

Definition at line 314 of file ecat7ml.c.

References ecat7_id_to_val(), ECAT7_Matval::frame, ECAT7_MatDir::id, ECAT7_MATRIXLIST::matdir, ECAT7_MATRIXLIST::matrixNr, and ECAT7_Matval::plane.

Referenced by ecat7GetPlaneAndFrameNr(), and imgReadEcat7().

Here is the call graph for this function:

int ecat7Write2DNormheader ( FILE *  fp,
int  blk,
ECAT7_2Dnormheader h 
)
int ecat7Write2DScanheader ( FILE *  fp,
int  blk,
ECAT7_2Dscanheader h 
)

Write ECAT 7.x 2D scan header

Parameters
fpoutput file pointer
blkheader block number, blk >= 2
hEcat7 2D scan header
Returns
0 in case of success, 1 == invalid parameters, 4 == file pointer is at wrong position, 5 == writing of MatBLKSIZE bytes was not success

Definition at line 499 of file ecat7w.c.

References ecat7_2Dscanheader::cor_singles, ecat7_2Dscanheader::corrections_applied, ecat7_2Dscanheader::data_type, ecat7_2Dscanheader::deadtime_correction_factor, ecat7_2Dscanheader::delayed, ECAT7_IEEER4, ECAT7_SUNI2, ECAT7_SUNI4, ECAT7_TEST, ECAT7_VAXI2, ECAT7_VAXI4, ECAT7_VAXR4, ecat7_2Dscanheader::fill_cti, ecat7_2Dscanheader::fill_gate, ecat7_2Dscanheader::fill_user, ecat7_2Dscanheader::frame_duration, ecat7_2Dscanheader::frame_start_time, ecat7_2Dscanheader::gate_duration, MatBLKSIZE, ecat7_2Dscanheader::multiples, ecat7_2Dscanheader::net_trues, ecat7_2Dscanheader::num_accepted_beats, ecat7_2Dscanheader::num_angles, ecat7_2Dscanheader::num_dimensions, ecat7_2Dscanheader::num_r_elements, ecat7_2Dscanheader::num_z_elements, ecat7_2Dscanheader::physical_planes, ecat7_2Dscanheader::prompts, ecat7_2Dscanheader::r_wave_offset, ecat7_2Dscanheader::ring_difference, ecat7_2Dscanheader::scale_factor, ecat7_2Dscanheader::scan_max, ecat7_2Dscanheader::scan_min, ecat7_2Dscanheader::tot_avg_cor, ecat7_2Dscanheader::tot_avg_uncor, ecat7_2Dscanheader::total_coin_rate, ecat7_2Dscanheader::uncor_singles, ecat7_2Dscanheader::w_resolution, ecat7_2Dscanheader::x_resolution, ecat7_2Dscanheader::y_resolution, and ecat7_2Dscanheader::z_resolution.

Referenced by ecat7Write2DScanMatrix().

int ecat7Write2DScanMatrix ( FILE *  fp,
int  matrix_id,
ECAT7_2Dscanheader h,
float *  fdata 
)

Write ECAT 7.x 2D sinogram matrix header and data

Parameters
fpoutput file pointer
matrix_idcoded matrix id
hEcat7 2D image scan header
fdatafloat data to be written
Returns
0 if ok.

Definition at line 767 of file ecat7w.c.

References ecat7_2Dscanheader::data_type, ecat7_is_scaling_needed(), ECAT7_SUNI2, ECAT7_TEST, ecat7EnterMatrix(), ecat7errmsg, ecat7pxlbytes(), ecat7Write2DScanheader(), ecat7WriteMatrixdata(), MatBLKSIZE, ecat7_2Dscanheader::num_angles, ecat7_2Dscanheader::num_dimensions, ecat7_2Dscanheader::num_r_elements, ecat7_2Dscanheader::num_z_elements, ecat7_2Dscanheader::scale_factor, ecat7_2Dscanheader::scan_max, and ecat7_2Dscanheader::scan_min.

Referenced by imgWrite2DEcat7(), and imgWriteEcat7Frame().

Here is the call graph for this function:

int ecat7WriteAttenheader ( FILE *  fp,
int  blk,
ECAT7_attenheader h 
)
int ecat7WriteImageheader ( FILE *  fp,
int  blk,
ECAT7_imageheader h 
)

Write ECAT 7.x image header. Changes data type to big endian.

Parameters
fpoutput file pointer
blkheader block number, blk >= 2
hEcat7 image header
Returns
0 in case of success, 1 == invalid parameters, 4 == file pointer is at wrong position, 5 == writing of MatBLKSIZE bytes was not success

Definition at line 164 of file ecat7w.c.

References ecat7_imageheader::annotation, ecat7_imageheader::data_type, ecat7_imageheader::decay_corr_fctr, ECAT7_IEEER4, ECAT7_SUNI2, ECAT7_SUNI4, ECAT7_TEST, ECAT7_VAXI2, ECAT7_VAXI4, ECAT7_VAXR4, ecat7_imageheader::fill_cti, ecat7_imageheader::fill_user, ecat7_imageheader::filter_code, ecat7_imageheader::filter_cutoff_frequency, ecat7_imageheader::filter_order, ecat7_imageheader::filter_ramp_slope, ecat7_imageheader::filter_resolution, ecat7_imageheader::filter_scatter_fraction, ecat7_imageheader::filter_scatter_slope, ecat7_imageheader::frame_duration, ecat7_imageheader::frame_start_time, ecat7_imageheader::gate_duration, ecat7_imageheader::image_max, ecat7_imageheader::image_min, MatBLKSIZE, ecat7_imageheader::mt_1_1, ecat7_imageheader::mt_1_2, ecat7_imageheader::mt_1_3, ecat7_imageheader::mt_1_4, ecat7_imageheader::mt_2_1, ecat7_imageheader::mt_2_2, ecat7_imageheader::mt_2_3, ecat7_imageheader::mt_2_4, ecat7_imageheader::mt_3_1, ecat7_imageheader::mt_3_2, ecat7_imageheader::mt_3_3, ecat7_imageheader::mt_3_4, ecat7_imageheader::num_accepted_beats, ecat7_imageheader::num_angles, ecat7_imageheader::num_dimensions, ecat7_imageheader::num_r_elements, ecat7_imageheader::processing_code, ecat7_imageheader::r_wave_offset, ecat7_imageheader::recon_type, ecat7_imageheader::recon_views, ecat7_imageheader::recon_zoom, ecat7_imageheader::rfilter_code, ecat7_imageheader::rfilter_cutoff, ecat7_imageheader::rfilter_order, ecat7_imageheader::rfilter_resolution, ecat7_imageheader::scale_factor, ecat7_imageheader::scatter_type, ecat7_imageheader::x_dimension, ecat7_imageheader::x_offset, ecat7_imageheader::x_pixel_size, ecat7_imageheader::x_resolution, ecat7_imageheader::y_dimension, ecat7_imageheader::y_offset, ecat7_imageheader::y_pixel_size, ecat7_imageheader::y_resolution, ecat7_imageheader::z_dimension, ecat7_imageheader::z_offset, ecat7_imageheader::z_pixel_size, ecat7_imageheader::z_resolution, ecat7_imageheader::z_rotation_angle, ecat7_imageheader::zfilter_code, ecat7_imageheader::zfilter_cutoff, ecat7_imageheader::zfilter_order, and ecat7_imageheader::zfilter_resolution.

Referenced by ecat7WriteImageMatrix().

int ecat7WriteImageMatrix ( FILE *  fp,
int  matrix_id,
ECAT7_imageheader h,
float *  fdata 
)

Write ECAT 7.x image or volume matrix header and data

Parameters
fpoutput file pointer
matrix_idcoded matrix id
hEcat7 image header
fdatafloat data to be written
Returns
0 if ok.

Definition at line 682 of file ecat7w.c.

References ecat7_imageheader::data_type, ecat7_is_scaling_needed(), ECAT7_SUNI2, ECAT7_TEST, ecat7EnterMatrix(), ecat7errmsg, ecat7pxlbytes(), ecat7WriteImageheader(), ecat7WriteMatrixdata(), ecat7_imageheader::image_max, ecat7_imageheader::image_min, MatBLKSIZE, ecat7_imageheader::num_dimensions, ecat7_imageheader::scale_factor, ecat7_imageheader::x_dimension, ecat7_imageheader::y_dimension, and ecat7_imageheader::z_dimension.

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

Here is the call graph for this function:

int ecat7WriteMainheader ( FILE *  fp,
ECAT7_mainheader h 
)

Write ECAT 7.x main header.

Parameters
fpoutput file pointer
hEcat7 main header Writes header always in big endian byte order.
Returns
0 in case of success, 1 == invalid parameters, 4 == file pointer is at wrong position, 5 == writing of MatBLKSIZE bytes was not success

Definition at line 73 of file ecat7w.c.

References ecat7_mainheader::acquisition_mode, ecat7_mainheader::acquisition_type, ecat7_mainheader::angular_compression, ecat7_mainheader::axial_samp_mode, ecat7_mainheader::bed_elevation, ecat7_mainheader::bed_position, ecat7_mainheader::bin_size, ecat7_mainheader::branching_fraction, ecat7_mainheader::calibration_units, ecat7_mainheader::calibration_units_label, ecat7_mainheader::coin_samp_mode, ecat7_mainheader::compression_code, ecat7_mainheader::data_units, ecat7_mainheader::distance_scanned, ecat7_mainheader::dosage, ecat7_mainheader::dose_start_time, ECAT7_TEST, ecat7_mainheader::ecat_calibration_factor, ecat7_mainheader::facility_name, ecat7_mainheader::file_type, ecat7_mainheader::fill_cti, ecat7_mainheader::gantry_rotation, ecat7_mainheader::gantry_tilt, ecat7_mainheader::init_bed_position, ecat7_mainheader::intrinsic_tilt, ecat7_mainheader::isotope_halflife, ecat7_mainheader::isotope_name, ecat7_mainheader::lwr_sctr_thres, ecat7_mainheader::lwr_true_thres, ecat7_mainheader::magic_number, MatBLKSIZE, ecat7_mainheader::num_bed_pos, ecat7_mainheader::num_frames, ecat7_mainheader::num_gates, ecat7_mainheader::num_planes, ecat7_mainheader::operator_name, ecat7_mainheader::original_file_name, ecat7_mainheader::patient_age, ecat7_mainheader::patient_birth_date, ecat7_mainheader::patient_dexterity, ecat7_mainheader::patient_height, ecat7_mainheader::patient_id, ecat7_mainheader::patient_name, ecat7_mainheader::patient_orientation, ecat7_mainheader::patient_sex, ecat7_mainheader::patient_weight, ecat7_mainheader::physician_name, ecat7_mainheader::plane_separation, ecat7_mainheader::radiopharmaceutical, ecat7_mainheader::scan_start_time, ecat7_mainheader::septa_state, ecat7_mainheader::serial_number, ecat7_mainheader::study_description, ecat7_mainheader::study_type, ecat7_mainheader::sw_version, ecat7_mainheader::system_type, ecat7_mainheader::transaxial_fov, ecat7_mainheader::transm_source_type, ecat7_mainheader::upr_true_thres, ecat7_mainheader::user_process_code, ecat7_mainheader::well_counter_corr_factor, and ecat7_mainheader::wobble_speed.

Referenced by ecat7Create(), and imgWriteEcat7Frame().

int ecat7WriteMatrixdata ( FILE *  fp,
int  start_block,
char *  data,
int  pxl_nr,
int  pxl_size 
)

Write ECAT 7.x matrix data to a specified file position. Data does not need to be allocated for full blocks. Data must be represented in current machines byte order, and it is always saved in big endian byte order.

Parameters
fpPointer to an opened ECAT file
start_blockBlock number where matrix data is written
dataPointer to matrix data
pxl_nrNumber of pixels
pxl_sizeSize of data for one pixel in bytes
Returns
>0 in case of an error.

Definition at line 1027 of file ecat7w.c.

References ECAT7_TEST, and MatBLKSIZE.

Referenced by ecat7Write2DScanMatrix(), ecat7WriteImageMatrix(), ecat7WritePolarmapMatrix(), and ecat7WriteScanMatrix().

int ecat7WriteNormheader ( FILE *  fp,
int  blk,
ECAT7_normheader h 
)
int ecat7WritePolarmapMatrix ( FILE *  fp,
int  matrix_id,
ECAT7_polmapheader h,
float *  fdata 
)

Write ECAT 7.x polarmap matrix header and data

Parameters
fpoutput file pointer
matrix_idcoded matrix information
hEcat7 polar map header
fdatafloat data
Returns
0 if ok.

Definition at line 939 of file ecat7w.c.

References ecat7_polmapheader::data_type, ecat7_is_scaling_needed(), ECAT7_SUNI2, ECAT7_TEST, ecat7EnterMatrix(), ecat7errmsg, ecat7pxlbytes(), ecat7WriteMatrixdata(), ecat7WritePolmapheader(), ecat7_polmapheader::image_max, ecat7_polmapheader::image_min, MatBLKSIZE, ecat7_polmapheader::num_rings, ecat7_polmapheader::scale_factor, and ecat7_polmapheader::sectors_per_ring.

Referenced by imgWriteEcat7Frame(), and imgWritePolarmap().

Here is the call graph for this function:

int ecat7WritePolmapheader ( FILE *  fp,
int  blk,
ECAT7_polmapheader h 
)
int ecat7WriteScanheader ( FILE *  fp,
int  blk,
ECAT7_scanheader h 
)

Write ECAT 7.x 3D scan header (512 bytes) Changes data type to big endian.

Parameters
fppointer to output file
blkblock number, blk >= 2
hEcat7 scan header
Returns
0 in case of success, 1 == invalid parameters, 4 == file pointer is at wrong position, 5 == writing of MatBLKSIZE bytes was not success

Definition at line 433 of file ecat7w.c.

References ecat7_scanheader::axial_compression, ecat7_scanheader::corrections_applied, ecat7_scanheader::data_type, ecat7_scanheader::deadtime_correction_factor, ecat7_scanheader::delayed, ECAT7_IEEER4, ECAT7_SUNI2, ECAT7_SUNI4, ECAT7_TEST, ECAT7_VAXI2, ECAT7_VAXI4, ECAT7_VAXR4, ecat7_scanheader::fill_cti, ecat7_scanheader::fill_gate, ecat7_scanheader::fill_user, ecat7_scanheader::frame_duration, ecat7_scanheader::frame_start_time, ecat7_scanheader::gate_duration, MatBLKSIZE, ecat7_scanheader::multiples, ecat7_scanheader::net_trues, ecat7_scanheader::num_accepted_beats, ecat7_scanheader::num_angles, ecat7_scanheader::num_dimensions, ecat7_scanheader::num_r_elements, ecat7_scanheader::num_z_elements, ecat7_scanheader::prompts, ecat7_scanheader::r_wave_offset, ecat7_scanheader::ring_difference, ecat7_scanheader::scale_factor, ecat7_scanheader::scan_max, ecat7_scanheader::scan_min, ecat7_scanheader::storage_order, ecat7_scanheader::tot_avg_cor, ecat7_scanheader::tot_avg_uncor, ecat7_scanheader::total_coin_rate, ecat7_scanheader::uncor_singles, ecat7_scanheader::v_resolution, ecat7_scanheader::w_resolution, ecat7_scanheader::x_resolution, and ecat7_scanheader::z_resolution.

Referenced by ecat7WriteScanMatrix().

int ecat7WriteScanMatrix ( FILE *  fp,
int  matrix_id,
ECAT7_scanheader h,
float *  fdata 
)

Write ECAT 7.x 3D sinogram matrix header and data

Parameters
fpoutput file pointer
matrix_idcoded matrix id
hEcat7 scan header
fdatafloat data
Returns
0 if ok.

Definition at line 852 of file ecat7w.c.

References ecat7_scanheader::data_type, ecat7_is_scaling_needed(), ECAT7_SUNI2, ECAT7_TEST, ecat7EnterMatrix(), ecat7errmsg, ecat7pxlbytes(), ecat7WriteMatrixdata(), ecat7WriteScanheader(), MatBLKSIZE, ecat7_scanheader::num_angles, ecat7_scanheader::num_r_elements, ecat7_scanheader::num_z_elements, ecat7_scanheader::scale_factor, ecat7_scanheader::scan_max, and ecat7_scanheader::scan_min.

Referenced by imgWriteEcat7(), and imgWriteEcat7Frame().

Here is the call graph for this function:

Variable Documentation

int ECAT7_TEST
char ecat7errmsg[128]