Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

Doxygen Source Code Documentation


Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search  

thd_statpval.c

Go to the documentation of this file.
00001 /*****************************************************************************
00002    Major portions of this software are copyrighted by the Medical College
00003    of Wisconsin, 1994-2000, and are released under the Gnu General Public
00004    License, Version 2.  See the file README.Copyright for details.
00005 ******************************************************************************/
00006 
00007 #include "mrilib.h"
00008 #include "thd.h"
00009 
00010 /*--------------------------------------------------------------------------
00011   See mri_stats.c for the actual routines.
00012 ----------------------------------------------------------------------------*/
00013 
00014 /****************************************************************/
00015 
00016 float THD_stat_to_pval( float thr , int statcode , float * stataux )
00017 {
00018    float pval = -1.0 ;   /* error flag */
00019 
00020    if( stataux == NULL && statcode != FUNC_ZT_TYPE ) return pval ;
00021 
00022    if( thr == 0.0 ) return 1.0 ;
00023 
00024    switch( statcode ){  /* if statcode is illegal, will return -1 */
00025 
00026       case FUNC_COR_TYPE:
00027          pval = correl_t2p( thr , stataux[0] , stataux[1] , stataux[2] ) ;
00028       break ;
00029 
00030       case FUNC_TT_TYPE:
00031          pval = student_t2p( thr , stataux[0] ) ;
00032       break ;
00033 
00034       case FUNC_FT_TYPE:
00035          pval = fstat_t2p( thr , stataux[0] , stataux[1] ) ;
00036       break ;
00037 
00038       case FUNC_ZT_TYPE:               /* only type that doesn't */
00039          pval = normal_t2p( thr ) ;    /* use stataux parameters */
00040       break ;
00041 
00042       case FUNC_CT_TYPE:
00043          pval = chisq_t2p( thr , stataux[0] ) ;
00044       break ;
00045 
00046       case FUNC_BT_TYPE:
00047          pval = beta_t2p( thr , stataux[0] , stataux[1] ) ;
00048       break ;
00049 
00050       case FUNC_BN_TYPE:
00051          pval = binomial_t2p( thr , stataux[0] , stataux[1] ) ;
00052       break ;
00053 
00054       case FUNC_GT_TYPE:
00055          pval = gamma_t2p( thr , stataux[0] , stataux[1] ) ;
00056       break ;
00057 
00058       case FUNC_PT_TYPE:
00059          pval = poisson_t2p( thr , stataux[0] ) ;
00060       break ;
00061    }
00062 
00063    return pval ;
00064 }
00065 
00066 /****************************************************************/
00067 
00068 float THD_pval_to_stat( float pval , int statcode , float * stataux )
00069 {
00070    float stat = -1.0 ;   /* error flag */
00071 
00072    if( pval >= 0.999999 ) return 0.0 ;  /* WTF */
00073 
00074    if( stataux == NULL && statcode != FUNC_ZT_TYPE ) return pval ;
00075 
00076    switch( statcode ){  /* if statcode is illegal, will return -1 */
00077 
00078       /** the routines below are in mri_stats.c **/
00079 
00080       case FUNC_COR_TYPE:
00081          stat = correl_p2t( pval , stataux[0] , stataux[1] , stataux[2] ) ;
00082       break ;
00083 
00084       case FUNC_TT_TYPE:
00085          stat = student_p2t( pval , stataux[0] ) ;
00086       break ;
00087 
00088       case FUNC_FT_TYPE:
00089          stat = fstat_p2t( pval , stataux[0] , stataux[1] ) ;
00090       break ;
00091 
00092       case FUNC_ZT_TYPE:                /* only type that doesn't */
00093          stat = normal_p2t( pval ) ;    /* use stataux parameters */
00094       break ;
00095 
00096       case FUNC_CT_TYPE:
00097          stat = chisq_p2t( pval , stataux[0] ) ;
00098       break ;
00099 
00100       case FUNC_BT_TYPE:
00101          stat = beta_p2t( pval , stataux[0] , stataux[1] ) ;
00102       break ;
00103 
00104       case FUNC_BN_TYPE:
00105          stat = binomial_p2t( pval , stataux[0] , stataux[1] ) ;
00106       break ;
00107 
00108       case FUNC_GT_TYPE:
00109          stat = gamma_p2t( pval , stataux[0] , stataux[1] ) ;
00110       break ;
00111 
00112       case FUNC_PT_TYPE:
00113          stat = poisson_p2t( pval , stataux[0] ) ;
00114       break ;
00115    }
00116 
00117    return stat ;
00118 }
00119 
00120 /****************************************************************/
00121 
00122 float THD_stat_to_zscore( float thr , int statcode , float * stataux )
00123 {
00124    float zscore = thr ;
00125 
00126    if( stataux == NULL && statcode != FUNC_ZT_TYPE ) return zscore ;
00127 
00128    switch( statcode ){  /* if statcode is illegal, will return -1 */
00129 
00130       /** the routines below are in mri_stats.c **/
00131 
00132       case FUNC_COR_TYPE:
00133          zscore = correl_t2z( thr , stataux[0] , stataux[1] , stataux[2] ) ;
00134       break ;
00135 
00136       case FUNC_TT_TYPE:
00137          zscore = student_t2z( thr , stataux[0] ) ;
00138       break ;
00139 
00140       case FUNC_FT_TYPE:
00141          zscore = fstat_t2z( thr , stataux[0] , stataux[1] ) ;
00142       break ;
00143 
00144       case FUNC_ZT_TYPE:                 /* only type that doesn't */
00145          zscore = normal_t2z( thr ) ;    /* use stataux parameters */
00146       break ;
00147 
00148       case FUNC_CT_TYPE:
00149          zscore = chisq_t2z( thr , stataux[0] ) ;
00150       break ;
00151 
00152       case FUNC_BT_TYPE:
00153          zscore = beta_t2z( thr , stataux[0] , stataux[1] ) ;
00154       break ;
00155 
00156       case FUNC_BN_TYPE:
00157          zscore = binomial_t2z( thr , stataux[0] , stataux[1] ) ;
00158       break ;
00159 
00160       case FUNC_GT_TYPE:
00161          zscore = gamma_t2z( thr , stataux[0] , stataux[1] ) ;
00162       break ;
00163 
00164       case FUNC_PT_TYPE:
00165          zscore = poisson_t2z( thr , stataux[0] ) ;
00166       break ;
00167    }
00168 
00169    return zscore ;
00170 }
 

Powered by Plone

This site conforms to the following standards: