# Tag Info

27

We know that in general transfer function of a filter is given by: $$H(z)=\dfrac{\sum_{k=0}^{M}b_kz^{-k}}{\sum_{k=0}^{N}a_kz^{-k}}$$ Now substitute $z=e^{j\omega}$ to evaluate the transfer function on the unit circle: $$H(e^{j\omega})=\dfrac{\sum_{k=0}^{M}b_ke^{-j\omega k}}{\sum_{k=0}^{N}a_ke^{-j\omega k}}$$ Thus this becomes only a problem of ...

15

this is just an addendum to jojek's answer which is more general and perfectly good when double-precision math is used. when there is less precision, there is a "cosine problem" that crops up when either the frequency in the frequency response is very low (much lower than Nyquist) and also when the resonant frequencies of the filter are very low. when you ...

14

You need to filter first and then downsample. Otherwise, you will run into aliasing problems. I.e. frequencies that are above 30 Hz will create images within your frequencies of interest. You can consider the little script below to compare both methods: Fs = 128.0 t = np.arange(0, 10, 1/Fs) signal = np.sin(2*np.pi*10*t) + np.sin(2*np.pi*50*t) sigma2 = 0.5 ...

9

"Zero-Mean" is the word that's commonly used to describe signals and signals with a zero average. "This is a zero-mean filter." If you really mean a filter that is specifically meant to cancel the DC component, a "DC blocker" is a name for that.

8

The filter that you're referring to is called a preselection filter. Its purpose is to filter out everything but the desired signal of interest before mixing to baseband. Unwanted components could include other signals that are nearby in frequency, or just noise that lies outside the desired signal's bandwidth. Preselection can serve multiple purposes: It ...

8

So the issue is that your filter order is too high. There are 2 problems with this: SciPy has a bug that generates inaccurate filters at high orders. On any platform, higher-order filters cannot be done in a single stage. SciPy bug: SciPy was previously generating prototype filters as a list of poles and zeros, then converting them to transfer functions, ...

7

In the $s$-domain, the LPF-to-BPF transformation doubles the order of the filter. that is because the LPF has one transition from passband to stopband, but the BPF has two such transitions. Remember that when we do frequency response, we substitute $s=j\omega$. That is, we evaluate the $s$-plane transfer function $H(s)$ as $H(j\omega)$. The magnitude of $... 7 This is just "faking" the magnitude response of an IIR filter. The output's magnitude spectrum looks just like it has been filtered by the IIR filter with the given frequency response. Although it may somehow work, there are some limitations: Frequency-domain filtering is usually much more computationally demanding. It is not for real-time. The problem ... 6 First of all, what is the order of your IIR filter? The highest order I have ever used was an order-10 IIR filter for a control loop application. I feel like it is unlikely that you need more that this. Second, it is a good idea to split your filter in second-order-sections (SOS) and cascade them , this usually fix most issues. https://www.dsprelated.com/... 6 In principle there is no reason why the filter order of a general bandpass or bandstop filter must be even. Such a restriction is a consequence of a specific design procedure. In classic IIR filter design (Butterworth, Chebyshev, Cauer) you start with an analog prototype lowpass filter. Bandpass or bandstop filters are then obtained by a frequency ... 5 It's not true that any real-valued band pass signal can be written as shown in your first equation: $$s(t)=A(t)\cos(\omega_c t)\tag{1}$$ The most general representation of a real-valued band pass signal is given by $$s(t)=\Re\{a(t)e^{j\omega_c t}\}\tag{2}$$ where$a(t)$is a complex-valued function, called the complex envelop of$s(t)$. It is the complex ... 5 This sort of filtering is done all the time, but it doesn't have the effect you think it should. Suppose you have an IIR filter with an impulse response of$h[n]$which is represented in the$z$domain as: $$H\left(z^{-1}\right) = \frac{h_n\left(z^{-1}\right)}{h_d\left(z^{-1}\right)}$$ where$h_n$is the numerator polynomial in$z^{-1}$of order$N$and$...

5

The denominator (recursive coefficients Ai) look OK: the poles of your system are at 45 degree angles ($\pi/4$), with magnitude 0.68 (which is not very aggressive for a notch filter; in my opinion they should be more like 0.9). But your numerator has its roots very near $z=1$, which corresponds to frequency 0 instead of the desired $\pi/4$ for implementing ...

5

So, first, to put things into perspective: 4kHz is not a high sampling rate these days (add 5 orders of magnitudes, and things become hard). Your 15 kHz passband doesn't say anything about the complexity of the filter; what counts is the transition width, ie. the distance between pass- and stopband, as well as the attenuation of the stopband. For a slightly ...

5

FIR coefficients are $h[n]$, the same as the impulse response. there are $N$ non-zero taps. $$h[n] = 0 \qquad \text{for } n<0, n \ge N$$ frequency response is \begin{align} H(e^{j \omega}) &= \sum\limits_{n=-\infty}^{+\infty} h[n] e^{-j \omega n} \\ &= \sum\limits_{n=0}^{N-1} h[n] e^{-j \omega n} \\ &= \... 5 It must have to do with the initial conditions used by the function filtfilt.m. The idea is to match initial conditions in a way such that startup and end transients are minimized. This, however, doesn't always seem to work, and it appears that for your filter specifications it actually does more harm than good. As far as I know there is no way to tell ... 5 What you are looking for are what we, in the audio space, call comb filters. Comb filters may or may not have a feedback path, just like FIR and IIR filters. In fact, there is a generalized theory about designing comb filters based simply on designing any digital filter. In fact, you can think of every LTI digital filter as being a comb filter where the ... 4 The mixer/LPF filter that you describe as the receiver is typically one that is designed (possibly for optimal performance e.g. matched filter) using a mathematical model that assumes its input is the desired signal plus noise (often AWGN) and nothing else. If other signals are present, they are assumed to be orthogonal to the signal of interest (as in CDMA ... 4 A filter bank is a collection of bandpass filters designed to split a signal into a number of bands. The centre frequencies of the band pass filters can be spaced linearly or according to a non-linear spacing depending on the intended application. H(z) denotes the z-domain transfer function of a filter in the bank. 4 As you stated there are some parameters associated with filters such as type of filter (butterworth, elliptic, chebyshev I,chebyshev II, bessel,...), order of filter, etc. (Note that there are lots of considerations in filter design bases on the application) Let's first talk about the order of filters: Filters with higher orders let you have a filter with ... 4 Frequency domain filtering (FFT), as suggested by some comments, is definitely wrong -- it's even slower, or same speed at best! A recursive filter (IIR) is the fastes possible solution. If you choose a typical second order filter (called biquad in engineering slang) of Butterworth type and do your math right (factoring out coefficients) you only have 3 ... 4 The filter you designed is a linear phase filter, therefore, response of the filter will start at N/2th sample, where N  is the filter order. As N increases so does the delay of the response. You can find this delay value by computing group delay of the filter. In case you want to reduce the delay, you can design a minimum phase filter. 4 Basically you never want to use the Transfer Function representation (with b and a) and rather use the Zeros-Poles-Gain (z,p,k). This will allow you to avoid the numerical errors. In your case you might design your filter in following way: fs = 44100; % Sampling frequency Wp = [30, 70]/(fs/2); % Pass band frequencies (as normalized frequency) Ws = ... 4 You just shifted the low pass filter to the right, so you generated a complex-valued filter, as you've observed. Multiplying a real-valued impulse response with a complex exponential naturally results in a complex-valued impulse response. What you actually have to do is shift the spectrum to the right and to the left:h_{BP}[n]=h_{LP}[n]e^{jn\omega_0}+h_{...

4

Since I can't comment on this particular site I'd say this, consider the following before you do what you're trying to do. Due to the Nyquist law you want your sampling frequency to be that of the DOUBLE of the maximum frequency your analog signal has. If you downsample to 64 hz that means you'll only be able to see signal data up to 32 Hz. EEG contains the ...

4

As the frequency bands are simple frequency ranges, I wonder if I can use several bandpass filters to get them (instead of using WPT / FFT)? Sure! That's how it's usually done! Is there any reason not to do it (performance)? diabolical laugther as it happens, I've prepared just the blog post for you… TL;DR: If you don't have to process more than 20 ...

4

I would bet this is just numerical error in the transfer function. Try using butter_sos = butter(..., output='sos') instead of ba format, and sosfreqz(butter_sos, ...) instead of freqz. Does that fix it? https://docs.scipy.org/doc/scipy-0.19.0/reference/generated/scipy.signal.sosfreqz.html Edit: I just tried it and it does. :D import scipy import numpy ...

4

Depending on the exact characteristics of the signal and implementation requirements (if any) I can think of a number of approaches to extract content at a "single" frequency. The most common: Apply an FFT to calculate the spectrum of the signal and extract the frequency of interest. Apply Goertzel's algorithm to effectively extract signal content at a ...

4

The generalized linear phase FIR filter has the following frequency response: $$H(\omega) = A(\omega)~e^{j (\alpha \omega + \beta)}$$ for some constant $\alpha$ and $\beta$ and $A(\omega)$ being real. The group delay of this filter is independent of frequency: $$\tau = -\frac{d (\alpha \omega + \beta) } {d \omega} = - \alpha$$ Now if you linearly shift ...

4

Your idea with the Hilbert transform doesn't work. The only signal (apart from $x(t)=0$) for which the Hilbert transform is zero, is a constant signal. A band pass signal $x(t)$ can be written in terms of its complex envelope $x_{LP}(t)$: \begin{align}x(t)&=\textrm{Re}\left\{x_{LP}(t)e^{j\omega_0t}\right\}\\&=\textrm{Re}\{x_{LP}(t)\}\cos(\...

Only top voted, non community-wiki answers of a minimum length are eligible