/**************************************-**************************************/ /* */ /* DATA_UTIL_FST_WRITE */ /* */ /*****************************************************************************/ void data_util_fst_write(outfile,data,x0,xn,y0,yn,t0,tn,drange,fcode,binoc) char outfile[]; // Output file name, should be .fst float ***data; // [xn][yn][tn] Stimulus data int x0,xn,y0,yn,t0,tn; // width, height, time duration int drange; // Data range, 0-[0..1], (NOT Imp'd: 1-[-1..1]) int fcode; // 1-unsigned char, 2-unsigned short, 3-int, 4-float // *** CURRENTLY, only option '2' is implemented int binoc; // 0-monoc, 2-binocular L/R frame interleave { int i,j,k; FILE *fopen(),*fout; int temp,nbytes,vcode,color_code; unsigned short int ds; printf(" DATA_UTIL_FST_WRITE\n"); printf(" xn,yn,tn = %d %d %d\n",xn,yn,tn); printf(" writing %s\n",outfile); if (fcode != 2) exit_error("DATA_UTIL_FST_WRITE","fcode expected to be 2"); if ((fout = fopen(outfile,"w")) == NULL){ printf(" *** File %s\n",outfile); exit_error("DATA_UTIL_FST_WRITE","Cannot open file"); } temp = 16909061; // This is hex 01 02 03 05, for checking byte order vcode = 1; // Version 1 color_code = 0; // Achromatic fwrite((char *)&temp,sizeof(int),1,fout); fwrite((char *)&vcode,sizeof(int),1,fout); fwrite((char *)&xn,sizeof(int),1,fout); fwrite((char *)&yn,sizeof(int),1,fout); fwrite((char *)&tn,sizeof(int),1,fout); fwrite((char *)&fcode,sizeof(int),1,fout); fwrite((char *)&color_code,sizeof(int),1,fout); fwrite((char *)&binoc,sizeof(int),1,fout); if (fcode == 1) nbytes = 1; else if (fcode == 2) nbytes = 2; else if ((fcode == 3) || (fcode == 4)) nbytes = 4; else exit_error("DATA_UTIL_FST_WRITE","Invalid fcode"); for(k=0;k