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_entropy16.c File Reference

#include "mrilib.h"

Go to the source code of this file.


Defines

#define SNUM   65536

Functions

void ENTROPY_setup (void)
void ENTROPY_setdown (void)
void ENTROPY_accumulate (int nbytes, void *var)
double ENTROPY_compute (void)
double ENTROPY_dataset (THD_3dim_dataset *dset)
double ENTROPY_datablock (THD_datablock *blk)

Variables

int * scount = NULL
int snum = 0

Define Documentation

#define SNUM   65536
 

Definition at line 7 of file thd_entropy16.c.

Referenced by ENTROPY_compute(), and ENTROPY_setup().


Function Documentation

void ENTROPY_accumulate int    nbytes,
void *    var
 

Definition at line 30 of file thd_entropy16.c.

References ENTROPY_setup(), scount, snum, and var.

Referenced by ENTROPY_datablock(), and main().

00031 {
00032    int nn = nbytes/2 , ii ;
00033    unsigned short * sar = (unsigned short *) var ;
00034 
00035    if( scount == NULL ) ENTROPY_setup() ;
00036 
00037    for( ii=0 ; ii < nn ; ii++ ) scount[sar[ii]]++ ;
00038    snum += nn ;
00039 }

double ENTROPY_compute void   
 

Definition at line 45 of file thd_entropy16.c.

References scount, SNUM, and snum.

Referenced by ENTROPY_datablock(), and main().

00046 {
00047    register int ii ;
00048    register double sum ;
00049 
00050    if( scount == NULL || snum == 0 ) return 0.0 ;
00051 
00052    sum = 0.0 ;
00053    for( ii=0 ; ii < SNUM ; ii++ )
00054       if( scount[ii] > 0 ) sum += scount[ii] * log((double)scount[ii]) ;
00055 
00056    sum = -(sum - snum*log((double)snum)) / ( log(2.0) * snum ) ;
00057    return sum ;
00058 }

double ENTROPY_datablock THD_datablock   blk
 

Definition at line 72 of file thd_entropy16.c.

References DBLK_ARRAY, DBLK_BRICK_BYTES, ENTROPY_accumulate(), ENTROPY_compute(), ENTROPY_setdown(), ENTROPY_setup(), ENTRY, THD_datablock::nvals, and RETURN.

Referenced by ENTROPY_dataset(), and THD_write_datablock().

00073 {
00074    int iv ;
00075    double sum ;
00076 
00077 ENTRY("ENTROPY_datablock") ;
00078 
00079    ENTROPY_setup() ;
00080 
00081    for( iv=0 ; iv < blk->nvals ; iv++ )
00082       ENTROPY_accumulate( DBLK_BRICK_BYTES(blk,iv) , DBLK_ARRAY(blk,iv) ) ;
00083 
00084    sum = ENTROPY_compute() ;
00085    ENTROPY_setdown() ;
00086    RETURN(sum) ;
00087 }

double ENTROPY_dataset THD_3dim_dataset   dset
 

Definition at line 62 of file thd_entropy16.c.

References THD_3dim_dataset::dblk, DSET_load, DSET_LOADED, ENTROPY_datablock(), and ISVALID_DSET.

Referenced by main().

00063 {
00064    if( !ISVALID_DSET(dset) ) return(0.0) ;
00065    DSET_load(dset) ;
00066    if( !DSET_LOADED(dset) ) return(0.0) ;
00067    return ENTROPY_datablock( dset->dblk ) ;
00068 }

void ENTROPY_setdown void   
 

Definition at line 23 of file thd_entropy16.c.

References free, scount, and snum.

Referenced by ENTROPY_datablock(), and main().

00024 {
00025    if( scount != NULL ){ free(scount); scount = NULL; snum = 0; }
00026 }

void ENTROPY_setup void   
 

Definition at line 14 of file thd_entropy16.c.

References malloc, scount, snum, and SNUM.

Referenced by ENTROPY_accumulate(), ENTROPY_datablock(), and main().

00015 {
00016    if( scount == NULL ) scount = (int *) malloc(sizeof(int)*SNUM) ;
00017    memset( scount , 0 , sizeof(int)*SNUM ) ;
00018    snum = 0 ;
00019 }

Variable Documentation

int* scount = NULL [static]
 

Definition at line 9 of file thd_entropy16.c.

Referenced by ENTROPY_accumulate(), ENTROPY_compute(), ENTROPY_setdown(), and ENTROPY_setup().

int snum = 0 [static]
 

Definition at line 10 of file thd_entropy16.c.

Referenced by ENTROPY_accumulate(), ENTROPY_compute(), ENTROPY_setdown(), and ENTROPY_setup().

 

Powered by Plone

This site conforms to the following standards: