%band pass filter the time series using the given cutoff periods
function [b,a]=band_filter_setup(fs, high_per, low_per); 



Wh = (1/high_per)/(fs/2); Wl = (1/low_per)/(fs/2); %define the cutoff frequencies on the normailzed interval 0 -> 1 with 1 the nyquist frequency
n=6; %order of the filter
[b,a] = butter(n,[Wl Wh],'stop'); %defined digitial filter for the bandpass filter- this is the opposite of the filter we want
%plot the filter response
[h,w]=freqz(b,a,128);
r=abs(h); %imaginary part has 
rhigh=1-r.*r; %r r conjugate for double pass
fr=fs*w/pi/2.0;  %convert from interval 0 to pi (angular frequency) to 0 to .5
figure(1); clf;
plot(fr,rhigh, 'b')
title('Filter Response Function');

