Doxygen Source Code Documentation
Main Page Alphabetical List Data Structures File List Data Fields Globals Search
3dFFT.c
Go to the documentation of this file.00001
00002 #include "mrilib.h"
00003
00004 #define FFT_ABS 1
00005 #define FFT_PHASE 2
00006 #define FFT_COMPLEX 3
00007
00008 int main( int argc , char *argv[] )
00009 {
00010 THD_3dim_dataset *dset_in , *dset_out ;
00011 int Lxx=-1 , Lyy=-1 , Lzz=-1 , Mode=FFT_ABS ;
00012 char *prefix = "FFT" ;
00013 int iarg ;
00014
00015 if( argc < 2 || strcmp(argv[1],"-help") == 0 ){
00016 printf(
00017 "Usage: 3dFFT [options] dataset\n"
00018 "Does the FFT of the input dataset in 3 directions (x,y,z) and\n"
00019 "produces the output dataset.\n"
00020 "\n"
00021 "Options\n"
00022 "=======\n"
00023 " -abs = Outputs the magnitude of the FFT [default]\n"
00024 " -phase = Outputs the phase of the FFT (-PI..PI)\n"
00025 " -complex = Outputs the complex FFT\n"
00026 " -Lx xx = Use FFT of length 'xx' in the x-direction\n"
00027 " -Ly yy = Use FFT of length 'yy' in the y-direction\n"
00028 " -Lz zz = Use FFT of length 'zz' in the z-direction\n"
00029 " * Set a length to 0 to skip\n"
00030 " the FFT in that direction\n"
00031 " -prefix pp = Use 'pp' for the output dataset prefix.\n"
00032 "\n"
00033 "Notes\n"
00034 "=====\n"
00035 " * The program can only do FFT lengths that are factorable\n"
00036 " into powers of 2, 3, and 5.\n"
00037 " * For -abs and -phase, the output dataset is in float format.\n"
00038 ) ;
00039 exit(0) ;
00040 }
00041
00042 mainENTRY("3dFFT main") ; machdep() ;
00043
00044
00045
00046 iarg = 1 ;
00047
00048 while( iarg < argc && argv[iarg][0] == '-' ){
00049
00050 if( strcmp(argv[iarg],"-abs") == 0 ){
00051 Mode = FFT_ABS ; iarg++ ; continue ;
00052 }
00053 if( strcmp(argv[iarg],"-phase") == 0 ){
00054 Mode = FFT_PHASE ; iarg++ ; continue ;
00055 }
00056 if( strcmp(argv[iarg],"-complex") == 0 ){
00057 Mode = FFT_COMPLEX ; iarg++ ; continue ;
00058 }
00059
00060 if( strlen(argv[iarg]) == 3 && strncmp(argv[iarg],"-L",2) == 0 ){
00061 int lll=-1 ; char *ept ;
00062 iarg++ ;
00063 if( iarg >= argc ){
00064 fprintf(stderr,"** ERROR: need an argument after %s\n",argv[iarg-1]) ;
00065 exit(1) ;
00066 }
00067 lll = strtol( argv[iarg] , &ept , 10 ) ;
00068 if( *ept != '\0' ){
00069 fprintf(stderr,"** ERROR: bad argument after %s\n",argv[iarg-1]) ;
00070 exit(1) ;
00071 }
00072 switch( argv[iarg-1][2] ){
00073 case 'x': Lxx = lll ; break ;
00074 case 'y': Lyy = lll ; break ;
00075 case 'z': Lzz = lll ; break ;
00076 default:
00077 fprintf(stderr,"** ERROR: unknown option '%s'\n",argv[iarg-1]) ;
00078 exit(1) ;
00079 }
00080 iarg++ ; continue ;
00081 }
00082
00083 if( strcmp(argv[iarg],"-prefix") == 0 ){
00084 iarg++ ;
00085 if( iarg >= argc ){
00086 fprintf(stderr,"** ERROR: need an argument after %s\n",argv[iarg-1]) ;
00087 exit(1) ;
00088 }
00089 prefix = strdup( argv[iarg] ) ;
00090 if( !THD_filename_ok(prefix) ){
00091 fprintf(stderr,"** ERROR: bad argument after %s\n",argv[iarg-1]) ;
00092 exit(1) ;
00093 }
00094 iarg++ ; continue ;
00095 }
00096
00097 fprintf(stderr,"** ERROR: unknown option '%s'\n",argv[iarg]) ;
00098 exit(1) ;
00099 }
00100
00101 if( iarg >= argc ){
00102 fprintf(stderr,"** ERROR: no input dataset on command line?!\n") ;
00103 exit(1) ;
00104 }
00105 if( Lxx == 0 && Lyy == 0 && Lzz == 0 ){
00106 fprintf(stderr,"** ERROR: -Lx, -Ly, -Lz all given as zero?!\n") ;
00107 exit(1) ;
00108 }
00109
00110
00111
00112 dset_in = THD_open_dataset( argv[iarg] ) ;
00113 if( dset_in == NULL ){
00114 fprintf(stderr,"** ERROR: can't open dataset %s\n",argv[iarg]) ;
00115 exit(1) ;
00116 }
00117 }