Read DICOM image matrix list.
127 {
128 int verbose=0;
if(status!=NULL) verbose=status->
verbose;
129 if(verbose>1) printf("%s()\n", __func__);
130 if(ift==NULL || ml==NULL) {
133 }
137 }
138
139
141
142
143
144
149
150
153
154
155 int dynamic=0;
158 if(iptr==NULL) {
161 }
162
163
164
165 {
167 if(verbose>2) printf("imageType := %s\n", buf);
168 if(
strcasestr(buf,
"DYNAMIC")!=NULL) dynamic=1;
else dynamic=0;
169 free(buf);
170 }
171 if(verbose>1) {printf("dynamic := %d\n", dynamic); fflush(stdout);}
172
173
174 int multiframe=0;
177 if(iptr!=NULL) {
178 if(verbose>1) fprintf(stderr, "Notice: Per-frame Functional Groups Sequence is available.\n");
179 multiframe=1;
180 }
181
182
183 if(multiframe) {
184
185
186 if(verbose>1) {printf("reading frame and slice number\n"); fflush(stdout);}
187 unsigned short int frameNr=0;
188
190 int a, b;
192 if(verbose>1) printf("frameNr := %u\n", frameNr);
193 unsigned short int sliceNr=0;
194
197 else {
198
201 }
202 if(verbose>1) printf("sliceNr := %u\n", sliceNr);
203 if(frameNr<=0 || sliceNr<=0) {
204 if(verbose>0) fprintf(stderr, "Error: cannot find frame/slice number.\n");
207 }
208
209
210 short unsigned int decayCorrection=0;
213 if(iptr!=NULL) {
215 if(verbose>2) printf("Decay Correction := '%s'\n", buf);
216 if(
strcasestr(buf,
"YES")!=NULL) decayCorrection=1;
217 free(buf);
218 }
219 if(verbose>1) printf("decayCorrection := %d\n", decayCorrection);
220
221
222 char zeroDateTime[32]; zeroDateTime[0]=(char)0;
223 if(decayCorrection==0) {
224
228 } else {
232 }
233 if(!zeroDateTime[0]) {
234 if(verbose>0) fprintf(stderr, "Error: missing Acquisition Date and Time.\n");
237 }
238 if(verbose>4) printf("zeroDateTime := %s\n", zeroDateTime);
239
240
243 statusSet(status, __func__, __FILE__, __LINE__, ret);
245 }
246
247
248
249
250
253 if(iptr==NULL) {
254 if(verbose>0) {
255 fprintf(stderr, "Error: cannot find Per Frame Functional Groups Sequence.\n");
256 fflush(stderr);
257 }
260 }
261
267 while(fptr!=NULL) {
268
270 if(verbose>10) printf(" found Frame Content Sequence\n");
271
272 if(ml->
nr>=ml->
anr) {
275 }
276
278
281 if(jptr==NULL) {
282 if(verbose>0) {printf("cannot find Temporal Position Index.\n"); fflush(stdout);}
284 }
287
288
291 if(jptr==NULL) {
294 }
295 if(jptr==NULL) {
296 if(verbose>0) {printf("cannot find Slice Index.\n"); fflush(stdout);}
298 }
301
303 char facqDateTime[32]; facqDateTime[0]=(char)0;
305 if(!facqDateTime[0]) {
306 if(verbose>0) {printf("cannot find Frame Acquisition DateTime.\n"); fflush(stdout);}
308 }
309 if(verbose>20) printf("facqDateTime := %s\n", facqDateTime);
312
314
317
318
321 }
322
325 statusSet(status, __func__, __FILE__, __LINE__, ret);
327 return(ret);
328 }
329
330 } else {
331
332
333 unsigned short int frameNr=0;
336 if(iptr!=NULL) {
338 } else {
339 if(dynamic!=0) {
342 } else {
343 frameNr=1;
344 }
345 }
346 if(verbose>1) printf("frameNr := %u\n", frameNr);
347
348
349 unsigned short int sliceNr=0;
352 if(iptr==NULL) {
355 }
357 if(verbose>1) printf("sliceNr := %u\n", sliceNr);
358
359
360 short unsigned int decayCorrection=0;
363 if(iptr!=NULL) {
365 if(verbose>2) printf("Decay Correction := %s\n", buf);
366 if(strcasecmp(buf, "NONE")==0) decayCorrection=0;
367 else if(strcasecmp(buf, "START")==0) decayCorrection=1;
368 else if(strcasecmp(buf, "ADMIN")==0) decayCorrection=2;
369 free(buf);
370 }
371
372
373 char injDateTime[32]; injDateTime[0]=(char)0;
374 if(decayCorrection==2) {
375
378 if(iptr!=NULL) {
380 }
381
382 if(iptr==NULL) {
383 char s1[16], s2[16];
384
387 if(iptr!=NULL) {
388
391 if(jptr!=NULL) {
393 sprintf(injDateTime, "%s %s", s1, s2);
394 }
395 }
396 }
397 if(injDateTime[0] && verbose>3) printf("injection_time := %s\n", injDateTime);
398 }
399
400
401
402
403 char seriesDateTime[32]; seriesDateTime[0]=(char)0;
406 if(iptr!=NULL) {
409 if(jptr!=NULL) {
410 char s1[16], s2[16];
412 sprintf(seriesDateTime, "%s %s", s1, s2);
413 }
414 }
415 if(seriesDateTime[0] && verbose>3) printf("seriesDateTime := %s\n", seriesDateTime);
416
417
418
421 statusSet(status, __func__, __FILE__, __LINE__, ret);
423 }
424
425
426
427
428
429
430
431 do {
432
433
434 unsigned short int imageIndex=0;
439
440 unsigned short int frameIndex, sliceIndex;
441 {
442 div_t meh=div(imageIndex-1, sliceNr);
443 frameIndex=meh.quot;
444 sliceIndex=meh.rem;
445 }
446
447 if(ml->
nr>=ml->
anr) {
450 }
454
455
456 char acqDateTime[32]; acqDateTime[0]=(char)0;
457
461
462 if(!acqDateTime[0]) {
465 if(iptr!=NULL) {
468 if(jptr!=NULL) {
469 char s1[16], s2[16];
471 sprintf(acqDateTime, "%s %s", s1, s2);
472 }
473 }
474 }
475 if(acqDateTime[0]) {
478 }
479
480
481 if(acqDateTime[0]) {
482 double t1=nan("");
483 if(decayCorrection==2 && injDateTime[0]) {
484
487 } else if(seriesDateTime[0]) {
488
491 }
492 }
493
494
498
499
500
503
504
508
509 } while(1);
512 statusSet(status, __func__, __FILE__, __LINE__, ret);
514 return(ret);
515 }
516 }
517
518
521}
double strDateTimeDifference(const char *dt1, const char *dt0)
long int dcmitemGetInt(DCMITEM *d)
void dcmfileInit(DCMFILE *d)
DCMITEM * dcmFindTag(DCMITEM *d, const short int omit, DCMTAG *tag, const int verbose)
DCMITEM * dcmFindDownTag(DCMITEM *d, const short int omit, DCMTAG *tag, const int verbose)
void dcmfileFree(DCMFILE *d)
int dcmTagIntRange(DCMITEM *d, DCMTAG *tag, int *mi, int *ma, const int verbose)
void dcmitemPrint(DCMITEM *d)
double dcmitemGetReal(DCMITEM *d)
char * dcmValueString(DCMITEM *d)
int dcmFileRead(const char *filename, DCMFILE *dcm, const short int headerOnly, TPCSTATUS *status)
int dcmmlAllocate(DCMML *d, int mNr)
char * dcmDT2intl(const char *orig, char *intl)
char * dcmDA2intl(const char *orig, char *intl)
char * dcmTM2intl(const char *orig, char *intl)
void statusSet(TPCSTATUS *s, const char *func, const char *srcfile, int srcline, tpcerror error)
char * strdup(const char *s)
size_t strlcpy(char *dst, const char *src, size_t dstsize)
char * strcasestr(const char *haystack, const char *needle)
struct DCMITEM * child_item
struct DCMITEM * next_item
unsigned short int element
int verbose
Verbose level, used by statusPrint() etc.
@ TPCERROR_NO_KEY
Key not found.
@ TPCERROR_NO_DATA
File contains no data.