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_floatscan.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 <math.h>
00008 #include <stdlib.h>
00009 
00010 #ifdef isfinite
00011 # define IS_GOOD_FLOAT(x) isfinite(x) /* 28 Aug 2003: use C99 macro if exists */
00012 #else
00013 # define IS_GOOD_FLOAT(x) finite(x)
00014 #endif
00015 
00016 #if 0
00017 # define IS_GOOD_FLOAT(x) isnan(x)
00018 #endif
00019 
00020 /*---------------------------------------------------------------------
00021    Scan an array of floats for illegal values, replacing them with 0.
00022    Return the number of illegal values found.
00023 -----------------------------------------------------------------------*/
00024 
00025 int thd_floatscan( int nbuf , float * fbuf )
00026 {
00027    int ii , nerr ;
00028 
00029    if( nbuf <= 0 || fbuf == NULL ) return 0 ;
00030 
00031    for( nerr=ii=0 ; ii < nbuf ; ii++ ){
00032       if( !IS_GOOD_FLOAT(fbuf[ii]) ){ fbuf[ii] = 0.0 ; nerr++ ; }
00033    }
00034 
00035    return nerr ;
00036 }
00037 
00038 typedef struct complex { float r , i ; } complex ;
00039 
00040 int thd_complexscan( int nbuf , complex * cbuf )
00041 {
00042    int ii , nerr ;
00043 
00044    if( nbuf <= 0 || cbuf == NULL ) return 0 ;
00045 
00046    for( nerr=ii=0 ; ii < nbuf ; ii++ ){
00047       if( !IS_GOOD_FLOAT(cbuf[ii].r) ){ cbuf[ii].r = 0.0 ; nerr++ ; }
00048       if( !IS_GOOD_FLOAT(cbuf[ii].i) ){ cbuf[ii].i = 0.0 ; nerr++ ; }
00049    }
00050 
00051    return nerr ;
00052 }
 

Powered by Plone

This site conforms to the following standards: