Doxygen Source Code Documentation
3dANOVA3.c File Reference
#include "3dANOVA.h"#include "3dANOVA.lib"Go to the source code of this file.
Define Documentation
|
|
Definition at line 156 of file 3dANOVA3.c. Referenced by get_options(). |
|
|
Definition at line 51 of file 3dANOVA3.c. Referenced by main(). |
|
|
Definition at line 52 of file 3dANOVA3.c. Referenced by main(). |
|
|
Definition at line 53 of file 3dANOVA3.c. Referenced by main(). |
|
|
Definition at line 50 of file 3dANOVA3.c. Referenced by get_options(), initialize(), and main(). |
|
|
Definition at line 57 of file 3dANOVA3.c. |
Function Documentation
|
|
Definition at line 4438 of file 3dANOVA3.c. References calculate_acontrasts(), calculate_adifferences(), calculate_ameans(), calculate_bcontrasts(), calculate_bdifferences(), calculate_bmeans(), calculate_ccontrasts(), calculate_cdifferences(), calculate_cmeans(), calculate_fa(), calculate_fab(), calculate_fabc(), calculate_fac(), calculate_fb(), calculate_fbc(), calculate_fc(), calculate_xdifferences(), calculate_xmeans(), anova_options::nfa, anova_options::nfab, anova_options::nfabc, anova_options::nfac, anova_options::nfb, anova_options::nfbc, anova_options::nfc, anova_options::num_acontr, anova_options::num_adiffs, anova_options::num_ameans, anova_options::num_bcontr, anova_options::num_bdiffs, anova_options::num_bmeans, anova_options::num_ccontr, anova_options::num_cdiffs, anova_options::num_cmeans, anova_options::num_xdiffs, and anova_options::num_xmeans.
04439 {
04440
04441 /*----- calculate F-statistic for factor A effect -----*/
04442 if (option_data->nfa) calculate_fa (option_data);
04443
04444 /*----- calculate F-statistic for factor B effect -----*/
04445 if (option_data->nfb) calculate_fb (option_data);
04446
04447 /*----- calculate F-statistic for factor C effect -----*/
04448 if (option_data->nfc) calculate_fc (option_data);
04449
04450 /*----- calculate F-statistic for A*B interaction effect -----*/
04451 if (option_data->nfab) calculate_fab (option_data);
04452
04453 /*----- calculate F-statistic for A*C interaction effect -----*/
04454 if (option_data->nfac) calculate_fac (option_data);
04455
04456 /*----- calculate F-statistic for B*C interaction effect -----*/
04457 if (option_data->nfbc) calculate_fbc (option_data);
04458
04459 /*----- calculate F-statistic for A*B*C interaction effect -----*/
04460 if (option_data->nfabc) calculate_fabc (option_data);
04461
04462 /*----- estimate level means for factor A -----*/
04463 if (option_data->num_ameans) calculate_ameans (option_data);
04464
04465 /*----- estimate level means for factor B -----*/
04466 if (option_data->num_bmeans) calculate_bmeans (option_data);
04467
04468 /*----- estimate level means for factor C -----*/
04469 if (option_data->num_cmeans) calculate_cmeans (option_data);
04470
04471 /*----- estimate cell means -----*/
04472 if (option_data->num_xmeans) calculate_xmeans (option_data);
04473
04474 /*----- estimate level differences for factor A -----*/
04475 if (option_data->num_adiffs) calculate_adifferences (option_data);
04476
04477 /*----- estimate level differences for factor B -----*/
04478 if (option_data->num_bdiffs) calculate_bdifferences (option_data);
04479
04480 /*----- estimate level differences for factor C -----*/
04481 if (option_data->num_cdiffs) calculate_cdifferences (option_data);
04482
04483 /*----- estimate differences in cell means -----*/
04484 if (option_data->num_xdiffs) calculate_xdifferences (option_data);
04485
04486 /*----- estimate level contrasts for factor A -----*/
04487 if (option_data->num_acontr) calculate_acontrasts (option_data);
04488
04489 /*----- estimate level contrasts for factor B -----*/
04490 if (option_data->num_bcontr) calculate_bcontrasts (option_data);
04491
04492 /*----- estimate level contrasts for factor C -----*/
04493 if (option_data->num_ccontr) calculate_ccontrasts (option_data);
04494
04495 }
|
|
|
Definition at line 4050 of file 3dANOVA3.c. References anova_options::a, a, anova_options::acname, anova_options::acontr, ANOVA_error(), anova_options::b, anova_options::c, c, calculate_sum(), free, malloc, anova_options::model, anova_options::n, anova_options::num_acontr, anova_options::nvoxel, anova_options::nxyz, volume_read(), volume_zero(), and write_afni_data(). Referenced by analyze_results().
04051 {
04052 const float EPSILON = 1.0e-10; /* protect against divide by zero */
04053 float * contr = NULL; /* pointer to contrast estimate */
04054 float * tcontr = NULL; /* pointer to t-statistic data */
04055 int a; /* number of levels for factor A */
04056 int b; /* number of levels for factor B */
04057 int c; /* number of levels for factor C */
04058 int n; /* number of observations per cell */
04059 int ixyz, nxyz; /* voxel counters */
04060 int nvoxel; /* output voxel # */
04061 int num_contr; /* number of user requested contrasts */
04062 int icontr; /* index of user requested contrast */
04063 int level; /* factor level index */
04064 int df; /* degrees of freedom for t-test */
04065 float fval; /* for calculating std. dev. */
04066 float coef; /* contrast coefficient */
04067 float stddev; /* est. std. dev. of contrast */
04068 char filename[MAX_NAME_LENGTH]; /* input data file name */
04069
04070
04071 /*----- initialize local variables -----*/
04072 a = option_data->a;
04073 b = option_data->b;
04074 c = option_data->c;
04075 n = option_data->n;
04076 num_contr = option_data->num_acontr;
04077 nxyz = option_data->nxyz;
04078 nvoxel = option_data->nvoxel;
04079
04080 /*----- allocate memory space for calculations -----*/
04081 contr = (float *) malloc(sizeof(float)*nxyz);
04082 tcontr = (float *) malloc(sizeof(float)*nxyz);
04083 if ((contr == NULL) || (tcontr == NULL))
04084 ANOVA_error ("unable to allocate sufficient memory");
04085
04086
04087 /*----- loop over user specified constrasts -----*/
04088 for (icontr = 0; icontr < num_contr; icontr++)
04089 {
04090 volume_zero (contr, nxyz);
04091 fval = 0.0;
04092
04093 for (level = 0; level < a; level++)
04094 {
04095 coef = option_data->acontr[icontr][level];
04096 if (coef == 0.0) continue;
04097
04098 /*----- add coef * treatment level mean to contrast -----*/
04099 calculate_sum (option_data, level, -1, -1, tcontr);
04100 fval += coef * coef / (b*c*n);
04101 for (ixyz = 0; ixyz < nxyz; ixyz++)
04102 contr[ixyz] += coef * tcontr[ixyz] / (b*c*n);
04103 }
04104
04105 if (nvoxel > 0)
04106 printf ("No.%d contrast for factor A = %f \n",
04107 icontr+1, contr[nvoxel-1]);
04108
04109 /*----- standard deviation depends on model type -----*/
04110 switch (option_data->model)
04111 {
04112 case 1:
04113 volume_read ("sse", tcontr, nxyz);
04114 df = a * b * c * (n-1);
04115 break;
04116 case 4:
04117 volume_read ("ssac", tcontr, nxyz);
04118 df = (a-1) * (c-1);
04119 break;
04120 case 5:
04121 volume_read ("ssca", tcontr, nxyz);
04122 df = a * (c-1);
04123 break;
04124 }
04125
04126 /*----- divide by estimated standard deviation of the contrast -----*/
04127 for (ixyz = 0; ixyz < nxyz; ixyz++)
04128 {
04129 stddev = sqrt ((tcontr[ixyz] / df) * fval);
04130 if (stddev < EPSILON)
04131 tcontr[ixyz] = 0.0;
04132 else
04133 tcontr[ixyz] = contr[ixyz] / stddev;
04134 }
04135
04136 if (nvoxel > 0)
04137 printf ("t of No.%d contrast for factor A = %f \n",
04138 icontr+1, tcontr[nvoxel-1]);
04139
04140 /*----- write out afni data file -----*/
04141 write_afni_data (option_data, option_data->acname[icontr],
04142 contr, tcontr, df, 0);
04143
04144 }
04145
04146 /*----- release memory -----*/
04147 free (tcontr); tcontr = NULL;
04148 free (contr); contr = NULL;
04149
04150 }
|
|
|
Definition at line 3646 of file 3dANOVA3.c. References anova_options::a, a, anova_options::adiffs, anova_options::adname, ANOVA_error(), anova_options::b, anova_options::c, c, calculate_sum(), free, i, malloc, anova_options::model, anova_options::n, anova_options::num_adiffs, anova_options::nvoxel, anova_options::nxyz, volume_read(), and write_afni_data(). Referenced by analyze_results().
03647 {
03648 const float EPSILON = 1.0e-10; /* protect against divide by zero */
03649 float * diff = NULL; /* pointer to est. diff. in means */
03650 float * tdiff = NULL; /* pointer to t-statistic data */
03651 int a; /* number of levels for factor A */
03652 int b; /* number of levels for factor B */
03653 int c; /* number of levels for factor C */
03654 int n; /* number of observations per cell */
03655 int ixyz, nxyz; /* voxel counters */
03656 int nvoxel; /* output voxel # */
03657 int num_diffs; /* number of user requested diffs. */
03658 int idiff; /* index for requested differences */
03659 int i, j; /* factor level indices */
03660 int df; /* degrees of freedom for t-test */
03661 float fval; /* for calculating std. dev. */
03662 float stddev; /* est. std. dev. of difference */
03663 char filename[MAX_NAME_LENGTH]; /* input file name */
03664
03665
03666 /*----- initialize local variables -----*/
03667 a = option_data->a;
03668 b = option_data->b;
03669 c = option_data->c;
03670 n = option_data->n;
03671 num_diffs = option_data->num_adiffs;
03672 nxyz = option_data->nxyz;
03673 nvoxel = option_data->nvoxel;
03674
03675 /*----- allocate memory space for calculations -----*/
03676 diff = (float *) malloc(sizeof(float)*nxyz);
03677 tdiff = (float *) malloc(sizeof(float)*nxyz);
03678 if ((diff == NULL) || (tdiff == NULL))
03679 ANOVA_error ("unable to allocate sufficient memory");
03680
03681 /*----- loop over user specified treatment differences -----*/
03682 for (idiff = 0; idiff < num_diffs; idiff++)
03683 {
03684
03685 /*----- read first treatment level mean -----*/
03686 i = option_data->adiffs[idiff][0];
03687 calculate_sum (option_data, i, -1, -1, diff);
03688 for (ixyz = 0; ixyz < nxyz; ixyz++)
03689 diff[ixyz] = diff[ixyz] / (b*c*n);
03690
03691 /*----- subtract second treatment level mean -----*/
03692 j = option_data->adiffs[idiff][1];
03693 calculate_sum (option_data, j, -1, -1, tdiff);
03694 for (ixyz = 0; ixyz < nxyz; ixyz++)
03695 diff[ixyz] -= tdiff[ixyz] / (b*c*n);
03696 if (nvoxel > 0)
03697 printf ("Difference of factor A level %d - level %d = %f \n",
03698 i+1, j+1, diff[nvoxel-1]);
03699
03700 /*----- standard deviation depends on model type -----*/
03701 switch (option_data->model)
03702 {
03703 case 1:
03704 volume_read ("sse", tdiff, nxyz);
03705 df = a * b * c * (n-1);
03706 break;
03707 case 4:
03708 volume_read ("ssac", tdiff, nxyz);
03709 df = (a-1) * (c-1);
03710 break;
03711 case 5:
03712 volume_read ("ssca", tdiff, nxyz);
03713 df = a * (c-1);
03714 break;
03715 }
03716
03717 /*----- divide by estimated standard deviation of difference -----*/
03718 fval = (1.0 / df) * (2.0 / (b*c*n));
03719 for (ixyz = 0; ixyz < nxyz; ixyz++)
03720 {
03721 stddev = sqrt (tdiff[ixyz] * fval);
03722 if (stddev < EPSILON)
03723 tdiff[ixyz] = 0.0;
03724 else
03725 tdiff[ixyz] = diff[ixyz] / stddev;
03726 }
03727
03728 if (nvoxel > 0)
03729 printf ("t for difference of factor A level %d - level %d = %f \n",
03730 i+1, j+1, tdiff[nvoxel-1]);
03731
03732 /*----- write out afni data file -----*/
03733 write_afni_data (option_data, option_data->adname[idiff],
03734 diff, tdiff, df, 0);
03735
03736 }
03737
03738 /*----- release memory -----*/
03739 free (tdiff); tdiff = NULL;
03740 free (diff); diff = NULL;
03741
03742 }
|
|
|
Definition at line 3275 of file 3dANOVA3.c. References anova_options::a, a, anova_options::ameans, anova_options::amname, ANOVA_error(), anova_options::b, anova_options::c, c, calculate_sum(), free, malloc, anova_options::model, anova_options::n, anova_options::num_ameans, anova_options::nvoxel, anova_options::nxyz, volume_read(), and write_afni_data(). Referenced by analyze_results().
03276 {
03277 const float EPSILON = 1.0e-10; /* protect against divide by zero */
03278 float * mean = NULL; /* pointer to treatment mean data */
03279 float * tmean = NULL; /* pointer to t-statistic data */
03280 int a; /* number of levels for factor A */
03281 int b; /* number of levels for factor B */
03282 int c; /* number of levels for factor C */
03283 int n; /* number of observations per cell */
03284 int ixyz, nxyz; /* voxel counters */
03285 int nvoxel; /* output voxel # */
03286 int num_means; /* number of user requested means */
03287 int imean; /* output mean option index */
03288 int level; /* factor A level index */
03289 int df; /* degrees of freedom for t-test */
03290 float fval; /* for calculating std. dev. */
03291 float stddev; /* est. std. dev. of factor mean */
03292 char filename[MAX_NAME_LENGTH]; /* input data file name */
03293
03294
03295 /*----- initialize local variables -----*/
03296 a = option_data->a;
03297 b = option_data->b;
03298 c = option_data->c;
03299 n = option_data->n;
03300 num_means = option_data->num_ameans;
03301 nxyz = option_data->nxyz;
03302 nvoxel = option_data->nvoxel;
03303
03304 /*----- allocate memory space for calculations -----*/
03305 mean = (float *) malloc(sizeof(float)*nxyz);
03306 tmean = (float *) malloc(sizeof(float)*nxyz);
03307 if ((mean == NULL) || (tmean == NULL))
03308 ANOVA_error ("unable to allocate sufficient memory");
03309
03310 /*----- loop over user specified treatment means -----*/
03311 for (imean = 0; imean < num_means; imean++)
03312 {
03313 level = option_data->ameans[imean];
03314
03315 /*----- estimate factor mean for this treatment level -----*/
03316 calculate_sum (option_data, level, -1, -1, mean);
03317 for (ixyz = 0; ixyz < nxyz; ixyz++)
03318 mean[ixyz] = mean[ixyz] / (b*c*n);
03319 if (nvoxel > 0)
03320 printf ("Mean of factor A level %d = %f \n", level+1, mean[nvoxel-1]);
03321
03322 /*----- standard deviation depends on model type -----*/
03323 switch (option_data->model)
03324 {
03325 case 1:
03326 volume_read ("sse", tmean, nxyz);
03327 df = a * b * c * (n-1);
03328 break;
03329 case 4:
03330 volume_read ("ssac", tmean, nxyz);
03331 df = (a-1) * (c-1);
03332 break;
03333 case 5:
03334 volume_read ("ssca", tmean, nxyz);
03335 df = a * (c-1);
03336 break;
03337 }
03338
03339 /*----- divide by estimated standard deviation of factor mean -----*/
03340 fval = (1.0 / df) * (1.0 / (b*c*n));
03341 for (ixyz = 0; ixyz < nxyz; ixyz++)
03342 {
03343 stddev = sqrt(tmean[ixyz] * fval);
03344 if (stddev < EPSILON)
03345 tmean[ixyz] = 0.0;
03346 else
03347 tmean[ixyz] = mean[ixyz] / stddev;
03348 }
03349
03350 if (nvoxel > 0)
03351 printf ("t for mean of factor A level %d = %f \n",
03352 level+1, tmean[nvoxel-1]);
03353
03354 /*----- write out afni data file -----*/
03355 write_afni_data (option_data, option_data->amname[imean],
03356 mean, tmean, df, 0);
03357
03358 }
03359
03360 /*----- release memory -----*/
03361 free (tmean); tmean = NULL;
03362 free (mean); mean = NULL;
03363 }
|
|
|
Definition at line 4364 of file 3dANOVA3.c. References calculate_ss0(), calculate_ssa(), calculate_ssab(), calculate_ssabc(), calculate_ssac(), calculate_ssb(), calculate_ssbc(), calculate_ssbca(), calculate_ssc(), calculate_ssca(), calculate_sse(), calculate_ssi(), calculate_ssij(), calculate_ssijk(), calculate_ssijkm(), calculate_ssik(), calculate_ssj(), calculate_ssjk(), calculate_ssk(), calculate_ssto(), anova_options::model, anova_options::n, and volume_delete(). Referenced by main().
04365 {
04366
04367 /*----- calculate various sum and sums of squares -----*/
04368 calculate_ss0 (option_data);
04369 calculate_ssi (option_data);
04370 calculate_ssj (option_data);
04371 if (option_data->model != 5) calculate_ssk (option_data);
04372 calculate_ssij (option_data);
04373 calculate_ssik (option_data);
04374 if (option_data->model != 5) calculate_ssjk (option_data);
04375 calculate_ssijk (option_data);
04376 if (option_data->n != 1) calculate_ssijkm (option_data);
04377
04378
04379 /*----- calculate total (corrected for the mean) sum of squares -----*/
04380 calculate_ssto (option_data);
04381 if (option_data->n != 1) volume_delete ("ssijkm");
04382
04383 /*----- calculate error sum of squares -----*/
04384 if (option_data->n != 1) calculate_sse (option_data);
04385 volume_delete ("ssijk");
04386
04387 /*----- calculate sum of squares due to A effect -----*/
04388 calculate_ssa (option_data);
04389 volume_delete ("ssi");
04390
04391 /*----- calculate sum of squares due to B effect -----*/
04392 calculate_ssb (option_data);
04393 volume_delete ("ssj");
04394
04395 if (option_data->model != 5)
04396 {
04397 /*----- calculate sum of squares due to C effect -----*/
04398 calculate_ssc (option_data);
04399 volume_delete ("ssk");
04400 }
04401
04402 /*----- calculate sum of squares due to A*B interaction -----*/
04403 calculate_ssab (option_data);
04404 volume_delete ("ssij");
04405
04406 if (option_data->model != 5)
04407 /*----- calculate sum of squares due to A*C interaction -----*/
04408 calculate_ssac (option_data);
04409 else
04410 /*----- calculate sum of squares due to C(A) effect -----*/
04411 calculate_ssca (option_data);
04412 volume_delete ("ssik");
04413
04414 if (option_data->model != 5)
04415 {
04416 /*----- calculate sum of squares due to B*C interaction -----*/
04417 calculate_ssbc (option_data);
04418 volume_delete ("ssjk");
04419 }
04420
04421 volume_delete ("ss0");
04422
04423 if (option_data->model != 5)
04424 /*----- calculate sum of squares due to A*B*C interaction -----*/
04425 calculate_ssabc (option_data);
04426 else
04427 /*----- calculate sum of squares due to B*C(A) interaction -----*/
04428 calculate_ssbca (option_data);
04429 volume_delete ("ssto");
04430 }
|
|
|
Definition at line 4160 of file 3dANOVA3.c. References anova_options::a, a, ANOVA_error(), anova_options::b, anova_options::bcname, anova_options::bcontr, anova_options::c, c, calculate_sum(), free, malloc, anova_options::model, anova_options::n, anova_options::num_bcontr, anova_options::nvoxel, anova_options::nxyz, volume_read(), volume_zero(), and write_afni_data(). Referenced by analyze_results().
04161 {
04162 const float EPSILON = 1.0e-10; /* protect against divide by zero */
04163 float * contr = NULL; /* pointer to contrast estimate */
04164 float * tcontr = NULL; /* pointer to t-statistic data */
04165 int a; /* number of levels for factor A */
04166 int b; /* number of levels for factor B */
04167 int c; /* number of levels for factor C */
04168 int n; /* number of observations per cell */
04169 int ixyz, nxyz; /* voxel counters */
04170 int nvoxel; /* output voxel # */
04171 int num_contr; /* number of user requested contrasts */
04172 int icontr; /* index of user requested contrast */
04173 int level; /* factor level index */
04174 int df; /* degrees of freedom for t-test */
04175 float fval; /* for calculating std. dev. */
04176 float coef; /* contrast coefficient */
04177 float stddev; /* est. std. dev. of contrast */
04178 char filename[MAX_NAME_LENGTH]; /* input data file name */
04179
04180
04181 /*----- initialize local variables -----*/
04182 a = option_data->a;
04183 b = option_data->b;
04184 c = option_data->c;
04185 n = option_data->n;
04186 num_contr = option_data->num_bcontr;
04187 nxyz = option_data->nxyz;
04188 nvoxel = option_data->nvoxel;
04189
04190 /*----- allocate memory space for calculations -----*/
04191 contr = (float *) malloc(sizeof(float)*nxyz);
04192 tcontr = (float *) malloc(sizeof(float)*nxyz);
04193 if ((contr == NULL) || (tcontr == NULL))
04194 ANOVA_error ("unable to allocate sufficient memory");
04195
04196
04197 /*----- loop over user specified constrasts -----*/
04198 for (icontr = 0; icontr < num_contr; icontr++)
04199 {
04200 volume_zero (contr, nxyz);
04201 fval = 0.0;
04202
04203 for (level = 0; level < b; level++)
04204 {
04205 coef = option_data->bcontr[icontr][level];
04206 if (coef == 0.0) continue;
04207
04208 /*----- add coef * treatment level mean to contrast -----*/
04209 calculate_sum (option_data, -1, level, -1, tcontr);
04210 fval += coef * coef / (a*c*n);
04211 for (ixyz = 0; ixyz < nxyz; ixyz++)
04212 contr[ixyz] += coef * tcontr[ixyz] / (a*c*n);
04213 }
04214
04215 if (nvoxel > 0)
04216 printf ("No.%d contrast for factor B = %f \n",
04217 icontr+1, contr[nvoxel-1]);
04218
04219 /*----- standard deviation depends on model type -----*/
04220 switch (option_data->model)
04221 {
04222 case 1:
04223 volume_read ("sse", tcontr, nxyz);
04224 df = a * b * c * (n-1);
04225 break;
04226 case 4:
04227 volume_read ("ssbc", tcontr, nxyz);
04228 df = (b-1) * (c-1);
04229 break;
04230 case 5:
04231 volume_read ("ssbca", tcontr, nxyz);
04232 df = a * (b-1) * (c-1);
04233 break;
04234 }
04235
04236 /*----- divide by estimated standard deviation of the contrast -----*/
04237 for (ixyz = 0; ixyz < nxyz; ixyz++)
04238 {
04239 stddev = sqrt ((tcontr[ixyz] / df) * fval);
04240 if (stddev < EPSILON)
04241 tcontr[ixyz] = 0.0;
04242 else
04243 tcontr[ixyz] = contr[ixyz] / stddev;
04244 }
04245
04246 if (nvoxel > 0)
04247 printf ("t of No.%d contrast for factor B = %f \n",
04248 icontr+1, tcontr[nvoxel-1]);
04249
04250 /*----- write out afni data file -----*/
04251 write_afni_data (option_data, option_data->bcname[icontr],
04252 contr, tcontr, df, 0);
04253
04254 }
04255
04256 /*----- release memory -----*/
04257 free (tcontr); tcontr = NULL;
04258 free (contr); contr = NULL;
04259
04260 }
|
|
|
Definition at line 3753 of file 3dANOVA3.c. References anova_options::a, a, ANOVA_error(), anova_options::b, anova_options::bdiffs, anova_options::bdname, anova_options::c, c, calculate_sum(), free, i, malloc, anova_options::model, anova_options::n, anova_options::num_bdiffs, anova_options::nvoxel, anova_options::nxyz, volume_read(), and write_afni_data(). Referenced by analyze_results().
03754 {
03755 const float EPSILON = 1.0e-10; /* protect against divide by zero */
03756 float * diff = NULL; /* pointer to est. diff. in means */
03757 float * tdiff = NULL; /* pointer to t-statistic data */
03758 int a; /* number of levels for factor A */
03759 int b; /* number of levels for factor B */
03760 int c; /* number of levels for factor C */
03761 int n; /* number of observations per cell */
03762 int ixyz, nxyz; /* voxel counters */
03763 int nvoxel; /* output voxel # */
03764 int num_diffs; /* number of user requested diffs. */
03765 int idiff; /* index for requested differences */
03766 int i, j; /* factor level indices */
03767 int df; /* degrees of freedom for t-test */
03768 float fval; /* for calculating std. dev. */
03769 float stddev; /* est. std. dev. of difference */
03770 char filename[MAX_NAME_LENGTH]; /* input file name */
03771
03772
03773 /*----- initialize local variables -----*/
03774 a = option_data->a;
03775 b = option_data->b;
03776 c = option_data->c;
03777 n = option_data->n;
03778 num_diffs = option_data->num_bdiffs;
03779 nxyz = option_data->nxyz;
03780 nvoxel = option_data->nvoxel;
03781
03782 /*----- allocate memory space for calculations -----*/
03783 diff = (float *) malloc(sizeof(float)*nxyz);
03784 tdiff = (float *) malloc(sizeof(float)*nxyz);
03785 if ((diff == NULL) || (tdiff == NULL))
03786 ANOVA_error ("unable to allocate sufficient memory");
03787
03788 /*----- loop over user specified treatment differences -----*/
03789 for (idiff = 0; idiff < num_diffs; idiff++)
03790 {
03791
03792 /*----- read first treatment level mean -----*/
03793 i = option_data->bdiffs[idiff][0];
03794 calculate_sum (option_data, -1, i, -1, diff);
03795 for (ixyz = 0; ixyz < nxyz; ixyz++)
03796 diff[ixyz] = diff[ixyz] / (a*c*n);
03797
03798 /*----- subtract second treatment level mean -----*/
03799 j = option_data->bdiffs[idiff][1];
03800 calculate_sum (option_data, -1, j, -1, tdiff);
03801 for (ixyz = 0; ixyz < nxyz; ixyz++)
03802 diff[ixyz] -= tdiff[ixyz] / (a*c*n);
03803 if (nvoxel > 0)
03804 printf ("Difference of factor B level %d - level %d = %f \n",
03805 i+1, j+1, diff[nvoxel-1]);
03806
03807 /*----- standard deviation depends on model type -----*/
03808 switch (option_data->model)
03809 {
03810 case 1:
03811 volume_read ("sse", tdiff, nxyz);
03812 df = a * b * c * (n-1);
03813 break;
03814 case 4:
03815 volume_read ("ssbc", tdiff, nxyz);
03816 df = (b-1) * (c-1);
03817 break;
03818 case 5:
03819 volume_read ("ssbca", tdiff, nxyz);
03820 df = a * (b-1) * (c-1);
03821 break;
03822 }
03823
03824 /*----- divide by estimated standard deviation of difference -----*/
03825 fval = (1.0 / df) * (2.0 / (a*c*n));
03826 for (ixyz = 0; ixyz < nxyz; ixyz++)
03827 {
03828 stddev = sqrt (tdiff[ixyz] * fval);
03829 if (stddev < EPSILON)
03830 tdiff[ixyz] = 0.0;
03831 else
03832 tdiff[ixyz] = diff[ixyz] / stddev;
03833 }
03834
03835 if (nvoxel > 0)
03836 printf ("t for difference of factor B level %d - level %d = %f \n",
03837 i+1, j+1, tdiff[nvoxel-1]);
03838
03839 /*----- write out afni data file -----*/
03840 write_afni_data (option_data, option_data->bdname[idiff],
03841 diff, tdiff, df, 0);
03842
03843 }
03844
03845 /*----- release memory -----*/
03846 free (tdiff); tdiff = NULL;
03847 free (diff); diff = NULL;
03848
03849 }
|
|
|
Definition at line 3373 of file 3dANOVA3.c. References anova_options::a, a, ANOVA_error(), anova_options::b, anova_options::bmeans, anova_options::bmname, anova_options::c, c, calculate_sum(), free, malloc, anova_options::model, anova_options::n, anova_options::nt, anova_options::num_bmeans, anova_options::nvoxel, anova_options::nxyz, volume_read(), and write_afni_data(). Referenced by analyze_results().
03374 {
03375 const float EPSILON = 1.0e-10; /* protect against divide by zero */
03376 float * mean = NULL; /* pointer to treatment mean data */
03377 float * tmean = NULL; /* pointer to t-statistic data */
03378 int a; /* number of levels for factor A */
03379 int b; /* number of levels for factor B */
03380 int c; /* number of levels for factor C */
03381 int n; /* number of observations per cell */
03382 int ixyz, nxyz; /* voxel counters */
03383 int nvoxel; /* output voxel # */
03384 int nt; /* total number of observations */
03385 int num_means; /* number of user requested means */
03386 int imean; /* output mean option index */
03387 int level; /* factor B level index */
03388 int df; /* degrees of freedom for t-test */
03389 float fval; /* for calculating std. dev. */
03390 float stddev; /* est. std. dev. of factor mean */
03391 char filename[MAX_NAME_LENGTH]; /* input data file name */
03392
03393
03394 /*----- initialize local variables -----*/
03395 a = option_data->a;
03396 b = option_data->b;
03397 c = option_data->c;
03398 n = option_data->n;
03399 nt = option_data->nt;
03400 num_means = option_data->num_bmeans;
03401 nxyz = option_data->nxyz;
03402 nvoxel = option_data->nvoxel;
03403
03404 /*----- allocate memory space for calculations -----*/
03405 mean = (float *) malloc(sizeof(float)*nxyz);
03406 tmean = (float *) malloc(sizeof(float)*nxyz);
03407 if ((mean == NULL) || (tmean == NULL))
03408 ANOVA_error ("unable to allocate sufficient memory");
03409
03410 /*----- loop over user specified treatment means -----*/
03411 for (imean = 0; imean < num_means; imean++)
03412 {
03413 level = option_data->bmeans[imean];
03414
03415 /*----- estimate factor mean for this treatment level -----*/
03416 calculate_sum (option_data, -1, level, -1, mean);
03417 for (ixyz = 0; ixyz < nxyz; ixyz++)
03418 mean[ixyz] = mean[ixyz] / (a*c*n);
03419 if (nvoxel > 0)
03420 printf ("Mean of factor B level %d = %f \n", level+1, mean[nvoxel-1]);
03421
03422 /*----- standard deviation depends on model type -----*/
03423 switch (option_data->model)
03424 {
03425 case 1:
03426 volume_read ("sse", tmean, nxyz);
03427 df = a * b * c * (n-1);
03428 break;
03429 case 4:
03430 volume_read ("ssbc", tmean, nxyz);
03431 df = (b-1) * (c-1);
03432 break;
03433 case 5:
03434 volume_read ("ssbca", tmean, nxyz);
03435 df = a * (b-1) * (c-1);
03436 break;
03437 }
03438
03439 /*----- divide by estimated standard deviation of factor mean -----*/
03440 fval = (1.0 / df) * (1.0 / (a*c*n));
03441 for (ixyz = 0; ixyz < nxyz; ixyz++)
03442 {
03443 stddev = sqrt(tmean[ixyz] * fval);
03444 if (stddev < EPSILON)
03445 tmean[ixyz] = 0.0;
03446 else
03447 tmean[ixyz] = mean[ixyz] / stddev;
03448 }
03449 if (nvoxel > 0)
03450 printf ("t for mean of factor B level %d = %f \n",
03451 level+1, tmean[nvoxel-1]);
03452
03453 /*----- write out afni data file -----*/
03454 write_afni_data (option_data, option_data->bmname[imean],
03455 mean, tmean, df, 0);
03456
03457 }
03458
03459 /*----- release memory -----*/
03460 free (tmean); tmean = NULL;
03461 free (mean); mean = NULL;
03462 }
|
|
|
Definition at line 4270 of file 3dANOVA3.c. References anova_options::a, a, ANOVA_error(), anova_options::b, anova_options::c, c, calculate_sum(), anova_options::ccname, anova_options::ccontr, free, malloc, anova_options::n, anova_options::num_ccontr, anova_options::nvoxel, anova_options::nxyz, volume_read(), volume_zero(), and write_afni_data(). Referenced by analyze_results().
04271 {
04272 const float EPSILON = 1.0e-10; /* protect against divide by zero */
04273 float * contr = NULL; /* pointer to contrast estimate */
04274 float * tcontr = NULL; /* pointer to t-statistic data */
04275 int a; /* number of levels for factor A */
04276 int b; /* number of levels for factor B */
04277 int c; /* number of levels for factor C */
04278 int n; /* number of observations per cell */
04279 int ixyz, nxyz; /* voxel counters */
04280 int nvoxel; /* output voxel # */
04281 int num_contr; /* number of user requested contrasts */
04282 int icontr; /* index of user requested contrast */
04283 int level; /* factor level index */
04284 int df; /* degrees of freedom for t-test */
04285 float fval; /* for calculating std. dev. */
04286 float coef; /* contrast coefficient */
04287 float stddev; /* est. std. dev. of contrast */
04288 char filename[MAX_NAME_LENGTH]; /* input data file name */
04289
04290
04291 /*----- initialize local variables -----*/
04292 a = option_data->a;
04293 b = option_data->b;
04294 c = option_data->c;
04295 n = option_data->n;
04296 num_contr = option_data->num_ccontr;
04297 nxyz = option_data->nxyz;
04298 nvoxel = option_data->nvoxel;
04299
04300 /*----- allocate memory space for calculations -----*/
04301 contr = (float *) malloc(sizeof(float)*nxyz);
04302 tcontr = (float *) malloc(sizeof(float)*nxyz);
04303 if ((contr == NULL) || (tcontr == NULL))
04304 ANOVA_error ("unable to allocate sufficient memory");
04305
04306
04307 /*----- loop over user specified constrasts -----*/
04308 for (icontr = 0; icontr < num_contr; icontr++)
04309 {
04310 volume_zero (contr, nxyz);
04311 fval = 0.0;
04312
04313 for (level = 0; level < c; level++)
04314 {
04315 coef = option_data->ccontr[icontr][level];
04316 if (coef == 0.0) continue;
04317
04318 /*----- add coef * treatment level mean to contrast -----*/
04319 calculate_sum (option_data, -1, -1, level, tcontr);
04320 fval += coef * coef / (a*b*n);
04321 for (ixyz = 0; ixyz < nxyz; ixyz++)
04322 contr[ixyz] += coef * tcontr[ixyz] / (a*b*n);
04323 }
04324
04325 if (nvoxel > 0)
04326 printf ("No.%d contrast for factor C = %f \n",
04327 icontr+1, contr[nvoxel-1]);
04328
04329 /*----- standard deviation -----*/
04330 volume_read ("sse", tcontr, nxyz);
04331 df = a * b * c * (n-1);
04332
04333 /*----- divide by estimated standard deviation of the contrast -----*/
04334 for (ixyz = 0; ixyz < nxyz; ixyz++)
04335 {
04336 stddev = sqrt ((tcontr[ixyz] / df) * fval);
04337 if (stddev < EPSILON)
04338 tcontr[ixyz] = 0.0;
04339 else
04340 tcontr[ixyz] = contr[ixyz] / stddev;
04341 }
04342
04343 if (nvoxel > 0)
04344 printf ("t of No.%d contrast for factor C = %f \n",
04345 icontr+1, tcontr[nvoxel-1]);
04346
04347 /*----- write out afni data file -----*/
04348 write_afni_data (option_data, option_data->ccname[icontr],
04349 contr, tcontr, df, 0);
04350
04351 }
04352
04353 /*----- release memory -----*/
04354 free (tcontr); tcontr = NULL;
04355 free (contr); contr = NULL;
04356
04357 }
|
|
|
Definition at line 3860 of file 3dANOVA3.c. References anova_options::a, a, ANOVA_error(), anova_options::b, anova_options::c, c, calculate_sum(), anova_options::cdiffs, anova_options::cdname, free, i, malloc, anova_options::n, anova_options::num_cdiffs, anova_options::nvoxel, anova_options::nxyz, volume_read(), and write_afni_data(). Referenced by analyze_results().
03861 {
03862 const float EPSILON = 1.0e-10; /* protect against divide by zero */
03863 float * diff = NULL; /* pointer to est. diff. in means */
03864 float * tdiff = NULL; /* pointer to t-statistic data */
03865 int a; /* number of levels for factor A */
03866 int b; /* number of levels for factor B */
03867 int c; /* number of levels for factor C */
03868 int n; /* number of observations per cell */
03869 int ixyz, nxyz; /* voxel counters */
03870 int nvoxel; /* output voxel # */
03871 int num_diffs; /* number of user requested diffs. */
03872 int idiff; /* index for requested differences */
03873 int i, j; /* factor level indices */
03874 int df; /* degrees of freedom for t-test */
03875 float fval; /* for calculating std. dev. */
03876 float stddev; /* est. std. dev. of difference */
03877 char filename[MAX_NAME_LENGTH]; /* input file name */
03878
03879
03880 /*----- initialize local variables -----*/
03881 a = option_data->a;
03882 b = option_data->b;
03883 c = option_data->c;
03884 n = option_data->n;
03885 num_diffs = option_data->num_cdiffs;
03886 nxyz = option_data->nxyz;
03887 nvoxel = option_data->nvoxel;
03888
03889 /*----- allocate memory space for calculations -----*/
03890 diff = (float *) malloc(sizeof(float)*nxyz);
03891 tdiff = (float *) malloc(sizeof(float)*nxyz);
03892 if ((diff == NULL) || (tdiff == NULL))
03893 ANOVA_error ("unable to allocate sufficient memory");
03894
03895 /*----- loop over user specified treatment differences -----*/
03896 for (idiff = 0; idiff < num_diffs; idiff++)
03897 {
03898
03899 /*----- read first treatment level mean -----*/
03900 i = option_data->cdiffs[idiff][0];
03901 calculate_sum (option_data, -1, -1, i, diff);
03902 for (ixyz = 0; ixyz < nxyz; ixyz++)
03903 diff[ixyz] = diff[ixyz] / (a*b*n);
03904
03905 /*----- subtract second treatment level mean -----*/
03906 j = option_data->cdiffs[idiff][1];
03907 calculate_sum (option_data, -1, -1, j, tdiff);
03908 for (ixyz = 0; ixyz < nxyz; ixyz++)
03909 diff[ixyz] -= tdiff[ixyz] / (a*b*n);
03910 if (nvoxel > 0)
03911 printf ("Difference of factor C level %d - level %d = %f \n",
03912 i+1, j+1, diff[nvoxel-1]);
03913
03914 /*----- standard deviation -----*/
03915 volume_read ("sse", tdiff, nxyz);
03916 df = a * b * c * (n-1);
03917
03918 /*----- divide by estimated standard deviation of difference -----*/
03919 fval = (1.0 / df) * (2.0 / (a*b*n));
03920 for (ixyz = 0; ixyz < nxyz; ixyz++)
03921 {
03922 stddev = sqrt (tdiff[ixyz] * fval);
03923 if (stddev < EPSILON)
03924 tdiff[ixyz] = 0.0;
03925 else
03926 tdiff[ixyz] = diff[ixyz] / stddev;
03927 }
03928
03929 if (nvoxel > 0)
03930 printf ("t for difference of factor C level %d - level %d = %f \n",
03931 i+1, j+1, tdiff[nvoxel-1]);
03932
03933 /*----- write out afni data file -----*/
03934 write_afni_data (option_data, option_data->cdname[idiff],
03935 diff, tdiff, df, 0);
03936
03937 }
03938
03939 /*----- release memory -----*/
03940 free (tdiff); tdiff = NULL;
03941 free (diff); diff = NULL;
03942
03943 }
|
|
|
Definition at line 3473 of file 3dANOVA3.c. References anova_options::a, a, ANOVA_error(), anova_options::b, anova_options::c, c, calculate_sum(), anova_options::cmeans, anova_options::cmname, free, malloc, anova_options::n, anova_options::nt, anova_options::num_cmeans, anova_options::nvoxel, anova_options::nxyz, volume_read(), and write_afni_data(). Referenced by analyze_results().
03474 {
03475 const float EPSILON = 1.0e-10; /* protect against divide by zero */
03476 float * mean = NULL; /* pointer to treatment mean data */
03477 float * tmean = NULL; /* pointer to t-statistic data */
03478 int a; /* number of levels for factor A */
03479 int b; /* number of levels for factor B */
03480 int c; /* number of levels for factor C */
03481 int n; /* number of observations per cell */
03482 int ixyz, nxyz; /* voxel counters */
03483 int nvoxel; /* output voxel # */
03484 int nt; /* total number of observations */
03485 int num_means; /* number of user requested means */
03486 int imean; /* output mean option index */
03487 int level; /* factor C level index */
03488 int df; /* degrees of freedom for t-test */
03489 float fval; /* for calculating std. dev. */
03490 float stddev; /* est. std. dev. of factor mean */
03491 char filename[MAX_NAME_LENGTH]; /* input data file name */
03492
03493
03494 /*----- initialize local variables -----*/
03495 a = option_data->a;
03496 b = option_data->b;
03497 c = option_data->c;
03498 n = option_data->n;
03499 df = a * b * c * (n-1);
03500 nt = option_data->nt;
03501 num_means = option_data->num_cmeans;
03502 nxyz = option_data->nxyz;
03503 nvoxel = option_data->nvoxel;
03504
03505 /*----- allocate memory space for calculations -----*/
03506 mean = (float *) malloc(sizeof(float)*nxyz);
03507 tmean = (float *) malloc(sizeof(float)*nxyz);
03508 if ((mean == NULL) || (tmean == NULL))
03509 ANOVA_error ("unable to allocate sufficient memory");
03510
03511 /*----- loop over user specified treatment means -----*/
03512 for (imean = 0; imean < num_means; imean++)
03513 {
03514 level = option_data->cmeans[imean];
03515
03516 /*----- estimate factor mean for this treatment level -----*/
03517 calculate_sum (option_data, -1, -1, level, mean);
03518 for (ixyz = 0; ixyz < nxyz; ixyz++)
03519 mean[ixyz] = mean[ixyz] / (a*b*n);
03520 if (nvoxel > 0)
03521 printf ("Mean of factor C level %d = %f \n", level+1, mean[nvoxel-1]);
03522
03523 /*----- divide by estimated standard deviation of factor mean -----*/
03524 volume_read ("sse", tmean, nxyz);
03525 fval = (1.0 / df) * (1.0 / (a*b*n));
03526 for (ixyz = 0; ixyz < nxyz; ixyz++)
03527 {
03528 stddev = sqrt(tmean[ixyz] * fval);
03529 if (stddev < EPSILON)
03530 tmean[ixyz] = 0.0;
03531 else
03532 tmean[ixyz] = mean[ixyz] / stddev;
03533 }
03534 if (nvoxel > 0)
03535 printf ("t for mean of factor C level %d = %f \n",
03536 level+1, tmean[nvoxel-1]);
03537
03538 /*----- write out afni data file -----*/
03539 write_afni_data (option_data, option_data->cmname[imean],
03540 mean, tmean, df, 0);
03541
03542 }
03543
03544 /*----- release memory -----*/
03545 free (tmean); tmean = NULL;
03546 free (mean); mean = NULL;
03547 }
|
|
|
Definition at line 2552 of file 3dANOVA3.c. References anova_options::a, a, ANOVA_error(), anova_options::b, anova_options::c, c, fa, anova_options::faname, free, malloc, anova_options::model, anova_options::n, anova_options::nvoxel, anova_options::nxyz, volume_read(), and write_afni_data(). Referenced by analyze_results().
02553 {
02554 const float EPSILON = 1.0e-10; /* protect against divide by zero */
02555 float * msa = NULL; /* pointer to MSA data */
02556 float * fa = NULL; /* pointer to F due to factor A */
02557 int a; /* number of levels for factor A */
02558 int b; /* number of levels for factor B */
02559 int c; /* number of levels for factor C */
02560 int n; /* number of observations per cell */
02561 int ixyz, nxyz; /* voxel counters */
02562 int nvoxel; /* output voxel # */
02563 int numdf; /* numerator degrees of freedom */
02564 int dendf; /* denominator degrees of freedom */
02565 float fval; /* denominator of F-statistic */
02566
02567
02568 /*----- initialize local variables -----*/
02569 a = option_data->a;
02570 b = option_data->b;
02571 c = option_data->c;
02572 n = option_data->n;
02573 nxyz = option_data->nxyz;
02574 nvoxel = option_data->nvoxel;
02575
02576 /*----- allocate memory space for calculations -----*/
02577 fa = (float *) malloc(sizeof(float)*nxyz);
02578 msa = (float *) malloc(sizeof(float)*nxyz);
02579 if ((fa == NULL) || (msa == NULL))
02580 ANOVA_error ("unable to allocate sufficient memory");
02581
02582 /*----- calculate mean SS due to factor A -----*/
02583 volume_read ("ssa", msa, nxyz);
02584 numdf = a - 1;
02585 for (ixyz = 0; ixyz < nxyz; ixyz++)
02586 msa[ixyz] = msa[ixyz] / numdf;
02587 if (nvoxel > 0)
02588 printf ("MSA = %f \n", msa[nvoxel-1]);
02589
02590 /*----- set up denominator of F-statistic -----*/
02591 switch (option_data->model)
02592 {
02593 case 1:
02594 volume_read ("sse", fa, nxyz);
02595 dendf = a * b * c * (n-1);
02596 break;
02597 case 4:
02598 volume_read ("ssac", fa, nxyz);
02599 dendf = (a-1) * (c-1);
02600 break;
02601 case 5:
02602 volume_read ("ssca", fa, nxyz);
02603 dendf = a * (c-1);
02604 break;
02605 }
02606
02607 /*----- calculate F-statistic -----*/
02608 for (ixyz = 0; ixyz < nxyz; ixyz++)
02609 {
02610 fval = fa[ixyz] / dendf;
02611 if (fval < EPSILON)
02612 fa[ixyz] = 0.0;
02613 else
02614 fa[ixyz] = msa[ixyz] / fval;
02615 }
02616
02617 if (nvoxel > 0)
02618 printf ("F(A) = %f \n", fa[nvoxel-1]);
02619
02620 /*----- write out afni data file -----*/
02621 for (ixyz = 0; ixyz < nxyz; ixyz++)
02622 msa[ixyz] = sqrt(msa[ixyz]); /*-- msa now holds square root --*/
02623 write_afni_data (option_data, option_data->faname,
02624 msa, fa, numdf, dendf);
02625
02626 /*----- release memory -----*/
02627 free (msa); msa = NULL;
02628 free (fa); fa = NULL;
02629
02630 }
|
|
|
Definition at line 2875 of file 3dANOVA3.c. References anova_options::a, a, ANOVA_error(), anova_options::b, anova_options::c, c, anova_options::fabname, free, malloc, anova_options::model, anova_options::n, anova_options::nvoxel, anova_options::nxyz, volume_read(), and write_afni_data(). Referenced by analyze_results().
02876 {
02877 const float EPSILON = 1.0e-10; /* protect against divide by zero */
02878 float * msab = NULL; /* pointer to MSAB data */
02879 float * fab = NULL; /* pointer to F due to interaction */
02880 int a; /* number of levels for factor A */
02881 int b; /* number of levels for factor B */
02882 int c; /* number of levels for factor C */
02883 int n; /* number of observations per cell */
02884 int ixyz, nxyz; /* voxel counters */
02885 int nvoxel; /* output voxel # */
02886 int numdf; /* numerator degrees of freedom */
02887 int dendf; /* denominator degrees of freedom */
02888 float fval; /* denominator of F-statistic */
02889
02890
02891 /*----- initialize local variables -----*/
02892 a = option_data->a;
02893 b = option_data->b;
02894 c = option_data->c;
02895 n = option_data->n;
02896 nxyz = option_data->nxyz;
02897 nvoxel = option_data->nvoxel;
02898
02899 /*----- allocate memory space for calculations -----*/
02900 fab = (float *) malloc(sizeof(float)*nxyz);
02901 msab = (float *) malloc(sizeof(float)*nxyz);
02902 if ((fab == NULL) || (msab == NULL))
02903 ANOVA_error ("unable to allocate sufficient memory");
02904
02905 /*----- calculate mean SS due to A*B interaction -----*/
02906 volume_read ("ssab", msab, nxyz);
02907 numdf = (a-1) * (b-1);
02908 for (ixyz = 0; ixyz < nxyz; ixyz++)
02909 msab[ixyz] = msab[ixyz] / numdf;
02910 if (nvoxel > 0)
02911 printf ("MSAB = %f \n", msab[nvoxel-1]);
02912
02913 /*----- set up denominator of F-statistic -----*/
02914 switch (option_data->model)
02915 {
02916 case 1:
02917 volume_read ("sse", fab, nxyz);
02918 dendf = a * b * c * (n-1);
02919 break;
02920 case 2:
02921 case 3:
02922 case 4:
02923 volume_read ("ssabc", fab, nxyz);
02924 dendf = (a-1) * (b-1) * (c-1);
02925 break;
02926 case 5:
02927 volume_read ("ssbca", fab, nxyz);
02928 dendf = a * (b-1) * (c-1);
02929 break;
02930 }
02931
02932 /*----- calculate F-statistic -----*/
02933 for (ixyz = 0; ixyz < nxyz; ixyz++)
02934 {
02935 fval = fab[ixyz] / dendf;
02936 if (fval < EPSILON)
02937 fab[ixyz] = 0.0;
02938 else
02939 fab[ixyz] = msab[ixyz] / fval;
02940 }
02941 if (nvoxel > 0)
02942 printf ("F(AB) = %f \n", fab[nvoxel-1]);
02943
02944
02945 /*----- write out afni data file -----*/
02946 for (ixyz = 0; ixyz < nxyz; ixyz++)
02947 msab[ixyz] = sqrt(msab[ixyz]); /*-- msab now holds square root --*/
02948 write_afni_data (option_data, option_data->fabname,
02949 msab, fab, numdf, dendf);
02950
02951
02952 /*----- release memory -----*/
02953 free (msab); msab = NULL;
02954 free (fab); fab = NULL;
02955
02956 }
|
|
|
Definition at line 3192 of file 3dANOVA3.c. References anova_options::a, a, ANOVA_error(), anova_options::b, anova_options::c, c, anova_options::fabcname, free, malloc, anova_options::model, anova_options::n, anova_options::nvoxel, anova_options::nxyz, volume_read(), and write_afni_data(). Referenced by analyze_results().
03193 {
03194 const float EPSILON = 1.0e-10; /* protect against divide by zero */
03195 float * msabc = NULL; /* pointer to MSABC data */
03196 float * fabc = NULL; /* pointer to F for A*B*C interaction */
03197 int a; /* number of levels for factor A */
03198 int b; /* number of levels for factor B */
03199 int c; /* number of levels for factor C */
03200 int n; /* number of observations per cell */
03201 int ixyz, nxyz; /* voxel counters */
03202 int nvoxel; /* output voxel # */
03203 int numdf; /* numerator degrees of freedom */
03204 int dendf; /* denominator degrees of freedom */
03205 float fval; /* denominator of F-statistic */
03206
03207
03208 /*----- initialize local variables -----*/
03209 a = option_data->a;
03210 b = option_data->b;
03211 c = option_data->c;
03212 n = option_data->n;
03213 nxyz = option_data->nxyz;
03214 nvoxel = option_data->nvoxel;
03215
03216 /*----- allocate memory space for calculations -----*/
03217 fabc = (float *) malloc(sizeof(float)*nxyz);
03218 msabc = (float *) malloc(sizeof(float)*nxyz);
03219 if ((fabc == NULL) || (msabc == NULL))
03220 ANOVA_error ("unable to allocate sufficient memory");
03221
03222 /*----- calculate mean SS due to A*B*C interaction -----*/
03223 volume_read ("ssabc", msabc, nxyz);
03224 numdf = (a-1) * (b-1) * (c-1);
03225 for (ixyz = 0; ixyz < nxyz; ixyz++)
03226 msabc[ixyz] = msabc[ixyz] / numdf;
03227 if (nvoxel > 0)
03228 printf ("MSABC = %f \n", msabc[nvoxel-1]);
03229
03230 /*----- set up denominator of F-statistic -----*/
03231 switch (option_data->model)
03232 {
03233 case 1:
03234 case 2:
03235 case 3:
03236 case 4:
03237 volume_read ("sse", fabc, nxyz);
03238 dendf = a * b * c * (n-1);
03239 break;
03240 }
03241
03242 /*----- calculate F-statistic -----*/
03243 for (ixyz = 0; ixyz < nxyz; ixyz++)
03244 {
03245 fval = fabc[ixyz] / dendf;
03246 if (fval < EPSILON)
03247 fabc[ixyz] = 0.0;
03248 else
03249 fabc[ixyz] = msabc[ixyz] / fval;
03250 }
03251 if (nvoxel > 0)
03252 printf ("F(ABC) = %f \n", fabc[nvoxel-1]);
03253
03254 /*----- write out afni data file -----*/
03255 for (ixyz = 0; ixyz < nxyz; ixyz++)
03256 msabc[ixyz] = sqrt(msabc[ixyz]); /*-- msabc now holds square root --*/
03257 write_afni_data (option_data, option_data->fabcname,
03258 msabc, fabc, numdf, dendf);
03259
03260 /*----- release memory -----*/
03261 free (msabc); msabc = NULL;
03262 free (fabc); fabc = NULL;
03263
03264 }
|
|
|
Definition at line 3097 of file 3dANOVA3.c. References anova_options::a, a, ANOVA_error(), anova_options::b, anova_options::c, c, anova_options::facname, free, malloc, anova_options::model, anova_options::n, anova_options::nvoxel, anova_options::nxyz, volume_read(), and write_afni_data(). Referenced by analyze_results().
03098 {
03099 const float EPSILON = 1.0e-10; /* protect against divide by zero */
03100 float * msac = NULL; /* pointer to MSAC data */
03101 float * fac = NULL; /* pointer to F for A*C interaction */
03102 int a; /* number of levels for factor A */
03103 int b; /* number of levels for factor B */
03104 int c; /* number of levels for factor C */
03105 int n; /* number of observations per cell */
03106 int ixyz, nxyz; /* voxel counters */
03107 int nvoxel; /* output voxel # */
03108 int numdf; /* numerator degrees of freedom */
03109 int dendf; /* denominator degrees of freedom */
03110 float fval; /* denominator of F-statistic */
03111
03112
03113 /*----- initialize local variables -----*/
03114 a = option_data->a;
03115 b = option_data->b;
03116 c = option_data->c;
03117 n = option_data->n;
03118 nxyz = option_data->nxyz;
03119 nvoxel = option_data->nvoxel;
03120
03121 /*----- allocate memory space for calculations -----*/
03122 fac = (float *) malloc(sizeof(float)*nxyz);
03123 msac = (float *) malloc(sizeof(float)*nxyz);
03124 if ((fac == NULL) || (msac == NULL))
03125 ANOVA_error ("unable to allocate sufficient memory");
03126
03127 /*----- calculate mean SS due to A*C interaction -----*/
03128 volume_read ("ssac", msac, nxyz);
03129 numdf = (a-1) * (c-1);
03130 for (ixyz = 0; ixyz < nxyz; ixyz++)
03131 msac[ixyz] = msac[ixyz] / numdf;
03132 if (nvoxel > 0)
03133 printf ("MSAC = %f \n", msac[nvoxel-1]);
03134
03135 /*----- set up denominator of F-statistic -----*/
03136 switch (option_data->model)
03137 {
03138 case 1:
03139 case 4:
03140 volume_read ("sse", fac, nxyz);
03141 dendf = a * b * c * (n-1);
03142 break;
03143 case 2:
03144 case 3:
03145 volume_read ("ssabc", fac, nxyz);
03146 dendf = (a-1) * (b-1) * (c-1);
03147 break;
03148 }
03149
03150 /*----- calculate F-statistic -----*/
03151 for (ixyz = 0; ixyz < nxyz; ixyz++)
03152 {
03153 fval = fac[ixyz] / dendf;
03154 if (fval < EPSILON)
03155 fac[ixyz] = 0.0;
03156 else
03157 fac[ixyz] = msac[ixyz] / fval;
03158 }
03159 if (nvoxel > 0)
03160 printf ("F(AC) = %f \n", fac[nvoxel-1]);
03161
03162 /*----- write out afni data file -----*/
03163 for (ixyz = 0; ixyz < nxyz; ixyz++)
03164 msac[ixyz] = sqrt(msac[ixyz]); /*-- msac now holds square root --*/
03165 write_afni_data (option_data, option_data->facname,
03166 msac, fac, numdf, dendf);
03167
03168 /*----- release memory -----*/
03169 free (msac); msac = NULL;
03170 free (fac); fac = NULL;
03171
03172 }
|
|
|
Definition at line 2653 of file 3dANOVA3.c. References anova_options::a, a, ANOVA_error(), anova_options::b, anova_options::c, c, fb, anova_options::fbname, free, malloc, anova_options::model, anova_options::n, anova_options::nvoxel, anova_options::nxyz, volume_read(), and write_afni_data(). Referenced by analyze_results().
02654 {
02655 const float EPSILON = 1.0e-10; /* protect against divide by zero */
02656 float * msb = NULL; /* pointer to MSB data */
02657 float * fb = NULL; /* pointer to F due to factor B */
02658 int a; /* number of levels for factor A */
02659 int b; /* number of levels for factor B */
02660 int c; /* number of levels for factor C */
02661 int n; /* number of observations per cell */
02662 int ixyz, nxyz; /* voxel counters */
02663 int nvoxel; /* output voxel # */
02664 int numdf; /* numerator degrees of freedom */
02665 int dendf; /* denominator degrees of freedom */
02666 float fval; /* denominator of F-statistic */
02667
02668
02669 /*----- initialize local variables -----*/
02670 a = option_data->a;
02671 b = option_data->b;
02672 c = option_data->c;
02673 n = option_data->n;
02674 nxyz = option_data->nxyz;
02675 nvoxel = option_data->nvoxel;
02676
02677 /*----- allocate memory space for calculations -----*/
02678 fb = (float *) malloc(sizeof(float)*nxyz);
02679 msb = (float *) malloc(sizeof(float)*nxyz);
02680 if ((fb == NULL) || (msb == NULL))
02681 ANOVA_error ("unable to allocate sufficient memory");
02682
02683 /*----- calculate mean SS due to factor B -----*/
02684 volume_read ("ssb", msb, nxyz);
02685 numdf = b - 1;
02686 for (ixyz = 0; ixyz < nxyz; ixyz++)
02687 msb[ixyz] = msb[ixyz] / numdf;
02688 if (nvoxel > 0)
02689 printf ("MSB = %f \n", msb[nvoxel-1]);
02690
02691 /*----- set up denominator of F-statistic -----*/
02692 switch (option_data->model)
02693 {
02694 case 1:
02695 volume_read ("sse", fb, nxyz);
02696 dendf = a * b * c * (n-1);
02697 break;
02698 case 3:
02699 case 4:
02700 volume_read ("ssbc", fb, nxyz);
02701 dendf = (b-1) * (c-1);
02702 break;
02703 case 5:
02704 volume_read ("ssbca", fb, nxyz);
02705 dendf = a * (b-1) * (c-1);
02706 break;
02707 }
02708
02709 /*----- calculate F-statistic -----*/
02710 for (ixyz = 0; ixyz < nxyz; ixyz++)
02711 {
02712 fval = fb[ixyz] / dendf;
02713 if (fval < EPSILON)
02714 fb[ixyz] = 0.0;
02715 else
02716 fb[ixyz] = msb[ixyz] / fval;
02717 }
02718
02719 if (nvoxel > 0)
02720 printf ("F(B) = %f \n", fb[nvoxel-1]);
02721
02722 /*----- write out afni data file -----*/
02723 for (ixyz = 0; ixyz < nxyz; ixyz++)
02724 msb[ixyz] = sqrt(msb[ixyz]); /*-- msb now holds square root --*/
02725 write_afni_data (option_data, option_data->fbname,
02726 msb, fb, numdf, dendf);
02727
02728 /*----- release memory -----*/
02729 free (msb); msb = NULL;
02730 free (fb); fb = NULL;
02731
02732 }
|
|
|
Definition at line 2980 of file 3dANOVA3.c. References anova_options::a, a, ANOVA_error(), anova_options::b, anova_options::c, c, fbc, anova_options::fbcname, free, malloc, anova_options::model, anova_options::n, anova_options::nvoxel, anova_options::nxyz, volume_read(), and write_afni_data(). Referenced by analyze_results().
02981 {
02982 const float EPSILON = 1.0e-10; /* protect against divide by zero */
02983 float * msbc = NULL; /* pointer to MSBC data */
02984 float * fbc = NULL; /* pointer to F for B*C interaction */
02985 int a; /* number of levels for factor A */
02986 int b; /* number of levels for factor B */
02987 int c; /* number of levels for factor C */
02988 int n; /* number of observations per cell */
02989 int ixyz, nxyz; /* voxel counters */
02990 int nvoxel; /* output voxel # */
02991 int numdf; /* numerator degrees of freedom */
02992 int dendf; /* denominator degrees of freedom */
02993 float fval; /* denominator of F-statistic */
02994
02995
02996 /*----- initialize local variables -----*/
02997 a = option_data->a;
02998 b = option_data->b;
02999 c = option_data->c;
03000 n = option_data->n;
03001 nxyz = option_data->nxyz;
03002 nvoxel = option_data->nvoxel;
03003
03004 /*----- allocate memory space for calculations -----*/
03005 fbc = (float *) malloc(sizeof(float)*nxyz);
03006 msbc = (float *) malloc(sizeof(float)*nxyz);
03007 if ((fbc == NULL) || (msbc == NULL))
03008 ANOVA_error ("unable to allocate sufficient memory");
03009
03010 /*----- set up numerator of F-statistic -----*/
03011 switch (option_data->model)
03012 {
03013 case 1:
03014 case 2:
03015 case 3:
03016 case 4:
03017 volume_read ("ssbc", msbc, nxyz);
03018 numdf = (b-1) * (c-1);
03019 break;
03020 case 5:
03021 volume_read ("ssbca", msbc, nxyz);
03022 numdf = a * (b-1) * (c-1);
03023 break;
03024 }
03025
03026 /*----- calculate mean SS due to B*C interaction -----*/
03027 for (ixyz = 0; ixyz < nxyz; ixyz++)
03028 msbc[ixyz] = msbc[ixyz] / numdf;
03029 if (nvoxel > 0)
03030 if (option_data->model != 5)
03031 printf ("MSBC = %f \n", msbc[nvoxel-1]);
03032 else
03033 printf ("MSBC(A) = %f \n", msbc[nvoxel-1]);
03034
03035 /*----- set up denominator of F-statistic -----*/
03036 switch (option_data->model)
03037 {
03038 case 1:
03039 case 3:
03040 case 4:
03041 case 5:
03042 volume_read ("sse", fbc, nxyz);
03043 dendf = a * b * c * (n-1);
03044 break;
03045 case 2:
03046 volume_read ("ssabc", fbc, nxyz);
03047 dendf = (a-1) * (b-1) * (c-1);
03048 break;
03049 }
03050
03051 /*----- calculate F-statistic -----*/
03052 for (ixyz = 0; ixyz < nxyz; ixyz++)
03053 {
03054 fval = fbc[ixyz] / dendf;
03055 if (fval < EPSILON)
03056 fbc[ixyz] = 0.0;
03057 else
03058 fbc[ixyz] = msbc[ixyz] / fval;
03059 }
03060 if (nvoxel > 0)
03061 if (option_data->model != 5)
03062 printf ("F(BC) = %f \n", fbc[nvoxel-1]);
03063 else
03064 printf ("F(BC(A)) = %f \n", fbc[nvoxel-1]);
03065
03066 /*----- write out afni data file -----*/
03067 for (ixyz = 0; ixyz < nxyz; ixyz++)
03068 msbc[ixyz] = sqrt(msbc[ixyz]); /*-- msbc now holds square root --*/
03069 write_afni_data (option_data, option_data->fbcname,
03070 msbc, fbc, numdf, dendf);
03071
03072 /*----- release memory -----*/
03073 free (msbc); msbc = NULL;
03074 free (fbc); fbc = NULL;
03075
03076 }
|
|
|
Definition at line 2755 of file 3dANOVA3.c. References anova_options::a, a, ANOVA_error(), anova_options::b, anova_options::c, c, anova_options::fcname, free, malloc, anova_options::model, anova_options::n, anova_options::nvoxel, anova_options::nxyz, volume_read(), and write_afni_data(). Referenced by analyze_results().
02756 {
02757 const float EPSILON = 1.0e-10; /* protect against divide by zero */
02758 float * msc = NULL; /* pointer to MSC(A) data */
02759 float * fc = NULL; /* pointer to F due to factor C */
02760 int a; /* number of levels for factor A */
02761 int b; /* number of levels for factor B */
02762 int c; /* number of levels for factor C */
02763 int n; /* number of observations per cell */
02764 int ixyz, nxyz; /* voxel counters */
02765 int nvoxel; /* output voxel # */
02766 int numdf; /* numerator degrees of freedom */
02767 int dendf; /* denominator degrees of freedom */
02768 float fval; /* denominator of F-statistic */
02769
02770
02771 /*----- initialize local variables -----*/
02772 a = option_data->a;
02773 b = option_data->b;
02774 c = option_data->c;
02775 n = option_data->n;
02776 nxyz = option_data->nxyz;
02777 nvoxel = option_data->nvoxel;
02778
02779 /*----- allocate memory space for calculations -----*/
02780 fc = (float *) malloc(sizeof(float)*nxyz);
02781 msc = (float *) malloc(sizeof(float)*nxyz);
02782 if ((fc == NULL) || (msc == NULL))
02783 ANOVA_error ("unable to allocate sufficient memory");
02784
02785 /*----- set up numerator of F-statistic -----*/
02786 switch (option_data->model)
02787 {
02788 case 1:
02789 case 3:
02790 case 4:
02791 volume_read ("ssc", msc, nxyz);
02792 numdf = c - 1;
02793 break;
02794 case 5:
02795 volume_read ("ssca", msc, nxyz);
02796 numdf = a * (c-1);
02797 break;
02798 }
02799
02800 /*----- calculate mean SS due to factor C -----*/
02801 for (ixyz = 0; ixyz < nxyz; ixyz++)
02802 msc[ixyz] = msc[ixyz] / numdf;
02803 if (nvoxel > 0)
02804 if (option_data->model != 5)
02805 printf ("MSC = %f \n", msc[nvoxel-1]);
02806 else
02807 printf ("MSC(A) = %f \n", msc[nvoxel-1]);
02808
02809
02810 /*----- set up denominator of F-statistic -----*/
02811 switch (option_data->model)
02812 {
02813 case 1:
02814 case 4:
02815 case 5:
02816 volume_read ("sse", fc, nxyz);
02817 dendf = a * b * c * (n-1);
02818 break;
02819 case 3:
02820 volume_read ("ssbc", fc, nxyz);
02821 dendf = (b-1) * (c-1);
02822 break;
02823 }
02824
02825 /*----- calculate F-statistic -----*/
02826 for (ixyz = 0; ixyz < nxyz; ixyz++)
02827 {
02828 fval = fc[ixyz] / dendf;
02829 if (fval < EPSILON)
02830 fc[ixyz] = 0.0;
02831 else
02832 fc[ixyz] = msc[ixyz] / fval;
02833 }
02834
02835 if (nvoxel > 0)
02836 if (option_data->model != 5)
02837 printf ("F(C) = %f \n", fc[nvoxel-1]);
02838 else
02839 printf ("F(C(A)) = %f \n", fc[nvoxel-1]);
02840
02841 /*----- write out afni data file -----*/
02842 for (ixyz = 0; ixyz < nxyz; ixyz++)
02843 msc[ixyz] = sqrt(msc[ixyz]); /*-- msc now holds square root --*/
02844 write_afni_data (option_data, option_data->fcname,
02845 msc, fc, numdf, dendf);
02846
02847 /*----- release memory -----*/
02848 free (msc); msc = NULL;
02849 free (fc); fc = NULL;
02850
02851 }
|
|
|
Definition at line 1318 of file 3dANOVA3.c. References anova_options::a, a, ANOVA_error(), anova_options::b, anova_options::c, c, calculate_sum(), free, malloc, anova_options::n, anova_options::nvoxel, anova_options::nxyz, and volume_write(). Referenced by calculate_anova().
01319 {
01320 float * ss0 = NULL; /* pointer to output data */
01321 float * ysum = NULL; /* pointer to sum over all observations */
01322 int a; /* number of levels for factor A */
01323 int b; /* number of levels for factor B */
01324 int c; /* number of levels for factor C */
01325 int n; /* number of observations per cell */
01326 int ixyz, nxyz; /* voxel counters */
01327 int nvoxel; /* output voxel # */
01328 int nval; /* divisor of sum */
01329 char filename[MAX_NAME_LENGTH]; /* name of output file */
01330
01331
01332 /*----- initialize local variables -----*/
01333 a = option_data->a;
01334 b = option_data->b;
01335 c = option_data->c;
01336 n = option_data->n;
01337 nxyz = option_data->nxyz;
01338 nvoxel = option_data->nvoxel;
01339 nval = a * b * c * n;
01340
01341 /*----- allocate memory space for calculations -----*/
01342 ss0 = (float *) malloc(sizeof(float)*nxyz);
01343 ysum = (float *) malloc(sizeof(float)*nxyz);
01344 if ((ss0 == NULL) || (ysum == NULL))
01345 ANOVA_error ("unable to allocate sufficient memory");
01346
01347 /*----- sum over all observations -----*/
01348 calculate_sum (option_data, -1, -1, -1, ysum);
01349
01350 /*----- calculate ss0 -----*/
01351 for (ixyz = 0; ixyz < nxyz; ixyz++)
01352 ss0[ixyz] = ysum[ixyz] * ysum[ixyz] / nval;
01353
01354
01355 /*----- save the sum -----*/
01356 if (nvoxel > 0)
01357 printf ("SS0 = %f \n", ss0[nvoxel-1]);
01358 strcpy (filename, "ss0");
01359 volume_write (filename, ss0, nxyz);
01360
01361
01362 /*----- release memory -----*/
01363 free (ysum); ysum = NULL;
01364 free (ss0); ss0 = NULL;
01365
01366 }
|
|
|
Definition at line 2024 of file 3dANOVA3.c. References ANOVA_error(), free, malloc, anova_options::nvoxel, anova_options::nxyz, volume_read(), and volume_write(). Referenced by calculate_anova().
02025 {
02026 float * y = NULL; /* input data pointer */
02027 float * ssa = NULL; /* output data pointer */
02028 int ixyz, nxyz; /* voxel counters */
02029 int nvoxel; /* output voxel # */
02030
02031
02032 /*----- assign local variables -----*/
02033 nxyz = option_data->nxyz;
02034 nvoxel = option_data->nvoxel;
02035
02036 /*----- allocate memory space for calculations -----*/
02037 ssa = (float *) malloc (sizeof(float)*nxyz);
02038 y = (float *) malloc (sizeof(float)*nxyz);
02039 if ((y == NULL) || (ssa == NULL))
02040 ANOVA_error ("unable to allocate sufficient memory");
02041
02042
02043 /*----- calculate SSA -----*/
02044 volume_read ("ssi", ssa, nxyz);
02045
02046 volume_read ("ss0", y, nxyz);
02047 for (ixyz = 0; ixyz < nxyz; ixyz++)
02048 ssa[ixyz] -= y[ixyz];
02049
02050
02051 /*----- protection against round-off error -----*/
02052 for (ixyz = 0; ixyz < nxyz; ixyz++)
02053 if (ssa[ixyz] < 0.0) ssa[ixyz] = 0.0;
02054
02055 /*----- save factor A sum of squares -----*/
02056 if (nvoxel > 0)
02057 printf ("SSA = %f \n", ssa[nvoxel-1]);
02058 volume_write ("ssa", ssa, nxyz);
02059
02060 /*----- release memory -----*/
02061 free (y); y = NULL;
02062 free (ssa); ssa = NULL;
02063
02064 }
|
|
|
Definition at line 2171 of file 3dANOVA3.c. References ANOVA_error(), free, malloc, anova_options::nvoxel, anova_options::nxyz, volume_read(), and volume_write(). Referenced by calculate_anova().
02172 {
02173 float * y = NULL; /* input data pointer */
02174 float * ssab = NULL; /* output data pointer */
02175 int ixyz, nxyz; /* voxel counters */
02176 int nvoxel; /* output voxel # */
02177
02178
02179 /*----- assign local variables -----*/
02180 nxyz = option_data->nxyz;
02181 nvoxel = option_data->nvoxel;
02182
02183 /*----- allocate memory space for calculations -----*/
02184 ssab = (float *) malloc (sizeof(float)*nxyz);
02185 y = (float *) malloc (sizeof(float)*nxyz);
02186 if ((y == NULL) || (ssab == NULL))
02187 ANOVA_error ("unable to allocate sufficient memory");
02188
02189
02190 /*----- calculate SSAB -----*/
02191 volume_read ("ssij", ssab, nxyz);
02192
02193 volume_read ("ssa", y, nxyz);
02194 for (ixyz = 0; ixyz < nxyz; ixyz++)
02195 ssab[ixyz] -= y[ixyz];
02196
02197 volume_read ("ssb", y, nxyz);
02198 for (ixyz = 0; ixyz < nxyz; ixyz++)
02199 ssab[ixyz] -= y[ixyz];
02200
02201 volume_read ("ss0", y, nxyz);
02202 for (ixyz = 0; ixyz < nxyz; ixyz++)
02203 ssab[ixyz] -= y[ixyz];
02204
02205
02206 /*----- protection against round-off error -----*/
02207 for (ixyz = 0; ixyz < nxyz; ixyz++)
02208 if (ssab[ixyz] < 0.0) ssab[ixyz] = 0.0;
02209
02210 /*----- save factor A*B sum of squares -----*/
02211 if (nvoxel > 0)
02212 printf ("SSAB = %f \n", ssab[nvoxel-1]);
02213 volume_write ("ssab", ssab, nxyz);
02214
02215 /*----- release memory -----*/
02216 free (y); y = NULL;
02217 free (ssab); ssab = NULL;
02218
02219 }
|
|
|
Definition at line 2395 of file 3dANOVA3.c. References ANOVA_error(), free, malloc, anova_options::n, anova_options::nvoxel, anova_options::nxyz, volume_read(), and volume_write(). Referenced by calculate_anova().
02396 {
02397 float * y = NULL; /* input data pointer */
02398 float * ssabc = NULL; /* output data pointer */
02399 int ixyz, nxyz; /* voxel counters */
02400 int nvoxel; /* output voxel # */
02401
02402
02403 /*----- assign local variables -----*/
02404 nxyz = option_data->nxyz;
02405 nvoxel = option_data->nvoxel;
02406
02407 /*----- allocate memory space for calculations -----*/
02408 ssabc = (float *) malloc (sizeof(float)*nxyz);
02409 y = (float *) malloc (sizeof(float)*nxyz);
02410 if ((y == NULL) || (ssabc == NULL))
02411 ANOVA_error ("unable to allocate sufficient memory");
02412
02413
02414 /*----- calculate SSABC -----*/
02415 volume_read ("ssto", ssabc, nxyz);
02416
02417 if (option_data->n > 1)
02418 {
02419 volume_read ("sse", y, nxyz);
02420 for (ixyz = 0; ixyz < nxyz; ixyz++)
02421 ssabc[ixyz] -= y[ixyz];
02422 }
02423
02424 volume_read ("ssa", y, nxyz);
02425 for (ixyz = 0; ixyz < nxyz; ixyz++)
02426 ssabc[ixyz] -= y[ixyz];
02427
02428 volume_read ("ssb", y, nxyz);
02429 for (ixyz = 0; ixyz < nxyz; ixyz++)
02430 ssabc[ixyz] -= y[ixyz];
02431
02432 volume_read ("ssc", y, nxyz);
02433 for (ixyz = 0; ixyz < nxyz; ixyz++)
02434 ssabc[ixyz] -= y[ixyz];
02435
02436 volume_read ("ssab", y, nxyz);
02437 for (ixyz = 0; ixyz < nxyz; ixyz++)
02438 ssabc[ixyz] -= y[ixyz];
02439
02440 volume_read ("ssac", y, nxyz);
02441 for (ixyz = 0; ixyz < nxyz; ixyz++)
02442 ssabc[ixyz] -= y[ixyz];
02443
02444 volume_read ("ssbc", y, nxyz);
02445 for (ixyz = 0; ixyz < nxyz; ixyz++)
02446 ssabc[ixyz] -= y[ixyz];
02447
02448
02449 /*----- protection against round-off error -----*/
02450 for (ixyz = 0; ixyz < nxyz; ixyz++)
02451 if (ssabc[ixyz] < 0.0) ssabc[ixyz] = 0.0;
02452
02453 /*----- save A*B*C interaction sum of squares -----*/
02454 if (nvoxel > 0)
02455 printf ("SSABC = %f \n", ssabc[nvoxel-1]);
02456 volume_write ("ssabc", ssabc, nxyz);
02457
02458 /*----- release memory -----*/
02459 free (y); y = NULL;
02460 free (ssabc); ssabc = NULL;
02461
02462 }
|
|
|
Definition at line 2228 of file 3dANOVA3.c. References ANOVA_error(), free, malloc, anova_options::nvoxel, anova_options::nxyz, volume_read(), and volume_write(). Referenced by calculate_anova().
02229 {
02230 float * y = NULL; /* input data pointer */
02231 float * ssac = NULL; /* output data pointer */
02232 int ixyz, nxyz; /* voxel counters */
02233 int nvoxel; /* output voxel # */
02234
02235
02236 /*----- assign local variables -----*/
02237 nxyz = option_data->nxyz;
02238 nvoxel = option_data->nvoxel;
02239
02240 /*----- allocate memory space for calculations -----*/
02241 ssac = (float *) malloc (sizeof(float)*nxyz);
02242 y = (float *) malloc (sizeof(float)*nxyz);
02243 if ((y == NULL) || (ssac == NULL))
02244 ANOVA_error ("unable to allocate sufficient memory");
02245
02246
02247 /*----- calculate SSAC -----*/
02248 volume_read ("ssik", ssac, nxyz);
02249
02250 volume_read ("ssa", y, nxyz);
02251 for (ixyz = 0; ixyz < nxyz; ixyz++)
02252 ssac[ixyz] -= y[ixyz];
02253
02254 volume_read ("ssc", y, nxyz);
02255 for (ixyz = 0; ixyz < nxyz; ixyz++)
02256 ssac[ixyz] -= y[ixyz];
02257
02258 volume_read ("ss0", y, nxyz);
02259 for (ixyz = 0; ixyz < nxyz; ixyz++)
02260 ssac[ixyz] -= y[ixyz];
02261
02262
02263 /*----- protection against round-off error -----*/
02264 for (ixyz = 0; ixyz < nxyz; ixyz++)
02265 if (ssac[ixyz] < 0.0) ssac[ixyz] = 0.0;
02266
02267 /*----- save factor A*C sum of squares -----*/
02268 if (nvoxel > 0)
02269 printf ("SSAC = %f \n", ssac[nvoxel-1]);
02270 volume_write ("ssac", ssac, nxyz);
02271
02272 /*----- release memory -----*/
02273 free (y); y = NULL;
02274 free (ssac); ssac = NULL;
02275
02276 }
|
|
|
Definition at line 2073 of file 3dANOVA3.c. References ANOVA_error(), free, malloc, anova_options::nvoxel, anova_options::nxyz, volume_read(), and volume_write(). Referenced by calculate_anova().
02074 {
02075 float * y = NULL; /* input data pointer */
02076 float * ssb = NULL; /* output data pointer */
02077 int ixyz, nxyz; /* voxel counters */
02078 int nvoxel; /* output voxel # */
02079
02080
02081 /*----- assign local variables -----*/
02082 nxyz = option_data->nxyz;
02083 nvoxel = option_data->nvoxel;
02084
02085 /*----- allocate memory space for calculations -----*/
02086 ssb = (float *) malloc (sizeof(float)*nxyz);
02087 y = (float *) malloc (sizeof(float)*nxyz);
02088 if ((y == NULL) || (ssb == NULL))
02089 ANOVA_error ("unable to allocate sufficient memory");
02090
02091
02092 /*----- calculate SSB -----*/
02093 volume_read ("ssj", ssb, nxyz);
02094
02095 volume_read ("ss0", y, nxyz);
02096 for (ixyz = 0; ixyz < nxyz; ixyz++)
02097 ssb[ixyz] -= y[ixyz];
02098
02099
02100 /*----- protection against round-off error -----*/
02101 for (ixyz = 0; ixyz < nxyz; ixyz++)
02102 if (ssb[ixyz] < 0.0) ssb[ixyz] = 0.0;
02103
02104 /*----- save factor B sum of squares -----*/
02105 if (nvoxel > 0)
02106 printf ("SSB = %f \n", ssb[nvoxel-1]);
02107 volume_write ("ssb", ssb, nxyz);
02108
02109 /*----- release memory -----*/
02110 free (y); y = NULL;
02111 free (ssb); ssb = NULL;
02112
02113 }
|
|
|
Definition at line 2338 of file 3dANOVA3.c. References ANOVA_error(), free, malloc, anova_options::nvoxel, anova_options::nxyz, volume_read(), and volume_write(). Referenced by calculate_anova().
02339 {
02340 float * y = NULL; /* input data pointer */
02341 float * ssbc = NULL; /* output data pointer */
02342 int ixyz, nxyz; /* voxel counters */
02343 int nvoxel; /* output voxel # */
02344
02345
02346 /*----- assign local variables -----*/
02347 nxyz = option_data->nxyz;
02348 nvoxel = option_data->nvoxel;
02349
02350 /*----- allocate memory space for calculations -----*/
02351 ssbc = (float *) malloc (sizeof(float)*nxyz);
02352 y = (float *) malloc (sizeof(float)*nxyz);
02353 if ((y == NULL) || (ssbc == NULL))
02354 ANOVA_error ("unable to allocate sufficient memory");
02355
02356
02357 /*----- calculate SSBC -----*/
02358 volume_read ("ssjk", ssbc, nxyz);
02359
02360 volume_read ("ssb", y, nxyz);
02361 for (ixyz = 0; ixyz < nxyz; ixyz++)
02362 ssbc[ixyz] -= y[ixyz];
02363
02364 volume_read ("ssc", y, nxyz);
02365 for (ixyz = 0; ixyz < nxyz; ixyz++)
02366 ssbc[ixyz] -= y[ixyz];
02367
02368 volume_read ("ss0", y, nxyz);
02369 for (ixyz = 0; ixyz < nxyz; ixyz++)
02370 ssbc[ixyz] -= y[ixyz];
02371
02372
02373 /*----- protection against round-off error -----*/
02374 for (ixyz = 0; ixyz < nxyz; ixyz++)
02375 if (ssbc[ixyz] < 0.0) ssbc[ixyz] = 0.0;
02376
02377 /*----- save factor B*C sum of squares -----*/
02378 if (nvoxel > 0)
02379 printf ("SSBC = %f \n", ssbc[nvoxel-1]);
02380 volume_write ("ssbc", ssbc, nxyz);
02381
02382 /*----- release memory -----*/
02383 free (y); y = NULL;
02384 free (ssbc); ssbc = NULL;
02385
02386 }
|
|
|
Definition at line 2471 of file 3dANOVA3.c. References ANOVA_error(), free, malloc, anova_options::n, anova_options::nvoxel, anova_options::nxyz, volume_read(), and volume_write(). Referenced by calculate_anova().
02472 {
02473 float * y = NULL; /* input data pointer */
02474 float * ssbca = NULL; /* output data pointer */
02475 int ixyz, nxyz; /* voxel counters */
02476 int nvoxel; /* output voxel # */
02477
02478
02479 /*----- assign local variables -----*/
02480 nxyz = option_data->nxyz;
02481 nvoxel = option_data->nvoxel;
02482
02483 /*----- allocate memory space for calculations -----*/
02484 ssbca = (float *) malloc (sizeof(float)*nxyz);
02485 y = (float *) malloc (sizeof(float)*nxyz);
02486 if ((y == NULL) || (ssbca == NULL))
02487 ANOVA_error ("unable to allocate sufficient memory");
02488
02489
02490 /*----- calculate SSBC(A) -----*/
02491 volume_read ("ssto", ssbca, nxyz);
02492
02493 if (option_data->n > 1)
02494 {
02495 volume_read ("sse", y, nxyz);
02496 for (ixyz = 0; ixyz < nxyz; ixyz++)
02497 ssbca[ixyz] -= y[ixyz];
02498 }
02499
02500 volume_read ("ssa", y, nxyz);
02501 for (ixyz = 0; ixyz < nxyz; ixyz++)
02502 ssbca[ixyz] -= y[ixyz];
02503
02504 volume_read ("ssb", y, nxyz);
02505 for (ixyz = 0; ixyz < nxyz; ixyz++)
02506 ssbca[ixyz] -= y[ixyz];
02507
02508 volume_read ("ssca", y, nxyz);
02509 for (ixyz = 0; ixyz < nxyz; ixyz++)
02510 ssbca[ixyz] -= y[ixyz];
02511
02512 volume_read ("ssab", y, nxyz);
02513 for (ixyz = 0; ixyz < nxyz; ixyz++)
02514 ssbca[ixyz] -= y[ixyz];
02515
02516
02517 /*----- protection against round-off error -----*/
02518 for (ixyz = 0; ixyz < nxyz; ixyz++)
02519 if (ssbca[ixyz] < 0.0) ssbca[ixyz] = 0.0;
02520
02521 /*----- save B*C(A) interaction sum of squares -----*/
02522 if (nvoxel > 0)
02523 printf ("SSBC(A) = %f \n", ssbca[nvoxel-1]);
02524 volume_write ("ssbca", ssbca, nxyz);
02525
02526 /*----- release memory -----*/
02527 free (y); y = NULL;
02528 free (ssbca); ssbca = NULL;
02529
02530 }
|
|
|
Definition at line 2122 of file 3dANOVA3.c. References ANOVA_error(), free, malloc, anova_options::nvoxel, anova_options::nxyz, volume_read(), and volume_write(). Referenced by calculate_anova().
02123 {
02124 float * y = NULL; /* input data pointer */
02125 float * ssc = NULL; /* output data pointer */
02126 int ixyz, nxyz; /* voxel counters */
02127 int nvoxel; /* output voxel # */
02128
02129
02130 /*----- assign local variables -----*/
02131 nxyz = option_data->nxyz;
02132 nvoxel = option_data->nvoxel;
02133
02134 /*----- allocate memory space for calculations -----*/
02135 ssc = (float *) malloc (sizeof(float)*nxyz);
02136 y = (float *) malloc (sizeof(float)*nxyz);
02137 if ((y == NULL) || (ssc == NULL))
02138 ANOVA_error ("unable to allocate sufficient memory");
02139
02140
02141 /*----- calculate SSC -----*/
02142 volume_read ("ssk", ssc, nxyz);
02143
02144 volume_read ("ss0", y, nxyz);
02145 for (ixyz = 0; ixyz < nxyz; ixyz++)
02146 ssc[ixyz] -= y[ixyz];
02147
02148
02149 /*----- protection against round-off error -----*/
02150 for (ixyz = 0; ixyz < nxyz; ixyz++)
02151 if (ssc[ixyz] < 0.0) ssc[ixyz] = 0.0;
02152
02153 /*----- save factor C sum of squares -----*/
02154 if (nvoxel > 0)
02155 printf ("SSC = %f \n", ssc[nvoxel-1]);
02156 volume_write ("ssc", ssc, nxyz);
02157
02158 /*----- release memory -----*/
02159 free (y); y = NULL;
02160 free (ssc); ssc = NULL;
02161
02162 }
|
|
|
Definition at line 2285 of file 3dANOVA3.c. References ANOVA_error(), free, malloc, anova_options::nvoxel, anova_options::nxyz, volume_read(), and volume_write(). Referenced by calculate_anova().
02286 {
02287 float * y = NULL; /* input data pointer */
02288 float * ssca = NULL; /* output data pointer */
02289 int ixyz, nxyz; /* voxel counters */
02290 int nvoxel; /* output voxel # */
02291
02292
02293 /*----- assign local variables -----*/
02294 nxyz = option_data->nxyz;
02295 nvoxel = option_data->nvoxel;
02296
02297 /*----- allocate memory space for calculations -----*/
02298 ssca = (float *) malloc (sizeof(float)*nxyz);
02299 y = (float *) malloc (sizeof(float)*nxyz);
02300 if ((y == NULL) || (ssca == NULL))
02301 ANOVA_error ("unable to allocate sufficient memory");
02302
02303
02304 /*----- calculate SSCA -----*/
02305 volume_read ("ssik", ssca, nxyz);
02306
02307 volume_read ("ssa", y, nxyz);
02308 for (ixyz = 0; ixyz < nxyz; ixyz++)
02309 ssca[ixyz] -= y[ixyz];
02310
02311 volume_read ("ss0", y, nxyz);
02312 for (ixyz = 0; ixyz < nxyz; ixyz++)
02313 ssca[ixyz] -= y[ixyz];
02314
02315
02316 /*----- protection against round-off error -----*/
02317 for (ixyz = 0; ixyz < nxyz; ixyz++)
02318 if (ssca[ixyz] < 0.0) ssca[ixyz] = 0.0;
02319
02320 /*----- save factor C(A) sum of squares -----*/
02321 if (nvoxel > 0)
02322 printf ("SSC(A) = %f \n", ssca[nvoxel-1]);
02323 volume_write ("ssca", ssca, nxyz);
02324
02325 /*----- release memory -----*/
02326 free (y); y = NULL;
02327 free (ssca); ssca = NULL;
02328
02329 }
|
|
|
Definition at line 1971 of file 3dANOVA3.c. References ANOVA_error(), free, malloc, anova_options::nvoxel, anova_options::nxyz, volume_read(), and volume_write(). Referenced by calculate_anova().
01972 {
01973 float * y = NULL; /* input data pointer */
01974 float * sse = NULL; /* sse data pointer */
01975 int ixyz, nxyz; /* voxel counters */
01976 int nvoxel; /* output voxel # */
01977
01978
01979 /*----- assign local variables -----*/
01980 nxyz = option_data->nxyz;
01981 nvoxel = option_data->nvoxel;
01982
01983 /*----- allocate memory space for calculations -----*/
01984 sse = (float *) malloc (sizeof(float)*nxyz);
01985 y = (float *) malloc (sizeof(float)*nxyz);
01986 if ((y == NULL) || (sse == NULL))
01987 ANOVA_error ("unable to allocate sufficient memory");
01988
01989
01990 /*----- calculate SSE -----*/
01991 volume_read ("ssto", sse, nxyz);
01992
01993 volume_read ("ssijk", y, nxyz);
01994 for (ixyz = 0; ixyz < nxyz; ixyz++)
01995 sse[ixyz] -= y[ixyz];
01996
01997 volume_read ("ss0", y, nxyz);
01998 for (ixyz = 0; ixyz < nxyz; ixyz++)
01999 sse[ixyz] += y[ixyz];
02000
02001
02002 /*----- protection against round-off error -----*/
02003 for (ixyz = 0; ixyz < nxyz; ixyz++)
02004 if (sse[ixyz] < 0.0) sse[ixyz] = 0.0;
02005
02006 /*----- save error sum of squares -----*/
02007 if (nvoxel > 0)
02008 printf ("SSE = %f \n", sse[nvoxel-1]);
02009 volume_write ("sse", sse, nxyz);
02010
02011 /*----- release memory -----*/
02012 free (y); y = NULL;
02013 free (sse); sse = NULL;
02014
02015 }
|
|
|
Definition at line 1375 of file 3dANOVA3.c. References anova_options::a, a, ANOVA_error(), anova_options::b, anova_options::c, c, calculate_sum(), free, i, malloc, anova_options::n, anova_options::nvoxel, anova_options::nxyz, volume_write(), and volume_zero(). Referenced by calculate_anova().
01376 {
01377 float * ssi = NULL; /* pointer to output data */
01378 float * ysum = NULL; /* pointer to sum over observations */
01379 int a; /* number of levels for factor A */
01380 int b; /* number of levels for factor B */
01381 int c; /* number of levels for factor C */
01382 int n; /* number of observations per cell */
01383 int i; /* index for factor A levels */
01384 int ixyz, nxyz; /* voxel counters */
01385 int nvoxel; /* output voxel # */
01386 int nval; /* divisor of sum */
01387 char filename[MAX_NAME_LENGTH]; /* name of output file */
01388
01389
01390 /*----- initialize local variables -----*/
01391 a = option_data->a;
01392 b = option_data->b;
01393 c = option_data->c;
01394 n = option_data->n;
01395 nxyz = option_data->nxyz;
01396 nvoxel = option_data->nvoxel;
01397 nval = b * c * n;
01398
01399 /*----- allocate memory space for calculations -----*/
01400 ssi = (float *) malloc(sizeof(float)*nxyz);
01401 ysum = (float *) malloc(sizeof(float)*nxyz);
01402 if ((ssi == NULL) || (ysum == NULL))
01403 ANOVA_error ("unable to allocate sufficient memory");
01404
01405 volume_zero (ssi, nxyz);
01406
01407 /*----- loop over levels of factor A -----*/
01408 for (i = 0; i < a; i++)
01409 {
01410 /*----- sum over observations -----*/
01411 calculate_sum (option_data, i, -1, -1, ysum);
01412
01413 /*----- add to ssi -----*/
01414 for (ixyz = 0; ixyz < nxyz; ixyz++)
01415 ssi[ixyz] += ysum[ixyz] * ysum[ixyz] / nval;
01416 }
01417
01418 /*----- save the sum -----*/
01419 if (nvoxel > 0)
01420 printf ("SSI = %f \n", ssi[nvoxel-1]);
01421 strcpy (filename, "ssi");
01422 volume_write (filename, ssi, nxyz);
01423
01424
01425 /*----- release memory -----*/
01426 free (ysum); ysum = NULL;
01427 free (ssi); ssi = NULL;
01428
01429 }
|
|
|
Definition at line 1564 of file 3dANOVA3.c. References anova_options::a, a, ANOVA_error(), anova_options::b, anova_options::c, c, calculate_sum(), free, i, malloc, anova_options::n, anova_options::nvoxel, anova_options::nxyz, volume_write(), and volume_zero(). Referenced by calculate_anova().
01565 {
01566 float * ssij = NULL; /* pointer to output data */
01567 float * ysum = NULL; /* pointer to sum over observations */
01568 int a; /* number of levels for factor A */
01569 int b; /* number of levels for factor B */
01570 int c; /* number of levels for factor C */
01571 int n; /* number of observations per cell */
01572 int i, j; /* indices for factor A and B levels */
01573 int ixyz, nxyz; /* voxel counters */
01574 int nvoxel; /* output voxel # */
01575 int nval; /* divisor of sum */
01576 char filename[MAX_NAME_LENGTH]; /* name of output file */
01577
01578
01579 /*----- initialize local variables -----*/
01580 a = option_data->a;
01581 b = option_data->b;
01582 c = option_data->c;
01583 n = option_data->n;
01584 nxyz = option_data->nxyz;
01585 nvoxel = option_data->nvoxel;
01586 nval = c * n;
01587
01588 /*----- allocate memory space for calculations -----*/
01589 ssij = (float *) malloc(sizeof(float)*nxyz);
01590 ysum = (float *) malloc(sizeof(float)*nxyz);
01591 if ((ssij == NULL) || (ysum == NULL))
01592 ANOVA_error ("unable to allocate sufficient memory");
01593
01594 volume_zero (ssij, nxyz);
01595
01596 /*----- loop over levels of factor A -----*/
01597 for (i = 0; i < a; i++)
01598 {
01599 /*----- loop over levels of factor B -----*/
01600 for (j = 0; j < b; j++)
01601 {
01602 /*----- sum over observations -----*/
01603 calculate_sum (option_data, i, j, -1, ysum);
01604
01605 /*----- add to ssij -----*/
01606 for (ixyz = 0; ixyz < nxyz; ixyz++)
01607 ssij[ixyz] += ysum[ixyz] * ysum[ixyz] / nval;
01608 }
01609 }
01610
01611 /*----- save the sum -----*/
01612 if (nvoxel > 0)
01613 printf ("SSIJ = %f \n", ssij[nvoxel-1]);
01614 strcpy (filename, "ssij");
01615 volume_write (filename, ssij, nxyz);
01616
01617
01618 /*----- release memory -----*/
01619 free (ysum); ysum = NULL;
01620 free (ssij); ssij = NULL;
01621
01622 }
|
|
|
Definition at line 1765 of file 3dANOVA3.c. References anova_options::a, a, ANOVA_error(), anova_options::b, anova_options::c, c, calculate_sum(), free, i, malloc, anova_options::n, anova_options::nvoxel, anova_options::nxyz, read_afni_data(), volume_write(), volume_zero(), and anova_options::xname. Referenced by calculate_anova().
01766 {
01767 float * ssijk = NULL; /* pointer to output data */
01768 float * ysum = NULL; /* pointer to sum over observations */
01769 int a; /* number of levels for factor A */
01770 int b; /* number of levels for factor B */
01771 int c; /* number of levels for factor C */
01772 int n; /* number of observations per cell */
01773 int i, j, k; /* indices for factor levels */
01774 int ixyz, nxyz; /* voxel counters */
01775 int nvoxel; /* output voxel # */
01776 int nval; /* divisor of sum */
01777 char filename[MAX_NAME_LENGTH]; /* name of output file */
01778
01779
01780 /*----- initialize local variables -----*/
01781 a = option_data->a;
01782 b = option_data->b;
01783 c = option_data->c;
01784 n = option_data->n;
01785 nxyz = option_data->nxyz;
01786 nvoxel = option_data->nvoxel;
01787 nval = n;
01788
01789 /*----- allocate memory space for calculations -----*/
01790 ssijk = (float *) malloc(sizeof(float)*nxyz);
01791 ysum = (float *) malloc(sizeof(float)*nxyz);
01792 if ((ssijk == NULL) || (ysum == NULL))
01793 ANOVA_error ("unable to allocate sufficient memory");
01794
01795 volume_zero (ssijk, nxyz);
01796
01797 /*----- loop over levels of factor A -----*/
01798 for (i = 0; i < a; i++)
01799 {
01800 /*----- loop over levels of factor B -----*/
01801 for (j = 0; j < b; j++)
01802 {
01803 /*----- loop over levels of factor C -----*/
01804 for (k = 0; k < c; k++)
01805 {
01806 /*----- sum over observations -----*/
01807 if (n != 1)
01808 calculate_sum (option_data, i, j, k, ysum);
01809 else
01810 {
01811 read_afni_data (option_data,
01812 option_data->xname[i][j][k][0], ysum);
01813 if (nvoxel > 0)
01814 printf ("y[%d][%d][%d][.] = %f \n",
01815 i+1, j+1, k+1, ysum[nvoxel-1]);
01816 }
01817
01818 /*----- add to ssijk -----*/
01819 for (ixyz = 0; ixyz < nxyz; ixyz++)
01820 ssijk[ixyz] += ysum[ixyz] * ysum[ixyz] / nval;
01821 }
01822 }
01823 }
01824
01825 /*----- save the sum -----*/
01826 if (nvoxel > 0)
01827 printf ("SSIJK = %f \n", ssijk[nvoxel-1]);
01828 strcpy (filename, "ssijk");
01829 volume_write (filename, ssijk, nxyz);
01830
01831
01832 /*----- release memory -----*/
01833 free (ysum); ysum = NULL;
01834 free (ssijk); ssijk = NULL;
01835
01836 }
|
|
|
Definition at line 1845 of file 3dANOVA3.c. References anova_options::a, a, ANOVA_error(), anova_options::b, anova_options::c, c, free, i, malloc, anova_options::n, anova_options::nvoxel, anova_options::nxyz, read_afni_data(), volume_write(), volume_zero(), and anova_options::xname. Referenced by calculate_anova().
01846 {
01847 float * ssijkm = NULL; /* pointer to output data */
01848 float * y = NULL; /* pointer to input data */
01849 int i; /* factor A level index */
01850 int j; /* factor B level index */
01851 int k; /* factor C level index */
01852 int m; /* observation number index */
01853 int a; /* number of levels for factor A */
01854 int b; /* number of levels for factor B */
01855 int c; /* number of levels for factor C */
01856 int n; /* number of observations per cell */
01857 int ixyz, nxyz; /* voxel counters */
01858 int nvoxel; /* output voxel # */
01859 float yval; /* temporary float value */
01860
01861
01862 /*----- initialize local variables -----*/
01863 a = option_data->a;
01864 b = option_data->b;
01865 c = option_data->c;
01866 n = option_data->n;
01867 nxyz = option_data->nxyz;
01868 nvoxel = option_data->nvoxel;
01869
01870 /*----- allocate memory space for calculations -----*/
01871 ssijkm = (float *) malloc(sizeof(float)*nxyz);
01872 y = (float *) malloc(sizeof(float)*nxyz);
01873 if ((ssijkm == NULL) || (y == NULL))
01874 ANOVA_error ("unable to allocate sufficient memory");
01875
01876
01877 volume_zero (ssijkm, nxyz);
01878
01879 for (i = 0; i < a; i++)
01880 {
01881 for (j = 0; j < b; j++)
01882 {
01883 for (k = 0; k < c; k++)
01884 {
01885 for (m = 0; m < n; m++)
01886 {
01887 read_afni_data (option_data,
01888 option_data->xname[i][j][k][m], y);
01889 if (nvoxel > 0)
01890 printf ("y[%d][%d][%d][%d] = %f \n",
01891 i+1, j+1, k+1, m+1, y[nvoxel-1]);
01892
01893 for (ixyz = 0; ixyz < nxyz; ixyz++)
01894 ssijkm[ixyz] += y[ixyz] * y[ixyz];
01895 }
01896 }
01897 }
01898 }
01899
01900
01901 /*----- save the sum -----*/
01902 if (nvoxel > 0)
01903 printf ("SSIJKM = %f \n", ssijkm[nvoxel-1]);
01904 volume_write ("ssijkm", ssijkm, nxyz);
01905
01906 /*----- release memory -----*/
01907 free (y); y = NULL;
01908 free (ssijkm); ssijkm = NULL;
01909
01910 }
|
|
|
Definition at line 1631 of file 3dANOVA3.c. References anova_options::a, a, ANOVA_error(), anova_options::b, anova_options::c, c, calculate_sum(), free, i, malloc, anova_options::n, anova_options::nvoxel, anova_options::nxyz, volume_write(), and volume_zero(). Referenced by calculate_anova().
01632 {
01633 float * ssik = NULL; /* pointer to output data */
01634 float * ysum = NULL; /* pointer to sum over observations */
01635 int a; /* number of levels for factor A */
01636 int b; /* number of levels for factor B */
01637 int c; /* number of levels for factor C */
01638 int n; /* number of observations per cell */
01639 int i, k; /* indices for factor A and C levels */
01640 int ixyz, nxyz; /* voxel counters */
01641 int nvoxel; /* output voxel # */
01642 int nval; /* divisor of sum */
01643 char filename[MAX_NAME_LENGTH]; /* name of output file */
01644
01645
01646 /*----- initialize local variables -----*/
01647 a = option_data->a;
01648 b = option_data->b;
01649 c = option_data->c;
01650 n = option_data->n;
01651 nxyz = option_data->nxyz;
01652 nvoxel = option_data->nvoxel;
01653 nval = b * n;
01654
01655 /*----- allocate memory space for calculations -----*/
01656 ssik = (float *) malloc(sizeof(float)*nxyz);
01657 ysum = (float *) malloc(sizeof(float)*nxyz);
01658 if ((ssik == NULL) || (ysum == NULL))
01659 ANOVA_error ("unable to allocate sufficient memory");
01660
01661 volume_zero (ssik, nxyz);
01662
01663 /*----- loop over levels of factor A -----*/
01664 for (i = 0; i < a; i++)
01665 {
01666 /*----- loop over levels of factor C -----*/
01667 for (k = 0; k < c; k++)
01668 {
01669 /*----- sum over observations -----*/
01670 calculate_sum (option_data, i, -1, k, ysum);
01671
01672 /*----- add to ssij -----*/
01673 for (ixyz = 0; ixyz < nxyz; ixyz++)
01674 ssik[ixyz] += ysum[ixyz] * ysum[ixyz] / nval;
01675 }
01676 }
01677
01678 /*----- save the sum -----*/
01679 if (nvoxel > 0)
01680 printf ("SSIK = %f \n", ssik[nvoxel-1]);
01681 strcpy (filename, "ssik");
01682 volume_write (filename, ssik, nxyz);
01683
01684
01685 /*----- release memory -----*/
01686 free (ysum); ysum = NULL;
01687 free (ssik); ssik = NULL;
01688
01689 }
|
|
|
Definition at line 1438 of file 3dANOVA3.c. References anova_options::a, a, ANOVA_error(), anova_options::b, anova_options::c, c, calculate_sum(), free, malloc, anova_options::n, anova_options::nvoxel, anova_options::nxyz, volume_write(), and volume_zero(). Referenced by calculate_anova().
01439 {
01440 float * ssj = NULL; /* pointer to output data */
01441 float * ysum = NULL; /* pointer to sum over observations */
01442 int a; /* number of levels for factor A */
01443 int b; /* number of levels for factor B */
01444 int c; /* number of levels for factor C */
01445 int n; /* number of observations per cell */
01446 int j; /* index for factor B levels */
01447 int ixyz, nxyz; /* voxel counters */
01448 int nvoxel; /* output voxel # */
01449 int nval; /* divisor of sum */
01450 char filename[MAX_NAME_LENGTH]; /* name of output file */
01451
01452
01453 /*----- initialize local variables -----*/
01454 a = option_data->a;
01455 b = option_data->b;
01456 c = option_data->c;
01457 n = option_data->n;
01458 nxyz = option_data->nxyz;
01459 nvoxel = option_data->nvoxel;
01460 nval = a * c * n;
01461
01462 /*----- allocate memory space for calculations -----*/
01463 ssj = (float *) malloc(sizeof(float)*nxyz);
01464 ysum = (float *) malloc(sizeof(float)*nxyz);
01465 if ((ssj == NULL) || (ysum == NULL))
01466 ANOVA_error ("unable to allocate sufficient memory");
01467
01468 volume_zero (ssj, nxyz);
01469
01470 /*----- loop over levels of factor B -----*/
01471 for (j = 0; j < b; j++)
01472 {
01473 /*----- sum over observations -----*/
01474 calculate_sum (option_data, -1, j, -1, ysum);
01475
01476 /*----- add to ssj -----*/
01477 for (ixyz = 0; ixyz < nxyz; ixyz++)
01478 ssj[ixyz] += ysum[ixyz] * ysum[ixyz] / nval;
01479 }
01480
01481 /*----- save the sum -----*/
01482 if (nvoxel > 0)
01483 printf ("SSJ = %f \n", ssj[nvoxel-1]);
01484 strcpy (filename, "ssj");
01485 volume_write (filename, ssj, nxyz);
01486
01487
01488 /*----- release memory -----*/
01489 free (ysum); ysum = NULL;
01490 free (ssj); ssj = NULL;
01491
01492 }
|
|
|
Definition at line 1698 of file 3dANOVA3.c. References anova_options::a, a, ANOVA_error(), anova_options::b, anova_options::c, c, calculate_sum(), free, malloc, anova_options::n, anova_options::nvoxel, anova_options::nxyz, volume_write(), and volume_zero(). Referenced by calculate_anova().
01699 {
01700 float * ssjk = NULL; /* pointer to output data */
01701 float * ysum = NULL; /* pointer to sum over observations */
01702 int a; /* number of levels for factor A */
01703 int b; /* number of levels for factor B */
01704 int c; /* number of levels for factor C */
01705 int n; /* number of observations per cell */
01706 int j, k; /* indices for factor B and C levels */
01707 int ixyz, nxyz; /* voxel counters */
01708 int nvoxel; /* output voxel # */
01709 int nval; /* divisor of sum */
01710 char filename[MAX_NAME_LENGTH]; /* name of output file */
01711
01712
01713 /*----- initialize local variables -----*/
01714 a = option_data->a;
01715 b = option_data->b;
01716 c = option_data->c;
01717 n = option_data->n;
01718 nxyz = option_data->nxyz;
01719 nvoxel = option_data->nvoxel;
01720 nval = a * n;
01721
01722 /*----- allocate memory space for calculations -----*/
01723 ssjk = (float *) malloc(sizeof(float)*nxyz);
01724 ysum = (float *) malloc(sizeof(float)*nxyz);
01725 if ((ssjk == NULL) || (ysum == NULL))
01726 ANOVA_error ("unable to allocate sufficient memory");
01727
01728 volume_zero (ssjk, nxyz);
01729
01730 /*----- loop over levels of factor B -----*/
01731 for (j = 0; j < b; j++)
01732 {
01733 /*----- loop over levels of factor C -----*/
01734 for (k = 0; k < c; k++)
01735 {
01736 /*----- sum over observations -----*/
01737 calculate_sum (option_data, -1, j, k, ysum);
01738
01739 /*----- add to ssjk -----*/
01740 for (ixyz = 0; ixyz < nxyz; ixyz++)
01741 ssjk[ixyz] += ysum[ixyz] * ysum[ixyz] / nval;
01742 }
01743 }
01744
01745 /*----- save the sum -----*/
01746 if (nvoxel > 0)
01747 printf ("SSJK = %f \n", ssjk[nvoxel-1]);
01748 strcpy (filename, "ssjk");
01749 volume_write (filename, ssjk, nxyz);
01750
01751
01752 /*----- release memory -----*/
01753 free (ysum); ysum = NULL;
01754 free (ssjk); ssjk = NULL;
01755
01756 }
|
|
|
Definition at line 1501 of file 3dANOVA3.c. References anova_options::a, a, ANOVA_error(), anova_options::b, anova_options::c, c, calculate_sum(), free, malloc, anova_options::n, anova_options::nvoxel, anova_options::nxyz, volume_write(), and volume_zero(). Referenced by calculate_anova().
01502 {
01503 float * ssk = NULL; /* pointer to output data */
01504 float * ysum = NULL; /* pointer to sum over observations */
01505 int a; /* number of levels for factor A */
01506 int b; /* number of levels for factor B */
01507 int c; /* number of levels for factor C */
01508 int n; /* number of observations per cell */
01509 int k; /* index for factor C levels */
01510 int ixyz, nxyz; /* voxel counters */
01511 int nvoxel; /* output voxel # */
01512 int nval; /* divisor of sum */
01513 char filename[MAX_NAME_LENGTH]; /* name of output file */
01514
01515
01516 /*----- initialize local variables -----*/
01517 a = option_data->a;
01518 b = option_data->b;
01519 c = option_data->c;
01520 n = option_data->n;
01521 nxyz = option_data->nxyz;
01522 nvoxel = option_data->nvoxel;
01523 nval = a * b * n;
01524
01525 /*----- allocate memory space for calculations -----*/
01526 ssk = (float *) malloc(sizeof(float)*nxyz);
01527 ysum = (float *) malloc(sizeof(float)*nxyz);
01528 if ((ssk == NULL) || (ysum == NULL))
01529 ANOVA_error ("unable to allocate sufficient memory");
01530
01531 volume_zero (ssk, nxyz);
01532
01533 /*----- loop over levels of factor C -----*/
01534 for (k = 0; k < c; k++)
01535 {
01536 /*----- sum over observations -----*/
01537 calculate_sum (option_data, -1, -1, k, ysum);
01538
01539 /*----- add to ssk -----*/
01540 for (ixyz = 0; ixyz < nxyz; ixyz++)
01541 ssk[ixyz] += ysum[ixyz] * ysum[ixyz] / nval;
01542 }
01543
01544 /*----- save the sum -----*/
01545 if (nvoxel > 0)
01546 printf ("SSK = %f \n", ssk[nvoxel-1]);
01547 strcpy (filename, "ssk");
01548 volume_write (filename, ssk, nxyz);
01549
01550
01551 /*----- release memory -----*/
01552 free (ysum); ysum = NULL;
01553 free (ssk); ssk = NULL;
01554
01555 }
|
|
|
Definition at line 1919 of file 3dANOVA3.c. References ANOVA_error(), free, malloc, anova_options::n, anova_options::nvoxel, anova_options::nxyz, volume_read(), and volume_write(). Referenced by calculate_anova().
01920 {
01921 float * y = NULL; /* input data pointer */
01922 float * ssto = NULL; /* ssto data pointer */
01923 int ixyz, nxyz; /* voxel counters */
01924 int nvoxel; /* output voxel # */
01925
01926
01927 /*----- assign local variables -----*/
01928 nxyz = option_data->nxyz;
01929 nvoxel = option_data->nvoxel;
01930
01931 /*----- allocate memory space for calculations -----*/
01932 ssto = (float *) malloc (sizeof(float)*nxyz);
01933 y = (float *) malloc (sizeof(float)*nxyz);
01934 if ((y == NULL) || (ssto == NULL))
01935 ANOVA_error ("unable to allocate sufficient memory");
01936
01937
01938 /*----- calculate SSTO -----*/
01939 if (option_data->n != 1)
01940 volume_read ("ssijkm", ssto, nxyz);
01941 else
01942 volume_read ("ssijk", ssto, nxyz);
01943
01944 volume_read ("ss0", y, nxyz);
01945 for (ixyz = 0; ixyz < nxyz; ixyz++)
01946 ssto[ixyz] -= y[ixyz];
01947
01948
01949 /*----- protection against round-off error -----*/
01950 for (ixyz = 0; ixyz < nxyz; ixyz++)
01951 if (ssto[ixyz] < 0.0) ssto[ixyz] = 0.0;
01952
01953 /*----- save total sum of squares -----*/
01954 if (nvoxel > 0)
01955 printf ("SSTO = %f \n", ssto[nvoxel-1]);
01956 volume_write ("ssto", ssto, nxyz);
01957
01958 /*----- release memory -----*/
01959 free (y); y = NULL;
01960 free (ssto); ssto = NULL;
01961
01962 }
|
|
||||||||||||||||||||||||
|
Definition at line 1203 of file 3dANOVA3.c. References anova_options::a, a, ANOVA_error(), anova_options::b, anova_options::c, c, free, i, malloc, anova_options::n, anova_options::nvoxel, anova_options::nxyz, read_afni_data(), volume_zero(), and anova_options::xname. Referenced by calc_acontr_mean(), calculate_acontrasts(), calculate_adifferences(), calculate_ameans(), calculate_bcontrasts(), calculate_bdifferences(), calculate_bmeans(), calculate_ccontrasts(), calculate_cdifferences(), calculate_cmeans(), calculate_ss0(), calculate_ssi(), calculate_ssij(), calculate_ssijk(), calculate_ssik(), calculate_ssj(), calculate_ssjk(), calculate_ssk(), calculate_xcontrasts(), calculate_xdifferences(), and calculate_xmeans().
01205 {
01206 float * y = NULL; /* pointer to input data */
01207 int i, itop, ibot; /* factor A level index */
01208 int j, jtop, jbot; /* factor B level index */
01209 int k, ktop, kbot; /* factor C level index */
01210 int m; /* observation number index */
01211 int a; /* number of levels for factor A */
01212 int b; /* number of levels for factor B */
01213 int c; /* number of levels for factor C */
01214 int n; /* number of observations per cell */
01215 int ixyz, nxyz; /* voxel counters */
01216 int nvoxel; /* output voxel # */
01217 char sum_label[MAX_NAME_LENGTH]; /* name of sum for print to screen */
01218 char str[MAX_NAME_LENGTH]; /* temporary string */
01219
01220
01221 /*----- initialize local variables -----*/
01222 a = option_data->a;
01223 b = option_data->b;
01224 c = option_data->c;
01225 n = option_data->n;
01226 nxyz = option_data->nxyz;
01227 nvoxel = option_data->nvoxel;
01228
01229 /*----- allocate memory space for calculations -----*/
01230 y = (float *) malloc(sizeof(float)*nxyz);
01231 if (y == NULL) ANOVA_error ("unable to allocate sufficient memory");
01232
01233
01234 /*----- set up summation limits -----*/
01235 if (ii < 0)
01236 { ibot = 0; itop = a; }
01237 else
01238 { ibot = ii; itop = ii+1; }
01239
01240 if (jj < 0)
01241 { jbot = 0; jtop = b; }
01242 else
01243 { jbot = jj; jtop = jj+1; }
01244
01245 if (kk < 0)
01246 { kbot = 0; ktop = c; }
01247 else
01248 { kbot = kk; ktop = kk+1; }
01249
01250
01251 volume_zero (ysum, nxyz);
01252
01253 /*----- loop over levels of factor A -----*/
01254 for (i = ibot; i < itop; i++)
01255 {
01256 /*----- loop over levels of factor B -----*/
01257 for (j = jbot; j < jtop; j++)
01258 {
01259 /*----- loop over levels of factor C -----*/
01260 for (k = kbot; k < ktop; k++)
01261 {
01262 /*----- sum observations within this cell -----*/
01263 for (m = 0; m < n; m++)
01264 {
01265 read_afni_data (option_data,
01266 option_data->xname[i][j][k][m], y);
01267 if (nvoxel > 0)
01268 printf ("y[%d][%d][%d][%d] = %f \n",
01269 i+1, j+1, k+1, m+1, y[nvoxel-1]);
01270 for (ixyz = 0; ixyz < nxyz; ixyz++)
01271 ysum[ixyz] += y[ixyz];
01272 } /* m */
01273 } /* k */
01274 } /* j */
01275 } /* i */
01276
01277
01278 /*----- print the sum for this cell -----*/
01279 if (nvoxel > 0)
01280 {
01281 strcpy (sum_label, "y");
01282 if (ii < 0)
01283 strcat (sum_label, "[.]");
01284 else
01285 {
01286 sprintf (str, "[%d]", ii+1);
01287 strcat (sum_label, str);
01288 }
01289 if (jj < 0)
01290 strcat (sum_label, "[.]");
01291 else
01292 {
01293 sprintf (str, "[%d]", jj+1);
01294 strcat (sum_label, str);
01295 }
01296 if (kk < 0)
01297 strcat (sum_label, "[.]");
01298 else
01299 {
01300 sprintf (str, "[%d]", kk+1);
01301 strcat (sum_label, str);
01302 }
01303 printf ("%s[.] = %f \n", sum_label, ysum[nvoxel-1]);
01304 }
01305
01306 /*----- release memory -----*/
01307 free (y); y = NULL;
01308
01309 }
|
|
|
Definition at line 3954 of file 3dANOVA3.c. References anova_options::a, a, ANOVA_error(), anova_options::b, anova_options::c, c, calculate_sum(), free, malloc, anova_options::n, anova_options::num_xdiffs, anova_options::nvoxel, anova_options::nxyz, volume_read(), write_afni_data(), anova_options::xdiffs, and anova_options::xdname. Referenced by analyze_results().
03955 {
03956 const float EPSILON = 1.0e-10; /* protect against divide by zero */
03957 float * diff = NULL; /* pointer to est. diff. in means */
03958 float * tdiff = NULL; /* pointer to t-statistic data */
03959 int a; /* number of levels for factor A */
03960 int b; /* number of levels for factor B */
03961 int c; /* number of levels for factor C */
03962 int n; /* number of observations per cell */
03963 int ixyz, nxyz; /* voxel counters */
03964 int nvoxel; /* output voxel # */
03965 int num_diffs; /* number of user requested diffs. */
03966 int idiff; /* index for requested differences */
03967 int ia, ib, ic, ja, jb, jc; /* cell indices */
03968 int df; /* degrees of freedom for t-test */
03969 float fval; /* for calculating std. dev. */
03970 float stddev; /* est. std. dev. of difference */
03971 char filename[MAX_NAME_LENGTH]; /* input file name */
03972
03973
03974 /*----- initialize local variables -----*/
03975 a = option_data->a;
03976 b = option_data->b;
03977 c = option_data->c;
03978 n = option_data->n;
03979 df = a * b * c * (n-1);
03980 num_diffs = option_data->num_xdiffs;
03981 nxyz = option_data->nxyz;
03982 nvoxel = option_data->nvoxel;
03983
03984 /*----- allocate memory space for calculations -----*/
03985 diff = (float *) malloc(sizeof(float)*nxyz);
03986 tdiff = (float *) malloc(sizeof(float)*nxyz);
03987 if ((diff == NULL) || (tdiff == NULL))
03988 ANOVA_error ("unable to allocate sufficient memory");
03989
03990 /*----- loop over user specified treatment differences -----*/
03991 for (idiff = 0; idiff < num_diffs; idiff++)
03992 {
03993
03994 /*----- read first treatment level mean -----*/
03995 ia = option_data->xdiffs[idiff][0][0];
03996 ib = option_data->xdiffs[idiff][0][1];
03997 ic = option_data->xdiffs[idiff][0][2];
03998 calculate_sum (option_data, ia, ib, ic, diff);
03999 for (ixyz = 0; ixyz < nxyz; ixyz++)
04000 diff[ixyz] = diff[ixyz] / n;
04001
04002 /*----- subtract second treatment level mean -----*/
04003 ja = option_data->xdiffs[idiff][1][0];
04004 jb = option_data->xdiffs[idiff][1][1];
04005 jc = option_data->xdiffs[idiff][1][2];
04006 calculate_sum (option_data, ja, jb, jc, tdiff);
04007 for (ixyz = 0; ixyz < nxyz; ixyz++)
04008 diff[ixyz] -= tdiff[ixyz] / n;
04009 if (nvoxel > 0)
04010 printf ("Difference Cell[%d][%d][%d] - Cell[%d][%d][%d] = %f \n",
04011 ia+1, ib+1, ic+1, ja+1, jb+1, jc+1, diff[nvoxel-1]);
04012
04013 /*----- divide by estimated standard deviation of difference -----*/
04014 volume_read ("sse", tdiff, nxyz);
04015 fval = (1.0 / df) * (2.0 / n);
04016 for (ixyz = 0; ixyz < nxyz; ixyz++)
04017 {
04018 stddev = sqrt (tdiff[ixyz] * fval);
04019 if (stddev < EPSILON)
04020 tdiff[ixyz] = 0.0;
04021 else
04022 tdiff[ixyz] = diff[ixyz] / stddev;
04023 }
04024
04025 if (nvoxel > 0)
04026 printf ("t-stat for Cell[%d][%d][%d] - Cell[%d][%d][%d] = %f \n",
04027 ia+1, ib+1, ic+1, ja+1, jb+1, jc+1, tdiff[nvoxel-1]);
04028
04029 /*----- write out afni data file -----*/
04030 write_afni_data (option_data, option_data->xdname[idiff],
04031 diff, tdiff, df, 0);
04032
04033 }
04034
04035 /*----- release memory -----*/
04036 free (tdiff); tdiff = NULL;
04037 free (diff); diff = NULL;
04038
04039 }
|
|
|
Definition at line 3558 of file 3dANOVA3.c. References anova_options::a, a, ANOVA_error(), anova_options::b, anova_options::c, c, calculate_sum(), free, malloc, anova_options::n, anova_options::nt, anova_options::num_xmeans, anova_options::nvoxel, anova_options::nxyz, volume_read(), write_afni_data(), anova_options::xmeans, and anova_options::xmname. Referenced by analyze_results().
03559 {
03560 const float EPSILON = 1.0e-10; /* protect against divide by zero */
03561 float * mean = NULL; /* pointer to treatment mean data */
03562 float * tmean = NULL; /* pointer to t-statistic data */
03563 int a; /* number of levels for factor A */
03564 int b; /* number of levels for factor B */
03565 int c; /* number of levels for factor C */
03566 int n; /* number of observations per cell */
03567 int ixyz, nxyz; /* voxel counters */
03568 int nvoxel; /* output voxel # */
03569 int nt; /* total number of observations */
03570 int num_means; /* number of user requested means */
03571 int imean; /* output mean option index */
03572 int alevel, blevel, clevel; /* factor level indices */
03573 int df; /* degrees of freedom for t-test */
03574 float fval; /* for calculating std. dev. */
03575 float stddev; /* est. std. dev. of cell mean */
03576 char filename[MAX_NAME_LENGTH]; /* input data file name */
03577
03578
03579 /*----- initialize local variables -----*/
03580 a = option_data->a;
03581 b = option_data->b;
03582 c = option_data->c;
03583 n = option_data->n;
03584 df = a * b * c * (n-1);
03585 nt = option_data->nt;
03586 num_means = option_data->num_xmeans;
03587 nxyz = option_data->nxyz;
03588 nvoxel = option_data->nvoxel;
03589
03590 /*----- allocate memory space for calculations -----*/
03591 mean = (float *) malloc(sizeof(float)*nxyz);
03592 tmean = (float *) malloc(sizeof(float)*nxyz);
03593 if ((mean == NULL) || (tmean == NULL))
03594 ANOVA_error ("unable to allocate sufficient memory");
03595
03596 /*----- loop over user specified treatment means -----*/
03597 for (imean = 0; imean < num_means; imean++)
03598 {
03599 alevel = option_data->xmeans[imean][0];
03600 blevel = option_data->xmeans[imean][1];
03601 clevel = option_data->xmeans[imean][2];
03602
03603 /*----- estimate factor mean for this treatment level -----*/
03604 calculate_sum (option_data, alevel, blevel, clevel, mean);
03605 for (ixyz = 0; ixyz < nxyz; ixyz++)
03606 mean[ixyz] = mean[ixyz] / n;
03607 if (nvoxel > 0)
03608 printf ("Mean of Cell[%d][%d][%d] = %f \n",
03609 alevel+1, blevel+1, clevel+1, mean[nvoxel-1]);
03610
03611 /*----- divide by estimated standard deviation of factor mean -----*/
03612 volume_read ("sse", tmean, nxyz);
03613 fval = (1.0 / df) * (1.0 / n);
03614 for (ixyz = 0; ixyz < nxyz; ixyz++)
03615 {
03616 stddev = sqrt(tmean[ixyz] * fval);
03617 if (stddev < EPSILON)
03618 tmean[ixyz] = 0.0;
03619 else
03620 tmean[ixyz] = mean[ixyz] / stddev;
03621 }
03622 if (nvoxel > 0)
03623 printf ("t-stat for Mean of Cell[%d][%d][%d] = %f \n",
03624 alevel+1, blevel+1, clevel+1, tmean[nvoxel-1]);
03625
03626 /*----- write out afni data file -----*/
03627 write_afni_data (option_data, option_data->xmname[imean],
03628 mean, tmean, df, 0);
03629
03630 }
03631
03632 /*----- release memory -----*/
03633 free (tmean); tmean = NULL;
03634 free (mean); mean = NULL;
03635 }
|
|
|
Definition at line 958 of file 3dANOVA3.c. References anova_options::a, ANOVA_error(), anova_options::b, anova_options::c, anova_options::model, anova_options::n, anova_options::nfa, anova_options::nfabc, anova_options::nfac, anova_options::nfb, anova_options::nfbc, anova_options::nfc, anova_options::num_acontr, anova_options::num_adiffs, anova_options::num_ameans, anova_options::num_bcontr, anova_options::num_bdiffs, anova_options::num_bmeans, anova_options::num_ccontr, anova_options::num_cdiffs, anova_options::num_cmeans, anova_options::num_xdiffs, and anova_options::num_xmeans.
00959 {
00960 int n;
00961
00962 /*----- check for valid inputs -----*/
00963 if (option_data->a < 2)
00964 ANOVA_error ("must specify number of factor A levels (a>1) ");
00965 if (option_data->b < 2)
00966 ANOVA_error ("must specify number of factor B levels (b>1) ");
00967 if (option_data->c < 2)
00968 ANOVA_error ("must specify number of factor C levels (c>1) ");
00969 if (option_data->n < 1) ANOVA_error ("sample size is too small");
00970
00971 n = option_data->n;
00972
00973 switch (option_data->model)
00974 {
00975 case 1:
00976 if (n == 1) ANOVA_error ("sample size is too small for Model 1");
00977 break;
00978 case 2:
00979 if (option_data->nfa > 0)
00980 ANOVA_error ("cannot calculate F(A) for Model 2");
00981 if (option_data->nfb > 0)
00982 ANOVA_error ("cannot calculate F(B) for Model 2");
00983 if (option_data->nfc > 0)
00984 ANOVA_error ("cannot calculate F(C) for Model 2");
00985 if ((option_data->nfabc > 0) && (n == 1))
00986 ANOVA_error ("sample size is too small for calculating F(ABC)");
00987 if (option_data->num_ameans > 0)
00988 ANOVA_error ("-amean not allowed for Model 2");
00989 if (option_data->num_bmeans > 0)
00990 ANOVA_error ("-bmean not allowed for Model 2");
00991 if (option_data->num_cmeans > 0)
00992 ANOVA_error ("-cmean not allowed for Model 2");
00993 if (option_data->num_xmeans > 0)
00994 ANOVA_error ("-xmean not allowed for Model 2");
00995 if (option_data->num_adiffs > 0)
00996 ANOVA_error ("-adiff not allowed for Model 2");
00997 if (option_data->num_bdiffs > 0)
00998 ANOVA_error ("-bdiff not allowed for Model 2");
00999 if (option_data->num_cdiffs > 0)
01000 ANOVA_error ("-cdiff not allowed for Model 2");
01001 if (option_data->num_xdiffs > 0)
01002 ANOVA_error ("-xdiff not allowed for Model 2");
01003 if (option_data->num_acontr > 0)
01004 ANOVA_error ("-acontr not allowed for Model 2");
01005 if (option_data->num_bcontr > 0)
01006 ANOVA_error ("-bcontr not allowed for Model 2");
01007 if (option_data->num_ccontr > 0)
01008 ANOVA_error ("-ccontr not allowed for Model 2");
01009 break;
01010 case 3:
01011 if (option_data->nfa > 0)
01012 ANOVA_error ("cannot calculate F(A) for Model 3");
01013 if ((option_data->nfbc > 0) && (n == 1))
01014 ANOVA_error ("sample size is too small for calculating F(BC)");
01015 if ((option_data->nfabc > 0) && (n == 1))
01016 ANOVA_error ("sample size is too small for calculating F(ABC)");
01017 if (option_data->num_ameans > 0)
01018 ANOVA_error ("-amean not allowed for Model 3");
01019 if (option_data->num_bmeans > 0)
01020 ANOVA_error ("-bmean not allowed for Model 3");
01021 if (option_data->num_cmeans > 0)
01022 ANOVA_error ("-cmean not allowed for Model 3");
01023 if (option_data->num_xmeans > 0)
01024 ANOVA_error ("-xmean not allowed for Model 3");
01025 if (option_data->num_adiffs > 0)
01026 ANOVA_error ("-adiff not allowed for Model 3");
01027 if (option_data->num_bdiffs > 0)
01028 ANOVA_error ("-bdiff not allowed for Model 3");
01029 if (option_data->num_cdiffs > 0)
01030 ANOVA_error ("-cdiff not allowed for Model 3");
01031 if (option_data->num_xdiffs > 0)
01032 ANOVA_error ("-xdiff not allowed for Model 3");
01033 if (option_data->num_acontr > 0)
01034 ANOVA_error ("-acontr not allowed for Model 3");
01035 if (option_data->num_bcontr > 0)
01036 ANOVA_error ("-bcontr not allowed for Model 3");
01037 if (option_data->num_ccontr > 0)
01038 ANOVA_error ("-ccontr not allowed for Model 3");
01039 break;
01040 case 4:
01041 if ((option_data->nfc > 0) && (n == 1))
01042 ANOVA_error ("sample size is too small for calculating F(C)");
01043 if ((option_data->nfac > 0) && (n == 1))
01044 ANOVA_error ("sample size is too small for calculating F(AC)");
01045 if ((option_data->nfbc > 0) && (n == 1))
01046 ANOVA_error ("sample size is too small for calculating F(BC)");
01047 if ((option_data->nfabc > 0) && (n == 1))
01048 ANOVA_error ("sample size is too small for calculating F(ABC)");
01049 if (option_data->num_cmeans > 0)
01050 ANOVA_error ("-cmean not allowed for Model 4");
01051 if (option_data->num_xmeans > 0)
01052 ANOVA_error ("-xmean not allowed for Model 4");
01053 if (option_data->num_cdiffs > 0)
01054 ANOVA_error ("-cdiff not allowed for Model 4");
01055 if (option_data->num_xdiffs > 0)
01056 ANOVA_error ("-xdiff not allowed for Model 4");
01057 if (option_data->num_ccontr > 0)
01058 ANOVA_error ("-ccontr not allowed for Model 4");
01059 break;
01060 case 5:
01061 if ((option_data->nfc > 0) && (n == 1))
01062 ANOVA_error ("sample size is too small for calculating F(C(A))");
01063 if ((option_data->nfbc > 0) && (n == 1))
01064 ANOVA_error ("sample size is too small for calculating F(BC(A))");
01065 if (option_data->nfac > 0)
01066 ANOVA_error ("F(AC) is meaningless for Model 5");
01067 if (option_data->nfabc > 0)
01068 ANOVA_error ("F(ABC) is meaningless for Model 5");
01069 if (option_data->num_cmeans > 0)
01070 ANOVA_error ("-cmean not allowed for Model 5");
01071 if (option_data->num_xmeans > 0)
01072 ANOVA_error ("-xmean not allowed for Model 5");
01073 if (option_data->num_cdiffs > 0)
01074 ANOVA_error ("-cdiff not allowed for Model 5");
01075 if (option_data->num_xdiffs > 0)
01076 ANOVA_error ("-xdiff not allowed for Model 5");
01077 if (option_data->num_ccontr > 0)
01078 ANOVA_error ("-ccontr not allowed for Model 5");
01079 break;
01080 }
01081
01082 }
|
|
|
Definition at line 878 of file 3dANOVA3.c. References anova_options::acname, anova_options::adname, anova_options::amname, anova_options::bcname, anova_options::bdname, anova_options::bmname, anova_options::bucket_filename, anova_options::ccname, anova_options::cdname, check_one_output_file(), anova_options::cmname, anova_options::fabcname, anova_options::fabname, anova_options::facname, anova_options::faname, anova_options::fbcname, anova_options::fbname, anova_options::fcname, i, anova_options::nfa, anova_options::nfab, anova_options::nfabc, anova_options::nfac, anova_options::nfb, anova_options::nfbc, anova_options::nfc, anova_options::num_acontr, anova_options::num_adiffs, anova_options::num_ameans, anova_options::num_bcontr, anova_options::num_bdiffs, anova_options::num_bmeans, anova_options::num_ccontr, anova_options::num_cdiffs, anova_options::num_cmeans, anova_options::num_xdiffs, anova_options::num_xmeans, anova_options::xdname, and anova_options::xmname.
00879 {
00880 int i; /* index */
00881
00882 if (option_data->nfa > 0)
00883 check_one_output_file (option_data, option_data->faname);
00884
00885 if (option_data->nfb > 0)
00886 check_one_output_file (option_data, option_data->fbname);
00887
00888 if (option_data->nfc > 0)
00889 check_one_output_file (option_data, option_data->fcname);
00890
00891 if (option_data->nfab > 0)
00892 check_one_output_file (option_data, option_data->fabname);
00893
00894 if (option_data->nfac > 0)
00895 check_one_output_file (option_data, option_data->facname);
00896
00897 if (option_data->nfbc > 0)
00898 check_one_output_file (option_data, option_data->fbcname);
00899
00900 if (option_data->nfabc > 0)
00901 check_one_output_file (option_data, option_data->fabcname);
00902
00903 if (option_data->num_ameans > 0)
00904 for (i = 0; i < option_data->num_ameans; i++)
00905 check_one_output_file (option_data, option_data->amname[i]);
00906
00907 if (option_data->num_bmeans > 0)
00908 for (i = 0; i < option_data->num_bmeans; i++)
00909 check_one_output_file (option_data, option_data->bmname[i]);
00910
00911 if (option_data->num_cmeans > 0)
00912 for (i = 0; i < option_data->num_cmeans; i++)
00913 check_one_output_file (option_data, option_data->cmname[i]);
00914
00915 if (option_data->num_xmeans > 0)
00916 for (i = 0; i < option_data->num_xmeans; i++)
00917 check_one_output_file (option_data, option_data->xmname[i]);
00918
00919 if (option_data->num_adiffs > 0)
00920 for (i = 0; i < option_data->num_adiffs; i++)
00921 check_one_output_file (option_data, option_data->adname[i]);
00922
00923 if (option_data->num_bdiffs > 0)
00924 for (i = 0; i < option_data->num_bdiffs; i++)
00925 check_one_output_file (option_data, option_data->bdname[i]);
00926
00927 if (option_data->num_cdiffs > 0)
00928 for (i = 0; i < option_data->num_cdiffs; i++)
00929 check_one_output_file (option_data, option_data->cdname[i]);
00930
00931 if (option_data->num_xdiffs > 0)
00932 for (i = 0; i < option_data->num_xdiffs; i++)
00933 check_one_output_file (option_data, option_data->xdname[i]);
00934
00935 if (option_data->num_acontr > 0)
00936 for (i = 0; i < option_data->num_acontr; i++)
00937 check_one_output_file (option_data, option_data->acname[i]);
00938
00939 if (option_data->num_bcontr > 0)
00940 for (i = 0; i < option_data->num_bcontr; i++)
00941 check_one_output_file (option_data, option_data->bcname[i]);
00942
00943 if (option_data->num_ccontr > 0)
00944 for (i = 0; i < option_data->num_ccontr; i++)
00945 check_one_output_file (option_data, option_data->ccname[i]);
00946
00947 if (option_data->bucket_filename != NULL)
00948 check_one_output_file (option_data, option_data->bucket_filename);
00949
00950 }
|
|
|
Definition at line 845 of file 3dANOVA3.c. References check_one_temporary_file().
00846 {
00847
00848 check_one_temporary_file ("ss0");
00849 check_one_temporary_file ("ssi");
00850 check_one_temporary_file ("ssj");
00851 check_one_temporary_file ("ssk");
00852 check_one_temporary_file ("ssij");
00853 check_one_temporary_file ("ssik");
00854 check_one_temporary_file ("ssjk");
00855 check_one_temporary_file ("ssijk");
00856 check_one_temporary_file ("ssijkm");
00857
00858 check_one_temporary_file ("ssto");
00859 check_one_temporary_file ("sse");
00860 check_one_temporary_file ("ssa");
00861 check_one_temporary_file ("ssb");
00862 check_one_temporary_file ("ssc");
00863 check_one_temporary_file ("ssab");
00864 check_one_temporary_file ("ssac");
00865 check_one_temporary_file ("ssbc");
00866 check_one_temporary_file ("ssabc");
00867 check_one_temporary_file ("ssca");
00868 check_one_temporary_file ("ssbca");
00869
00870 }
|
|
|
Definition at line 4503 of file 3dANOVA3.c. References anova_options::acname, add_file_name(), ADN_directory_name, ADN_none, anova_options::adname, anova_options::amname, anova_options::bcname, anova_options::bdname, anova_options::bmname, anova_options::bucket_filename, anova_options::ccname, anova_options::cdname, anova_options::cmname, DSET_IS_1D, DSET_IS_3D, EDIT_dset_items(), EDIT_empty_copy(), anova_options::fabcname, anova_options::fabname, anova_options::facname, anova_options::faname, anova_options::fbcname, anova_options::fbname, anova_options::fcname, anova_options::first_dataset, i, ISVALID_3DIM_DATASET, anova_options::nfa, anova_options::nfab, anova_options::nfabc, anova_options::nfac, anova_options::nfb, anova_options::nfbc, anova_options::nfc, anova_options::num_acontr, anova_options::num_adiffs, anova_options::num_ameans, anova_options::num_bcontr, anova_options::num_bdiffs, anova_options::num_bmeans, anova_options::num_ccontr, anova_options::num_cdiffs, anova_options::num_cmeans, anova_options::num_xdiffs, anova_options::num_xmeans, anova_options::session, THD_delete_3dim_dataset(), THD_open_dataset(), anova_options::xdname, and anova_options::xmname. Referenced by terminate().
04505 {
04506 char bucket_str[10000]; /* command line for program 3dbucket */
04507 char refit_str[10000]; /* command line for program 3drefit */
04508 THD_3dim_dataset * dset=NULL; /* input afni data set pointer */
04509 THD_3dim_dataset * new_dset=NULL; /* output afni data set pointer */
04510 int i; /* file index */
04511 int ibrick; /* sub-brick index number */
04512 char str[100]; /* temporary character string */
04513
04514
04515 /*----- read first dataset -----*/
04516 dset = THD_open_dataset (option_data->first_dataset) ;
04517 if( ! ISVALID_3DIM_DATASET(dset) ){
04518 fprintf(stderr,"*** Unable to open dataset file %s\n",
04519 option_data->first_dataset);
04520 exit(1) ;
04521 }
04522
04523 if( DSET_IS_1D(dset) ) USE_1D_filenames(1) ; /* 14 Mar 2003 */
04524 else if( DSET_IS_3D(dset) ) USE_1D_filenames(3) ; /* 21 Mar 2003 */
04525
04526
04527 /*----- make an empty copy of this dataset -----*/
04528 new_dset = EDIT_empty_copy( dset ) ;
04529 THD_delete_3dim_dataset (dset , False); dset = NULL;
04530 EDIT_dset_items (new_dset,
04531 ADN_directory_name, option_data->session,
04532 ADN_none);
04533
04534
04535 /*----- begin command line for program 3dbucket -----*/
04536 strcpy (bucket_str, "3dbucket");
04537 strcat (bucket_str, " -prefix ");
04538 strcat (bucket_str, option_data->bucket_filename);
04539
04540
04541 /*----- begin command line for program 3drefit -----*/
04542 strcpy (refit_str, "3drefit ");
04543 ibrick = -1;
04544
04545
04546 /*----- make F-stat for factor A data sub-bricks -----*/
04547 if (option_data->nfa != 0)
04548 {
04549 add_file_name (new_dset, option_data->faname, bucket_str);
04550
04551 ibrick++;
04552 sprintf (str, " -sublabel %d %s:Inten ",
04553 ibrick, option_data->faname);
04554 strcat (refit_str, str);
04555
04556 ibrick++;
04557 sprintf (str, " -sublabel %d %s:F-stat ",
04558 ibrick, option_data->faname);
04559 strcat (refit_str, str);
04560 }
04561
04562
04563 /*----- make F-stat for factor B sub-bricks -----*/
04564 if (option_data->nfb != 0)
04565 {
04566 add_file_name (new_dset, option_data->fbname, bucket_str);
04567
04568 ibrick++;
04569 sprintf (str, " -sublabel %d %s:Inten ",
04570 ibrick, option_data->fbname);
04571 strcat (refit_str, str);
04572
04573 ibrick++;
04574 sprintf (str, " -sublabel %d %s:F-stat ",
04575 ibrick, option_data->fbname);
04576 strcat (refit_str, str);
04577 }
04578
04579
04580 /*----- make F-stat for factor C sub-bricks -----*/
04581 if (option_data->nfc != 0)
04582 {
04583 add_file_name (new_dset, option_data->fcname, bucket_str);
04584
04585 ibrick++;
04586 sprintf (str, " -sublabel %d %s:Inten ",
04587 ibrick, option_data->fcname);
04588 strcat (refit_str, str);
04589
04590 ibrick++;
04591 sprintf (str, " -sublabel %d %s:F-stat ",
04592 ibrick, option_data->fcname);
04593 strcat (refit_str, str);
04594 }
04595
04596
04597 /*----- make F-stat for A*B interaction sub-bricks -----*/
04598 if (option_data->nfab != 0)
04599 {
04600 add_file_name (new_dset, option_data->fabname, bucket_str);
04601
04602 ibrick++;
04603 sprintf (str, " -sublabel %d %s:Inten ",
04604 ibrick, option_data->fabname);
04605 strcat (refit_str, str);
04606
04607 ibrick++;
04608 sprintf (str, " -sublabel %d %s:F-stat ",
04609 ibrick, option_data->fabname);
04610 strcat (refit_str, str);
04611 }
04612
04613
04614 /*----- make F-stat for A*C interaction sub-bricks -----*/
04615 if (option_data->nfac != 0)
04616 {
04617 add_file_name (new_dset, option_data->facname, bucket_str);
04618
04619 ibrick++;
04620 sprintf (str, " -sublabel %d %s:Inten ",
04621 ibrick, option_data->facname);
04622 strcat (refit_str, str);
04623
04624 ibrick++;
04625 sprintf (str, " -sublabel %d %s:F-stat ",
04626 ibrick, option_data->facname);
04627 strcat (refit_str, str);
04628 }
04629
04630
04631 /*----- make F-stat for B*C interaction sub-bricks -----*/
04632 if (option_data->nfbc != 0)
04633 {
04634 add_file_name (new_dset, option_data->fbcname, bucket_str);
04635
04636 ibrick++;
04637 sprintf (str, " -sublabel %d %s:Inten ",
04638 ibrick, option_data->fbcname);
04639 strcat (refit_str, str);
04640
04641 ibrick++;
04642 sprintf (str, " -sublabel %d %s:F-stat ",
04643 ibrick, option_data->fbcname);
04644 strcat (refit_str, str);
04645 }
04646
04647
04648 /*----- make F-stat for A*B*C interaction sub-bricks -----*/
04649 if (option_data->nfabc != 0)
04650 {
04651 add_file_name (new_dset, option_data->fabcname, bucket_str);
04652
04653 ibrick++;
04654 sprintf (str, " -sublabel %d %s:Inten ",
04655 ibrick, option_data->fabcname);
04656 strcat (refit_str, str);
04657
04658 ibrick++;
04659 sprintf (str, " -sublabel %d %s:F-stat ",
04660 ibrick, option_data->fabcname);
04661 strcat (refit_str, str);
04662 }
04663
04664
04665 /*----- make factor A level mean sub-bricks -----*/
04666 if (option_data->num_ameans > 0)
04667 for (i = 0; i < option_data->num_ameans; i++)
04668 {
04669 add_file_name (new_dset, option_data->amname[i], bucket_str);
04670
04671 ibrick++;
04672 sprintf (str, " -sublabel %d %s:Mean ",
04673 ibrick, option_data->amname[i]);
04674 strcat (refit_str, str);
04675
04676 ibrick++;
04677 sprintf (str, " -sublabel %d %s:t-stat ",
04678 ibrick, option_data->amname[i]);
04679 strcat (refit_str, str);
04680 }
04681
04682
04683 /*----- make factor B level mean sub-bricks -----*/
04684 if (option_data->num_bmeans > 0)
04685 for (i = 0; i < option_data->num_bmeans; i++)
04686 {
04687 add_file_name (new_dset, option_data->bmname[i], bucket_str);
04688
04689 ibrick++;
04690 sprintf (str, " -sublabel %d %s:Mean ",
04691 ibrick, option_data->bmname[i]);
04692 strcat (refit_str, str);
04693
04694 ibrick++;
04695 sprintf (str, " -sublabel %d %s:t-stat ",
04696 ibrick, option_data->bmname[i]);
04697 strcat (refit_str, str);
04698 }
04699
04700
04701 /*----- make factor C level mean sub-bricks -----*/
04702 if (option_data->num_cmeans > 0)
04703 for (i = 0; i < option_data->num_cmeans; i++)
04704 {
04705 add_file_name (new_dset, option_data->cmname[i], bucket_str);
04706
04707 ibrick++;
04708 sprintf (str, " -sublabel %d %s:Mean ",
04709 ibrick, option_data->cmname[i]);
04710 strcat (refit_str, str);
04711
04712 ibrick++;
04713 sprintf (str, " -sublabel %d %s:t-stat ",
04714 ibrick, option_data->cmname[i]);
04715 strcat (refit_str, str);
04716 }
04717
04718
04719 /*----- make individual cell mean sub-bricks -----*/
04720 if (option_data->num_xmeans > 0)
04721 for (i = 0; i < option_data->num_xmeans; i++)
04722 {
04723 add_file_name (new_dset, option_data->xmname[i], bucket_str);
04724
04725 ibrick++;
04726 sprintf (str, " -sublabel %d %s:Mean ",
04727 ibrick, option_data->xmname[i]);
04728 strcat (refit_str, str);
04729
04730 ibrick++;
04731 sprintf (str, " -sublabel %d %s:t-stat ",
04732 ibrick, option_data->xmname[i]);
04733 strcat (refit_str, str);
04734 }
04735
04736
04737 /*----- make difference in factor A level means sub-bricks -----*/
04738 if (option_data->num_adiffs > 0)
04739 for (i = 0; i < option_data->num_adiffs; i++)
04740 {
04741 add_file_name (new_dset, option_data->adname[i], bucket_str);
04742
04743 ibrick++;
04744 sprintf (str, " -sublabel %d %s:Diff ",
04745 ibrick, option_data->adname[i]);
04746 strcat (refit_str, str);
04747
04748 ibrick++;
04749 sprintf (str, " -sublabel %d %s:t-stat ",
04750 ibrick, option_data->adname[i]);
04751 strcat (refit_str, str);
04752 }
04753
04754
04755 /*----- make difference in factor B level means sub-bricks -----*/
04756 if (option_data->num_bdiffs > 0)
04757 for (i = 0; i < option_data->num_bdiffs; i++)
04758 {
04759 add_file_name (new_dset, option_data->bdname[i], bucket_str);
04760
04761 ibrick++;
04762 sprintf (str, " -sublabel %d %s:Diff ",
04763 ibrick, option_data->bdname[i]);
04764 strcat (refit_str, str);
04765
04766 ibrick++;
04767 sprintf (str, " -sublabel %d %s:t-stat ",
04768 ibrick, option_data->bdname[i]);
04769 strcat (refit_str, str);
04770 }
04771
04772
04773 /*----- make difference in factor C level means sub-bricks -----*/
04774 if (option_data->num_cdiffs > 0)
04775 for (i = 0; i < option_data->num_cdiffs; i++)
04776 {
04777 add_file_name (new_dset, option_data->cdname[i], bucket_str);
04778
04779 ibrick++;
04780 sprintf (str, " -sublabel %d %s:Diff ",
04781 ibrick, option_data->cdname[i]);
04782 strcat (refit_str, str);
04783
04784 ibrick++;
04785 sprintf (str, " -sublabel %d %s:t-stat ",
04786 ibrick, option_data->cdname[i]);
04787 strcat (refit_str, str);
04788 }
04789
04790
04791 /*----- make difference in cell means sub-bricks -----*/
04792 if (option_data->num_xdiffs > 0)
04793 for (i = 0; i < option_data->num_xdiffs; i++)
04794 {
04795 add_file_name (new_dset, option_data->xdname[i], bucket_str);
04796
04797 ibrick++;
04798 sprintf (str, " -sublabel %d %s:Diff ",
04799 ibrick, option_data->xdname[i]);
04800 strcat (refit_str, str);
04801
04802 ibrick++;
04803 sprintf (str, " -sublabel %d %s:t-stat ",
04804 ibrick, option_data->xdname[i]);
04805 strcat (refit_str, str);
04806 }
04807
04808
04809 /*----- make contrast in factor A level means sub-brickss -----*/
04810 if (option_data->num_acontr > 0)
04811 for (i = 0; i < option_data->num_acontr; i++)
04812 {
04813 add_file_name (new_dset, option_data->acname[i], bucket_str);
04814
04815 ibrick++;
04816 sprintf (str, " -sublabel %d %s:Contr ",
04817 ibrick, option_data->acname[i]);
04818 strcat (refit_str, str);
04819
04820 ibrick++;
04821 sprintf (str, " -sublabel %d %s:t-stat ",
04822 ibrick, option_data->acname[i]);
04823 strcat (refit_str, str);
04824 }
04825
04826
04827 /*----- make contrast in factor B level means sub-bricks -----*/
04828 if (option_data->num_bcontr > 0)
04829 for (i = 0; i < option_data->num_bcontr; i++)
04830 {
04831 add_file_name (new_dset, option_data->bcname[i], bucket_str);
04832
04833 ibrick++;
04834 sprintf (str, " -sublabel %d %s:Contr ",
04835 ibrick, option_data->bcname[i]);
04836 strcat (refit_str, str);
04837
04838 ibrick++;
04839 sprintf (str, " -sublabel %d %s:t-stat ",
04840 ibrick, option_data->bcname[i]);
04841 strcat (refit_str, str);
04842 }
04843
04844
04845 /*----- make contrast in factor C level means sub-bricks -----*/
04846 if (option_data->num_ccontr > 0)
04847 for (i = 0; i < option_data->num_ccontr; i++)
04848 {
04849 add_file_name (new_dset, option_data->ccname[i], bucket_str);
04850
04851 ibrick++;
04852 sprintf (str, " -sublabel %d %s:Contr ",
04853 ibrick, option_data->ccname[i]);
04854 strcat (refit_str, str);
04855
04856 ibrick++;
04857 sprintf (str, " -sublabel %d %s:t-stat ",
04858 ibrick, option_data->ccname[i]);
04859 strcat (refit_str, str);
04860 }
04861
04862
04863 /*----- invoke program 3dbucket to generate bucket type output dataset
04864 by concatenating previous output files -----*/
04865 printf("Writing `bucket' dataset ");
04866 printf("into %s\n", option_data->bucket_filename);
04867 fprintf(stderr,"RUNNING COMMAND: %s\n",bucket_str) ;
04868 system (bucket_str);
04869
04870
04871 /*----- invoke program 3drefit to label individual sub-bricks -----*/
04872 add_file_name (new_dset, option_data->bucket_filename, refit_str);
04873 fprintf(stderr,"RUNNING COMMAND: %s\n",refit_str) ;
04874 system (refit_str);
04875
04876
04877 /*----- release memory -----*/
04878 THD_delete_3dim_dataset (new_dset , False); new_dset = NULL;
04879
04880 }
|
|
|
Definition at line 68 of file 3dANOVA3.c. References MASTER_SHORTHELP_STRING.
00069 {
00070 printf
00071 (
00072 "This program performs three-factor ANOVA on 3D data sets. \n\n"
00073 "Usage: \n"
00074 "3dANOVA3 \n"
00075 "-type k type of ANOVA model to be used: \n"
00076 " k = 1 A,B,C fixed; AxBxC \n"
00077 " k = 2 A,B,C random; AxBxC \n"
00078 " k = 3 A fixed; B,C random; AxBxC \n"
00079 " k = 4 A,B fixed; C random; AxBxC \n"
00080 " k = 5 A,B fixed; C random; AxB,BxC,C(A) \n"
00081 " \n"
00082 "-alevels a a = number of levels of factor A \n"
00083 "-blevels b b = number of levels of factor B \n"
00084 "-clevels c c = number of levels of factor C \n"
00085 "-dset 1 1 1 filename data set for level 1 of factor A \n"
00086 " and level 1 of factor B \n"
00087 " and level 1 of factor C \n"
00088 " . . . . . . \n"
00089 " \n"
00090 "-dset i j k filename data set for level i of factor A \n"
00091 " and level j of factor B \n"
00092 " and level k of factor C \n"
00093 " . . . . . . \n"
00094 " \n"
00095 "-dset a b c filename data set for level a of factor A \n"
00096 " and level b of factor B \n"
00097 " and level c of factor C \n"
00098 " \n"
00099 "[-voxel num] screen output for voxel # num \n"
00100 "[-diskspace] print out disk space required for \n"
00101 " program execution \n"
00102 " \n"
00103 " \n"
00104 "The following commands generate individual AFNI 2 sub-brick datasets: \n"
00105 " (In each case, output is written to the file with the specified \n"
00106 " prefix file name.) \n"
00107 " \n"
00108 "[-fa prefix] F-statistic for factor A effect \n"
00109 "[-fb prefix] F-statistic for factor B effect \n"
00110 "[-fc prefix] F-statistic for factor C effect \n"
00111 "[-fab prefix] F-statistic for A*B interaction \n"
00112 "[-fac prefix] F-statistic for A*C interaction \n"
00113 "[-fbc prefix] F-statistic for B*C interaction \n"
00114 "[-fabc prefix] F-statistic for A*B*C interaction \n"
00115 " \n"
00116 "[-amean i prefix] estimate of factor A level i mean \n"
00117 "[-bmean i prefix] estimate of factor B level i mean \n"
00118 "[-cmean i prefix] estimate of factor C level i mean \n"
00119 "[-xmean i j k prefix] estimate mean of cell at factor A level i,\n"
00120 " factor B level j, factor C level k \n"
00121 " \n"
00122 "[-adiff i j prefix] difference between factor A levels i and j\n"
00123 "[-bdiff i j prefix] difference between factor B levels i and j\n"
00124 "[-cdiff i j prefix] difference between factor C levels i and j\n"
00125 "[-xdiff i j k l m n prefix] difference between cell mean at A=i,B=j, \n"
00126 " C=k, and cell mean at A=l,B=m,C=n \n"
00127 " \n"
00128 "[-acontr c1...ca prefix] contrast in factor A levels \n"
00129 "[-bcontr c1...cb prefix] contrast in factor B levels \n"
00130 "[-ccontr c1...cc prefix] contrast in factor C levels \n"
00131 " \n"
00132 " \n"
00133 "The following command generates one AFNI 'bucket' type dataset: \n"
00134 " \n"
00135 "[-bucket prefix] create one AFNI 'bucket' dataset whose \n"
00136 " sub-bricks are obtained by concatenating \n"
00137 " the above output files; the output 'bucket'\n"
00138 " is written to file with prefix file name \n"
00139 "\n");
00140
00141 printf
00142 (
00143 "\n"
00144 "N.B.: For this program, the user must specify 1 and only 1 sub-brick \n"
00145 " with each -dset command. That is, if an input dataset contains \n"
00146 " more than 1 sub-brick, a sub-brick selector must be used, e.g.: \n"
00147 " -dset 2 4 5 'fred+orig[3]' \n"
00148 );
00149
00150 printf("\n" MASTER_SHORTHELP_STRING ) ;
00151
00152 exit(0);
00153 }
|
|
||||||||||||||||
|
Definition at line 163 of file 3dANOVA3.c. References anova_options::a, anova_options::acname, anova_options::acontr, anova_options::adiffs, anova_options::adname, AFNI_logger(), anova_options::ameans, anova_options::amname, ANOVA_error(), argc, anova_options::b, anova_options::bcname, anova_options::bcontr, anova_options::bdiffs, anova_options::bdname, anova_options::bmeans, anova_options::bmname, anova_options::bucket_filename, anova_options::c, calloc, anova_options::ccname, anova_options::ccontr, anova_options::cdiffs, anova_options::cdname, anova_options::cmeans, anova_options::cmname, anova_options::datum, anova_options::diskspace, display_help_menu(), DSET_NVALS, anova_options::fabcname, anova_options::fabname, anova_options::facname, anova_options::faname, anova_options::fbcname, anova_options::fbname, anova_options::fcname, free, i, initialize_options(), ISVALID_3DIM_DATASET, malloc, MAX_CONTR, MAX_DIFFS, MAX_LEVELS, MAX_MEANS, anova_options::model, anova_options::n, N_INDEX, anova_options::nfa, anova_options::nfab, anova_options::nfabc, anova_options::nfac, anova_options::nfb, anova_options::nfbc, anova_options::nfc, anova_options::num_acontr, anova_options::num_adiffs, anova_options::num_ameans, anova_options::num_bcontr, anova_options::num_bdiffs, anova_options::num_bmeans, anova_options::num_ccontr, anova_options::num_cdiffs, anova_options::num_cmeans, anova_options::num_xdiffs, anova_options::num_xmeans, anova_options::nvoxel, PROGRAM_NAME, anova_options::session, THD_delete_3dim_dataset(), THD_open_dataset(), anova_options::xdiffs, anova_options::xdname, anova_options::xmeans, anova_options::xmname, and anova_options::xname.
00164 {
00165 int nopt = 1; /* input option argument counter */
00166 int ival, jval, kval; /* integer input */
00167 int i, j, k; /* factor level counters */
00168 int nijk; /* number of data files in cell i,j,k */
00169 float fval; /* float input */
00170 THD_3dim_dataset * dset=NULL; /* test whether data set exists */
00171 char message[MAX_NAME_LENGTH]; /* error message */
00172 /* int n[MAX_LEVELS][MAX_LEVELS][MAX_LEVELS]; data file counters */
00173 int * n; /* save stack space 19 Jul 2004 [rickr] */
00174
00175
00176 /*----- does user request help menu? -----*/
00177 if (argc < 2 || strncmp(argv[1], "-help", 5) == 0) display_help_menu();
00178
00179 /*----- add to program log -----*/
00180 AFNI_logger (PROGRAM_NAME,argc,argv);
00181
00182 /*----- initialize the input options -----*/
00183 initialize_options (option_data);
00184
00185 /*----- initialize data file counters -----*/
00186 n = (int *)calloc(MAX_LEVELS*MAX_LEVELS*MAX_LEVELS, sizeof(int));
00187 if ( !n )
00188 {
00189 sprintf(message, "failed to allocate %u bytes for file counters\n",
00190 (unsigned int)(MAX_LEVELS*MAX_LEVELS*MAX_LEVELS * sizeof(int)) );
00191 ANOVA_error(message);
00192 }
00193
00194 #if 0 /* replaced array and init with pointer and calloc() */
00195 for (i = 0; i < MAX_LEVELS; i++)
00196 for (j = 0; j < MAX_LEVELS; j++)
00197 for (k = 0; k < MAX_LEVELS; k++)
00198 n[i][j][k] = 0;
00199 #endif
00200
00201
00202 /*----- main loop over input options -----*/
00203 while (nopt < argc )
00204 {
00205
00206 /*----- allocate memory for storing data file names -----*/
00207 if ((option_data->xname == NULL) && (option_data->a > 0) &&
00208 (option_data->b > 0) && (option_data->c > 0))
00209 {
00210 option_data->xname =
00211 (char *****) malloc (sizeof(char ****) * option_data->a);
00212 for (i = 0; i < option_data->a; i++)
00213 {
00214 option_data->xname[i] =
00215 (char ****) malloc (sizeof(char ***) * option_data->b);
00216 for (j = 0; j < option_data->b; j++)
00217 {
00218 option_data->xname[i][j] =
00219 (char ***) malloc (sizeof(char **) * option_data->c);
00220 for (k = 0; k < option_data->c; k++)
00221 {
00222 option_data->xname[i][j][k] =
00223 (char **) malloc (sizeof(char *) * MAX_OBSERVATIONS);
00224 }
00225 }
00226 }
00227 }
00228
00229
00230 /*----- -diskspace -----*/
00231 if( strncmp(argv[nopt],"-diskspace",5) == 0 )
00232 {
00233 option_data->diskspace = 1;
00234 nopt++ ; continue ; /* go to next arg */
00235 }
00236
00237
00238 /*----- -datum type -----*/
00239 if( strncmp(argv[nopt],"-datum",5) == 0 ){
00240 if( ++nopt >= argc ) ANOVA_error("need an argument after -datum!") ;
00241
00242 if( strcmp(argv[nopt],"short") == 0 ){
00243 option_data->datum = MRI_short ;
00244 } else if( strcmp(argv[nopt],"float") == 0 ){
00245 option_data->datum = MRI_float ;
00246 } else {
00247 char buf[256] ;
00248 sprintf(buf,"-datum of type '%s' is not supported in 3dANOVA3!",
00249 argv[nopt] ) ;
00250 ANOVA_error(buf) ;
00251 }
00252 nopt++ ; continue ; /* go to next arg */
00253 }
00254
00255
00256 /*----- -session dirname -----*/
00257 if( strncmp(argv[nopt],"-session",5) == 0 ){
00258 nopt++ ;
00259 if( nopt >= argc ) ANOVA_error("need argument after -session!") ;
00260 strcpy(option_data->session , argv[nopt++]) ;
00261 continue ;
00262 }
00263
00264
00265 /*----- -voxel num -----*/
00266 if (strncmp(argv[nopt], "-voxel", 6) == 0)
00267 {
00268 nopt++;
00269 if (nopt >= argc) ANOVA_error ("need argument after -voxel ");
00270 sscanf (argv[nopt], "%d", &ival);
00271 if (ival <= 0)
00272 ANOVA_error ("illegal argument after -voxel ");
00273 option_data->nvoxel = ival;
00274 nopt++;
00275 continue;
00276 }
00277
00278
00279 /*----- -type k -----*/
00280 if (strncmp(argv[nopt], "-type", 5) == 0)
00281 {
00282 nopt++;
00283 if (nopt >= argc) ANOVA_error ("need argument after -type ");
00284 sscanf (argv[nopt], "%d", &ival);
00285 if ((ival < 1) || (ival > 5))
00286 ANOVA_error ("illegal argument after -type ");
00287 option_data->model = ival;
00288 nopt++;
00289 continue;
00290 }
00291
00292
00293 /*----- -alevels a -----*/
00294 if (strncmp(argv[nopt], "-alevels", 5) == 0)
00295 {
00296 nopt++;
00297 if (nopt >= argc) ANOVA_error ("need argument after -alevels ");
00298 sscanf (argv[nopt], "%d", &ival);
00299 if ((ival <= 0) || (ival > MAX_LEVELS))
00300 ANOVA_error ("illegal argument after -alevels ");
00301 option_data->a = ival;
00302 nopt++;
00303 continue;
00304 }
00305
00306
00307 /*----- -blevels b -----*/
00308 if (strncmp(argv[nopt], "-blevels", 5) == 0)
00309 {
00310 nopt++;
00311 if (nopt >= argc) ANOVA_error ("need argument after -blevels ");
00312 sscanf (argv[nopt], "%d", &ival);
00313 if ((ival <= 0) || (ival > MAX_LEVELS))
00314 ANOVA_error ("illegal argument after -blevels ");
00315 option_data->b = ival;
00316 nopt++;
00317 continue;
00318 }
00319
00320
00321 /*----- -clevels c -----*/
00322 if (strncmp(argv[nopt], "-clevels", 5) == 0)
00323 {
00324 nopt++;
00325 if (nopt >= argc) ANOVA_error ("need argument after -clevels ");
00326 sscanf (argv[nopt], "%d", &ival);
00327 if ((ival <= 0) || (ival > MAX_LEVELS))
00328 ANOVA_error ("illegal argument after -clevels ");
00329 option_data->c = ival;
00330 nopt++;
00331 continue;
00332 }
00333
00334
00335 /*----- -dset alevel blevel clevel filename -----*/
00336 if (strncmp(argv[nopt], "-dset", 5) == 0)
00337 {
00338 nopt++;
00339 if (nopt+3 >= argc) ANOVA_error ("need 4 arguments after -dset ");
00340 sscanf (argv[nopt], "%d", &ival);
00341 if ((ival <= 0) || (ival > option_data->a))
00342 ANOVA_error ("illegal argument after -dset ");
00343
00344 nopt++;
00345 sscanf (argv[nopt], "%d", &jval);
00346 if ((jval <= 0) || (jval > option_data->b))
00347 ANOVA_error ("illegal argument after -dset ");
00348
00349 nopt++;
00350 sscanf (argv[nopt], "%d", &kval);
00351 if ((kval <= 0) || (kval > option_data->c))
00352 ANOVA_error ("illegal argument after -dset ");
00353
00354 N_INDEX(ival-1, jval-1, kval-1) += 1;
00355 nijk = N_INDEX(ival-1, jval-1, kval-1);
00356 if (nijk > MAX_OBSERVATIONS)
00357 ANOVA_error ("too many data files");
00358
00359 /*--- check whether input files exist ---*/
00360 nopt++;
00361 dset = THD_open_dataset( argv[nopt] ) ;
00362 if( ! ISVALID_3DIM_DATASET(dset) )
00363 {
00364 sprintf(message,"Unable to open dataset file %s\n",
00365 argv[nopt]);
00366 ANOVA_error (message);
00367 }
00368
00369 /*--- check number of selected sub-bricks ---*/
00370 if (DSET_NVALS(dset) != 1)
00371 {
00372 sprintf(message,"Must specify exactly 1 sub-brick for file %s\n",
00373 argv[nopt]);
00374 ANOVA_error (message);
00375 }
00376
00377 THD_delete_3dim_dataset( dset , False ) ; dset = NULL ;
00378
00379 option_data->xname[ival-1][jval-1][kval-1][nijk-1]
00380 = malloc (sizeof(char) * MAX_NAME_LENGTH);
00381 strcpy (option_data->xname[ival-1][jval-1][kval-1][nijk-1],
00382 argv[nopt]);
00383 nopt++;
00384 continue;
00385 }
00386
00387
00388 /*----- -fa filename -----*/
00389 if (strncmp(argv[nopt], "-fa", 5) == 0)
00390 {
00391 nopt++;
00392 if (nopt >= argc) ANOVA_error ("need argument after -fa ");
00393 option_data->nfa = 1;
00394 option_data->faname = malloc (sizeof(char) * MAX_NAME_LENGTH);
00395 strcpy (option_data->faname, argv[nopt]);
00396 nopt++;
00397 continue;
00398 }
00399
00400
00401 /*----- -fb filename -----*/
00402 if (strncmp(argv[nopt], "-fb", 5) == 0)
00403 {
00404 nopt++;
00405 if (nopt >= argc) ANOVA_error ("need argument after -fb ");
00406 option_data->nfb = 1;
00407 option_data->fbname = malloc (sizeof(char) * MAX_NAME_LENGTH);
00408 strcpy (option_data->fbname, argv[nopt]);
00409 nopt++;
00410 continue;
00411 }
00412
00413
00414 /*----- -fc filename -----*/
00415 if (strncmp(argv[nopt], "-fc", 5) == 0)
00416 {
00417 nopt++;
00418 if (nopt >= argc) ANOVA_error ("need argument after -fc ");
00419 option_data->nfc = 1;
00420 option_data->fcname = malloc (sizeof(char) * MAX_NAME_LENGTH);
00421 strcpy (option_data->fcname, argv[nopt]);
00422 nopt++;
00423 continue;
00424 }
00425
00426
00427 /*----- -fab filename -----*/
00428 if (strncmp(argv[nopt], "-fab", 5) == 0)
00429 {
00430 nopt++;
00431 if (nopt >= argc) ANOVA_error ("need argument after -fab ");
00432 option_data->nfab = 1;
00433 option_data->fabname = malloc (sizeof(char) * MAX_NAME_LENGTH);
00434 strcpy (option_data->fabname, argv[nopt]);
00435 nopt++;
00436 continue;
00437 }
00438
00439
00440 /*----- -fac filename -----*/
00441 if (strncmp(argv[nopt], "-fac", 5) == 0)
00442 {
00443 nopt++;
00444 if (nopt >= argc) ANOVA_error ("need argument after -fac ");
00445 option_data->nfac = 1;
00446 option_data->facname = malloc (sizeof(char) * MAX_NAME_LENGTH);
00447 strcpy (option_data->facname, argv[nopt]);
00448 nopt++;
00449 continue;
00450 }
00451
00452
00453 /*----- -fbc filename -----*/
00454 if (strncmp(argv[nopt], "-fbc", 5) == 0)
00455 {
00456 nopt++;
00457 if (nopt >= argc) ANOVA_error ("need argument after -fbc ");
00458 option_data->nfbc = 1;
00459 option_data->fbcname = malloc (sizeof(char) * MAX_NAME_LENGTH);
00460 strcpy (option_data->fbcname, argv[nopt]);
00461 nopt++;
00462 continue;
00463 }
00464
00465
00466 /*----- -fabc filename -----*/
00467 if (strncmp(argv[nopt], "-fabc", 5) == 0)
00468 {
00469 nopt++;
00470 if (nopt >= argc) ANOVA_error ("need argument after -fabc ");
00471 option_data->nfabc = 1;
00472 option_data->fabcname = malloc (sizeof(char) * MAX_NAME_LENGTH);
00473 strcpy (option_data->fabcname, argv[nopt]);
00474 nopt++;
00475 continue;
00476 }
00477
00478
00479 /*----- -amean level filename -----*/
00480 if (strncmp(argv[nopt], "-amean", 5) == 0)
00481 {
00482 nopt++;
00483 if (nopt+1 >= argc) ANOVA_error ("need 2 arguments after -amean ");
00484
00485 option_data->num_ameans++;
00486 if (option_data->num_ameans > MAX_MEANS)
00487 ANOVA_error ("too many factor A level mean estimates");
00488
00489 sscanf (argv[nopt], "%d", &ival);
00490 if ((ival <= 0) || (ival > option_data->a))
00491 ANOVA_error ("illegal argument after -amean ");
00492 option_data->ameans[option_data->num_ameans-1] = ival - 1;
00493 nopt++;
00494
00495 option_data->amname[option_data->num_ameans-1]
00496 = malloc (sizeof(char) * MAX_NAME_LENGTH);
00497 strcpy (option_data->amname[option_data->num_ameans-1], argv[nopt]);
00498 nopt++;
00499 continue;
00500 }
00501
00502
00503 /*----- -bmean level filename -----*/
00504 if (strncmp(argv[nopt], "-bmean", 5) == 0)
00505 {
00506 nopt++;
00507 if (nopt+1 >= argc) ANOVA_error ("need 2 arguments after -bmean ");
00508
00509 option_data->num_bmeans++;
00510 if (option_data->num_bmeans > MAX_MEANS)
00511 ANOVA_error ("too many factor B level mean estimates");
00512
00513 sscanf (argv[nopt], "%d", &ival);
00514 if ((ival <= 0) || (ival > option_data->b))
00515 ANOVA_error ("illegal argument after -bmean ");
00516 option_data->bmeans[option_data->num_bmeans-1] = ival - 1;
00517 nopt++;
00518
00519 option_data->bmname[option_data->num_bmeans-1]
00520 = malloc (sizeof(char) * MAX_NAME_LENGTH);
00521 strcpy (option_data->bmname[option_data->num_bmeans-1], argv[nopt]);
00522 nopt++;
00523 continue;
00524 }
00525
00526
00527 /*----- -cmean level filename -----*/
00528 if (strncmp(argv[nopt], "-cmean", 5) == 0)
00529 {
00530 nopt++;
00531 if (nopt+1 >= argc) ANOVA_error ("need 2 arguments after -cmean ");
00532
00533 option_data->num_cmeans++;
00534 if (option_data->num_cmeans > MAX_MEANS)
00535 ANOVA_error ("too many factor C level mean estimates");
00536
00537 sscanf (argv[nopt], "%d", &ival);
00538 if ((ival <= 0) || (ival > option_data->c))
00539 ANOVA_error ("illegal argument after -cmean ");
00540 option_data->cmeans[option_data->num_cmeans-1] = ival - 1;
00541 nopt++;
00542
00543 option_data->cmname[option_data->num_cmeans-1]
00544 = malloc (sizeof(char) * MAX_NAME_LENGTH);
00545 strcpy (option_data->cmname[option_data->num_cmeans-1], argv[nopt]);
00546 nopt++;
00547 continue;
00548 }
00549
00550
00551 /*----- -xmean i j k filename -----*/
00552 if (strncmp(argv[nopt], "-xmean", 5) == 0)
00553 {
00554 nopt++;
00555 if (nopt+3 >= argc) ANOVA_error ("need 4 arguments after -xmean ");
00556
00557 option_data->num_xmeans++;
00558 if (option_data->num_xmeans > MAX_MEANS)
00559 ANOVA_error ("too many cell mean estimates");
00560
00561 sscanf (argv[nopt], "%d", &ival);
00562 if ((ival <= 0) || (ival > option_data->a))
00563 ANOVA_error ("illegal argument after -xmean ");
00564 option_data->xmeans[option_data->num_xmeans-1][0] = ival - 1;
00565 nopt++;
00566
00567 sscanf (argv[nopt], "%d", &ival);
00568 if ((ival <= 0) || (ival > option_data->b))
00569 ANOVA_error ("illegal argument after -xmean ");
00570 option_data->xmeans[option_data->num_xmeans-1][1] = ival - 1;
00571 nopt++;
00572
00573 sscanf (argv[nopt], "%d", &ival);
00574 if ((ival <= 0) || (ival > option_data->c))
00575 ANOVA_error ("illegal argument after -xmean ");
00576 option_data->xmeans[option_data->num_xmeans-1][2] = ival - 1;
00577 nopt++;
00578
00579 option_data->xmname[option_data->num_xmeans-1]
00580 = malloc (sizeof(char) * MAX_NAME_LENGTH);
00581 strcpy (option_data->xmname[option_data->num_xmeans-1], argv[nopt]);
00582 nopt++;
00583 continue;
00584 }
00585
00586
00587 /*----- -adiff level1 level2 filename -----*/
00588 if (strncmp(argv[nopt], "-adiff", 5) == 0)
00589 {
00590 nopt++;
00591 if (nopt+2 >= argc) ANOVA_error ("need 3 arguments after -adiff ");
00592
00593 option_data->num_adiffs++;
00594 if (option_data->num_adiffs > MAX_DIFFS)
00595 ANOVA_error ("too many factor A level differences");
00596
00597 sscanf (argv[nopt], "%d", &ival);
00598 if ((ival <= 0) || (ival > option_data->a))
00599 ANOVA_error ("illegal argument after -adiff ");
00600 option_data->adiffs[option_data->num_adiffs-1][0] = ival - 1;
00601 nopt++;
00602
00603 sscanf (argv[nopt], "%d", &ival);
00604 if ((ival <= 0) || (ival > option_data->a))
00605 ANOVA_error ("illegal argument after -adiff ");
00606 option_data->adiffs[option_data->num_adiffs-1][1] = ival - 1;
00607 nopt++;
00608
00609 option_data->adname[option_data->num_adiffs-1]
00610 = malloc (sizeof(char) * MAX_NAME_LENGTH);
00611 strcpy (option_data->adname[option_data->num_adiffs-1], argv[nopt]);
00612 nopt++;
00613 continue;
00614 }
00615
00616
00617 /*----- -bdiff level1 level2 filename -----*/
00618 if (strncmp(argv[nopt], "-bdiff", 5) == 0)
00619 {
00620 nopt++;
00621 if (nopt+2 >= argc) ANOVA_error ("need 3 arguments after -bdiff ");
00622
00623 option_data->num_bdiffs++;
00624 if (option_data->num_bdiffs > MAX_DIFFS)
00625 ANOVA_error ("too many factor B level differences");
00626
00627 sscanf (argv[nopt], "%d", &ival);
00628 if ((ival <= 0) || (ival > option_data->b))
00629 ANOVA_error ("illegal argument after -bdiff ");
00630 option_data->bdiffs[option_data->num_bdiffs-1][0] = ival - 1;
00631 nopt++;
00632
00633 sscanf (argv[nopt], "%d", &ival);
00634 if ((ival <= 0) || (ival > option_data->b))
00635 ANOVA_error ("illegal argument after -bdiff ");
00636 option_data->bdiffs[option_data->num_bdiffs-1][1] = ival - 1;
00637 nopt++;
00638
00639 option_data->bdname[option_data->num_bdiffs-1]
00640 = malloc (sizeof(char) * MAX_NAME_LENGTH);
00641 strcpy (option_data->bdname[option_data->num_bdiffs-1], argv[nopt]);
00642 nopt++;
00643 continue;
00644 }
00645
00646
00647 /*----- -cdiff level1 level2 filename -----*/
00648 if (strncmp(argv[nopt], "-cdiff", 5) == 0)
00649 {
00650 nopt++;
00651 if (nopt+2 >= argc) ANOVA_error ("need 3 arguments after -cdiff ");
00652
00653 option_data->num_cdiffs++;
00654 if (option_data->num_cdiffs > MAX_DIFFS)
00655 ANOVA_error ("too many factor C level differences");
00656
00657 sscanf (argv[nopt], "%d", &ival);
00658 if ((ival <= 0) || (ival > option_data->c))
00659 ANOVA_error ("illegal argument after -cdiff ");
00660 option_data->cdiffs[option_data->num_cdiffs-1][0] = ival - 1;
00661 nopt++;
00662
00663 sscanf (argv[nopt], "%d", &ival);
00664 if ((ival <= 0) || (ival > option_data->c))
00665 ANOVA_error ("illegal argument after -cdiff ");
00666 option_data->cdiffs[option_data->num_cdiffs-1][1] = ival - 1;
00667 nopt++;
00668
00669 option_data->cdname[option_data->num_cdiffs-1]
00670 = malloc (sizeof(char) * MAX_NAME_LENGTH);
00671 strcpy (option_data->cdname[option_data->num_cdiffs-1], argv[nopt]);
00672 nopt++;
00673 continue;
00674 }
00675
00676
00677 /*----- -xdiff i j k l m n filename -----*/
00678 if (strncmp(argv[nopt], "-xdiff", 5) == 0)
00679 {
00680 nopt++;
00681 if (nopt+6 >= argc) ANOVA_error ("need 7 arguments after -xdiff ");
00682
00683 option_data->num_xdiffs++;
00684 if (option_data->num_xdiffs > MAX_DIFFS)
00685 ANOVA_error ("too many cell means differences");
00686
00687 sscanf (argv[nopt], "%d", &ival);
00688 if ((ival <= 0) || (ival > option_data->a))
00689 ANOVA_error ("illegal argument after -xdiff ");
00690 option_data->xdiffs[option_data->num_xdiffs-1][0][0] = ival - 1;
00691 nopt++;
00692
00693 sscanf (argv[nopt], "%d", &ival);
00694 if ((ival <= 0) || (ival > option_data->b))
00695 ANOVA_error ("illegal argument after -xdiff ");
00696 option_data->xdiffs[option_data->num_xdiffs-1][0][1] = ival - 1;
00697 nopt++;
00698
00699 sscanf (argv[nopt], "%d", &ival);
00700 if ((ival <= 0) || (ival > option_data->c))
00701 ANOVA_error ("illegal argument after -xdiff ");
00702 option_data->xdiffs[option_data->num_xdiffs-1][0][2] = ival - 1;
00703 nopt++;
00704
00705 sscanf (argv[nopt], "%d", &ival);
00706 if ((ival <= 0) || (ival > option_data->a))
00707 ANOVA_error ("illegal argument after -xdiff ");
00708 option_data->xdiffs[option_data->num_xdiffs-1][1][0] = ival - 1;
00709 nopt++;
00710
00711 sscanf (argv[nopt], "%d", &ival);
00712 if ((ival <= 0) || (ival > option_data->b))
00713 ANOVA_error ("illegal argument after -xdiff ");
00714 option_data->xdiffs[option_data->num_xdiffs-1][1][1] = ival - 1;
00715 nopt++;
00716
00717 sscanf (argv[nopt], "%d", &ival);
00718 if ((ival <= 0) || (ival > option_data->c))
00719 ANOVA_error ("illegal argument after -xdiff ");
00720 option_data->xdiffs[option_data->num_xdiffs-1][1][2] = ival - 1;
00721 nopt++;
00722
00723 option_data->xdname[option_data->num_xdiffs-1]
00724 = malloc (sizeof(char) * MAX_NAME_LENGTH);
00725 strcpy (option_data->xdname[option_data->num_xdiffs-1], argv[nopt]);
00726 nopt++;
00727 continue;
00728 }
00729
00730
00731 /*----- -acontr c1 ... cr filename -----*/
00732 if (strncmp(argv[nopt], "-acontr", 5) == 0)
00733 {
00734 nopt++;
00735 if (nopt + option_data->a >= argc)
00736 ANOVA_error ("need a+1 arguments after -acontr ");
00737
00738 option_data->num_acontr++;
00739 if (option_data->num_acontr > MAX_CONTR)
00740 ANOVA_error ("too many factor A level contrasts");
00741
00742 for (i = 0; i < option_data->a; i++)
00743 {
00744 sscanf (argv[nopt], "%f", &fval);
00745 option_data->acontr[option_data->num_acontr - 1][i] = fval ;
00746 nopt++;
00747 }
00748
00749 option_data->acname[option_data->num_acontr-1]
00750 = malloc (sizeof(char) * MAX_NAME_LENGTH);
00751 strcpy (option_data->acname[option_data->num_acontr-1], argv[nopt]);
00752 nopt++;
00753 continue;
00754 }
00755
00756
00757 /*----- -bcontr c1 ... cr filename -----*/
00758 if (strncmp(argv[nopt], "-bcontr", 5) == 0)
00759 {
00760 nopt++;
00761 if (nopt + option_data->b >= argc)
00762 ANOVA_error ("need b+1 arguments after -bcontr ");
00763
00764 option_data->num_bcontr++;
00765 if (option_data->num_bcontr > MAX_CONTR)
00766 ANOVA_error ("too many factor B level contrasts");
00767
00768 for (i = 0; i < option_data->b; i++)
00769 {
00770 sscanf (argv[nopt], "%f", &fval);
00771 option_data->bcontr[option_data->num_bcontr - 1][i] = fval ;
00772 nopt++;
00773 }
00774
00775 option_data->bcname[option_data->num_bcontr-1]
00776 = malloc (sizeof(char) * MAX_NAME_LENGTH);
00777 strcpy (option_data->bcname[option_data->num_bcontr-1], argv[nopt]);
00778 nopt++;
00779 continue;
00780 }
00781
00782
00783 /*----- -ccontr c1 ... cr filename -----*/
00784 if (strncmp(argv[nopt], "-ccontr", 5) == 0)
00785 {
00786 nopt++;
00787 if (nopt + option_data->c >= argc)
00788 ANOVA_error ("need c+1 arguments after -ccontr ");
00789
00790 option_data->num_ccontr++;
00791 if (option_data->num_ccontr > MAX_CONTR)
00792 ANOVA_error ("too many factor C level contrasts");
00793
00794
00795 for (i = 0; i < option_data->c; i++)
00796 {
00797 sscanf (argv[nopt], "%f", &fval);
00798 option_data->ccontr[option_data->num_ccontr - 1][i] = fval ;
00799 nopt++;
00800 }
00801
00802 option_data->ccname[option_data->num_ccontr-1]
00803 = malloc (sizeof(char) * MAX_NAME_LENGTH);
00804 strcpy (option_data->ccname[option_data->num_ccontr-1], argv[nopt]);
00805 nopt++;
00806 continue;
00807 }
00808
00809
00810 /*----- -bucket filename -----*/
00811 if (strncmp(argv[nopt], "-bucket", 4) == 0)
00812 {
00813 nopt++;
00814 if (nopt >= argc) ANOVA_error ("need argument after -bucket ");
00815 option_data->bucket_filename = malloc (sizeof(char)*MAX_NAME_LENGTH);
00816 strcpy (option_data->bucket_filename, argv[nopt]);
00817 nopt++;
00818 continue;
00819 }
00820
00821
00822 /*----- unknown command -----*/
00823 sprintf (message,"Unrecognized command line option: %s\n", argv[nopt]);
00824 ANOVA_error (message);
00825 }
00826
00827
00828 /*----- check that all treatment sample sizes are equal -----*/
00829 option_data->n = N_INDEX(0, 0, 0);
00830 for (i = 0; i < option_data->a; i++)
00831 for (j = 0; j < option_data->b; j++)
00832 for (k = 0; k < option_data->c; k++)
00833 if (N_INDEX(i, j, k) != option_data->n)
00834 ANOVA_error ("must have equal sample sizes for 3dANOVA3");
00835
00836 free(n);
00837 }
|
|
||||||||||||||||
|
Definition at line 1143 of file 3dANOVA3.c. References a, ANOVA_error(), argc, c, check_disk_space(), check_for_valid_inputs(), check_output_files(), check_temporary_files(), get_dimensions(), get_options(), i, malloc, PROGRAM_NAME, and tross_commandline().
01144 {
01145 int i, j, k; /* factor level indices */
01146 int a, b, c; /* number of factor levels */
01147 int n; /* number of observations per cell */
01148 int nxyz; /* number of voxels */
01149 char message[MAX_NAME_LENGTH]; /* error message */
01150
01151
01152 /*----- save command line for history notes -----*/
01153 commandline = tross_commandline( PROGRAM_NAME , argc,argv ) ;
01154
01155
01156 /*----- allocate memory space for input data -----*/
01157 *option_data = (anova_options *) malloc(sizeof(anova_options));
01158 if (*option_data == NULL)
01159 ANOVA_error ("memory allocation error");
01160
01161 /*----- get command line inputs -----*/
01162 get_options(argc, argv, *option_data);
01163
01164 /*----- use first data set to get data set dimensions -----*/
01165 (*option_data)->first_dataset = (*option_data)->xname[0][0][0][0];
01166 get_dimensions (*option_data);
01167 printf ("Data set dimensions: nx = %d ny = %d nz = %d nxyz = %d \n",
01168 (*option_data)->nx, (*option_data)->ny,
01169 (*option_data)->nz, (*option_data)->nxyz);
01170 if ((*option_data)->nvoxel > (*option_data)->nxyz)
01171 ANOVA_error ("argument of -voxel is too large");
01172
01173 /*----- initialize local variables -----*/
01174 a = (*option_data)->a;
01175 b = (*option_data)->b;
01176 c = (*option_data)->c;
01177 n = (*option_data)->n;
01178
01179 /*----- total number of observations -----*/
01180 (*option_data)->nt = n * a * b * c;
01181 printf ("Number of input datasets = %d \n", (*option_data)->nt);
01182
01183 /*----- check for valid inputs -----*/
01184 check_for_valid_inputs (*option_data);
01185
01186 /*----- check whether temporary files already exist -----*/
01187 check_temporary_files (*option_data);
01188
01189 /*----- check whether output files already exist -----*/
01190 check_output_files (*option_data);
01191
01192 /*----- check whether there is sufficient disk space -----*/
01193 if ((*option_data)->diskspace) check_disk_space (*option_data);
01194 }
|
|
||||||||||||
|
Definition at line 5039 of file 3dANOVA3.c. References addto_args(), analyze_results(), argc, calculate_anova(), display_help_menu(), free, initialize(), machdep(), mainENTRY, PROGRAM_AUTHOR, PROGRAM_INITIAL, PROGRAM_LATEST, PROGRAM_NAME, and terminate().
05040 {
05041 anova_options * option_data = NULL;
05042
05043
05044 /*----- Identify software -----*/
05045 printf ("\n\n");
05046 printf ("Program: %s \n", PROGRAM_NAME);
05047 printf ("Author: %s \n", PROGRAM_AUTHOR);
05048 printf ("Initial Release: %s \n", PROGRAM_INITIAL);
05049 printf ("Latest Revision: %s \n", PROGRAM_LATEST);
05050 printf ("\n");
05051
05052 /*----- does user request help menu? -----*/
05053 if (argc < 2 || strncmp(argv[1], "-help", 5) == 0) display_help_menu();
05054
05055 /*-- 20 Apr 2001: addto the arglist, if user wants to [RWCox] --*/
05056
05057 mainENTRY("3dANOVA3 main") ; machdep() ;
05058 { int new_argc ; char ** new_argv ;
05059 addto_args( argc , argv , &new_argc , &new_argv ) ;
05060 if( new_argv != NULL ){ argc = new_argc ; argv = new_argv ; }
05061 }
05062
05063 /*----- program initialization -----*/
05064 initialize (argc, argv, &option_data);
05065
05066 /*----- calculate sums and sums of squares -----*/
05067 calculate_anova (option_data);
05068
05069 /*----- generate requested output -----*/
05070 analyze_results (option_data);
05071
05072 /*----- terminate program -----*/
05073 terminate (option_data);
05074 free (option_data); option_data = NULL;
05075
05076 exit(0);
05077 }
|
|
|
Definition at line 1090 of file 3dANOVA3.c. References anova_options::bucket_filename, max, anova_options::model, anova_options::n, anova_options::nfa, anova_options::nfab, anova_options::nfabc, anova_options::nfac, anova_options::nfb, anova_options::nfbc, anova_options::nfc, anova_options::num_acontr, anova_options::num_adiffs, anova_options::num_ameans, anova_options::num_bcontr, anova_options::num_bdiffs, anova_options::num_bmeans, anova_options::num_ccontr, anova_options::num_cdiffs, anova_options::num_cmeans, anova_options::num_xdiffs, and anova_options::num_xmeans.
01091 {
01092 int now; /* current number of disk files */
01093 int nout; /* number of output files */
01094 int nmax; /* maximum number of disk files */
01095
01096
01097 /*----- maximum and current number of temporary data files -----*/
01098 if (option_data->model != 5)
01099 {
01100 nmax = 10;
01101 now = 8;
01102 }
01103 else
01104 {
01105 nmax = 8;
01106 now = 6;
01107 }
01108
01109 if (option_data->n == 1)
01110 {
01111 nmax -= 1;
01112 now -= 1;
01113 }
01114
01115
01116 /*----- space for output files -----*/
01117 nout = option_data->nfa + option_data->nfb + option_data->nfc
01118 + option_data->nfab + option_data->nfac + option_data->nfbc
01119 + option_data->nfabc
01120 + option_data->num_ameans + option_data->num_bmeans
01121 + option_data->num_cmeans + option_data->num_xmeans
01122 + option_data->num_adiffs + option_data->num_bdiffs
01123 + option_data->num_cdiffs + option_data->num_xdiffs
01124 + option_data->num_acontr + option_data->num_bcontr
01125 + option_data->num_ccontr;
01126
01127 now = now + nout;
01128
01129 nmax = max (now, nmax);
01130
01131 if (option_data->bucket_filename != NULL)
01132 nmax = max (nmax, 2*nout);
01133
01134 return (nmax);
01135 }
|
|
|
Definition at line 4890 of file 3dANOVA3.c. References anova_options::acname, ADN_directory_name, ADN_none, anova_options::adname, anova_options::amname, anova_options::bcname, anova_options::bdname, anova_options::bmname, anova_options::bucket_filename, anova_options::ccname, anova_options::cdname, anova_options::cmname, create_bucket(), destroy_anova_options(), EDIT_dset_items(), EDIT_empty_copy(), anova_options::fabcname, anova_options::fabname, anova_options::facname, anova_options::faname, anova_options::fbcname, anova_options::fbname, anova_options::fcname, anova_options::first_dataset, i, ISVALID_3DIM_DATASET, anova_options::model, anova_options::n, anova_options::nfa, anova_options::nfab, anova_options::nfabc, anova_options::nfac, anova_options::nfb, anova_options::nfbc, anova_options::nfc, anova_options::num_acontr, anova_options::num_adiffs, anova_options::num_ameans, anova_options::num_bcontr, anova_options::num_bdiffs, anova_options::num_bmeans, anova_options::num_ccontr, anova_options::num_cdiffs, anova_options::num_cmeans, anova_options::num_xdiffs, anova_options::num_xmeans, remove_dataset(), anova_options::session, THD_delete_3dim_dataset(), THD_open_dataset(), volume_delete(), anova_options::xdname, and anova_options::xmname.
04891 {
04892 int i;
04893 THD_3dim_dataset * dset=NULL; /* input afni data set pointer */
04894 THD_3dim_dataset * new_dset=NULL; /* output afni data set pointer */
04895
04896
04897 /*----- remove temporary data files -----*/
04898 if (option_data->n != 1) volume_delete ("sse");
04899 volume_delete ("ssa");
04900 volume_delete ("ssb");
04901 volume_delete ("ssab");
04902 if (option_data->model != 5)
04903 {
04904 volume_delete ("ssc");
04905 volume_delete ("ssac");
04906 volume_delete ("ssbc");
04907 volume_delete ("ssabc");
04908 }
04909 else
04910 {
04911 volume_delete ("ssca");
04912 volume_delete ("ssbca");
04913 }
04914
04915
04916 /*----- create bucket dataset -----*/
04917 if (option_data->bucket_filename != NULL)
04918 create_bucket (option_data);
04919
04920
04921 /*----- if 'bucket' datset was created, remove the individual 2-subbrick
04922 data files -----*/
04923 if (option_data->bucket_filename != NULL)
04924 {
04925
04926 /*----- read first dataset -----*/
04927 dset = THD_open_dataset (option_data->first_dataset) ;
04928 if( ! ISVALID_3DIM_DATASET(dset) ){
04929 fprintf(stderr,"*** Unable to open dataset file %s\n",
04930 option_data->first_dataset);
04931 exit(1) ;
04932 }
04933
04934 /*----- make an empty copy of this dataset -----*/
04935 new_dset = EDIT_empty_copy (dset);
04936 THD_delete_3dim_dataset (dset , False); dset = NULL;
04937 EDIT_dset_items (new_dset,
04938 ADN_directory_name, option_data->session,
04939 ADN_none);
04940
04941 /*----- remove F-stat for factor A main effect data file -----*/
04942 if (option_data->nfa != 0)
04943 remove_dataset (new_dset, option_data->faname);
04944
04945 /*----- remove F-stat for factor B main effect data file -----*/
04946 if (option_data->nfb != 0)
04947 remove_dataset (new_dset, option_data->fbname);
04948
04949 /*----- remove F-stat for factor C main effect data file -----*/
04950 if (option_data->nfc != 0)
04951 remove_dataset (new_dset, option_data->fcname);
04952
04953 /*----- remove F-stat for A*B interaction data file -----*/
04954 if (option_data->nfab != 0)
04955 remove_dataset (new_dset, option_data->fabname);
04956
04957 /*----- remove F-stat for A*C interaction data file -----*/
04958 if (option_data->nfac != 0)
04959 remove_dataset (new_dset, option_data->facname);
04960
04961 /*----- remove F-stat for B*C interaction data file -----*/
04962 if (option_data->nfbc != 0)
04963 remove_dataset (new_dset, option_data->fbcname);
04964
04965 /*----- remove F-stat for A*B*C interaction data file -----*/
04966 if (option_data->nfabc != 0)
04967 remove_dataset (new_dset, option_data->fabcname);
04968
04969 /*----- remove factor A level mean data files -----*/
04970 if (option_data->num_ameans > 0)
04971 for (i = 0; i < option_data->num_ameans; i++)
04972 remove_dataset (new_dset, option_data->amname[i]);
04973
04974 /*----- remove factor B level mean data files -----*/
04975 if (option_data->num_bmeans > 0)
04976 for (i = 0; i < option_data->num_bmeans; i++)
04977 remove_dataset (new_dset, option_data->bmname[i]);
04978
04979 /*----- remove factor C level mean data files -----*/
04980 if (option_data->num_cmeans > 0)
04981 for (i = 0; i < option_data->num_cmeans; i++)
04982 remove_dataset (new_dset, option_data->cmname[i]);
04983
04984 /*----- remove individual cell mean data files -----*/
04985 if (option_data->num_xmeans > 0)
04986 for (i = 0; i < option_data->num_xmeans; i++)
04987 remove_dataset (new_dset, option_data->xmname[i]);
04988
04989 /*----- remove difference in factor A levels data files -----*/
04990 if (option_data->num_adiffs > 0)
04991 for (i = 0; i < option_data->num_adiffs; i++)
04992 remove_dataset (new_dset, option_data->adname[i]);
04993
04994 /*----- remove difference in factor B levels data files -----*/
04995 if (option_data->num_bdiffs > 0)
04996 for (i = 0; i < option_data->num_bdiffs; i++)
04997 remove_dataset (new_dset, option_data->bdname[i]);
04998
04999 /*----- remove difference in factor C levels data files -----*/
05000 if (option_data->num_cdiffs > 0)
05001 for (i = 0; i < option_data->num_cdiffs; i++)
05002 remove_dataset (new_dset, option_data->cdname[i]);
05003
05004 /*----- remove difference in cell means data files -----*/
05005 if (option_data->num_xdiffs > 0)
05006 for (i = 0; i < option_data->num_xdiffs; i++)
05007 remove_dataset (new_dset, option_data->xdname[i]);
05008
05009 /*----- remove contrast in factor A levels data files -----*/
05010 if (option_data->num_acontr > 0)
05011 for (i = 0; i < option_data->num_acontr; i++)
05012 remove_dataset (new_dset, option_data->acname[i]);
05013
05014 /*----- remove contrast in factor B levels data files -----*/
05015 if (option_data->num_bcontr > 0)
05016 for (i = 0; i < option_data->num_bcontr; i++)
05017 remove_dataset (new_dset, option_data->bcname[i]);
05018
05019 /*----- remove contrast in factor C levels data files -----*/
05020 if (option_data->num_ccontr > 0)
05021 for (i = 0; i < option_data->num_ccontr; i++)
05022 remove_dataset (new_dset, option_data->ccname[i]);
05023
05024 THD_delete_3dim_dataset (new_dset , False); new_dset = NULL;
05025 }
05026
05027
05028 /*----- deallocate memory -----*/
05029 destroy_anova_options (option_data);
05030
05031 }
|