Chaogan-Yan / DPABI

DPABI: a toolbox for Data Processing & Analysis of Brain Imaging
http://rfmri.org/DPABI
GNU Lesser General Public License v2.1
88 stars 42 forks source link

A question for the ideal filter in DPABI #68

Closed Shunqiang-Feng closed 1 year ago

Shunqiang-Feng commented 1 year ago

I read your code of the ideal filter, which just cuts off the spectrum obtained from FFT, and then recover the signal after the IFFT. It's a great attempt, which I used in my experiment before. However, I noticed that there are some problems in this method.

In the web page(https://www.dsprelated.com/showthread/comp.dsp/111418-1.php), it pointed out that:

  1. You're falling into the classic "if I just zero the appropriate FFT bins, I'll have a perfect lowpass/bandpass/highpass/whateverpass filter" trap. Consider what happens in-between FFT bins -- you have no control over frequencies that do not correspond to FFT bins, and they will not automatically be zero just because the adjacent FFT bins are zero. If you FFT longer and longer time signals in order to be able to explicitly zero more and more of those in-between frequencies, eventually you will realize that you have to FFT an infinitely long time signal in order to actually accomplish what you desire.
  2. A filter that is "rectangular" (nonzero at most frequencies and zero over a small group of frequencies, or zero at most frequencies and nonzero over a small group of frequencies) will have a sinc-like [sine(x)/x] impulse response that extends to infinite time in both directions. This is caused by the fact that multiplying by a rectangular window in the frequency domain is equivalent to convolving with a sinc window in the time domain.

To be honest, I have tried many methods to filter the fMRI signals, but many classical filters have failed because of the property of fMRI signals. I wonder how do you view these problems the webpage mentioned above, and do u have other optional methods for filtering fMRI signals?

I am waiting for your reply.

Chaogan-Yan commented 1 year ago

Filtering has many different ways, e.g., FIR, IIR, Butterworth. But I do agree with the below reply, thus we chose this way. The simply way cannot process signal in real time, but other filters can. However, we will not process the fMRI signals in real time.

I do encourage you play with these different filters, and then reply us an comparison report, thus we can better decide to choose which kind of filters. Thanks!

“I think it should work OK, too. But you can't do itin real time as you often need for digital filters.If you wanted a graphic equalizer for your stereo system,you would find that you didn't hear each track on theCD until after it was finished, not to mention thatyou couldn't change the filter while the track wasplaying. Being O(NlogN) isn't so good, either.”

Shunqiang-Feng commented 1 year ago

Thanks for your reply. This question has confused me for months, and your method was a truly "general" filter to deal with fMRI signals. From where I stand, reseachers in this area do want to choose( or seperate) specific frequency band of fMRI signals and analyse them.

IIR filters are out of consideration because they can cause disorders in phase.

FIR filters will also cause some unexpected problems. Here is a signal distortion I came across before.image After calculation, I believed this is because the mean of fMRI signal is too high, and direct filtering in this case is not a good idea. Even if we can remove mean before the filtering as you do in your code, FIR is not a "general" filter. Because some frequency band in fMRI preprocessing work is too NARROW (such as slow-6). That means the FIR filters are expected to have a very high order and we cannot completely seperate different frquency bands neither!

In short, I believe this ideal filter is almost the best one for general filter. Thanks for your work. And this comment maybe not formal, but I do hope it can contribute to your work.

By the way, for low-pass filter, such as [0~0.1] Hz frequency band, I think maybe it's better to add the mean of the signal, because the signal of zero-frequency is also in consideration.

Chaogan-Yan commented 1 year ago

Thanks for your reply! The mean doesn't have any effect on functional connectivity, ALFF or ReHo analyses. But you can modify the code if you like.