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  

imaver.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 <string.h>
00009 
00010 #ifndef MAX
00011 # define MAX(x,y) (((x)>(y))?(x):(y))
00012 #endif
00013 
00014 /*---------------------------------------------------------------------------*/
00015 
00016 int main( int argc , char * argv[] )
00017 {
00018    int narg , narg_ave,narg_sig ;
00019    MRI_IMAGE * imin , ** imstat ;
00020    int to_short = -1 ;
00021 
00022 /*** process command switches ***/
00023 
00024    if( argc < 5 || strncmp(argv[1],"-help",2) == 0 ){
00025       printf( "Usage: imaver out_ave out_sig input_images ...\n"
00026               "       (use - to skip output of out_ave and/or out_sig)\n"
00027               "* Computes the mean and standard deviation, pixel-by-pixel,\n"
00028               "   of a whole bunch of images.\n"
00029               "* Write output images in 'short int' format if inputs are\n"
00030               "   short ints, otherwise output images are floating point.\n"
00031             ) ;
00032       exit(0) ;
00033    }
00034 
00035    machdep() ;
00036 
00037    narg = 1 ;
00038 
00039 /*** process input files ***/
00040 
00041    narg_ave = narg++ ;
00042    narg_sig = narg++ ;
00043 
00044    do{
00045       imin = mri_read_just_one( argv[narg] ) ;
00046       if( imin == NULL ) continue ;   /* skip this image! */
00047 
00048       if( to_short == -1 ) to_short = (imin->kind == MRI_short) ;
00049 
00050       (void) mri_stat_seq( imin ) ;
00051       mri_free( imin ) ;
00052    } while( ++narg < argc ) ;
00053 
00054 /*** compute output ***/
00055 
00056    imstat = mri_stat_seq( NULL ) ;
00057 
00058    if( strcmp(argv[narg_ave],"-") != 0 ){
00059       if( to_short ) imin = mri_to_short( 1.0 , imstat[0] ) ;
00060       else           imin = imstat[0] ;
00061       
00062       mri_write( argv[narg_ave] , imin ) ;
00063       mri_free( imin ) ;
00064    }
00065 
00066    if( strcmp(argv[narg_sig],"-") != 0 ){
00067       if( to_short ) imin = mri_to_short( 1.0 , imstat[1] ) ;
00068       else           imin = imstat[1] ;
00069       
00070       mri_write( argv[narg_sig] , imin ) ;
00071       mri_free( imin ) ;
00072    }
00073 
00074    exit(0) ;
00075 }
 

Powered by Plone

This site conforms to the following standards: