How to calculate FIR filter coefficients?

I have EEG signal data (19 channels) sampled at 128Hz. I am trying to retrieve the coefficients that are mentioned in a research paper included below.

To decompose an EEG signal, a digital FIR filter was used, which is based on a level-3 DAUB4 wavelet. The spectral Domain of the filter ranges between 5 and 45 Hz.

1. How can I calculate filter coefficients of order 22?

2. If we denote the input signal on one data channel as $$x_k$$ and the FIR filter coefficients by $$b_0, b_1 \cdots b_{21}$$, how can I calculate the filter output $$y_k$$? $$y_k = \sum_{j=0}^{p-1}b_jx_{k-j}$$

• Hi there, I'm not sure what you're asking: do you already have the filter coefficients and are asking how to filter the signal? Or are you asking how to retrieve the coefficients that have been used in a paper or something? What data do you have access to? Please edit your question with a little more detail ;)
– Jdip
Sep 13, 2022 at 6:39
• 1) The paper mentions theres's a "graph of the filter coefficients". Those are the coefficients you're looking for. Please add this to your question, as well as the the "PSD estimate". 2) What is the sampling frequency for the EEG in the paper (not talking about your signals)
– Jdip
Sep 14, 2022 at 12:58
• As far as the second part of your question, how to calculate the output: that's what the equation with the Sum does. If you're asking this I'm guessing you have very limited experience with signal processing and implementing a signal processing paper is going to be a challenge... What tools are you using? Matlab? Python? R?
– Jdip
Sep 14, 2022 at 13:06
• @Jdip Yes. I had no experience with signal processing. I am using Python. My doubt is whatever the graph of filter coefficients shown in the paper, can I use them for any signal data? or do I have to calculate them? I am asking this doubt because one of my senior told me that I had to calculate these coefficients as they change with data. In the paper they didn't mentioned the sampling frequency of the data they have used. But 128 Hz was the sampling frequency of my data. Oct 4, 2022 at 10:38
• Actually, they do: 240Hz (see label for Figure 1)
– Jdip
Oct 4, 2022 at 15:08

1 Answer

I am faster in Matlab, the following should be readable and easy to translate. The figure matches, and coefficients follow:

%%% Set a long-enough 'dummy' zero signal
data = zeros(256,1);
%%% Compute the corresponding 'dummy' zero wavelet decomposition
%%% on 3 levels. Warning, Daub4 (basic filter length) mean db2 (moments)
[c,l] = wavedec(data,3,'db2');
%%% Create a new coefficient structure
cDb = c;
%%% Put a discrete delta in the middle on the 3rd AC band
cDb(floor((l(1)+1+l(1)+l(2))/2)) = 1;
%%% Reconstruct the signal. The non-zero samples give you FIR coefficients
dataDb = waverec(cDb,l,'db2');
%%% Ad-hoc selection of the non-zero samples
% dataDbCoefficient = dataDb(115:136);
% plot(dataDbCoefficient,'x-');grid on;axis tight
%%% Better selection of the non-zero samples
dataDbCoefficientBetter = dataDb(dataDb~=0);
plot(dataDbCoefficientBetter,'x-');grid on;axis tight
disp(dataDbCoefficientBetter)


   -0.0302
-0.0523
-0.0663
-0.0825
-0.0906
-0.1008
-0.1132
-0.1251
0.1326
0.3180
0.4313
0.5638
0.1413
-0.1326
-0.2577
-0.4226
-0.1671
-0.0243
0.0059
0.0663
0.0140
-0.0081