Doxygen Source Code Documentation
cdf.c File Reference
#include "mrilib.h"
Go to the source code of this file.
Functions | |
void | Syntax (void) |
int | main (int argc, char *argv[]) |
Variables | |
char * | Usage_str [3] |
Function Documentation
|
convert DTIStudio fiber format data to SUMA segment data Definition at line 48 of file cdf.c. References argc, FIRST_FUNC_TYPE, FUNC_IS_STAT, LAST_FUNC_TYPE, MAX_STAT_AUX, strtod(), Syntax(), THD_pval_to_stat(), THD_stat_to_pval(), THD_stat_to_zscore(), and Usage_str.
00049 { 00050 int usage = -1 , statcode = -1 , ii,fc,iarg , npar , verb=0 ; 00051 float stat , prob , val ; 00052 float par[MAX_STAT_AUX] ; 00053 char * cpt ; 00054 00055 if( argc < 4 || strcmp(argv[1],"-help") == 0 ) Syntax() ; 00056 00057 iarg = 1 ; 00058 00059 if( strcmp(argv[iarg],"-v") == 0 ){ verb = 1 ; iarg++ ; } 00060 00061 if( strcmp(argv[iarg],"-t2p")==0 || strcmp(argv[iarg],"t2p")==0 ) usage = 1 ; 00062 else if( strcmp(argv[iarg],"-p2t")==0 || strcmp(argv[iarg],"p2t")==0 ) usage = 2 ; 00063 else if( strcmp(argv[iarg],"-t2z")==0 || strcmp(argv[iarg],"t2z")==0 ) usage = 3 ; 00064 00065 if( usage < 0 ){ 00066 fprintf(stderr,"Don't recognize usage code: %s\n",argv[iarg]) ; exit(1) ; 00067 } 00068 if( verb ) printf("*** usage=%d: %s\n",usage,Usage_str[usage-1]) ; 00069 00070 iarg++ ; 00071 00072 fc = (argv[iarg][0] == '-') ? 1 : 0 ; 00073 for( ii=FIRST_FUNC_TYPE ; ii <= LAST_FUNC_TYPE ; ii++ ){ 00074 if( ! FUNC_IS_STAT(ii) ) continue ; 00075 if( strcmp( &(argv[iarg][fc]) , FUNC_prefixstr[ii] ) == 0 ){ 00076 statcode = ii ; break ; 00077 } 00078 } 00079 00080 if( statcode < 0 ){ 00081 fprintf(stderr,"Don't recognize statname: %s\n",argv[iarg]) ; exit(1) ; 00082 } 00083 if( verb ) printf("*** statcode=%d type=%s\n",statcode,FUNC_typestr[ii]+6) ; 00084 iarg++ ; 00085 00086 stat = strtod( argv[iarg] , &cpt ) ; 00087 if( usage == 2 ) prob = stat ; 00088 00089 if( verb ) printf("*** value=%g\n",stat) ; 00090 00091 if( *cpt != '\0' ){ 00092 fprintf(stderr,"Illegal numeric parameter: %s\n",argv[iarg]) ; exit(1) ; 00093 } 00094 00095 iarg++ ; ii = 0 ; 00096 while( iarg < argc && ii < MAX_STAT_AUX ){ 00097 val = strtod( argv[iarg] , &cpt ) ; 00098 if( *cpt != '\0' ){ 00099 fprintf(stderr,"Illegal numeric parameter: %s\n",argv[iarg]) ; exit(1) ; 00100 } 00101 par[ii++] = val ; iarg++ ; 00102 } 00103 npar = ii ; 00104 00105 if( verb ){ 00106 printf("*** npar=%d parameters=",npar) ; 00107 for( ii=0 ; ii < npar ; ii++ ) printf("%g ",par[ii]) ; 00108 printf("\n") ; 00109 } 00110 00111 if( npar < FUNC_need_stat_aux[statcode] ){ 00112 fprintf(stderr,"Need %d parameters, but you only gave %d\n", 00113 FUNC_need_stat_aux[statcode] , npar ) ; 00114 exit(1) ; 00115 } 00116 00117 switch( usage ){ 00118 00119 case 1: prob = THD_stat_to_pval( stat , statcode , par ) ; 00120 printf("p = %g\n",prob) ; 00121 break ; 00122 00123 case 2: stat = THD_pval_to_stat( prob , statcode , par ) ; 00124 printf("t = %g\n",stat) ; 00125 break ; 00126 00127 case 3: val = THD_stat_to_zscore( stat , statcode , par ) ; 00128 printf("z = %g\n",val) ; 00129 break ; 00130 } 00131 00132 exit(0) ; 00133 } |
|
31 July 1996: be more specific about errors * Definition at line 9 of file cdf.c. References FIRST_FUNC_TYPE, FUNC_IS_STAT, and LAST_FUNC_TYPE.
00010 { 00011 int ii ; 00012 00013 printf("Usage 1: cdf [-v] -t2p statname t params\n" 00014 "Usage 2: cdf [-v] -p2t statname p params\n" 00015 "Usage 3: cdf [-v] -t2z statname t params\n" 00016 "\n" 00017 "This program does various conversions using the cumulative distribution\n" 00018 "function (cdf) of certain canonical probability functions. The optional\n" 00019 "'-v' indicates to be verbose -- this is for debugging purposes, mostly.\n" 00020 "\n" 00021 "Usage 1: Converts a statistic 't' to a tail probability.\n" 00022 "Usage 2: Converts a tail probability 'p' to a statistic.\n" 00023 "Usage 3: Converts a statistic 't' to a N(0,1) value (or z-score)\n" 00024 " that has the same tail probability.\n" 00025 "\n" 00026 "The parameter 'statname' refers to the type of distribution to be used.\n" 00027 "The numbers in the params list are the auxiliary parameters for the\n" 00028 "particular distribution. The following table shows the available\n" 00029 "distribution functions and their parameters:\n\n" 00030 ) ; 00031 00032 printf(" statname Description PARAMETERS\n" 00033 " -------- ----------- ----------------------------------------\n" ) ; 00034 for( ii=FIRST_FUNC_TYPE ; ii <= LAST_FUNC_TYPE ; ii++ ){ 00035 if( FUNC_IS_STAT(ii) ) 00036 printf(" %4s %-11.11s %s\n", 00037 FUNC_prefixstr[ii] , FUNC_typestr[ii]+6 , FUNC_label_stat_aux[ii] ) ; 00038 } 00039 00040 printf("\n") ; exit(0) ; 00041 } |
Variable Documentation
|
Initial value: { "-t2p = statistic-to-probability" , "-p2t = probability-to-statistic" , "-t2z = statistic-to-N(0,1) [z-score]" } Definition at line 43 of file cdf.c. Referenced by main(). |