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  

uuu2.c File Reference

#include "mrilib.h"

Go to the source code of this file.


Functions

void set_unusuality_tail (float p)
void find_unusual_correlations (int nr, float *rr, int *nhi, int *ihi)

Variables

float zstar = 0.0
float pstar = 0.0

Function Documentation

void find_unusual_correlations int    nr,
float *    rr,
int *    nhi,
int *    ihi
 

Definition at line 27 of file uuu2.c.

References free, getenv(), malloc, nr, qsort_float(), qsort_floatint(), set_unusuality_tail(), strtod(), and zstar.

00029 {
00030    int   ii , nzero,mzero ;
00031    float zmid,zsig,zmed , rmid,rcut ;
00032    float * zz , * aa ;
00033    int   * iz ;
00034 
00035    if( nhi == NULL ) return ;  /* illegal entry */
00036 
00037    *nhi = 0 ;                  /* default return */
00038 
00039    if( nr < 1000 || rr == NULL || ihi == NULL ) return ;  /* illegal entry */
00040 
00041    /*-- make workspace --*/
00042 
00043    zz = (float *) malloc(sizeof(float)*nr*2) ; aa = zz + nr ;
00044    iz = (int *)   malloc(sizeof(int)  *nr  ) ;
00045 
00046    if( zstar <= 0.0 ){               /* initialize zstar if needed */
00047       char * cp = getenv("PTAIL") ;
00048       float pp = 0.0001 ;
00049       if( cp != NULL ){
00050          float xx = strtod( cp , NULL ) ;
00051          if( xx > 0.0 && xx < 1.0 ) pp = xx ;
00052       }
00053       set_unusuality_tail( pp ) ;
00054    }
00055 
00056    /*-- copy data into workspace --*/
00057 
00058    memcpy( zz , rr , sizeof(float)*nr ) ;             /* the copy */
00059    for( ii=0 ; ii < nr ; ii++ ) iz[ii] = ii ;         /* tag location */
00060    qsort_floatint( nr , zz , iz ) ;                   /* sort now */
00061 
00062    /*- trim off 1's (perfect correlations) -*/
00063 
00064    for( ii=nr-1 ; ii > 0 && zz[ii] > 0.999 ; ii-- ) ;  /* nada */
00065    if( ii == 0 ){ free(zz); free(iz); return; }        /* shouldn't happen */
00066    nr = ii+1 ;                                         /* the trim */
00067 
00068    /*-- find median of atanh(rr) --*/
00069 
00070    if( nr%2 == 1 )              /* median */
00071       zmid = zz[nr/2] ;
00072    else
00073       zmid = 0.5 * ( zz[nr/2] + zz[nr/2-1] ) ;
00074 
00075    rmid = zmid ;        /* median of rr */
00076    zmid = atanh(zmid) ; /* median of atanh(rr) */
00077 
00078    /*-- aa = fabs( tanh( atanh(zz) - atanh(rmid) ) ) --*/
00079 
00080    for( ii=0 ; ii < nr ; ii++ )
00081       aa[ii] = fabs( (zz[ii]-rmid)/(1.0-zz[ii]*rmid) ) ;
00082 
00083    /*-- find MAD of atanh(rr) --*/
00084 
00085    qsort_float( nr , aa ) ;
00086    if( nr%2 == 1 )              /* MAD = median absolute deviation */
00087       zmed = aa[nr/2] ;
00088    else
00089       zmed = 0.5 * ( aa[nr/2] + aa[nr/2-1] ) ;
00090 
00091    zmed = atanh(zmed) ;         /* MAD of atanh(rr) */
00092    zsig = 1.4826 * zmed ;       /* estimate standard dev. of atanh(rr) */
00093                                 /* 1.4826 = 1/(sqrt(2)*erfinv(0.5))    */
00094 
00095    if( zsig <= 0.0 ){ free(zz); free(iz); return; } /* shouldn't happen */
00096 
00097    /*-- find values of correlation greater than threshold --*/
00098    /*-- that is, with (atanh(rr)-zmid)/zsig > zstar       --*/
00099 
00100    rcut = tanh( zsig*zstar + zmid ) ;
00101    for( ii=nr-1 ; ii > 0 ; ii-- ) if( zz[ii] < rcut ) break ;
00102 
00103    nzero = ii+1 ; mzero = nr - nzero ;
00104 
00105    *nhi = mzero ;
00106    for( ii=0 ; ii < mzero ; ii++ ) ihi[ii] = iz[nzero+ii] ;
00107 
00108    free(zz) ; free(iz) ; return ;
00109 }

void set_unusuality_tail float    p
 

Definition at line 11 of file uuu2.c.

References p, pstar, qginv(), and zstar.

00012 {
00013    if( p > 0.0 && p < 1.0 ){
00014       zstar = qginv(p) ;
00015       pstar = p ;
00016    }
00017    return ;
00018 }

Variable Documentation

float pstar = 0.0 [static]
 

Definition at line 9 of file uuu2.c.

Referenced by set_unusuality_tail().

float zstar = 0.0 [static]
 

Definition at line 8 of file uuu2.c.

Referenced by find_unusual_correlations(), and set_unusuality_tail().

 

Powered by Plone

This site conforms to the following standards: