1 /*****************************************************************************
2 Major portions of this software are copyrighted by the Medical College
3 of Wisconsin, 1994-2000, and are released under the Gnu General Public
4 License, Version 2. See the file README.Copyright for details.
5 ******************************************************************************/
6
7 #include "mrilib.h"
8
9 /*----------------------------------------------------------------------------
10 Convert an array of statistics to N(0,1) (or z-score) values.
11 For t and correlation statistics, the z-scores will be signed.
12 For other types, the statistic is always positive and so will the z-score.
13 17 Sep 1998 -- RWCox
14 ------------------------------------------------------------------------------*/
15
EDIT_zscore_vol(int nvox,int vtype,float vfac,void * var,int statcode,float * stataux)16 void EDIT_zscore_vol( int nvox ,
17 int vtype , float vfac , void * var ,
18 int statcode , float * stataux )
19 {
20 register int ii ;
21
22 ENTRY("EDIT_zscore_vol") ;
23
24 /*-- sanity checks --*/
25
26 if( nvox < 1 || /* no data? */
27 var == NULL || /* no data? */
28 ! FUNC_IS_STAT(statcode) || /* not a statistic? */
29 statcode == FUNC_ZT_TYPE || /* already a z-score? */
30 ( vtype != MRI_short && vtype != MRI_float ) /* illegal type of data? */
31 ) EXRETURN ;
32
33 /*-- what type of data? --*/
34
35 switch( vtype ){
36
37 case MRI_float:{
38 register float * bar = (float *) var ;
39 register float fac = (vfac != 0.0 ) ? vfac : 1.0 ;
40
41 for( ii=0 ; ii < nvox ; ii++ )
42 bar[ii] = THD_stat_to_zscore( fac*bar[ii] , statcode , stataux ) ;
43 }
44 break ;
45
46 case MRI_short:{
47 register short * bar = (short *) var ;
48 register float fac = (vfac != 0.0 ) ? vfac : 1.0 ;
49
50 for( ii=0 ; ii < nvox ; ii++ )
51 bar[ii] = (short) ( FUNC_ZT_SCALE_SHORT
52 * THD_stat_to_zscore(fac*bar[ii],statcode,stataux) ) ;
53 }
54 break ;
55 }
56
57 EXRETURN ;
58 }
59