#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/img.h"
#include "include/ecat63.h"
Go to the source code of this file.
Functions | |
void | ecat63InitMatlist (MATRIXLIST *mlist) |
void | ecat63EmptyMatlist (MATRIXLIST *mlist) |
int | ecat63ReadMatlist (FILE *fp, MATRIXLIST *ml) |
void | ecat63PrintMatlist (MATRIXLIST *ml) |
int | ecat63Matenter (FILE *fp, int matnum, int blkNr) |
int | mat_numcod (int frame, int plane, int gate, int data, int bed) |
void | mat_numdoc (int matnum, Matval *matval) |
void | ecat63SortMatlistByPlane (MATRIXLIST *ml) |
void | ecat63SortMatlistByFrame (MATRIXLIST *ml) |
int | ecat63CheckMatlist (MATRIXLIST *ml) |
int | ecat63DeleteLateFrames (MATRIXLIST *ml, int frame_nr) |
int | ecat63GetMatrixBlockSize (MATRIXLIST *mlist, int *blk_nr) |
int | ecat63GetPlaneAndFrameNr (MATRIXLIST *mlist, ECAT63_mainheader *h, int *plane_nr, int *frame_nr) |
int | ecat63GetNums (MATRIXLIST *ml, short int *num_planes, short int *num_frames, short int *num_gates, short int *num_bed_pos) |
int | ecat63GatherMatlist (MATRIXLIST *ml, short int do_planes, short int do_frames, short int do_gates, short int do_beds) |
int ecat63CheckMatlist | ( | MATRIXLIST * | ml | ) |
Checks that all matrixlist entries have read/write status.
ml | matrix list |
Definition at line 342 of file ecat63ml.c.
References MATRIXLIST::matdir, MATRIXLIST::matrixNr, and MatDir::matstat.
int ecat63DeleteLateFrames | ( | MATRIXLIST * | ml, |
int | frame_nr | ||
) |
Mark deleted the frames after the specified frame number. This can be used to delete sum images from the end of dynamic ECAT images.
ml | matrix list |
frame_nr | last index not to be marked as deleted |
Definition at line 360 of file ecat63ml.c.
References Matval::frame, mat_numdoc(), MATRIXLIST::matdir, MatDir::matnum, MATRIXLIST::matrixNr, and MatDir::matstat.
Referenced by ecat63ReadAllToImg(), ecat63ReadPlaneToImg(), and imgReadEcat63Header().
void ecat63EmptyMatlist | ( | MATRIXLIST * | mlist | ) |
Free memory allocated for ECAT matrix list
mlist | matrix list |
Definition at line 80 of file ecat63ml.c.
References MATRIXLIST::matdir, MATRIXLIST::matrixNr, and MATRIXLIST::matrixSpace.
Referenced by ecat63AddImg(), ecat63ReadAllToImg(), ecat63ReadMatlist(), ecat63ReadPlaneToImg(), ecat6PrintSubheader(), imgReadEcat63Frame(), and imgReadEcat63Header().
int ecat63GatherMatlist | ( | MATRIXLIST * | ml, |
short int | do_planes, | ||
short int | do_frames, | ||
short int | do_gates, | ||
short int | do_beds | ||
) |
Matrix numbers in ECAT 6.3 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.
ml | ECAT 6.3 matrix list, where the matrix numbers will be edited |
do_planes | Plane numbers are gathered together (1) or not (0) |
do_frames | Frame numbers are gathered together (1) or not (0) |
do_gates | Gate numbers are gathered together (1) or not (0) |
do_beds | Bed numbers are gathered together (1) or not (0) |
Definition at line 519 of file ecat63ml.c.
References Matval::bed, Matval::frame, Matval::gate, mat_numcod(), mat_numdoc(), MATRIXLIST::matdir, MatDir::matnum, MATRIXLIST::matrixNr, and Matval::plane.
Referenced by imgReadEcat63Frame(), and imgReadEcat63Header().
int ecat63GetMatrixBlockSize | ( | MATRIXLIST * | mlist, |
int * | blk_nr | ||
) |
Calculate the size of one data matrix in ECAT 6.3 file matrix list, and check that the size is same in all matrices.
mlist | Ecat 6.3 matrix list; note that this list is here sorted by planes |
blk_nr | Number of blocks will be put here; NULL if not needed |
Definition at line 382 of file ecat63ml.c.
References MatDir::endblk, MATRIXLIST::matdir, MATRIXLIST::matrixNr, STATUS_FAULT, STATUS_OK, STATUS_VARMATSIZE, and MatDir::strtblk.
Referenced by imgReadEcat63Frame(), and imgReadEcat63Header().
int ecat63GetNums | ( | MATRIXLIST * | ml, |
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.
ml | Pointer to matrixlist |
num_planes | number of planes will be put here; NULL if not needed |
num_frames | number of frames will be put here; NULL if not needed |
num_gates | number of gates will be put here; NULL if not needed |
num_bed_pos | number of gates will be put here; NULL if not needed |
Definition at line 462 of file ecat63ml.c.
References Matval::bed, Matval::frame, Matval::gate, mat_numdoc(), MATRIXLIST::matdir, MatDir::matnum, MATRIXLIST::matrixNr, and Matval::plane.
int ecat63GetPlaneAndFrameNr | ( | MATRIXLIST * | mlist, |
ECAT63_mainheader * | h, | ||
int * | plane_nr, | ||
int * | frame_nr | ||
) |
Calculate the number of planes and frames/gates from ECAT 6.3 matrix list. Check that all planes have equal nr of frames/gates, that frames/gates are sequentally numbered. This routines sorts the matrix list by planes.
mlist | Ecat 6.3 matrix list; note that this list is here sorted by planes |
h | Ecat 6.3 mainheader |
plane_nr | Number of planes will be put here; NULL if not needed |
frame_nr | Number of frames/gates will be put here; NULL if not needed |
Definition at line 414 of file ecat63ml.c.
References ecat63SortMatlistByPlane(), Matval::frame, Matval::gate, mat_numdoc(), MATRIXLIST::matdir, MatDir::matnum, MATRIXLIST::matrixNr, MatDir::matstat, ecat63_mainheader::num_frames, ecat63_mainheader::num_gates, Matval::plane, STATUS_FAULT, STATUS_MISSINGMATRIX, and STATUS_OK.
Referenced by imgReadEcat63Header().
void ecat63InitMatlist | ( | MATRIXLIST * | mlist | ) |
Initiate ECAT matrix list. Call this once before first use.
mlist | matrix list |
Definition at line 69 of file ecat63ml.c.
References MATRIXLIST::matdir, MATRIXLIST::matrixNr, and MATRIXLIST::matrixSpace.
Referenced by ecat63AddImg(), ecat63ReadAllToImg(), ecat63ReadPlaneToImg(), ecat6PrintSubheader(), imgReadEcat63Frame(), and imgReadEcat63Header().
int ecat63Matenter | ( | FILE * | fp, |
int | matnum, | ||
int | blkNr | ||
) |
Prepare matrix list for additional matrix data and Directory records are written in big endian byte order. Set block_nr to the number of data blocks excluding header;
fp | file pointer |
matnum | matrix number [1..number of matrixes] |
blkNr | matrix block number [ >= 1] |
Definition at line 186 of file ecat63ml.c.
References ECAT63_TEST, MatBLKSIZE, and MatFirstDirBlk.
Referenced by ecat63WriteAttn(), ecat63WriteImage(), ecat63WriteImageMatrix(), ecat63WriteNorm(), ecat63WriteScan(), and ecat63WriteScanMatrix().
void ecat63PrintMatlist | ( | MATRIXLIST * | ml | ) |
Print ECAT matrix list on stdout.
ml | matrix list |
Definition at line 160 of file ecat63ml.c.
References Matval::bed, MatDir::endblk, Matval::frame, Matval::gate, mat_numdoc(), MATRIXLIST::matdir, MatDir::matnum, MATRIXLIST::matrixNr, Matval::plane, and MatDir::strtblk.
Referenced by ecat63ReadAllToImg(), and ecat6PrintSubheader().
int ecat63ReadMatlist | ( | FILE * | fp, |
MATRIXLIST * | ml | ||
) |
Read ECAT matrix list. Matrix list must be initiated (once) before calling this.
fp | file pointer |
ml | matrix list |
Definition at line 97 of file ecat63ml.c.
References ECAT63_TEST, ecat63EmptyMatlist(), MatDir::endblk, MatBLKSIZE, MATRIXLIST::matdir, MatFirstDirBlk, MatDir::matnum, MATRIXLIST::matrixNr, MATRIXLIST::matrixSpace, MatDir::matstat, and MatDir::strtblk.
Referenced by ecat63AddImg(), ecat63ReadAllToImg(), ecat63ReadPlaneToImg(), ecat6PrintSubheader(), imgReadEcat63Frame(), and imgReadEcat63Header().
void ecat63SortMatlistByFrame | ( | MATRIXLIST * | ml | ) |
Sort matrixlist by frame and plane. Bubble sorting algorithm.
ml | matrix list |
Definition at line 316 of file ecat63ml.c.
References Matval::frame, mat_numdoc(), MATRIXLIST::matdir, MatDir::matnum, MATRIXLIST::matrixNr, and Matval::plane.
Referenced by imgReadEcat63Frame().
void ecat63SortMatlistByPlane | ( | MATRIXLIST * | ml | ) |
Sort matrixlist by plane and frame. Bubble sorting algorithm.
ml | marix list. |
Definition at line 291 of file ecat63ml.c.
References Matval::frame, mat_numdoc(), MATRIXLIST::matdir, MatDir::matnum, MATRIXLIST::matrixNr, and Matval::plane.
Referenced by ecat63GetPlaneAndFrameNr(), and imgReadEcat63Header().
int mat_numcod | ( | int | frame, |
int | plane, | ||
int | gate, | ||
int | data, | ||
int | bed | ||
) |
Returns the matrix identifier
frame | frame number [0..4096] |
plane | plane number [0..256] |
gate | gate number [0..64] |
data | data number [0..8] |
bed | bed position [0..16] |
Definition at line 266 of file ecat63ml.c.
Referenced by ecat63AddImg(), ecat63GatherMatlist(), ecat63WriteAllImg(), and imgWriteEcat63Frame().
void mat_numdoc | ( | int | matnum, |
Matval * | matval | ||
) |
Conversion of matrix identifier to numerical values
matnum | matrix identifier coding |
matval | target matrix value structure |
Definition at line 276 of file ecat63ml.c.
References Matval::bed, Matval::data, Matval::frame, Matval::gate, and Matval::plane.
Referenced by ecat63AddImg(), ecat63DeleteLateFrames(), ecat63GatherMatlist(), ecat63GetNums(), ecat63GetPlaneAndFrameNr(), ecat63PrintMatlist(), ecat63ReadAllToImg(), ecat63ReadPlaneToImg(), ecat63SortMatlistByFrame(), ecat63SortMatlistByPlane(), ecat6PrintSubheader(), and imgReadEcat63Frame().