#include #include #include #include #include "struct_TAC_in.h" /* C source code name: parse_in_akc_.c */ /* edit, e.g., with emacs. compile with Makefile */ /* By: Alexander K. Converse, University of Wisconsin-Madison */ /* Created: 01 Dec 2012 */ /* Modified: 26 March 2014 */ /* Purpose: Read CSV input file of structure below */ /* * subject */ /* RBO015 */ /* * scan */ /* 2011_05_03_e_RBO015_F18_60m */ /* * comment */ /* dev testing */ /* * administered activity (Bq) */ /* 11520000 */ /* * ASIPro Tacs file */ /* /study/converse/micropet/DeJesus/PlantScans/3_analysis_RBO_fluoride/IEEE_poster/stem_ROIs/2011_05_03_e_RBO015_F18_60m_10x1_x5m_stem_coronal_20111018.csv */ /* * number of ROIs */ /* 4 */ /* * MAT UB */ /* 11 */ /* nFrames */ /* 28 */ /* n60Frames */ /* 20 */ /* *ROIi */ /* cor_75 */ /* cor_70 */ /* cor_65 */ /* cor_60 */ /* * Xi (mm) */ /* 0 */ /* 9.5 */ /* 19 */ /* 28.5 */ /* * Times (s) */ /* 30.0 */ /* 60.0 */ /* ... */ int parse_in_akc(struct TAC_t *p, char const *inputFile) { FILE *fp_in; char temp[MAXLEN]; int i; /* Read input file, print file data with labels, store file data in TAC_t struct*/ fp_in = fopen(inputFile, "r"); if (fp_in == NULL) { printf("Cannot open the input file. Exiting program\n"); return 0; } // Read label fgets(p->label, MAXLEN, fp_in); // Read and store scan-specific information fgets(p->subject, MAXLEN, fp_in); /* subject */ // Print scan-specific information printf("%s %s\n", p->label, p->subject); fgets(p->label, MAXLEN, fp_in); fgets(p->scan, MAXLEN, fp_in); /* scan */ printf("%s %s\n", p->label, p->scan); fgets(p->label, MAXLEN, fp_in); fgets(p->comment, MAXLEN, fp_in); /* comment */ printf("%s %s\n", p->label, p->comment); fgets(p->label, MAXLEN, fp_in); fgets(temp, MAXLEN, fp_in); p->admAct = atof(temp); /* administered activity (Bq) */ printf("%s %f\n\n", p->label, p->admAct); fgets(p->label, MAXLEN, fp_in); fgets(p->inTacsFile, MAXLEN, fp_in); /* ASIPro TACs file */ printf("%s %s\n", p->label, p->inTacsFile); fgets(p->label, MAXLEN, fp_in); fgets(temp, MAXLEN, fp_in); p->nROIs = atoi(temp); /* number of ROIs */ printf("%s %d\n\n", p->label, p->nROIs); fgets(p->label, MAXLEN, fp_in); fgets(temp, MAXLEN, fp_in); p->MAT = atoi(temp); /* MAT Upper Bound */ printf("%s %d\n\n", p->label, p->MAT); fgets(p->label, MAXLEN, fp_in); fgets(temp, MAXLEN, fp_in); p->nFrames = atoi(temp); /* nFrames (s) */ printf("%s %d\n\n", p->label, p->nFrames); fgets(p->label, MAXLEN, fp_in); fgets(temp, MAXLEN, fp_in); p->n60Frames = atoi(temp); /* n60Frames (s) */ printf("%s %d\n\n", p->label, p->n60Frames); fgets(p->label, MAXLEN, fp_in); /* ROIs */ printf("%s", p->label); for(i = 0; i < (p->nROIs); ++i) { fgets(p->ROIs[i], MAXLEN, fp_in); printf("%d : %s", i, p->ROIs[i]); } fgets(p->label, MAXLEN, fp_in); /* ROIsPositions - Xi (mm) */ printf("\n %s", p->label); for(i = 0; i < p->nROIs; ++i) { fgets(temp, MAXLEN, fp_in); p->X[i] = atof(temp); printf("%d : %f\n", i, p->X[i]); } fgets(p->label, MAXLEN, fp_in); fgets(temp, MAXLEN, fp_in); p->sliceThickness = atof(temp); /* Slice Thickness (mm) */ printf("\n%s %f\n", p->label, p->sliceThickness); fgets(p->label, MAXLEN, fp_in); /* ROIs Areas - mm2 */ printf("\n %s", p->label); for(i = 0; i < p->nROIs; ++i) { fgets(temp, MAXLEN, fp_in); p->area[i] = atof(temp); printf("%d : %f\n", i, p->area[i]); } fgets(p->label, MAXLEN, fp_in); /* Times (s) */ printf("\n %s", p->label); for(i = 0; i < p->nFrames; ++i) { fgets(temp, MAXLEN, fp_in); p->inFileTime[i] = atof(temp); printf("%d : %f\n", i, p->inFileTime[i]); } fclose(fp_in); return 1; }