# 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 ...

14

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 ...

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

The Butterworth filter's frequency response is the result of specific formulas and its characteristic is the flat passband frequency response. Consequently, if the coefficients of the IIR filter are modified in any way, the filter might not maintain the "Butterworth" characteristics. In addition to the responses by "Hilmar" and "Jason R", maybe you could ...

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 theory you can do this, but in practice it is difficult to do because the time and phase alignment must be pretty good for it to work. If the alignment is good you will get the destructive interference that you are seeking. If they aren't, you will get some constructive interference. Even worse, whether they are destructively or constructively ...

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 There is no magic bullet, I'm afraid. You can use an elliptic filter to independently control pass band ripple and stop band attenuation, however you will find that the decay rate is closely related to the steepness and overall bandwidth of the filter. You can make the filter decay drastically faster by reducing the filter order to 1, but then again the ... 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 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/... 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 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 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 You can design the different filter types directly with the scipy.signal functions. There are three main functions for creating finite impulse response filters with the scipy.signal package. signal.remez signal.firwin signal.firwin2 The remez function, as arguments, takes the number of taps (order+1), the "bands", and the "desired" gain. The "bands" is ... 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 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

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(\... 3 Your denominator is wrong. It should be on this form (1-z_0z^{-1})(1-z_0^*z^{-1}) = 1-2R\cos(\phi)z^{-1}+R^2z^{-2}  where $z_0 = Re^{j\phi}$. If your goal is to block DC and create an anti-aliasing filter in a simple way, I would recommend not to use complex poles. Instead use the procedure described in detail here: http://www.dsprelated.com/...

3

You indicated that you're having trouble figuring out how to design a suitable highpass filter. One method is to first design a lowpass filter prototype, then apply a transform that warps the filter's response into a filter of another type (such as a highpass or bandpass filter). This is done by substituting an expression for $z^{-1}$ into the transfer ...

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