Dear Darren, > I have been going over the code for filtering in the process of trying > to set up a low pass filter and I wonder if there is a problem with how > the hi-pass filtering is set up. Also, I then have a question about low > pass filtering. > > In the limiting case if the high pass filter length was = length of the > experiment, currently the code generates 2 covariates, 1 - 1/2 cycle > and 1 full cycle. Shouldn't it just generate a full cycle covariate? If one were using a Fourier set to model low frequency components you would be absolutely right. However we choose to use a Discrete Cosine set. One advantage of this is that the first component effects something like a linear detrending (exactly in the way you note above). > =========== > Now if I wanted to generate a low pass filter would the code be as > follows? I'm using Hz here instead of a time window. Also the sin > function seems to provide a steeper cutoff, but perhaps I'm mistaken. I would include the cosine terms to give you a complete Fourier set. > u = [1:k/2]; > u = find(u > k*RT*Hz); > D = []; > for i = 1:length(u) > d = sin(2*pi*[0:(k - 1)]*u(i)/(k - 1)); > D = [D d(:)]; > d = cos(2*pi*[0:(k - 1)]*u(i)/(k - 1)); > D = [D d(:)]; > end In SPM99 we are in fact moving the other way and incorporating both high and low pass filtering in the convolution kernel. I hope this helps - Karl %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%