Doxygen Source Code Documentation
3dFourier.c File Reference
#include "mrilib.h"#include <stdio.h>#include <stdlib.h>#include <string.h>#include <math.h>#include "fourier_filter.c"Go to the source code of this file.
Functions | |
| void * | My_Malloc (size_t) |
| void | Error_Exit (char *message) |
| void | help_message (void) |
| int | main (int argc, char *argv[]) |
Function Documentation
|
|
Definition at line 25 of file 3dFourier.c.
00026 {
00027 fprintf(stderr, "\n\nError in 3dFourier:\n%s\n\nTry 3dFourier -help\n",message);
00028 exit(1);
00029 }
|
|
|
Definition at line 37 of file 3dFourier.c. References MASTER_SHORTHELP_STRING. Referenced by main().
00038 {
00039 printf(
00040 "3dFourier \n"
00041 "(c) 1999 Medical College of Wisconsin\n"
00042 "by T. Ross and K. Heimerl\n"
00043 "Version 0.8 last modified 8-17-99\n\n"
00044 "Usage: 3dFourier [options] dataset\n\n"
00045 "The paramters and options are:\n"
00046 " dataset an afni compatible 3d+time dataset to be operated upon\n"
00047 " -prefix name output name for new 3d+time dataset [default = fourier]\n"
00048 " -lowpass f low pass filter with a cutoff of f Hz\n"
00049 " -highpass f high pass filter with a cutoff of f Hz\n"
00050 " -ignore n ignore the first n images [default = 1]\n"
00051 /* " -autocorr compute the autocorrelation of the data\n" */
00052 " -retrend Any mean and linear trend are removed before filtering.\n"
00053 " This will restore the trend after filtering.\n"
00054 "\nNote that by combining the lowpass and highpass options, one can construct\n"
00055 "bandpass and notch filters\n"
00056 );
00057
00058 printf("\n" MASTER_SHORTHELP_STRING ) ;
00059
00060 }
|
|
||||||||||||
|
compute the overall minimum and maximum voxel values for a dataset Definition at line 64 of file 3dFourier.c. References argc, DSET_BRICK_TYPE, DSET_GRAPHABLE, Error_Exit(), Fourier_Filter_Driver(), help_message(), My_Malloc(), and THD_open_dataset().
00065 {
00066 int j, narg=1, autocorr=FALSE, retrend=FALSE, ignore=1;
00067 char *prefix=NULL, *err;
00068 float low_fc = 0.0, high_fc = 0.0;
00069 THD_3dim_dataset *input=NULL;
00070
00071 if (argc < 2 || strcmp(argv[1],"-help") == 0 ) {
00072 help_message();
00073 exit(1);
00074 }
00075
00076 /* Loop over arguements and pull out what we need */
00077 while( narg < argc && argv[narg][0] == '-' ){
00078
00079 if( strncmp(argv[narg],"-prefix",5) == 0 ) {
00080 narg++;
00081 if (narg==argc)
00082 Error_Exit("-prefix must be followed by a file name");
00083 j = strlen(argv[narg]);
00084 prefix =(char *)My_Malloc((j+1)*sizeof(char));
00085 strcpy(prefix, argv[narg++]);
00086 continue;
00087 }
00088
00089 if (strncmp(argv[narg], "-lowpass", 5) == 0) {
00090 narg++;
00091 if (narg==argc)
00092 Error_Exit("-lowpass must be followed by a frequency");
00093 low_fc = (float)atof(argv[narg++]);
00094 continue;
00095 }
00096
00097 if (strncmp(argv[narg], "-highpass", 5) == 0) {
00098 narg++;
00099 if (narg==argc)
00100 Error_Exit("-highpass must be followed by a frequency");
00101 high_fc = (float)atof(argv[narg++]);
00102 continue;
00103 }
00104
00105 if (strncmp(argv[narg], "-ignore", 5) == 0) {
00106 narg++;
00107 if (narg==argc)
00108 Error_Exit("-ignore must be followed by an integer");
00109 ignore = (int)atol(argv[narg++]);
00110 if ((ignore<0) || (ignore>10))
00111 Error_Exit("-ignore must be between 0 and 10, inclusive");
00112 continue;
00113 }
00114 /*
00115 if (strncmp(argv[narg], "-autocorr", 5) == 0) {
00116 narg++;
00117 autocorr = TRUE;
00118 continue;
00119 }
00120 */
00121 if (strncmp(argv[narg], "-retrend", 5) == 0) {
00122 narg++;
00123 retrend = TRUE;
00124 continue;
00125 }
00126
00127 if (strncmp(argv[narg], "-help", 5) == 0) {
00128 help_message();
00129 }
00130
00131
00132 Error_Exit("Illegal or unrecoginized option");
00133
00134 } /* end of while over arguements */
00135
00136 #if 1
00137 if( low_fc > 0.0f && high_fc > 0.0f && low_fc <= high_fc )
00138 fprintf(stderr,"** WARNING: lowpass=%f is <= than highpass=%f\n"
00139 "** -------: results from 3dFourier are suspect!\n" ,
00140 low_fc,high_fc) ;
00141 #endif
00142
00143 if( narg >= argc )
00144 Error_Exit("No input datasets!?\n");
00145
00146 if(prefix==NULL) {
00147 prefix=(char *)My_Malloc(8*sizeof(char));
00148 strcpy(prefix,"fourier");
00149 }
00150
00151 /* try to open input dataset */
00152
00153 input = THD_open_dataset( argv[narg] ) ; /* 16 Sep 1999 */
00154
00155 if( input == NULL )
00156 Error_Exit("Cannot open input dataset!") ;
00157
00158 if (!DSET_GRAPHABLE(input))
00159 Error_Exit("Input dataset is not a 3d+time dataset");
00160
00161 if (DSET_BRICK_TYPE(input, 0)==MRI_complex)
00162 Error_Exit("Sorry, I can't deal with complex 3d+time datasets");
00163
00164 err=Fourier_Filter_Driver(input, low_fc, high_fc, ignore, autocorr, retrend, prefix);
00165 if (err!=NULL)
00166 Error_Exit(err);
00167
00168 return 0; /* All went well exit code */
00169 }
|
|
|
Definition at line 11 of file fourier_filter.c.
00011 {
00012 void *ptr=NULL;
00013
00014 ptr = (void *)malloc(size);
00015 if (ptr == NULL) {
00016 #ifdef IN_FOURIER_PLUGIN
00017 fprintf(stderr, "Fatal error in Fourier Filter Driver, malloc returned NULL");
00018 exit(1);
00019 #else
00020 Error_Exit("Fatal: malloc returned NULL");
00021 #endif
00022 }
00023 return ptr;
00024 }
|