MATLAB: Efficient pass filters for EEG signals

eegfiltersignal processing

Hello everyone.
I am working with EEG signals of frequence 300 and I would like to apply a low pass filter of 25-50 Hz (depends on the problem) and a high pass filter of 0.1 Hz. I am working with 12 seconds long patches of the signal.
At the moment, I am using the function
newSample = lowpass(sample,25,300)
But it seems to dramatically slow down my code, much more than extracting a spectrogram.
Are there any usful functions to do the same thing more efficiently? The code should work in real time, so future parts of the signal are not availabel for the computation.
Thank you very much!

Best Answer

The lowpass function (and those like it) have 2 outputs, the second being a digital filter object. Save the digital filter object and use it with filtfilt to use it with other signals.
That is much more efficient than designing it each time you use it, which is what it appears you are doing now. So, design it once and use it as often as necessary afterwards.
Related Question