00001
00005 #include <bpm/bpm_interface.h>
00006 #include <bpm/bpm_rf.h>
00007 #include <bpm/bpm_alloc.h>
00008 #include <bpm/bpm_nr.h>
00009
00024 int rf_butterworthhighpass( double **RF, int order, double fc ) {
00025
00026
00027 int i = 0;
00028 double f;
00029
00030 if ( ! RF ) {
00031 bpm_error( "Invalid RF pointer in rf_butterworthlowpass(...)",
00032 __FILE__, __LINE__ );
00033 return BPM_FAILURE;
00034 }
00035
00036 if ( fc <= 0 ) {
00037 bpm_error( "Cut off frequency =< 0 in rf_butterworthlowpass(...)",
00038 __FILE__, __LINE__);
00039 return BPM_FAILURE;
00040 }
00041
00042 if ( order <= 0 ) {
00043 bpm_error( "Order of filter =< 0 in rf_butterworthlowpass(...)",
00044 __FILE__, __LINE__);
00045 return BPM_FAILURE;
00046 }
00047
00048
00049 double **FFT = alloc_complex_wave_double( rf_nsamples );
00050
00051
00052 rf_complexFFT( RF, FFT, NR_FFTFORWARD );
00053
00054
00055 for( i = 0; i < rf_nsamples; i++ ) {
00056
00057
00058
00059 f = rf_samplefreq * 1.e6 / rf_nsamples * ( i + 0.5 );
00060
00061 if ( f > rf_samplefreq * 1.e6 / 2. ) f -= rf_samplefreq * 1.e6;
00062 FFT[i][Re] *= 1. / ( 1. + pow( f / ( fc * 1.e6 ), 2.* order ) );
00063 FFT[i][Im] *= 1. / ( 1. + pow( f / ( fc * 1.e6 ), 2.* order ) );
00064 }
00065
00066
00067 rf_complexFFT( FFT, RF, NR_FFTBACKWARD );
00068
00069
00070 for( i = 0; i < rf_nsamples; i++ ) {
00071 RF[i][Re] *= 2. / (double) rf_nsamples;
00072 RF[i][Im] *= 2. / (double) rf_nsamples;
00073 }
00074
00075
00076 free_complex_wave_double( FFT, rf_nsamples );
00077
00078 return BPM_SUCCESS;
00079 }
00080