TPCCLIB
Loading...
Searching...
No Matches
tpcecat.h File Reference

Header file for libtpcecat. More...

#include "tpcclibConfig.h"
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdint.h>
#include <stdlib.h>
#include <strings.h>
#include <ctype.h>
#include <float.h>
#include <unistd.h>
#include <locale.h>
#include <time.h>
#include "tpcextensions.h"
#include "tpcift.h"

Go to the source code of this file.

Data Structures

struct  ECAT_MATDIR
 
struct  ECAT_MATRIXLIST
 
struct  ECAT_MATVAL
 

Macros

#define BACKUP_EXTENSION   ".bak"
 
#define ECATBLKSIZE   512
 

Functions

int ecatReadBlock (const char *filename, FILE *fp, const unsigned int blocknumber, unsigned char *data)
 
int ecatVerifyMagic (const char *filename, FILE *fp)
 
int ecatWriteMainheader (IFT *ift, unsigned char *buf, TPCSTATUS *status)
 
int ecatReadMainheader (const unsigned char *buf, IFT *ift, TPCSTATUS *status)
 
void ecatMListInit (ECAT_MATRIXLIST *ml)
 
void ecatMListFree (ECAT_MATRIXLIST *ml)
 
void ecatMListReadId (int format, unsigned int id, ECAT_MATVAL *mv)
 
unsigned int ecatMListMakeId (int format, unsigned int frame, unsigned int plane, unsigned int gate, unsigned int data, unsigned int bed)
 
unsigned int ecatMValToId (int format, ECAT_MATVAL *mv)
 
int ecatMListRead (int format, FILE *fp, ECAT_MATRIXLIST *ml, TPCSTATUS *status)
 
void ecatMListPrint (int format, ECAT_MATRIXLIST *ml, FILE *fp)
 

Detailed Description

Header file for libtpcecat.

Author
Vesa Oikonen

Definition in file tpcecat.h.

Macro Definition Documentation

◆ BACKUP_EXTENSION

#define BACKUP_EXTENSION   ".bak"

Backup file extension

Definition at line 31 of file tpcecat.h.

◆ ECATBLKSIZE

#define ECATBLKSIZE   512

ECAT matrix block size

Definition at line 37 of file tpcecat.h.

Referenced by ecatMListRead(), ecatReadBlock(), ecatVerifyMagic(), and imgWrite().

Function Documentation

◆ ecatMListFree()

void ecatMListFree ( ECAT_MATRIXLIST * ml)

Free memory allocated for ECAT matrix list. All contents are destroyed.

Precondition
Before first use initialize the struct with ecatMListInit().
See also
ecatMListInit
Parameters
mlPointer to matrix list.

Definition at line 38 of file ecatmatrixlist.c.

41 {
42 if(ml==NULL) return;
43 if(ml->matrixSpace>0) free((char*)(ml->matdir));
44 ml->matrixSpace=ml->matrixNr=0;
45}
ECAT_MATDIR * matdir
Definition tpcecat.h:58
unsigned int matrixNr
Definition tpcecat.h:54
unsigned int matrixSpace
Definition tpcecat.h:56

Referenced by ecatMListRead().

◆ ecatMListInit()

void ecatMListInit ( ECAT_MATRIXLIST * ml)

Initiate the ECAT matrix list struct before any use.

See also
ecatMListFree, ecatMListRead, ecatMListPrint
Parameters
mlPointer to matrix list.

Definition at line 23 of file ecatmatrixlist.c.

26 {
27 if(ml==NULL) return;
28 ml->matdir=NULL;
29 ml->matrixSpace=ml->matrixNr=0;
30}

◆ ecatMListMakeId()

unsigned int ecatMListMakeId ( int format,
unsigned int frame,
unsigned int plane,
unsigned int gate,
unsigned int data,
unsigned int bed )

Make matrix identifier (matnum) code for specific matrix.

See also
ecatMListReadId, ecatMValToId
Returns
The matrix identifier.
Parameters
formatECAT format: 6 or 7.
frameFrame [0..511] for ECAT7, [0..4095] for ECAT6.
planePlane [0..1023] for ECAT7, [0..255] for ECAT6.
gateGate [0..63].
dataData [0..7] for ECAT7, [0..3] for ECAT6.
bedBed position [0..15].

Definition at line 84 of file ecatmatrixlist.c.

97 {
98 if(format==7) {
99 return(
100 (frame & 0x1FF) | /* frame */
101 ((plane & 0x300) << 1) | /* plane high */
102 ((data & 0x4) << 9) | /* data high */
103 ((bed & 0xF) << 12) | /* bed */
104 ((plane & 0xFF) << 16) | /* plane low */
105 ((gate & 0x3F) << 24) | /* gate */
106 ((data & 0x3) << 30) /* data low */
107 );
108 } else if(format==6) {
109 return(
110 (frame&0xFFF) |
111 ((bed&0xF)<<12) |
112 ((plane&0xFF)<<16) |
113 ((gate&0x3F)<<24) |
114 ((data&0x3)<<30)
115 );
116 }
117 return(0);
118}

Referenced by ecatMValToId().

◆ ecatMListPrint()

void ecatMListPrint ( int format,
ECAT_MATRIXLIST * ml,
FILE * fp )

Print ECAT matrix list.

See also
ecatMListInit, ecatMListRead, ecatMListFree
Parameters
formatECAT format: 6 or 7.
mlPointer to matrix list to print.
fpFile pointer to print to; usually stdout.

Definition at line 250 of file ecatmatrixlist.c.

257 {
258 if(ml==NULL || fp==NULL) return;
259 ECAT_MATVAL mv;
260
261 fprintf(fp, "nr\tmatrix\tpl\tfr\tgate\tbed\tstartblk\tblknr\n");
262 for(unsigned int i=0; i<ml->matrixNr; i++) {
263 ecatMListReadId(format, ml->matdir[i].id, &mv);
264 fprintf(fp, "%u\t%u\t%u\t%u\t%u\t%u\t%u\t%u\n", i+1, ml->matdir[i].id,
265 mv.plane, mv.frame, mv.gate, mv.bed,
266 ml->matdir[i].strtblk, 1+ml->matdir[i].endblk-ml->matdir[i].strtblk);
267 }
268 return;
269}
void ecatMListReadId(int format, unsigned int id, ECAT_MATVAL *mv)
unsigned int endblk
Definition tpcecat.h:46
unsigned int id
Definition tpcecat.h:42
unsigned int strtblk
Definition tpcecat.h:44
unsigned int gate
Definition tpcecat.h:68
unsigned int plane
Definition tpcecat.h:66
unsigned int frame
Definition tpcecat.h:64
unsigned int bed
Definition tpcecat.h:72

◆ ecatMListRead()

int ecatMListRead ( int format,
FILE * fp,
ECAT_MATRIXLIST * ml,
TPCSTATUS * status )

Read ECAT matrix list from ECAT file.

See also
ecatMListInit, ecatMListPrint, ecatMListFree
Returns
enum tpcerror (TPCERROR_OK when successful).
Parameters
formatECAT format: 6 or 7.
fpFile pointer of file, opened with fp=fopen(filename, "rb"), to read the matrix list from.
mlPointer to initiated matrix list; any previous content is deleted.
Precondition
Matrix list must be initiated (once) before calling this.
Parameters
statusPointer to status data; enter NULL if not needed.

Definition at line 140 of file ecatmatrixlist.c.

150 {
151 int verbose=0; if(status!=NULL) verbose=status->verbose;
152 if(verbose>0) {printf("%s(%d, ...)\n", __func__, format); fflush(stdout);}
153
154 if(fp==NULL || ml==NULL) {
155 statusSet(status, __func__, __FILE__, __LINE__, TPCERROR_FAIL);
156 return(TPCERROR_FAIL);
157 }
158
159 /* Is current platform little endian (1) or not (0) ? */
160 int little=endianLittle();
161 if(verbose>2) {
162 if(little) printf("little endian platform\n"); else printf("big endian platform\n");
163 }
164
165 /* Make sure that matrix list is empty */
166 ecatMListFree(ml);
167
168 /* Read the blocks belonging to the matrix list */
169 unsigned int blk=2; // Matrix list starts at block 2
170 unsigned int blkNext=0, blkPrev=0, nrFree=0, nrUsed=0;
171 unsigned int dirbuf[ECATBLKSIZE/4];
172 do {
173 /* Read the data block */
174 if(verbose>1) printf(" reading block %u\n", blk);
175 int ret=ecatReadBlock(NULL, fp, blk, (unsigned char*)dirbuf);
176 if(ret!=TPCERROR_OK) {
177 if(verbose>0) fprintf(stderr, "Error: cannot read block %u\n", blk);
178 ecatMListFree(ml);
179 statusSet(status, __func__, __FILE__, __LINE__, ret);
180 return(ret);
181 }
182 /* Byte order conversion for integers in little/big endian platforms */
183 if(little && format==7) swawbip(dirbuf, ECATBLKSIZE);
184 if(!little && format==6) swawbip(dirbuf, ECATBLKSIZE);
185 /* Read the "header" integers from the block */
186 nrFree = dirbuf[0];
187 blkNext = dirbuf[1];
188 blkPrev = dirbuf[2];
189 nrUsed = dirbuf[3];
190 if(verbose>2)
191 printf("nrFree=%u blkNext=%u blkPrev=%u nrUsed=%u\n", nrFree, blkNext, blkPrev, nrUsed);
192 /* Allocate (more) memory for the matrix list */
193 if(ml->matrixSpace==0) {
195 ml->matdir=(ECAT_MATDIR*)malloc(ml->matrixSpace*sizeof(ECAT_MATDIR));
196 } else if(ml->matrixSpace<(ml->matrixNr+ECATBLKSIZE/4)) {
198 ml->matdir=(ECAT_MATDIR*)realloc(ml->matdir, sizeof(ECAT_MATDIR)*ml->matrixSpace);
199 }
200 if(ml->matdir==NULL) {
201 ecatMListFree(ml);
202 statusSet(status, __func__, __FILE__, __LINE__, TPCERROR_OUT_OF_MEMORY);
204 }
205 /* Add the content of this block to the matrix list */
206 for(unsigned int i=4; i<ECATBLKSIZE/4; i+=4) if(dirbuf[i]>0) {
207 ml->matdir[ml->matrixNr].id=dirbuf[i];
208 ml->matdir[ml->matrixNr].strtblk=dirbuf[i+1];
209 ml->matdir[ml->matrixNr].endblk=dirbuf[i+2];
210 ml->matdir[ml->matrixNr].status=dirbuf[i+3];
211 if(verbose>3) {
212 printf("matnum=%u strtblk=%u endblk=%u matstat=%u matrixNr=%u\n",
213 ml->matdir[ml->matrixNr].id, ml->matdir[ml->matrixNr].strtblk,
214 ml->matdir[ml->matrixNr].endblk, ml->matdir[ml->matrixNr].status,
215 ml->matrixNr);
216 }
217 /* verify that referred data block can be found in the file */
218 fpos_t current_fp; fgetpos(fp, &current_fp); // save current file position
219 int ret=fseeko(fp, (off_t)(ml->matdir[ml->matrixNr].endblk-1)*ECATBLKSIZE, SEEK_SET);
220 fsetpos(fp, &current_fp); // back to saved file position
221 if(ret==0) { // end block can be found
222 ml->matrixNr++; // save this matrix into the list
223 } else { // not found, file probably broken
224 if(verbose>0) {
225 printf("matnum %d points to data outside of file.\n", ml->matdir[ml->matrixNr].id);
226 fflush(stdout);
227 }
228 // matrixNr not incremented, thus this matrix is left out of the list
229 }
230 }
231 blk=blkNext;
232 } while(feof(fp)==0 && blk>2);
233
234 if(ml->matrixNr==0) {
235 ecatMListFree(ml);
236 statusSet(status, __func__, __FILE__, __LINE__, TPCERROR_NO_DATA);
237 return(TPCERROR_NO_DATA);
238 }
239 if(verbose>1) printf(" matrixNr := %u\n", ml->matrixNr);
240
241 statusSet(status, __func__, __FILE__, __LINE__, TPCERROR_OK);
242 return(TPCERROR_OK);
243}
int ecatReadBlock(const char *filename, FILE *fp, const unsigned int blocknumber, unsigned char *data)
Definition ecatio.c:23
void ecatMListFree(ECAT_MATRIXLIST *ml)
int endianLittle()
Definition endian.c:53
void swawbip(void *buf, int size)
Definition endian.c:138
void statusSet(TPCSTATUS *s, const char *func, const char *srcfile, int srcline, tpcerror error)
Definition statusmsg.c:142
int status
Definition tpcecat.h:48
int verbose
Verbose level, used by statusPrint() etc.
#define ECATBLKSIZE
Definition tpcecat.h:37
@ TPCERROR_FAIL
General error.
@ TPCERROR_OUT_OF_MEMORY
Cannot allocate memory.
@ TPCERROR_OK
No error.
@ TPCERROR_NO_DATA
File contains no data.

◆ ecatMListReadId()

void ecatMListReadId ( int format,
unsigned int id,
ECAT_MATVAL * mv )

Read matrix identifier code (matnum) into matrix value structure.

See also
ecatMListMakeId, ecatMValToId, ecatMListPrint
Parameters
formatECAT format: 6 or 7.
idMatrix identifier code (matnum) to decode.
mvPointer to data structure in where frame, plane etc numbers are written.

Definition at line 52 of file ecatmatrixlist.c.

59 {
60 if(mv==NULL) return;
61 mv->frame=mv->plane=mv->gate=mv->data=mv->bed=0;
62 if(format==7) {
63 mv->frame = id & 0x1FF;
64 mv->plane = ((id >> 16) & 0xFF) + ((id >> 1) & 0x300);
65 mv->gate = (id >> 24) & 0x3F;
66 mv->data = ((id >> 30) & 0x3) + ((id >> 9) & 0x4);
67 mv->bed = (id >> 12) & 0xF;
68 } else if(format==6) {
69 mv->frame = id&0xFFF;
70 mv->plane = (id>>16)&0xFF;
71 mv->gate = (id>>24)&0x3F;
72 mv->data = (id>>30)&0x3;
73 mv->bed = (id>>12)&0xF;
74 }
75 return;
76}
unsigned int data
Definition tpcecat.h:70

Referenced by ecatMListPrint().

◆ ecatMValToId()

unsigned int ecatMValToId ( int format,
ECAT_MATVAL * mv )

Make matrix identifier (matnum) code for specific matrix.

See also
ecatMListReadId, ecatMListMakeId
Returns
The matrix identifier.
Parameters
formatECAT format: 6 or 7.
mvPointer to data structure from where frame, plane etc numbers are read.

Definition at line 124 of file ecatmatrixlist.c.

129 {
130 if(mv==NULL) return(0);
131 return(ecatMListMakeId(format, mv->frame, mv->plane, mv->gate, mv->data, mv->bed));
132}
unsigned int ecatMListMakeId(int format, unsigned int frame, unsigned int plane, unsigned int gate, unsigned int data, unsigned int bed)

◆ ecatReadBlock()

int ecatReadBlock ( const char * filename,
FILE * fp,
const unsigned int blocknumber,
unsigned char * data )

Read specified data block from an ECAT file.

See also
ecatVerifyMagic
Returns
enum tpcerror (TPCERROR_OK when successful).
Parameters
filenameName of file to open and read specified data block; file is closed after reading; enter NULL to use the file pointer (next argument) instead.
fpFile pointer of file, opened with fp=fopen(filename, "rb"), to read the specified data block from; enter NULL to open file (previous argument) locally. This function leaves the file pointer to the end of data block.
blocknumberBlock number to read; enter 0 to read the block from current file pointer position, if file pointer was given.
dataPointer to write block data in; must be allocated for at least ECATBLKSIZE bytes.

Definition at line 23 of file ecatio.c.

36 {
37 if(filename==NULL && fp==NULL) return(TPCERROR_FAIL);
38 if(data==NULL) return(TPCERROR_FAIL);
39
40 if(fp!=NULL) { // read from given file pointer
41
42 /* If block number was given, then seek the block */
43 if(blocknumber>0) {
44 if(fseeko(fp, (off_t)(blocknumber-1)*ECATBLKSIZE, SEEK_SET) != 0)
45 return(TPCERROR_NO_DATA);
46 }
47 /* Read the block */
48 if(fread(data, ECATBLKSIZE, 1, fp)<1) return(TPCERROR_CANNOT_READ);
49
50 } else { // read from given file name
51
52 /* Open file for read */
53 FILE *localfp=fopen(filename, "rb");
54 if(localfp==NULL) return(TPCERROR_CANNOT_OPEN);
55
56 /* If block number was given, then seek the block */
57 if(blocknumber>0) {
58 if(fseeko(localfp, (off_t)(blocknumber-1)*ECATBLKSIZE, SEEK_SET) != 0)
59 {fclose(localfp); return(TPCERROR_NO_DATA);}
60 }
61 /* Read the block */
62 if(fread(data, ECATBLKSIZE, 1, localfp)<1) {fclose(localfp); return(TPCERROR_CANNOT_READ);}
63 fclose(localfp);
64
65 }
66
67 /* That's it then */
68 return(TPCERROR_OK);
69}
@ TPCERROR_CANNOT_OPEN
Cannot open file.
@ TPCERROR_CANNOT_READ
Cannot read file.

Referenced by ecatMListRead(), and ecatVerifyMagic().

◆ ecatReadMainheader()

int ecatReadMainheader ( const unsigned char * buf,
IFT * ift,
TPCSTATUS * status )

Read ECAT main header from data block into IFT struct.

Remarks
Stub function.
See also
ecatWriteMainheader, ecatVerifyMagic
Returns
enum tpcerror (TPCERROR_OK when successful).
Parameters
bufPointer to data block containing main header.
iftPointer to initiated IFT struct; any previous contents are NOT deleted.
statusPointer to status data; enter NULL if not needed.

Definition at line 100 of file ecatheader.c.

107 {
108 int verbose=0; if(status!=NULL) verbose=status->verbose;
109 if(verbose>0) {printf("%s()\n", __func__); fflush(stdout);}
110
111 if(buf==NULL || ift==NULL) {
112 statusSet(status, __func__, __FILE__, __LINE__, TPCERROR_FAIL);
113 return(TPCERROR_FAIL);
114 }
115
116 /* Is current platform little endian (1) or not (0) ? */
117 int little=endianLittle();
118 if(verbose>1) {
119 if(little) printf("little endian platform\n");
120 else printf("big endian platform\n");
121 }
122
123 /* Check if the start matches the ECAT 7 magic numbers */
124 int format=6;
125 if(strncmp((char*)buf, "MATRIX72v", 9)==0 || strncmp((char*)buf, "MATRIX7011", 10)==0) format=7;
126 if(verbose>1) {printf("format := %d\n", format); fflush(stdout);}
127
128 /* Copy the header fields to IFT; byte swapping when necessary */
129 statusSet(status, __func__, __FILE__, __LINE__, TPCERROR_INVALID_FORMAT);
130 char tmp[512];
131
132 if(format==7) {
133
134 strlcpy(tmp, (char*)buf+0, 15);
135 if(iftPut(ift, "magic_number", tmp, 0, NULL)!=0) return(TPCERROR_INVALID_FORMAT);
136 strlcpy(tmp, (char*)buf+14, 33);
137 if(iftPut(ift, "original_file_name", tmp, 0, NULL)!=0) return(TPCERROR_INVALID_FORMAT);
138
139 } else { // ECAT 6
140
141 strlcpy(tmp, (char*)buf+0, 15);
142 if(iftPut(ift, "magic_number", tmp, 0, NULL)!=0) return(TPCERROR_INVALID_FORMAT);
143 strlcpy(tmp, (char*)buf+28, 21);
144 if(iftPut(ift, "original_file_name", tmp, 0, NULL)!=0) return(TPCERROR_INVALID_FORMAT);
145
146 }
147
148
149 statusSet(status, __func__, __FILE__, __LINE__, TPCERROR_OK);
150 return(TPCERROR_OK);
151}
int iftPut(IFT *ift, const char *key, const char *value, char comment, TPCSTATUS *status)
Definition ift.c:63
size_t strlcpy(char *dst, const char *src, size_t dstsize)
Definition stringext.c:632
@ TPCERROR_INVALID_FORMAT
Invalid file format.

◆ ecatVerifyMagic()

int ecatVerifyMagic ( const char * filename,
FILE * fp )

Verify that given file (either file name or file pointer) appears to be ECAT file, based on the magic number.

ECAT 7 has defined magic numbers, which are checked. ECAT 6 format does not a defined magic number, therefore here the file is only checked to not indicate anything else than ECAT 6.

Returns
Returns 0 if magic number is definitely not ECAT; 7 if ECAT 7 magic number is found, and 6 if magic number does not indicate anything other than ECAT 6.
Author
Vesa Oikonen
Parameters
filenameName of file to open and to verify for the magic number; file is closed after reading; enter NULL to use the file pointer (next argument) instead.
fpFile pointer of file to check, opened with fp=fopen(filename, "rb"); enter NULL to open file (previous argument) locally. This function rewinds the file pointer to start before and after reading the data.

Definition at line 84 of file ecatio.c.

93 {
94
95 /* Read the first data block (512 bytes) */
96 unsigned char buf[ECATBLKSIZE];
97 int ret=ecatReadBlock(filename, fp, 0, buf);
98 if(fp!=NULL) rewind(fp);
99 if(ret!=TPCERROR_OK) return(0);
100
101 /* Check if the start matches the ECAT 7 magic numbers */
102 if(strncmp((char*)buf, "MATRIX72v", 9)==0 || strncmp((char*)buf, "MATRIX7011", 10)==0) return(7);
103
104 /* ECAT 6 does not have defined magic numbers, but check anyway */
105 if(strncmp((char*)buf, "MATRIX6", 7)==0 || strncmp((char*)buf, "ECAT6", 5)==0) return(6);
106
107 /* Check that we do NOT have DICOM magic number */
108 if(strncmp((char*)buf+128, "DICM", 4)==0) return(0);
109
110 /* Check that we do NOT have NIfTI magic number */
111 if(strncmp((char*)buf+344, "ni1", 3)==0 || strncmp((char*)buf, "n+1", 3)==0) return(0);
112
113 /* Check that we do NOT have Interfile magic number */
114 if(strncmp((char*)buf, "!INTERFILE", 10)==0) return(0);
115
116 /* There is no indication that this IS NOT an ECAT 6 file */
117 return(6);
118}

◆ ecatWriteMainheader()

int ecatWriteMainheader ( IFT * ift,
unsigned char * buf,
TPCSTATUS * status )

Write ECAT main header from IFT struct into data block.

Remarks
Stub function.
See also
ecatReadMainheader, ecatVerifyMagic
Returns
enum tpcerror (TPCERROR_OK when successful).
Parameters
iftPointer to IFT struct containing main header fields; contents are not modified.
bufPointer to data block of size ECATBLKSIZE bytes.
statusPointer to status data; enter NULL if not needed.

Definition at line 25 of file ecatheader.c.

32 {
33 int verbose=0; if(status!=NULL) verbose=status->verbose;
34 if(verbose>0) {printf("%s()\n", __func__); fflush(stdout);}
35
36 if(ift==NULL || buf==NULL) {
37 statusSet(status, __func__, __FILE__, __LINE__, TPCERROR_FAIL);
38 return(TPCERROR_FAIL);
39 }
40 if(ift->keyNr<1) {
41 statusSet(status, __func__, __FILE__, __LINE__, TPCERROR_MISSING_DATA);
43 }
44
45 /* Is current platform little endian (1) or not (0) ? */
46 int little=endianLittle();
47 if(verbose>1) {
48 if(little) printf("little endian platform\n");
49 else printf("big endian platform\n");
50 }
51
52 /* Determine ECAT format version */
53 int format=6;
54 /* If ECAT 7 magic_number not found, then assume ECAT 6 */
55 int ii=iftFindKey(ift, "magic_number", 0);
56 if(ii>=0) {
57 if(strncmp(ift->item[ii].value, "MATRIX72v", 9)==0 ||
58 strncmp(ift->item[ii].value, "MATRIX7011", 10)==0) format=7;
59 }
60 if(verbose>1) {printf("format := %d\n", format); fflush(stdout);}
61
62 /* Copy the header fields; byte swapping when necessary */
63 statusSet(status, __func__, __FILE__, __LINE__, TPCERROR_MISSING_DATA);
64 char tmp[512];
65
66 if(format==7) {
67
68 ii=iftFindKey(ift, "magic_number", 0);
69 if(ii>=0) strlcpy(tmp, ift->item[ii].value, 15); else strcpy(tmp, "MATRIX72v");
70 memcpy((char*)buf+0, tmp, 14);
71
72 ii=iftFindKey(ift, "original_file_name", 0);
73 if(ii>=0) strlcpy(tmp, ift->item[ii].value, 33); else strcpy(tmp, "");
74 memcpy((char*)buf+14, tmp, 32);
75
76 } else { // ECAT 6
77
78 ii=iftFindKey(ift, "magic_number", 0);
79 if(ii>=0) strlcpy(tmp, ift->item[ii].value, 15); else strcpy(tmp, "MATRIX6");
80 memcpy((char*)buf+0, tmp, 14);
81
82 ii=iftFindKey(ift, "original_file_name", 0);
83 if(ii>=0) strlcpy(tmp, ift->item[ii].value, 21); else strcpy(tmp, "");
84 memcpy((char*)buf+28, tmp, 20);
85
86 }
87
88
89 statusSet(status, __func__, __FILE__, __LINE__, TPCERROR_OK);
90 return(TPCERROR_OK);
91}
int iftFindKey(IFT *ift, const char *key, int start_index)
Definition iftfind.c:30
char * value
Definition tpcift.h:37
IFT_ITEM * item
Definition tpcift.h:57
int keyNr
Definition tpcift.h:47
@ TPCERROR_MISSING_DATA
File contains missing values.

Referenced by imgWrite().