1 /*****************************************************************************
2    Major portions of this software are copyrighted by the Medical College
3    of Wisconsin, 1994-2000, and are released under the Gnu General Public
4    License, Version 2.  See the file README.Copyright for details.
5 ******************************************************************************/
6 
7 /* Functional image is made by correlating refernce function from an ASCII
8    file with the series of images.  All orthogonal ~ to a + b*x.
9    All is scaled accodingly to number of time points an independent
10    of referece function amplitude. Abs % change added.
11    Andre Jesmanowicz, MCW Milwaukee, 12.15.1992 */
12 
13 #ifdef SPARKY
14 #undef _POSIX_SOURCE
15 #endif
16 #include <sys/types.h>
17 
18 #include <stdio.h>
19 #include <math.h>
20 #include <ctype.h>
21 #include <sys/stat.h>
22 #include <stdlib.h>
23 #ifdef   SYSV
24 #include <sys/fcntl.h>
25 #endif
26 
27 #define min(a,b) ((a) < (b) ? (a) : (b))
28 #define max(a,b) ((a) > (b) ? (a) : (b))
29 
30 #define EPX1      64                   /* List of supported EPI image sizes */
31 #define EPY1      64                   /* Each triple is: */
32 #define EPS1      (2*EPX1*EPY1)        /* xsize, ysize, filesize */
33 #define EPX2      128
34 #define EPY2      128
35 #define EPS2      (2*EPX2*EPY2)
36 
37 #define NOISE_THR 10.                  /* Minimum signal for delta comput */
38 #define SCALE     10000
39 #define D_COEF    1.
40 #define CORR      ".CORR"
41 #define IM_HEIGHT 256
42 #define IM_ARR    (IM_HEIGHT*IM_HEIGHT)
43 #define OFFSET    (28*IM_HEIGHT)       /* offset to data in 145408 bytes im */
44 #define H_SIZE    (OFFSET+IM_ARR)      /* 256x256 image with header */
45 #define IM_SIZE   (2*H_SIZE)
46 
47 #define SEQ_SIZE  1024                /* The length of reference sequence */
48 #define NF_MAX    1050                /* Max # of files */
49 #define EXT_FILES 1                   /* Number of external func files */
50 
51 extern double   strtod();
52 
53 char            *ProgName, *SQ_name, *f_name[NF_MAX], **ptr, *file_out;
54 char            *ort_name, file_CORR[256];
55 int             ORT_ar[EXT_FILES][SEQ_SIZE], ORT_Nr[EXT_FILES], idot, isq;
56 float           fORT[EXT_FILES][SEQ_SIZE], alpha, fdot, fsq, noise_thr;
57 int             SQ_Nr, SQ_arr[SEQ_SIZE], n_ort;
58 int             Im_frst = 0, npoints = 0, m_points;
59 int             N_im, fsize, isize, ar_size, itmp;
60 short int       *ar, tmp_ar[H_SIZE], corr_ar[H_SIZE];
61 float           fSQ[SEQ_SIZE], ft[SEQ_SIZE], fSQ1[SEQ_SIZE], dt[SEQ_SIZE];
62 float           fa, fb, fim[IM_ARR], amin, amax, ftmp, abmax, del_1, max_dev;
63 float           pct = 30., pcc, fSQ_vl, fll, coef = D_COEF, fzz;
64 float           fl_1ref, sq_1n, fcorr, max_cor, delr, next_cor = 0;;
65 FILE            *fp;
66 int             offs, normalize = 1, correl_im = 0, diff_im = 0;
67 int             n_ess = 0;
68 
69 /* --------------- */
main(argc,argv)70    main(argc,argv)
71    int argc;
72    char *argv[];
73 /* --------------- */
74 {
75    int i, j, m;
76 
77    ProgName = argv[0];
78    if (argc <  2)  Syntax();
79 
80    noise_thr = NOISE_THR;
81 
82    get_line_args(argc, argv);
83 
84    if ( is_file(file_out) ) {
85       fprintf(stderr, "\n !!! Output file: %s exist. !!!\n", file_out);
86       Syntax();
87    }
88 
89                                 /* Init to zero functional image */
90    for (i=0; i < IM_ARR; i++) fim[i] = 0.;
91 
92    pcc = 1. - .01 * pct;     /* Reference projection value (for rejecton) */
93 
94    m_points = 0;                         /* considered time cours points */
95    idot = 0;                             /* set integral of ref to zero */
96    for (j=0; j < N_im; j++) {
97       if (SQ_arr[j] < 33333 ) {
98          idot += SQ_arr[j];
99          m_points++;
100       }
101    }
102    if ( m_points == 0) {
103       fprintf (stderr, "\n\n !!! Check reference file: %s !!!\n\n",SQ_name);
104       exit(-1);
105    }
106    sq_1n = 1./sqrt((double) m_points);  /* points # normalizing coeff */
107 
108    /* make reference function orthogonal to constant one */
109    fa = (float) idot / (float) m_points;
110    for (j=0; j < N_im; j++) {
111       if ( SQ_arr[j] < 33333 )
112          fSQ[j] = (float) SQ_arr[j] - fa;
113       else
114          fSQ[j] = 0.;
115    }
116    /* The same orthogoanlization to const for ref ort files */
117    for (m=0; m < n_ort; m++) {
118       idot = 0;
119       for (j=0; j < N_im; j++)
120          if (SQ_arr[j] < 33333 ) idot += ORT_ar[m][j];
121       fa = (float) idot / (float) m_points;
122       for (j=0; j < N_im; j++) {
123          if (SQ_arr[j] < 33333 )
124             fORT[m][j] = (float) ORT_ar[m][j] - fa;
125          else
126             fORT[m][j] = 0;
127       }
128    }
129 
130 /* once othogonalized to const make orthogonalization to -ort files */
131 /* Temporarly single ort file case. AJ */
132    for (m=0; m < n_ort; m++) {
133       isq = 0;                                   /* set integral to zero */
134       idot = 0;
135       for (j=0; j < N_im; j++) {
136          if (SQ_arr[j] < 33333 ) {
137             fdot += fSQ[j]*fORT[m][j];
138             fsq  += fORT[m][j]*fORT[m][j];
139          }
140       }
141       if ( fsq == 0. ) {
142          fprintf (stderr, "\n\n !!! Orthogonal file #%d has zeros only !!!\n",
143                   m+1);
144          exit(-3);
145       }
146       alpha = fdot / fsq;
147       for (j=0; j < N_im; j++)
148          if (SQ_arr[j] < 33333 ) fSQ[j] -= alpha * fORT[m][j];
149    }
150 
151 
152                                     /* normalize ref vector */
153    fSQ_vl = 0.;
154    for (j=0; j < N_im; j++)  fSQ_vl += fSQ[j] * fSQ[j];
155    if (fSQ_vl < 1.e-10) {
156     fprintf (stderr, "\n\n !!! Too small variartion in reference file !!!\n\n");
157       exit(-1);
158    }
159    fl_1ref = 1./sqrt((double) fSQ_vl);
160    for (j=0; j < N_im; j++) fSQ1[j] = fSQ[j] * fl_1ref;
161 
162    amin =  1.e37;
163    amax = -1.e37;
164    for (j=0; j < N_im; j++) {
165       if ( fSQ1[j] > amax ) amax = fSQ1[j];
166       if ( fSQ1[j] < amin ) amin = fSQ1[j];
167    }
168    del_1 = amax - amin;  /* for reference of deviation */
169 
170 
171    max_dev = -1.e37;                 /* for max deviation of the function */
172    max_cor = 0.;
173 
174    /* go over all pixels */
175    for (i=0; i < ar_size; i++) {
176 
177    /* othogonalize (to const) data vector */
178       ftmp = 0;                                 /* for average brightness */
179       for (j=0; j < N_im; j++) {
180          if ( SQ_arr[j] < 33333 ) {
181             dt[j] = ar[j*ar_size+i];
182             ftmp += dt[j];
183          }
184       }
185       fa = ftmp /(float) m_points;      /* average value in data pixel */
186 
187       if ( ftmp < 0 ) diff_im = 1;  /* not regular images => no % of dev */
188 
189       for (j=0; j < N_im; j++) {
190          if ( SQ_arr[j] < 33333 )
191             dt[j] -= fa;
192          else
193             dt[j] = 0.;
194       }
195    /* once data othogonalized to const make orthogonalization to ref files */
196    /* Temporarly single ort file case. AJ */
197       for (m=0; m < n_ort; m++) {
198          fdot = 0;
199          for (j=0; j < N_im; j++)
200             if ( SQ_arr[j] < 33333 ) fdot += dt[j] * fORT[m][j];
201          alpha = fdot / fsq;
202          for (j=0; j < N_im; j++)
203             if (SQ_arr[j] < 33333 ) dt[j] -= alpha * fORT[m][j];
204       }
205 
206 /* normalize data vector */
207       fSQ_vl = 0.;
208       for (j=0; j < N_im; j++)
209          fSQ_vl += dt[j] * dt[j];
210 
211       if (fSQ_vl < 1.e-10)
212          for (j=0; j < N_im; j++) ft[j] = 0.;
213       else {
214          fll = 1./sqrt(fSQ_vl);
215          for (j=0; j < N_im; j++)
216               ft[j] = dt[j] * fll;
217       }
218 
219    /* make projection of normalized vectors */
220       fcorr = 0.;
221       for (j=0; j < N_im; j++) fcorr += ft[j] * fSQ1[j];
222 
223    /* make correlation image */
224       corr_ar[i+offs] = fcorr * (float) SCALE;
225 
226    /* make functional image for not too far data (correralte with normalized
227       vector) */
228       if ( (fb = fabs((double) fcorr)) > pcc ) {
229 
230          for (j=0; j < N_im; j++) fim[i] += dt[j] * fSQ1[j];
231 
232          if ( fa > noise_thr ) delr = del_1 * fim[i] / fa;    /* rel change */
233          else                  delr = 0.;
234 
235          if ( delr > max_dev ) max_dev = delr;       /* max rel dev */
236          if ( fb > max_cor ) {
237             next_cor = max_cor;
238             max_cor = fb;         /* max correl */
239          }
240          fim[i] *= fl_1ref;             /* make a ratio rel to ref function */
241          n_ess++;
242       }
243    }
244 
245    /* Make functional image independent of number of time course points.
246       Find min and max. */
247    amin =  1.e37;
248    amax = -1.e37;
249    for (i=0; i < ar_size; i++) {
250       if ( fim[i] > amax ) amax = fim[i];
251       if ( fim[i] < amin ) amin = fim[i];
252    }
253    fa = fabs((double) amax);
254    fb = fabs((double) amin);
255    abmax = max(fa, fb);
256    if (abmax < 1.e-10) {
257       fprintf (stderr, "\n !!! Check you reference and data files !!!");
258       fprintf (stderr, "\n !!! or increase value of -pcnt option. !!!");
259       fprintf (stderr, "\n !!! No variation in functional image.  !!!");
260       fprintf (stderr, "\n !!! No output file created.            !!!\n\n");
261       exit(-2);
262    }
263 
264    if ( normalize ) fa = (float) SCALE / abmax;
265    else             fa = coef;
266 
267    printf ("\n Output file: %s\n", file_out);
268    printf (" Image data (relative to reference function):\n");
269    printf (" max value : %g , scaled : %g\n", amax, amax*fa);
270    printf (" min value : %g , scaled : %g\n", amin, amin*fa);
271    printf (" max variation : %g %%\n", max_dev*100.);
272    printf (" the best correlation: %g %%\n", max_cor*100.);
273    printf (" next to the best    : %g %%\n", next_cor*100.);
274    printf (" number of essential pixels: %d\n", n_ess);
275 
276    for (i=0; i < ar_size; i++) {
277       fzz = fim[i]*fa;
278       if ( fzz >= 0. ) tmp_ar[i+offs] = min((int) fzz,  SCALE);
279       if ( fzz <  0. ) tmp_ar[i+offs] = max((int) fzz, -SCALE);
280    }
281 
282                        /* reload header (if present) to corr_ar */
283    for (i=0; i < offs; i++) corr_ar[i] = tmp_ar[i];
284 
285    corr_ar[0+offs] = 0;
286    corr_ar[1+offs] = -SCALE;
287    corr_ar[2+offs] =  SCALE;   /* so color image will show zero as green */
288 
289    tmp_ar[0+offs] = 0;
290    tmp_ar[1+offs] = -SCALE;
291    tmp_ar[2+offs] =  SCALE;   /* so color image will show zero as green */
292 
293                                         /* Write functional image to file */
294    if (i = write_iqm(file_out, &fsize, tmp_ar) )
295      fprintf (stderr, "\n\n Error writing output_file: %s (will not overwrite) %d\n\n", file_out, i);
296 
297    if (correl_im) {
298      strcpy(file_CORR, file_out);
299      strcat(file_CORR, CORR);
300      if (i = write_iqm(file_CORR, &fsize, corr_ar) )
301        fprintf (stderr, "\n\n Error writing output_file: %s (will not overwrite) %d\n\n", file_CORR, i);
302    }
303    exit(0) ;
304 }
305 
306 /* ------------------------- */
get_line_args(argc,argv)307    get_line_args(argc, argv)
308    int  argc;
309    char *argv[];
310 /* ------------------------- */
311 {
312    register int i, j, k, nopt, nnn;
313    int          sp;
314    float	ff;
315 
316    n_ort = 0;
317    nopt = 0;
318    for (i = 1; i < argc; i++) { /* ------- Options ------- */
319       if (!strncmp(argv[i], "-h", 2)) {          /* help */
320          Syntax();
321       }
322       if (strncmp(argv[i], "-non", 4) == 0) { /* don't normalize fim image */
323          normalize = 0;
324          nopt++;
325          continue;
326       }
327       if (strncmp(argv[i], "-corr", 4) == 0) { /* make correlation image */
328          correl_im = 1;
329          nopt++;
330          continue;
331       }
332       if (strncmp(argv [i], "-coe", 4) == 0) {   /* extra coeff for im_out */
333          if (++i >= argc) { Syntax(); exit(2); }
334          ptr = argv;
335          coef = strtod(argv[i], ptr);
336          if ( **ptr ) {
337             fprintf (stderr, "\n !!! Wrong value in option -coef: %g !!!\n\n",
338                                      coef);
339             exit(1);
340          }
341          nopt++; nopt++;
342          continue;
343       }
344       if (strncmp(argv [i], "-im1", 4) == 0) {  /* first image to count */
345          if (++i >= argc) { Syntax(); exit(2); }
346          ptr = argv;
347          Im_frst = strtod(argv[i], ptr) + .5;
348          if ( **ptr || (Im_frst < 1)) {
349             fprintf (stderr, "\n !!! First_image_# < 1 in -im1 !!!\n\n");
350             exit(1);
351          }
352          nopt++; nopt++;
353          continue;
354       }
355       if (strncmp(argv [i], "-ort", 4) == 0) {   /* extra orthogonalize */
356          if (++i >= argc) { Syntax(); exit(2); }
357          ort_name = argv[i];
358          if ((fp = fopen(ort_name, "r")) == 0) {
359             fprintf(stderr,"\n !!! Problem opening ort file: %s !!!\n",
360                 ort_name);
361             Syntax();
362          }
363          for(k=0; k < SEQ_SIZE; k++)                      /* Read sequence */
364             if (fscanf(fp, "%d", &ORT_ar[n_ort][k]) == EOF) break;
365          ORT_Nr[n_ort] = k;
366          if ( ORT_Nr[n_ort] == 0 ) {
367             fprintf(stderr,"\n !!! Problem reading %s file !!!\n", ort_name);
368             Syntax();
369          }
370          fclose(fp);
371          n_ort++;
372          nopt++; nopt++;
373          continue;
374       }
375       if (strncmp(argv [i], "-num", 4) == 0) {
376          if (++i >= argc) { Syntax(); exit(2); }
377          ptr = argv;
378          npoints = strtod(argv[i], ptr) + .5;
379          if ( **ptr || (npoints < 1)) {
380             fprintf (stderr, "\n !!! Too few images specified !!!\n\n");
381             exit(1); /* now symbolic for min npoints = 1 . AJ */
382          }
383          nopt++; nopt++;
384          continue;
385       }
386       if (strncmp(argv [i], "-pcnt", 5) == 0) {
387          if (++i >= argc) { Syntax(); exit(2); }
388          ptr = argv;
389          ff = strtod(argv[i], ptr);
390          if ( **ptr || (ff < .0) || (ff > 100.)) {
391             fprintf (stderr, "\n !!! %% accuracy in -pcnt out of range: %g !!!\n\n", ff);
392             exit(1);
393          }
394          pct = ff;
395          nopt++; nopt++;
396          continue;
397       }
398       if (strncmp(argv [i], "-list", 5) == 0) {
399          if (++i >= argc) { Syntax(); exit(2); }
400          ptr = argv;
401          ff = strtod(argv[i], ptr);
402          if ( **ptr || (ff < .0) ) {
403             fprintf (stderr, "\n !!! min_value in -list < 0 : %g !!!\n\n", ff);
404             exit(1);
405          }
406          noise_thr = ff;
407          nopt++; nopt++;
408          continue;
409       }
410    }
411    nopt++;
412 
413    SQ_name = argv[nopt];                   /* reference seqence file name */
414 
415    if ((fp = fopen(SQ_name, "r")) == 0) {
416       fprintf(stderr,"\n !!! Problem opening sequence file: %s !!!\n", SQ_name);
417       Syntax();
418    }
419    for(k=0; k < SEQ_SIZE; k++)                      /* Read sequence */
420       if (fscanf(fp, "%d", &SQ_arr[k]) == EOF) break;
421    SQ_Nr = k;
422    if (SQ_Nr == 0) {
423       fprintf(stderr,"\n !!! Problem reading %s file !!!\n", SQ_name);
424       Syntax();
425    }
426    fclose(fp);
427 
428    nopt++;                                   /* Files to read (minimum one) */
429 
430    if ( nopt > (argc-1) || nopt < (argc - NF_MAX) ) {  /* Nr of files check */
431       fprintf (stderr, "\n Wrong # of files. %d files entered :\n", argc-nopt);
432       for(i=nopt, j=1; i < argc; i++, j++)
433          fprintf (stderr, "  %3d -  %s\n", j, argv[i]);
434          Syntax(); exit(2);
435    }
436 
437    file_out = argv[argc-1];
438 
439    N_im = argc-nopt-1;                                        /* # of images */
440    if ( Im_frst > N_im ) {
441       fprintf (stderr, "\n !!! First_im_# %d in -im1 is bigger then number of images (%d) !!!\n\n", Im_frst, N_im);
442       Syntax(); exit(2);
443    }
444    for (i=0; i < N_im; i++) f_name[i] = argv[i+nopt];
445    for (i=0; i < Im_frst-1; i++) f_name[i] = f_name[Im_frst-1];
446 
447                /* read and check the length of the first file for validity */
448    isize = 0;
449    fprintf(stderr, "\n\n Reading file %s\n", f_name[0]);
450    if (k = read_iqm(f_name[0], &isize, tmp_ar)) {
451       fprintf (stderr, "\n Problem with file: %s\n", f_name[0]);
452       Syntax(); exit(2);
453    }
454    if ( (isize != EPS1) && (isize != EPS2) && (isize != IM_SIZE) ) {
455       fprintf (stderr, "\n\n !!! File %s has wrong format !!!\n", f_name[0]);
456       Syntax(); exit(2);
457    }
458 
459    fsize = isize;
460    if (fsize == IM_SIZE) {
461       ar_size = IM_ARR;    /* 256x256 + header image */
462       offs    = OFFSET;
463    }
464    else {
465       ar_size = fsize/2;   /* AxA and no header */
466       offs    = 0;
467    }
468 
469    ar = (short int *) malloc((unsigned) ((ar_size*N_im)*sizeof(short int)));
470 
471    for (i=0; i < ar_size; i++) ar[i] = tmp_ar[offs+i]; /* reload first image */
472 
473    for (i=1; i < N_im; i++) {                            /* Read image files */
474       fprintf(stderr, " Reading file %s\n", f_name[i]);
475       isize = 0;
476       if ( k = read_iqm(f_name[i], &isize, tmp_ar) ) {
477          fprintf (stderr, "\n Problem with file: %s\n", f_name[i]);
478          Syntax(); exit(2);
479       }
480       if ( isize != fsize) {  /* check lengthes of other files */
481          fprintf (stderr, "\n\n !!! File %s has different format !!!\n",
482                   f_name[i]);
483          Syntax(); exit(2);
484       }
485       k = i*ar_size;
486       for (j=0; j < ar_size; j++) ar[k+j] = tmp_ar[offs+j]; /* reload data */
487    }
488    if (!npoints || npoints > N_im) npoints = N_im;
489    for (i=0; i < n_ort; i++) {
490       if ( ORT_Nr[i] < N_im ) {
491          fprintf(stderr,"\n !!! Orthogonal file # %d too short !!!\n", i);
492          exit(-4);
493       }
494    }
495    if ( SQ_Nr < N_im ) {
496      fprintf(stderr, "\n\n !!! Reference file to short. Add %d lines !!!\n\n",
497               N_im - SQ_Nr);
498      exit(-1);
499    }
500 }
501 
502 /* ----------------------------------------------------------------
503    Read file subroutine fo use in C.        A.Jesmanowicz, MCW 1991
504         return error :  0 - OK,
505                         1 - opening problem,
506                         2 - file longer then array.
507         fname : file name.
508         size  : on input - max size of the arr or 0 for any length,
509                 on output- real size of the file (and arr in bytes).
510         arr   : returned file as array.
511    ---------------------------------------------------------------- */
512 /* ----------------------------- */
read_iqm(fname,size,arr)513    int  read_iqm(fname,size,arr)
514    int  *size;
515    char fname[],arr[];
516 /* ----------------------------- */
517 {
518         int     isize = *size;
519         int     fp;                             /* file descriptor  */
520         struct  stat file_stat;                 /* status structure */
521 
522         if ((fp = open(fname, O_RDONLY)) <= 0)  /* file must exist */
523            return(1);                           /* or error = 1.   */
524 
525         fstat(fp, &file_stat);                  /* get file size in bytes   */
526 
527         if(file_stat.st_size > isize && isize)  /* file can not be too long */
528            return(2);                           /* or error = 2.            */
529 
530         *size =  file_stat.st_size;             /* return file size */
531 
532         read(fp, arr, file_stat.st_size);       /* read whole file  */
533         close(fp);
534         return(0);                              /* no error : 0 */
535 }
536 
537 /* ----------------------------------------------------------------
538    Write file subroutine fo use in C.       A.Jesmanowicz, MCW 1991
539         return error :  0 - OK,
540                         1 - opening problem,
541                         2 - negative length.
542         fname : file name.
543         size  : size of the file.
544         arr   : file array.
545    ---------------------------------------------------------------- */
546 /* ----------------------------- */
write_iqm(fname,size,arr)547    int write_iqm(fname,size,arr)
548    int  *size;
549    char fname[],arr[];
550 /* ----------------------------- */
551 {
552         int     isize = *size;
553         int     fp;                             /* file descriptor  */
554 
555         if(isize < 0)                           /* size has to be real */
556            return(2);                           /* or error = 2.       */
557 
558         if ((fp = open(fname, O_WRONLY|O_CREAT|O_EXCL,0444)) <= 0)
559            return(1);                           /* file must not exist */
560                                                 /* or error = 1.       */
561 
562         write(fp, arr, isize);                  /* write whole file */
563         close(fp);
564         return(0);
565 }
566 
567 /* ------------------ */ /* Check for unpleasant existence of output file */
is_file(fname)568    int is_file(fname)
569    char  *fname;
570 /* ------------------ */
571 {
572    FILE          *fp;
573 
574    if ( (fp = fopen(fname, "r")) != NULL ) {    /* return = 1 if file exist */
575       fclose(fp);
576       return(1);
577    }
578    else
579       return(0);
580 }
581 
582 /* ------------------- */
Syntax()583    Syntax()
584 /* ------------------- */
585 {
586    fprintf (stderr, "\n\n %s makes functional image from time series of images and", ProgName);
587    fprintf (stderr, "\n reference (formated) functional-sequence file.");
588    fprintf (stderr, "\n Reference function is normalized before any correlation is done, so");
589    fprintf (stderr, "\n the results are proportional to the amplitude of functional changes.");
590    fprintf (stderr, "\n Additionally, output values are scaled to be independent of the number of");
591    fprintf (stderr, "\n used points in the reference functional-sequence file. Output data can");
592    fprintf (stderr, "\n be orthogonalized to additional external function using option -ort.");
593    fprintf (stderr, "\n Maximum number of external functios: %d", EXT_FILES);
594    fprintf (stderr, "\n Image resolusion: up to 256x256\n");
595    fprintf (stderr, "\n Usage: %s  [options] func_seq_file  file_1  [file_2 ... file_n]  out_file\n", ProgName);
596   fprintf (stderr, "\n Where options are:\n");
597   fprintf (stderr, "\n    -non             - don't make normalization (def. normalize to %d)", SCALE);
598   fprintf (stderr, "\n    -coef value      - coefficient for output data (def. = %g)", D_COEF);
599   fprintf (stderr, "\n    -im1 image_#     - first image in time course. Previous images will be ");
600   fprintf (stderr, "\n                       filled with this one for proper timing of others.");
601   fprintf (stderr, "\n    -num #_of_images - # of images in time course [2-%d].", NF_MAX);
602   fprintf (stderr, "\n    -pcnt #          - accuracy in %% of functional fit (def. = %g%%).", pct);
603   fprintf (stderr, "\n                       This value applies to the shape (not amplitude)");
604   fprintf (stderr, "\n                       and 30%% means that all data having correlation");
605   fprintf (stderr, "\n                       coefficient greater than .7 will be included.");
606   fprintf (stderr, "\n    -ort file        - additional function files to which data will be");
607   fprintf (stderr, "\n                       orthogonalized. Use one file with each option -ort .");
608   fprintf (stderr, "\n                       Maximum number of options -ort: %d .", EXT_FILES);
609   fprintf (stderr, "\n    -corr            - make image of correlation coefficients. Range -1 to 1");
610   fprintf (stderr, "\n                       is scaled to -/+ %d. The program will create second", SCALE);
611   fprintf (stderr, "\n                       output file with extention %s .", CORR);
612   fprintf (stderr, "\n    -list min_value  - make report for pixels brighter than min_value.");
613   fprintf (stderr, "\n                       Default min_value: %g", NOISE_THR);
614    fprintf (stderr, "\n\n Reference functional-sequence file can contain zero in each line for image");
615    fprintf (stderr, "\n with no action and value one for action. More complicated functions are OK.");
616    fprintf (stderr, "\n All values should be in the range -32768 to 32767. Any image can");
617    fprintf (stderr, "\n be discarded from computation by placing value 33,000 or more");
618    fprintf (stderr, "\n in equivalent line. Plot file of center pixel, made by program FD (using 'p')");
619    fprintf (stderr, "\n can be used as reference file too. AJ.");
620    fprintf (stderr, "\n\n");
621    exit(1);
622 }
623