My Project
Functions
ecat63ml.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/img.h"
#include "include/ecat63.h"
Include dependency graph for ecat63ml.c:

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)
 

Function Documentation

◆ ecat63CheckMatlist()

int ecat63CheckMatlist ( MATRIXLIST ml)

Checks that all matrixlist entries have read/write status.

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

Definition at line 342 of file ecat63ml.c.

References MATRIXLIST::matdir, MATRIXLIST::matrixNr, and MatDir::matstat.

◆ ecat63DeleteLateFrames()

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.

Parameters
mlmatrix list
frame_nrlast index not to be marked as deleted
Returns
number of deleted matrices.

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ecat63EmptyMatlist()

void ecat63EmptyMatlist ( MATRIXLIST mlist)

Free memory allocated for ECAT matrix list

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

Here is the caller graph for this function:

◆ ecat63GatherMatlist()

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.

Parameters
mlECAT 6.3 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 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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ecat63GetMatrixBlockSize()

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.

Parameters
mlistEcat 6.3 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 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().

Here is the caller graph for this function:

◆ ecat63GetNums()

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.

Parameters
mlPointer to matrixlist
num_planesnumber of planes will be put here; NULL if not needed
num_framesnumber of frames will be put here; NULL if not needed
num_gatesnumber of gates will be put here; NULL if not needed
num_bed_posnumber of gates will be put here; NULL if not needed
Returns
0 if successful, 1 no matrix list, 2 invalid matrix number, 3 failed to allocate memory

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.

Here is the call graph for this function:

◆ ecat63GetPlaneAndFrameNr()

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.

Parameters
mlistEcat 6.3 matrix list; note that this list is here sorted by planes
hEcat 6.3 mainheader
plane_nrNumber of planes will be put here; NULL if not needed
frame_nrNumber of frames/gates 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 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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ecat63InitMatlist()

void ecat63InitMatlist ( MATRIXLIST mlist)

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

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

Here is the caller graph for this function:

◆ ecat63Matenter()

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;

Parameters
fpfile pointer
matnummatrix number [1..number of matrixes]
blkNrmatrix block number [ >= 1]
Returns
block number for matrix header, or 0 in case of an error.

Definition at line 186 of file ecat63ml.c.

References ECAT63_TEST, MatBLKSIZE, and MatFirstDirBlk.

Referenced by ecat63WriteAttn(), ecat63WriteImage(), ecat63WriteImageMatrix(), ecat63WriteNorm(), ecat63WriteScan(), and ecat63WriteScanMatrix().

Here is the caller graph for this function:

◆ ecat63PrintMatlist()

void ecat63PrintMatlist ( MATRIXLIST ml)

Print ECAT matrix list on stdout.

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ecat63ReadMatlist()

int ecat63ReadMatlist ( FILE *  fp,
MATRIXLIST ml 
)

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

Parameters
fpfile pointer
mlmatrix list
Returns
Returns 0 if ok, 1 if invalid input, 2 first matrix is not found, 3 if failed to read matrix, 4 failed to allocate memory, 5 other error

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ecat63SortMatlistByFrame()

void ecat63SortMatlistByFrame ( MATRIXLIST ml)

Sort matrixlist by frame and plane. Bubble sorting algorithm.

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ecat63SortMatlistByPlane()

void ecat63SortMatlistByPlane ( MATRIXLIST ml)

Sort matrixlist by plane and frame. Bubble sorting algorithm.

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mat_numcod()

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

Returns the matrix identifier

Parameters
frameframe number [0..4096]
planeplane number [0..256]
gategate number [0..64]
datadata number [0..8]
bedbed position [0..16]
Returns
matrix indentifier coding

Definition at line 266 of file ecat63ml.c.

Referenced by ecat63AddImg(), ecat63GatherMatlist(), ecat63WriteAllImg(), and imgWriteEcat63Frame().

Here is the caller graph for this function:

◆ mat_numdoc()

void mat_numdoc ( int  matnum,
Matval matval 
)

Conversion of matrix identifier to numerical values

Parameters
matnummatrix identifier coding
matvaltarget 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().

Here is the caller graph for this function: