#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/ecat7.h"
Go to the source code of this file.
Functions | |
| 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) |
| void ecat7_id_to_val | ( | int | matrix_id, |
| ECAT7_Matval * | matval | ||
| ) |
Conversion of matrix identifier to numerical values
| matrix_id | matrix identifire coding |
| matval | matrix 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_val_to_id | ( | int | frame, |
| int | plane, | ||
| int | gate, | ||
| int | data, | ||
| int | bed | ||
| ) |
Returns the matrix identifier.
| frame | frame number [0..65536] |
| plane | plane number [0..65536] |
| gate | gate number [0..64] |
| data | data [0..1] |
| bed | bed position [0..16] |
Definition at line 282 of file ecat7ml.c.
Referenced by ecat7GatherMatlist(), imgWrite2DEcat7(), imgWriteEcat7(), imgWriteEcat7Frame(), and imgWritePolarmap().
| int ecat7CheckMatlist | ( | ECAT7_MATRIXLIST * | ml | ) |
Checks that all matrixlist entries have read/write status.
| ml | checked matrix list |
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().
| int ecat7DeleteLateFrames | ( | ECAT7_MATRIXLIST * | ml, |
| int | frame_nr | ||
| ) |
Mark deleted the frames after the specified frame number.
| ml | target matrix list |
| frame_nr | first index to be marked as deleted [1..number of frames] |
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.

| void ecat7EmptyMatlist | ( | ECAT7_MATRIXLIST * | mlist | ) |
Free memory allocated for ECAT matrix list.
| mlist | target 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)
| fp | file pointer |
| matrix_id | matrix identifier coding |
| block_nr | matrix number [1..number of matrixes] |
Definition at line 184 of file ecat7ml.c.
References ECAT7_TEST, MatBLKSIZE, and MatFirstDirBlk.
Referenced by ecat7Write2DScanMatrix(), ecat7WriteImageMatrix(), ecat7WritePolarmapMatrix(), and ecat7WriteScanMatrix().
| 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.
| ml | ECAT 7 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 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().

| 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.
| mlist | Ecat7 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 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.
| ml | Pointer to matrixlist |
| mh | Pointer to mainheader |
| fp | File pointer to ECAT7 file opened in binary mode |
| num_planes | num_planes will be put here; NULL if not needed to be read |
| num_frames | num_planes will be put here; NULL if not needed to be read |
| num_gates | num_planes will be put here; NULL if not needed to be read |
| num_bed_pos | num_planes will be put here; NULL if not needed to be read |
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.

| 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.
| mlist | Ecat7 matrix list; note that this list is here sorted by planes |
| h | Ecat7 main header structure |
| plane_nr | Number of planes will be put here; NULL if not needed [1..number of planes, or NULL] |
| frame_nr | Number of frames/gates will be put here; NULL if not needed [1..number of frames, or NULL] |
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().

| void ecat7InitMatlist | ( | ECAT7_MATRIXLIST * | mlist | ) |
Initiate ECAT matrix list. Call this once before first use.
| mlist | target 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 ecat7PrintMatlist | ( | ECAT7_MATRIXLIST * | ml | ) |
Print ECAT matrix list on stdout.
| ml | matrix 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().

| int ecat7ReadMatlist | ( | FILE * | fp, |
| ECAT7_MATRIXLIST * | ml | ||
| ) |
Read ECAT matrix list. Matrix list must be initiated (once) before calling this.
| fp | file pointer |
| ml | matrix list structure for Ecat7 |
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().

| void ecat7SortMatlistByFrame | ( | ECAT7_MATRIXLIST * | ml | ) |
Sort matrixlist by frame and plane. Bubble sorting algorithm.
| ml | target 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().

| void ecat7SortMatlistByPlane | ( | ECAT7_MATRIXLIST * | ml | ) |
Sort matrixlist by plane and frame. Bubble sorting algorithm.
| ml | target 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().

1.8.11