00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061 #define PROGRAM_NAME "RSFgen"
00062 #define PROGRAM_AUTHOR "B. Douglas Ward"
00063 #define PROGRAM_INITIAL "06 July 1999"
00064 #define PROGRAM_LATEST "13 March 2003"
00065
00066
00067
00068 #include <math.h>
00069 #include <stdlib.h>
00070 #include <stdio.h>
00071
00072 #include "mrilib.h"
00073 #include "matrix.h"
00074
00075 #include "randgen.c"
00076 #include "matrix.c"
00077
00078
00079
00080
00081
00082
00083
00084
00085 int NT = 0;
00086 int nt = 0;
00087 int num_stimts = 0;
00088 int * num_reps = NULL;
00089 int * nblock = NULL;
00090 int expand = 0;
00091 long seed = 1234567;
00092 long pseed = 0;
00093 char * prefix = NULL;
00094 int one_file = 0;
00095 int one_col = 0;
00096 int markov = 0;
00097 char * tpm_file = NULL;
00098 float pzero = 0.0;
00099 int quiet = 0;
00100 char * table_file = NULL;
00101
00102
00103
00104
00105
00106
00107
00108 void RSF_error (char * message)
00109 {
00110 fprintf (stderr, "\n%s Error: %s \n", PROGRAM_NAME, message);
00111 exit(1);
00112 }
00113
00114
00115
00116
00117
00118
00119 #define MTEST(ptr) \
00120 if((ptr)==NULL) \
00121 ( RSF_error ("Cannot allocate memory") )
00122
00123
00124
00125
00126
00127
00128
00129 void identify_software ()
00130 {
00131
00132
00133 printf ("\n\n");
00134 printf ("Program: %s \n", PROGRAM_NAME);
00135 printf ("Author: %s \n", PROGRAM_AUTHOR);
00136 printf ("Initial Release: %s \n", PROGRAM_INITIAL);
00137 printf ("Latest Revision: %s \n", PROGRAM_LATEST);
00138 printf ("\n");
00139 }
00140
00141
00142
00143
00144
00145
00146
00147 void display_help_menu()
00148 {
00149 identify_software();
00150
00151 printf (
00152 "Sample program to generate random stimulus functions. \n"
00153 " \n"
00154 "Usage: \n"
00155 PROGRAM_NAME " \n"
00156 "-nt n n = length of time series \n"
00157 "-num_stimts p p = number of input stimuli (experimental conditions) \n"
00158 "[-nblock i k] k = block length for stimulus i (1<=i<=p) \n"
00159 " (default: k = 1) \n"
00160 "[-seed s] s = random number seed \n"
00161 "[-quiet] flag to suppress screen output \n"
00162 "[-one_file] place stimulus functions into a single .1D file \n"
00163 "[-one_col] write stimulus functions as a single column of decimal\n"
00164 " integers (default: multiple columns of binary nos.) \n"
00165 "[-prefix pname] pname = prefix for p output .1D stimulus functions \n"
00166 " e.g., pname1.1D, pname2.1D, ..., pnamep.1D \n"
00167 " \n"
00168 "The following Random Permutation, Markov Chain, and Input Table options\n"
00169 "are mutually exclusive. \n"
00170 " \n"
00171 "Random Permutation options: \n"
00172 "-nreps i r r = number of repetitions for stimulus i (1<=i<=p) \n"
00173 "[-pseed s] s = stim label permutation random number seed \n"
00174 " p \n"
00175 " Note: Require n >= Sum (r[i] * k[i]) \n"
00176 " i=1 \n"
00177 " \n"
00178 "Markov Chain options: \n"
00179 "-markov mfile mfile = file containing the transition prob. matrix \n"
00180 "[-pzero z] probability of a zero (i.e., null) state \n"
00181 " (default: z = 0) \n"
00182 " \n"
00183 "Input Table row permutation options: \n"
00184 "[-table dfile] dfile = filename of column or table of numbers \n"
00185 " Note: dfile may have a column selector attached \n"
00186 " Note: With this option, all other input options, \n"
00187 " except -seed and -prefix, are ignored \n"
00188 " \n"
00189 " \n"
00190 "Warning: This program will overwrite pre-existing .1D files \n"
00191 " \n"
00192 );
00193
00194 exit(0);
00195 }
00196
00197
00198
00199
00200
00201
00202
00203 void get_options
00204 (
00205 int argc,
00206 char ** argv
00207 )
00208
00209 {
00210 int nopt = 1;
00211 int ival;
00212 float fval;
00213 long lval;
00214 char message[THD_MAX_NAME];
00215 int i;
00216
00217
00218
00219 if (argc < 2 || strncmp(argv[1], "-help", 5) == 0) display_help_menu();
00220
00221
00222
00223 AFNI_logger (PROGRAM_NAME,argc,argv);
00224
00225
00226
00227 while (nopt < argc )
00228 {
00229
00230
00231 if (strncmp(argv[nopt], "-nt", 3) == 0)
00232 {
00233 nopt++;
00234 if (nopt >= argc) RSF_error ("need argument after -nt ");
00235 sscanf (argv[nopt], "%d", &ival);
00236 if (ival <= 0)
00237 RSF_error ("illegal argument after -nt ");
00238 NT = ival;
00239 nopt++;
00240 continue;
00241 }
00242
00243
00244
00245 if (strncmp(argv[nopt], "-num_stimts", 11) == 0)
00246 {
00247 nopt++;
00248 if (nopt >= argc) RSF_error ("need argument after -num_stimts ");
00249 sscanf (argv[nopt], "%d", &ival);
00250 if (ival <= 0)
00251 RSF_error ("illegal argument after -num_stimts ");
00252 num_stimts = ival;
00253
00254
00255 num_reps = (int *) malloc (sizeof(int) * num_stimts);
00256 MTEST (num_reps);
00257 for (i = 0; i < num_stimts; i++)
00258 num_reps[i] = 0;
00259
00260
00261 nblock = (int *) malloc (sizeof(int) * num_stimts);
00262 MTEST (nblock);
00263 for (i = 0; i < num_stimts; i++)
00264 nblock[i] = 1;
00265
00266 nopt++;
00267 continue;
00268 }
00269
00270
00271
00272 if (strncmp(argv[nopt], "-nreps", 6) == 0)
00273 {
00274 nopt++;
00275 if (nopt+1 >= argc) RSF_error ("need 2 arguments after -nreps ");
00276 sscanf (argv[nopt], "%d", &ival);
00277 if ((ival <= 0) || (ival > num_stimts))
00278 RSF_error ("illegal i argument for -nreps i r ");
00279 i = ival - 1;
00280 nopt++;
00281
00282 sscanf (argv[nopt], "%d", &ival);
00283 if (ival <= 0)
00284 RSF_error ("illegal r argument for -nreps i r ");
00285 num_reps[i] = ival;
00286 nopt++;
00287 continue;
00288 }
00289
00290
00291
00292 if (strncmp(argv[nopt], "-nblock", 7) == 0)
00293 {
00294 nopt++;
00295 if (nopt+1 >= argc) RSF_error ("need 2 arguments after -nblock ");
00296 sscanf (argv[nopt], "%d", &ival);
00297 if ((ival <= 0) || (ival > num_stimts))
00298 RSF_error ("illegal i argument for -nblock i k ");
00299 i = ival - 1;
00300 nopt++;
00301
00302 sscanf (argv[nopt], "%d", &ival);
00303 if (ival <= 0)
00304 RSF_error ("illegal k argument for -nblock i k ");
00305 nblock[i] = ival;
00306 if (ival > 1) expand = 1;
00307 nopt++;
00308 continue;
00309 }
00310
00311
00312
00313 if (strncmp(argv[nopt], "-seed", 5) == 0)
00314 {
00315 nopt++;
00316 if (nopt >= argc) RSF_error ("need argument after -seed ");
00317 sscanf (argv[nopt], "%ld", &lval);
00318 if (lval <= 0)
00319 RSF_error ("illegal argument after -seed ");
00320 seed = lval;
00321 nopt++;
00322 continue;
00323 }
00324
00325
00326
00327 if (strcmp(argv[nopt], "-pseed") == 0)
00328 {
00329 nopt++;
00330 if (nopt >= argc) RSF_error ("need argument after -pseed ");
00331 sscanf (argv[nopt], "%ld", &lval);
00332 if (lval <= 0)
00333 RSF_error ("illegal argument after -pseed ");
00334 pseed = lval;
00335 nopt++;
00336 continue;
00337 }
00338
00339
00340
00341 if (strcmp(argv[nopt], "-quiet") == 0)
00342 {
00343 quiet = 1;
00344 nopt++;
00345 continue;
00346 }
00347
00348
00349
00350 if (strncmp(argv[nopt], "-one_file", 9) == 0)
00351 {
00352 one_file = 1;
00353 nopt++;
00354 continue;
00355 }
00356
00357
00358
00359 if (strcmp(argv[nopt], "-one_col") == 0)
00360 {
00361 one_col = 1;
00362 nopt++;
00363 continue;
00364 }
00365
00366
00367
00368 if (strncmp(argv[nopt], "-prefix", 7) == 0)
00369 {
00370 nopt++;
00371 if (nopt >= argc) RSF_error ("need argument after -prefix ");
00372 prefix = AFMALL(char, sizeof(char) * THD_MAX_NAME);
00373 MTEST (prefix);
00374 strcpy (prefix, argv[nopt]);
00375 nopt++;
00376 continue;
00377 }
00378
00379
00380
00381 if (strcmp(argv[nopt], "-markov") == 0)
00382 {
00383 markov = 1;
00384 nopt++;
00385 if (nopt >= argc) RSF_error ("need argument after -markov ");
00386 tpm_file = AFMALL(char, sizeof(char) * THD_MAX_NAME);
00387 MTEST (tpm_file);
00388 strcpy (tpm_file, argv[nopt]);
00389 nopt++;
00390 continue;
00391 }
00392
00393
00394
00395 if (strcmp(argv[nopt], "-pzero") == 0)
00396 {
00397 nopt++;
00398 if (nopt >= argc) RSF_error ("need argument after -pzero ");
00399 sscanf (argv[nopt], "%f", &fval);
00400 if ((fval < 0.0) || (fval > 1.0))
00401 RSF_error ("Require 0.0 <= pzero <= 1.0");
00402 pzero = fval;
00403 nopt++;
00404 continue;
00405 }
00406
00407
00408
00409 if (strcmp(argv[nopt], "-table") == 0)
00410 {
00411 nopt++;
00412 if (nopt >= argc) RSF_error ("need argument after -table ");
00413 table_file = AFMALL(char, sizeof(char) * THD_MAX_NAME);
00414 MTEST (table_file);
00415 strcpy (table_file, argv[nopt]);
00416 nopt++;
00417 continue;
00418 }
00419
00420
00421
00422 sprintf(message,"Unrecognized command line option: %s\n", argv[nopt]);
00423 RSF_error (message);
00424
00425 }
00426 }
00427
00428
00429
00430
00431
00432
00433
00434 void read_table
00435 (
00436 char * table_file,
00437 MRI_IMAGE ** flim
00438 )
00439
00440 {
00441 int i;
00442 char message[THD_MAX_NAME];
00443
00444
00445 *flim = mri_read_1D(table_file);
00446 if ((*flim) == NULL)
00447 {
00448 sprintf (message, "Unable to read table file: %s", table_file);
00449 RSF_error (message);
00450 }
00451
00452
00453 NT = (*flim)->nx;
00454 num_stimts = NT;
00455 markov = 0;
00456 pseed = 0;
00457
00458
00459 num_reps = (int *) malloc (sizeof(int) * num_stimts);
00460 MTEST (num_reps);
00461 for (i = 0; i < num_stimts; i++)
00462 num_reps[i] = 1;
00463
00464
00465 nblock = (int *) malloc (sizeof(int) * num_stimts);
00466 MTEST (nblock);
00467 for (i = 0; i < num_stimts; i++)
00468 nblock[i] = 1;
00469
00470 }
00471
00472
00473
00474
00475
00476
00477
00478 void print_options ()
00479
00480 {
00481 int i;
00482
00483 identify_software();
00484
00485 if (table_file != NULL)
00486 {
00487 printf ("table file = %s \n", table_file);
00488 printf ("nt = %d \n", NT);
00489 printf ("seed = %ld \n", seed);
00490 printf ("output prefix = %s \n", prefix);
00491 }
00492 else
00493 {
00494 printf ("nt = %d \n", NT);
00495 printf ("num_stimts = %d \n", num_stimts);
00496 printf ("seed = %ld \n", seed);
00497 if (pseed) printf ("pseed = %ld \n", pseed);
00498 printf ("output prefix = %s \n", prefix);
00499 if (markov)
00500 {
00501 printf ("TPM file = %s \n", tpm_file);
00502 printf ("pzero = %f \n", pzero);
00503 for (i = 0; i < num_stimts; i++)
00504 printf ("nblock[%d] = %d \n", i+1, nblock[i]);
00505 }
00506 else
00507 for (i = 0; i < num_stimts; i++)
00508 printf ("nreps[%d] = %d nblock[%d] = %d \n",
00509 i+1, num_reps[i], i+1, nblock[i]);
00510 }
00511 }
00512
00513
00514
00515
00516
00517
00518
00519 void initialize
00520 (
00521 int argc,
00522 char ** argv,
00523 int ** darray,
00524 int ** earray,
00525 MRI_IMAGE ** flim
00526 )
00527
00528 {
00529 int i, total;
00530
00531
00532
00533 get_options (argc, argv);
00534
00535
00536
00537 if (table_file != NULL) read_table (table_file, flim);
00538
00539
00540
00541 if (! quiet) print_options ();
00542
00543
00544
00545 if (NT == 0) RSF_error ("Must specify nt");
00546 if (num_stimts == 0) RSF_error ("Must specify num_stimts");
00547 total = 0;
00548 nt = NT;
00549
00550 if (! markov)
00551 {
00552 for (i = 0; i < num_stimts; i++)
00553 {
00554 if (num_reps[i] == 0)
00555 RSF_error ("Must specify nreps > 0 for each stimulus");
00556 total += num_reps[i] * nblock[i];
00557 nt -= num_reps[i] * (nblock[i] - 1);
00558 }
00559 if (total > NT) RSF_error ("Require nt >= Sum (r[i] * k[i]) ");
00560 }
00561
00562
00563
00564 *darray = (int *) malloc (sizeof(int) * nt); MTEST (*darray);
00565 *earray = (int *) malloc (sizeof(int) * NT); MTEST (*earray);
00566
00567
00568 }
00569
00570
00571
00572
00573
00574
00575
00576 void markov_array (int * design)
00577
00578 {
00579 int it, is, id, isprev;
00580 float prob, cumprob;
00581 matrix tpm;
00582 char message[THD_MAX_NAME];
00583
00584
00585 matrix_initialize (&tpm);
00586
00587
00588
00589 matrix_file_read (tpm_file, num_stimts, num_stimts, &tpm, 1);
00590 if (tpm.elts == NULL)
00591 {
00592 sprintf (message, "Unable to read Markov chain matrix from file: %s",
00593 tpm_file);
00594 RSF_error (message);
00595 }
00596 if (!quiet) matrix_sprint ("\nTPM matrix:", tpm);
00597
00598
00599
00600 for (is = 0; is < num_stimts; is++)
00601 {
00602 cumprob = 0.0;
00603 for (it = 0; it < num_stimts; it++)
00604 cumprob += tpm.elts[is][it];
00605 if (cumprob < 0.9999)
00606 {
00607 sprintf (message, "Row %d of TPM sums to %f, which is < 1.0",
00608 is, cumprob);
00609 RSF_error (message);
00610 }
00611 if (cumprob > 1.0001)
00612 {
00613 sprintf (message, "Row %d of TPM sums to %f, which is > 1.0",
00614 is, cumprob);
00615 RSF_error (message);
00616 }
00617 }
00618
00619
00620
00621 for (it = 0; it < NT; it++)
00622 design[it] = 0;
00623
00624
00625
00626 srand48 (seed);
00627
00628
00629
00630 isprev = (int) (rand_uniform(0.0,1.0)*num_stimts);
00631 it = 0; id = 0;
00632 while (it < NT)
00633 {
00634 if ((pzero > 0.0) && (rand_uniform(0.0,1.0) < pzero))
00635 {
00636 design[id] = 0;
00637 id++; it++;
00638 }
00639 else
00640 {
00641 prob = rand_uniform(0.0,1.0);
00642 cumprob = 0.0;
00643 for (is = 0; is < num_stimts; is++)
00644 {
00645 cumprob += tpm.elts[isprev][is];
00646 if (prob <= cumprob)
00647 {
00648 design[id] = is+1;
00649 isprev = is;
00650 id++; it += nblock[is];
00651 break;
00652 }
00653 }
00654 }
00655 }
00656
00657 nt = id;
00658
00659
00660 matrix_destroy (&tpm);
00661
00662 return;
00663 }
00664
00665
00666
00667
00668
00669
00670
00671 void fill_array (int * design)
00672
00673 {
00674 int i, is, m;
00675
00676
00677 for (i = 0; i < nt; i++)
00678 design[i] = 0;
00679
00680 i = 0;
00681 for (is = 0; is < num_stimts; is++)
00682 {
00683 for (m = 0; m < num_reps[is]; m++)
00684 {
00685 design[i] = is+1;
00686 i++;
00687 }
00688 }
00689
00690
00691 return;
00692 }
00693
00694
00695
00696
00697
00698
00699
00700 void permute_array (int * design)
00701
00702 {
00703 int i, j, temp;
00704 int is, nb;
00705
00706
00707
00708 srand48 (pseed);
00709
00710
00711
00712 nb = 0;
00713 for (is = 0; is < num_stimts; is++)
00714 nb += num_reps[is];
00715
00716
00717
00718 for (i = 0; i < nb; i++)
00719 {
00720 j = rand_uniform(0.0,1.0) * nb;
00721
00722
00723 if (j < 0) j = 0;
00724 if (j > nb-1) j = nb-1;
00725
00726 temp = design[i];
00727 design[i] = design[j];
00728 design[j] = temp;
00729 }
00730
00731 return;
00732 }
00733
00734
00735
00736
00737
00738
00739
00740 void shuffle_array (int * design)
00741
00742 {
00743 int i, j, temp;
00744
00745
00746
00747 srand48 (seed);
00748
00749
00750 for (i = 0; i < nt; i++)
00751 {
00752 j = rand_uniform(0.0,1.0) * nt;
00753
00754
00755 if (j < 0) j = 0;
00756 if (j > nt-1) j = nt-1;
00757
00758 temp = design[i];
00759 design[i] = design[j];
00760 design[j] = temp;
00761 }
00762
00763 return;
00764 }
00765
00766
00767
00768
00769
00770
00771
00772 void expand_array (int * darray, int * earray)
00773
00774 {
00775 int i, j, k, m;
00776
00777 j = 0;
00778 for (i = 0; i < nt, j < NT; i++)
00779 {
00780 m = darray[i];
00781
00782 if (m == 0)
00783 {
00784 earray[j] = 0;
00785 j++;
00786 }
00787 else
00788 {
00789 for (k = 0; k < nblock[m-1]; k++)
00790 {
00791 earray[j] = m;
00792 j++;
00793 if (j >= NT) break;
00794 }
00795 }
00796 }
00797
00798 return;
00799 }
00800
00801
00802
00803
00804
00805
00806
00807 void print_array (int * array, int n)
00808
00809 {
00810 int i;
00811
00812 for (i = 0; i < n; i++)
00813 {
00814 printf (" %2d ", array[i]);
00815 if ((i+1) % 20 == 0) printf ("\n");
00816 }
00817
00818 printf ("\n");
00819
00820 return;
00821 }
00822
00823
00824
00825
00826
00827
00828
00829 void sprint_array (char * str, int * array, int n)
00830
00831 {
00832 int i;
00833
00834 if (!quiet)
00835 {
00836 printf ("%s \n", str);
00837 print_array (array, n);
00838 }
00839
00840 return;
00841 }
00842
00843
00844
00845
00846
00847
00848
00849 void write_one_ts (char * filename, int * array)
00850 {
00851 int i;
00852 FILE * outfile = NULL;
00853
00854
00855 outfile = fopen (filename, "w");
00856
00857
00858 for (i = 0; i < NT; i++)
00859 {
00860 fprintf (outfile, "%d", array[i]);
00861 fprintf (outfile, " \n");
00862 }
00863
00864
00865 fclose (outfile);
00866 }
00867
00868
00869
00870
00871
00872
00873
00874 void write_many_ts (char * filename, int * design)
00875 {
00876 int it, is;
00877 FILE * outfile = NULL;
00878
00879
00880 outfile = fopen (filename, "w");
00881
00882
00883 for (it = 0; it < NT; it++)
00884 {
00885 if (one_col)
00886 fprintf (outfile, " %d", design[it]);
00887 else
00888 for (is = 0; is < num_stimts; is++)
00889 if (design[it] == is+1)
00890 fprintf (outfile, " %d", 1);
00891 else
00892 fprintf (outfile, " %d", 0);
00893 fprintf (outfile, " \n");
00894 }
00895
00896
00897 fclose (outfile);
00898 }
00899
00900
00901
00902
00903
00904
00905
00906 void write_results (char * prefix, int * design, int NT)
00907 {
00908 char filename[THD_MAX_NAME];
00909 int * array;
00910
00911 int is, i;
00912
00913
00914 if (one_file || one_col)
00915 {
00916 sprintf (filename, "%s.1D", prefix);
00917 if (!quiet) printf ("\nWriting file: %s\n", filename);
00918 write_many_ts (filename, design);
00919 }
00920
00921 else
00922 {
00923
00924 array = (int *) malloc (sizeof(int) * NT);
00925 MTEST (array);
00926
00927 for (is = 1; is <= num_stimts; is++)
00928 {
00929 sprintf (filename, "%s%d.1D", prefix, is);
00930 if (!quiet) printf ("\nWriting file: %s\n", filename);
00931 for (i = 0; i < NT; i++)
00932 {
00933 if (design[i] == is) array[i] = 1;
00934 else array[i] = 0;
00935 }
00936 write_one_ts (filename, array);
00937 }
00938
00939
00940 free (array); array = NULL;
00941 }
00942
00943 }
00944
00945
00946
00947
00948
00949
00950
00951 void write_table
00952 (
00953 char * prefix,
00954 int * design,
00955 MRI_IMAGE * flim
00956 )
00957
00958 {
00959 FILE * outfile = NULL;
00960 char filename[THD_MAX_NAME];
00961 int nx, ny;
00962 int it, is, icol;
00963 float * far;
00964
00965
00966
00967 sprintf (filename, "%s.1D", prefix);
00968 outfile = fopen (filename, "w");
00969
00970
00971 nx = flim->nx ;
00972 ny = flim->ny ;
00973
00974
00975 far = MRI_FLOAT_PTR (flim);
00976
00977
00978 for (it = 0; it <nx; it++)
00979 {
00980
00981 is = design[it]-1;
00982
00983
00984 for (icol = 0; icol < ny; icol++)
00985 {
00986 fprintf (outfile, " %f", far[icol*nx+is]);
00987 }
00988 fprintf (outfile, " \n");
00989 }
00990
00991 fclose (outfile);
00992 }
00993
00994
00995
00996
00997 int main
00998 (
00999 int argc,
01000 char ** argv
01001 )
01002
01003 {
01004 int * darray = NULL;
01005 int * earray = NULL;
01006 MRI_IMAGE * flim = NULL;
01007
01008
01009
01010 initialize (argc, argv, &darray, &earray, &flim);
01011
01012
01013
01014 if (markov)
01015 {
01016 markov_array (darray);
01017 sprint_array ("\nMarkov chain time series: ", darray, nt);
01018 }
01019
01020
01021 else
01022 {
01023
01024 fill_array (darray);
01025 if (!quiet) sprint_array ("\nOriginal array: ", darray, nt);
01026
01027
01028 if (pseed)
01029 {
01030 permute_array (darray);
01031 if (!quiet) sprint_array ("\nPermuted array: ", darray, nt);
01032 }
01033
01034
01035 shuffle_array (darray);
01036 if (!quiet) sprint_array ("\nShuffled array: ", darray, nt);
01037
01038 }
01039
01040
01041
01042 expand_array (darray, earray);
01043 if (expand && (!quiet)) sprint_array ("\nExpanded array: ", earray, NT);
01044
01045
01046
01047 if (prefix != NULL)
01048 {
01049 if (flim == NULL)
01050 write_results (prefix, earray, NT);
01051 else
01052 write_table (prefix, earray, flim);
01053 }
01054
01055
01056
01057 if (darray != NULL) { free (darray); darray = NULL; }
01058 if (earray != NULL) { free (earray); earray = NULL; }
01059 if (flim != NULL) { mri_free(flim); flim = NULL; }
01060
01061 exit(0);
01062 }
01063
01064
01065
01066
01067
01068