texts: Phase information of a signal when creating a spectrogram

texts:
Sorry for the uninformed question but I need some help understanding this. I'm trying to understand what phase information is and it would be very helpful if someone could correct my understanding of it.

Fourier transforms are used to create spectrograms (I understand the vanilla DFT). They allow us to see the different frequencies that make up a signal, and with this knowledge we can plot create an amplitude spectrogram. During this process, phase information is discarded. Correct?

Therefore we can not reconstruct the original audio signal because we are missing phase information. Now what I don't understand is what this phase information is telling us. The way I understand it, is that phase tells us how the different frequencies are aligned/arranged in the original signal? Is this correct?


texts: What is the benefit of FFT when we're already sampling at an acceptable rate?

texts:
As I'm learning about DSP I can understand the process of taking a continuous signal into a discrete signal. I understand an oscillator producing different types of signals, including a periodic signals (especially sinusoids), phase shifts and amplitudes etc.,

I'm following a coursera class, and reading DSP theory.. Rather than blindly using the DSP libraries out there I want to know exactly why something is happening. My 1st roadblock is this:

If we already have enough samples of amplitudes collected at a reasonably sample rate (using Nyquist-Shannon) Why does it matter that a signal (Sinusoid) can be broken down into other sinusoids? Aren't the samples enough to reconstruct the original signal/sound?
What is advantageous by knowing that the Fast Fourier Transform can decompose a signal into multiple signals?
The sinusoids that make up a single sinusoid also have other sinusoids that compose them. If a signal has say 5 sinusoids, those 5 sinusoids, according to DFT if I'm correct, can also each have sinusoids.. Isn't this recursive or infinite? At what point can we say we have "enough" sinusoids to represent a signal.

Thanks in advance for the clarification & patience.


texts: How to sample continuous signal correctly?

texts:
import numpy as np
import matplotlib.pyplot as plt

j = 1j
pi = np.pi

interval = 0.5
fs = 1024
Ts = 1/fs
N = np.uint(interval*fs)
t = np.linspace(0, interval - Ts, N)
freq = 2*pi/N * np.arange(N)
f0 = 16

# x(t) = sin(2pi * f0 * t)
# a[n] = x(n*Ts) = sin(2pi * f0 * n * Ts)
n = np.arange(N)
a = np.sin(2*pi*f0*Ts*n)

# visualisation de a
# on ajoute a droite la valeur de gauche pour la periodicite
plt.subplot(311)
plt.plot( t, a)

# calcul de A
A = 1/N * np.fft.fft(a)

# visualisation de A
# on ajoute a droite la valeur de gauche pour la periodicite

plt.subplot(312)
plt.plot(freq, np.real(A))

plt.ylabel("Real Part")

plt.subplot(313)
plt.plot(freq, np.imag(A))

plt.ylabel("Imaginary Part")

plt.show()

So I have a signal $$x(t) = \sin(2\pi \cdot  f_0 \cdot  t),\ t = 0\rightarrow0.5s$$

I wish to sample the signal at $f_s = 1024\ \mathrm{H_z} \longrightarrow T_s = 1/1024$

So I make $$a[n] = x(n\cdot T_s) \longrightarrow a[n] = \sin(2\pi\cdot f_0\cdot T_s\cdot n)$$

But clearly, this makes the discrete signal have $f = f_0\cdot T_s$.

So when I FFT $a[n]$, the 2 frequency spike is at the wrong location. You can see that the $\sin$ spike is at $2\pi\cdot f_0\cdot T_s$, instead of $2\pi\cdot f_0$

I don't want to make $$a[n] = \sin(2\pi\cdot f_0\cdot n)$$ because then I only get the values of $x(t)$ at positions $t = 2\pi\cdot f_0\cdot n$

Which step did I forget (or did wrong)? How to sample the $x(t)$ so that the FFT is correct? Thank you.


texts: Echo Cancellation over Voice Telephone Network

texts:
I'm a bit confused about the way echo canellation over a voice telephone network works like in the following figure

My issue is with the fact that the point of the adaptive filter and LMS algorithim is to drive the error e(t) to zero correct?
Then surely, Speaker B would hear nothing as the algorithim converges.


texts: 1D Deconvolution with Gaussian Kernel (MATLAB)

texts:
Suppose that I know the output and the transfer functions of a system and I would like to calculate the input function using deconvolution.

To get a grasp of the idea I have created a simple demonstration using Gaussians.

As a sanity check I first calculated the output function y using conv and then used deconv to replicate the original function. This works as expected. The input function calculated by deconvolution (green) is the same as the original input function (blue).

x = -2:0.1:2;
% the input function
a = 1; b=0; c=.5;
u = a*exp(-((x-b).^2)/(2*c^2));
figure(1)
plot(x, u), hold on,

% the transfer function
a = 0.1; b=0; c=.5;
h = a*exp(-(x-b).^2/(2*c^2));

% calculate the output function using conv
y = conv(h, u);
y2plot = conv(h, u,'same');
figure(1)
plot(x, y2plot, 'r')
legend('input func', 'output func')

u1 = deconv(y ,h);
figure
plot(x, u1,'g')

Fig 1.Input and Output functions

Fig 2.Transfer function

Fig 3.Input function calculated by deconv

Going back to the original problem, suppose that I know the output and transfer functions (the red and black curves in figures 1 and 2) and  I want to estimate the input function u.

x = -2:0.1:2;
% the transfer function
a = 0.1; b=0; c=.5;
h = a*exp(-(x-b).^2/(2*c^2));

% the output function
a = 0.9; b=0; c=.7;
y = a*exp(-(x-b).^2/(2*c^2));
figure;
plot(x, y, 'r')

u = deconv([zeros(1,20) y zeros(1,20)], h);
figure
plot(x, u,'g')

Fig 4.Input function calculated by deconv

The result I am getting is not what I would expect. Although I would expect a Gaussian similar to the green curve in Fig. 3 I am getting something different. Is this a matter of padding? Any ideas would be really appreciated.


texts: Is the phase difference between recorded sounds from left and right ear the same as the phase difference between their HRTF?

texts: Pardon my ignorance if my question is silly. Lets say I did a binaural recording and found the phase difference between right and left channel. If the recording was done in anechoic chamber, where there is no reverberation, can I say that this phase difference is same as the phase difference between their HRTFs which they were filtered by (on their way from speaker to my ear)?


texts: Mathematical Proof of Complementary Filter？

texts:
Having found some unofficial sources on Complementary Filter (Thousand Thoughts Sensor Fusion and The Balance Filter by Shane Colton), I wish to work out its rigorous mathematical proof.

The Complementary Filter,
$$y=\alpha \times y+(1-\alpha) \times x$$
where $\alpha$ is the filter parameter, usually chosen to be ~0.98, is named as such, because effectively the filter highpasses $y$ and lowpasses $x$.

With this setup ($\alpha=0.98$), man claims that the filter can filter out the low-frequency part of $y$ and meanwhile the high-frequency part of $x$.

What is the mathematical proof here?

There is no rigorous proof so far available. All the sources simply take it as granted and validates it with experiment data, which is unacceptable in scientific validation.


texts: How to generate wireless O-QPSK modulated signal in Matlab?

texts:
I am trying to create a small simulation where I would need to transmit a wireless signal from one wireless node to another and then transmit one more message back to node 1. Considering this is LR-WPAN device, the IEEE standard is 802.15.4 and signal supposed to be O-QPSK modulated. I use the in-built function which is

lrwpan.PHYGeneratorOQPSK (message, spc, '2450 MHz');

I defined a message  myself according to MPDU format. However when I transfer my waveform into frequecy domain, my signal does not look wireless and have a drastical drop of amplitude every 400 Hz, so I am not sure if it is a normal thing or no. I also added AWGN noise to my signal and visualized the corresponding plots. I was wondering if someone can look at my plots and my code and confirm if my plots are fine and  I do everything correct. Here is my code to generate two wireless signals:

clc,clear
spc = 4;              % symbols per chip

%mesage length is 18 bytes
message1_2 = [1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 ...
    0 0 0 0 0 0 0 1 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 ...
    0 1 1 0 1 0 0 0 0 1 1 0 0 1 0 1 0 1 1 0 1 1 0 0 0 1 1 0 1 1 0 0 0 1 1 0 1 1 1 1 ...
    0 0 1 1 1 0 1 0 0 0 1 0 0 1 0 0]';
message2_1 = [1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 ...
    0 0 0 0 0 0 0 1 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 ...
    0 1 1 0 1 0 0 0 0 1 1 0 0 1 0 1 0 1 1 0 1 1 0 0 0 1 1 0 1 1 0 0 0 1 1 0 1 1 1 1 ...
    1 0 1 1 1 0 1 1 1 1 0 1 1 0 0 0]';
% % O-QPSK PHY, 2450 MHz
waveform = lrwpan.PHYGeneratorOQPSK(message, spc, '2450 MHz');
SNR1 = -300;
waveform1 = lrwpan.PHYGeneratorOQPSK(message1_2, spc, '2450 MHz');
waveform2 = lrwpan.PHYGeneratorOQPSK(message2_1, spc, '2450 MHz');
waveform1 = std(waveform1)/std(waveform1)*(sqrt(10^(SNR1/10)))*waveform1; %% increase signal1 transmission power
waveform2 = std(waveform2)/std(waveform2)*(sqrt(10^(SNR1/10)))*waveform2; %% increase signal2 transmission power
%Calculate Number of FFT points
l = length(waveform1);
NFFT = 2.^nextpow2(l);
%take FFT of original signal
wavesignal1 = abs(fft(waveform1,NFFT)); %signal1
wavesignal2 = abs(fft(waveform2,NFFT)); %signal2
SNR= 35;    % average SNR for wireless sensor networks application
%applying white gaussian noise to both signals
S = RandStream('mt19937ar','Seed',5489);
%received signals
received_at_node2= awgn(waveform1, SNR, 'measured', S);
reset(S);
received_at_node1 = awgn(waveform2, SNR, 'measured', S);
reset(S);
%take FFT of received signal with noise
wave_fft_signal1 = abs(fft(received_at_node2,NFFT));
wave_fft_signal2 = abs(fft(received_at_node1,NFFT));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%SIGNAL PLOTS%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %signal 1 Dbm Spectrum plot
%
%
%
% %original signal 1
XdB1 = 10*log10(wavesignal1);
subplot(2,2,1);
plot(f,XdB1(1:NFFT));
title('Wireless Signal 1 without Noise');
xlabel('Frequency (Hz)');
ylabel('|signal 1| (dBm)');
%
%
% %noisy signal 1
XdB1_n = 10*log10(wave_fft_signal1);
xdB1_f = 10*log10(filtered1);
subplot(2,2,2);
plot(f,XdB1_n(1:NFFT));
title('Wireless Signal 1 with AWGN applied');
xlabel('Frequency (Hz)');
ylabel('|signal 1| (dBm)');
%
% %signal 2 Power Spectrum plot
%
%
%
%original signal 2
XdB2 = 10*log10(wavesignal2);
subplot(2,2,3);
plot(f,XdB2(1:NFFT),'color','black');
title('Wireless Signal 2 without Noise');
xlabel('Frequency (Hz)');
ylabel('|signal 1| (dBm)');
%
%
%
% %noisy signal 2
XdB2_n = 10*log10(wave_fft_signal2);
subplot(2,2,4);
plot(f,XdB2_n(1:NFFT),'color','black');
title('Wireless Signal 2 with AWGN noise Applied');
xlabel('Frequency (Hz)');
ylabel('|signal 2| (dBm)');

I've read some papers related to wireless signal simulation and this is how their plots usually  look like:

whereas my plots are as follows:

What am I doing wrong and how to bring it to the visual form that was depicted above?
Do I have to center it around 2.4 GHz?
If yes , how to do it?
Why does the amplitude go down so much every ~500 Hz?


texts: I started to learn MATLAB and reading paper.i have faced difficulty where to start, how to start in the field of biomedical signal filtering (fNIR)?


texts: Which window function to use for QPSK signal?

texts:
I am trying to Receive a QPSK signal and for Sampling I need to recover clock. Now QPSK Signal is generated at 2.4GBaud. It is than sampled at 80GHz.Than further it is downsampled to 10GS/s (Symbols per second).
Note: This signal have only one polarization.

Now I have Inphase and Quadrature Phase component of the signal(10GS/s). This signal is ofcourse in time-domain. Now I want to window the whole signal (the entire length in time). So which window function is suitable ?
Am I missing any details?


texts:
Imagine I have a nonlinear system:
$$
\frac{\text{d} x}{\text{d} t} = f(x,t)\\
y = g(x).
$$
I can design a nonlinear observer to estimate the state $x$ based on the measurements $y$. However, this estimation does not need to be done online. Meaning that I have the whole measurement signal $y(t=0- T_{\text{end}})$ and would like to estimate the state in the corresponding time interval [$0, T_{\text{end}}$]. Is there an offline method for doing so?
I am asking this question, because having the whole measurement signal (previous and future steps for any given state $x(t)$) might help improving the estimation accuracy. Something like Matlab filtfilt, which removes the potential filtering phase shifts by doing filtering from both time ends.


texts: Can I model process noise as a known "error" in my dynamics while designing a Kalman Filter?

texts:
Consider I am modelling the dynamics of a robot and using a Kalman filter to obtain estimates of some state. I have certain terms in my equation which correspond to data not accessible to this robot ( states of other robots etc).

1) Is it fair to model these as process noise by assuming these terms to evolve based on some random process and act "Gaussian like" ? This also raises another important question:
2) Why does the Kalman Filter require us to have a positive definite covariance associated with the process noise. How do I interpret this in the real world when I am writing down process noise as some unmodeled physical terms ?


texts: How to get the scale bar of an FFT for a 2d image

texts:
I've been analyzing some images from a transmission electron microscope, including their FFTs, and I'm not sure how to apply a scale bar to the FFT images. I have calibrations for the real space image, and I was thinking it might just be the inverse of that scale, but I really have a hard time visualizing reciprocal space and would like to be sure.

This seems like it would have an easy answer, but I haven't been able to find it and I would appreciate your help.


texts: How to accurately pinpoint multiple overlapping circles in image?

texts:
I have binary bitmap images (medical annotation overlays) where sometimes multiple circle perimeters are present which are overlapping.
I need to extract the individual center and radius for each circle independently - for example see attached image which two circles are present, slightly offset.
Is there a reliable method of doing this (e.g. in open-cv)?
NOTE: Having played around with HoughCircles it seems like a candidate algorithm except that there are so many magic numbers you have to tune it often misses them or find way to many nonsense ones. This isn't reliable enough for my purposes!


texts: Definition of causality of a system in Discrete Time Signal Processing [Alan V. Oppenheim]

texts:
The book states:

  Causality implies that, if x1[n] = x2[n] for n <= n0, then y1[n] = y2[n] for n <= n0.

But isn't it always the case, that for same inputs we're getting same outputs except for the case of time-variance, which this sentence is not about?


texts: A General Question regarding OFDM symbol

texts:
I have cross across an OFDM modulator that says that

A frequency domain sequence is passed into a 64 point IFFT. A cyclis prefix is added (0.8 $\mu$sec) and creates as a result a 4 $\mu$sec time domain sequence (OFDM symbol). I am wondering The input of IFFT is discrete the output is also discrete of length 64. Then what do the authors mean by 3.2 $\mu$sec OFDM symbol? Is it a continuous time domain signal?


texts: What is the cause of slow roll off of windowed filters

texts:
Exactly why using the of windowing function, such as Hamming or Blackman, causes a slower transition to stop band? Everywhere it is mentioned just as an obvious fact that this happens but I haven't found a text that mentions what is the cause.

An example for what I mean:

An FIR low-pass filter designed with cut off frequency 1 Hz without a window function reaches stop band at little over this frequency (1.04 Hz or so).
When window function is applied, the filter reaches the stop band at over 1.2 Hz

Also, is there a way to compensate for this? For example, if I really want the cut off frequency to be 1 Hz and use window function, should I design the filter to have cut off say 0.9 Hz?


texts: How to distinguish between the different frequency domains?

texts:
Sometimes the terms 'Fourier domain', 'complex frequency domain', 'Frequency domain' and 's domain' are used interchangeably.

Take those answers here for example: http://answers.yahoo.com/question/index?qid=20090924230321AAxvnJg

Can you really use them interchangeably all the time, without being technically wrong? So, could you describe what would be wrong if I would replace 's domain' by 'fourier domain' for example? Or replacing 'complex frequency domain' by 'frequency domain'?


texts: Characterization of the amount of modulation in a signal

texts:
We have used the ICRA babble noise to generate an 8-talker babble. As a background - babble noise is used as a substitute for competing talkers as babble noise lacks lexical content, but contains the same envelope and frequency content as 'real' speech. Babble noise is, therefore, less distracting for listeners and hence it's a more direct, 'peripheral' type of masker. Lexical masking occurs more centrally.

Anyway - we are interested in whether the masking effects we see are due to the slowly varying part of the babble noise (the envelope) or the frequency content.

Now, because we used an 8-talker babble using asynchronous, random starting points, the amount of modulation in the masker is less, as all the 8 babble noises are randomly added. Hence, it becomes more of a static type of noise, and  listening in the gaps is hardly possible. The latter is especially important - are there gaps present in the noise, and if yes, how long are they? Likely there are no true gaps anymore, but only stretches of noise where relatively little noise is present, so shallow gaps in the noise.

Now, I wish to compare the characteristics of the single-talker original noise and our 8-talker babble in terms of:

amount (number/density) of gaps present in the noise
the gap duration
and amplitude of the gaps (modulation depth)

I think a good starting point is to determine the envelope of the fluctuating noise using a Hilbert transform. But then, how do I go about analyzing the envelope in terms of the two parameters, namely gap-duration and amplitude? I have added the envelope of a shorty stretch of the original single-talker babble below (x-axis label is seconds):

FWIW:

I'm used to do my signal analysis in Matlab;
Noise files were software-corrected for rms for overall sound level;
Noise was played back in a sound-proof booth and we will record the signals back with a KEMAR manikin to include the head shadow effect.


texts:
We have an acquisition hardware in our lab that acquires and digitizes data from a source generating band-limited signal in the MHz range. It samples the signal at a rate of 4 times the center frequency $f_0$ of the signal. In the documentation, they say that this specific sample rate makes it easier to convert the RF samples to demodulated IQ samples.
How would $f_s=4f_0$ make the demodulation easier? I have been using Hilbert transform to achieve the demodulation (the old-fashioned way). But, if there is any shortcut offered by this specific sample rate, that would be really helpful.
Thanks.


texts: Energy of a signal with decreasing amplitude

texts: I read that a infinite extension continuous time signal with decreasing amplitude will always be an energy signal. Though if you take the integral of, for example, f(t)=1/(t+1) we can see that is diverges to infinity. Doesn't the saying that if a signal has finite area then it is an energy signal? But that doesn't go the other way, meaning that if a signal is power signal then it has a finite area? I suppect something happens when you square the signal to calculate it's energy but I don't want to dive into caclulus and series convergence and such


texts: Is information lost due to Hanning window perturbations?

texts:
I apologize for the obscure phrasing of the title of the post...My question is quite simple...

Let us imagine an audio signal (any song will do). We want to apply the Short Time Fourier Transform algorithm, so we break our signal into frames and view each frame through a window. For the sake of the example let us assume the window is a Hanning window.

Many algorithms have a parameter to specify the sample at which to center the Hanning curve in a given frame. Now, let us assume that the dominant signal in that frame happens to fall near one of the the tails of the Hanning window for that frame. The window will then squash the importance of the sample and boost some samples which were not that prominent in the original signal. In essense, we have lost some possibly valuable information.

Would I then be correct in assuming that not only is the number of frames of importance in FT, but also the samples at which the window functions are centered?

Thanks in advance.


texts: Image processing on a surveillance image

texts:
I was given this question on a job interview and think I really messed up. I was wondering how others would go about it so I could learn from this experience.

  You have one image from a surveillance video located at an airport which includes line of people waiting for check-in. You have to assess if the line is big/crowded and therefore additional clerks are necessary. You can assume anything that may help your answer. What would you do?

I told them I would try to:

Segment the area containing people from the rest by edge detection
Use assumptions on body contour such as relative height/width to denoise unwanted edges
Use color knowledge; but then they asked how to do that and I didn't know


texts: Channel equalization affect on input signal

texts:
I have the following problem.

Am trying to understand how the channel block affects the input signal s(n).
I know that x(n), the input signal to the filter is basically:
\begin{equation}
x\left(n\right)\:=\:s\left(n\right)* h\left(n\right)+v\left(n\right)
\end{equation}
However, the end goal is to find the Wiener filter tap weights: w0, w1, and w2.
So, in order to find that, I need to find the correlation matrix R of the filter tap inputs and the cross-correlation vector p relating the input of the filter to the output
My process to solving this problem was first by decomposing the channel block using partial fractions. As in the following:
\begin{equation}
H\left(z\right)\:=\:\frac{1}{1-1.2z^{-1}+0.35z^{-2}}=\frac{1}{\left(1-0.5z^{-1}\right)\left(1-0.7z^{-1}\right)}=-\frac{2.5}{1-0.5z^{-1}}+\frac{3.5}{1-0.7z^{-1}}
\end{equation}
This in turn, using the inverse z transform, would turn into the impulse response:
\begin{equation}
h\left(n\right)\:=\:-2.5\left(0.5\right)^n+3.5\left(0.7\right)^n
\end{equation}
Am stuck at this point because I don't know what to do next given the concept of convolution stated above.
The essence later is to find the correlation matrix R which should be in this form:
\begin{equation}
\left[R\right]\:=E\left[\begin{pmatrix}x\left(n\right)x\left(n\right)&x\left(n\right)x\left(n-1\right)&x\left(n\right)x\left(n-2\right)\\ \:x\left(n-1\right)x\left(n\right)&x\left(n-1\right)x\left(n-1\right)&x\left(n-1\right)x\left(n-2\right)\\ \:x\left(n-2\right)x\left(n\right)&x\left(n-2\right)x\left(n-1\right)&x\left(n-2\right)x\left(n-2\right)\end{pmatrix}\right]\:
\end{equation}
and also, to find the coss-correlation matrix p, which is in this form:
\begin{equation}
\left[p\right]\:=\:\begin{pmatrix}E\left(x\left(n\right)s\left(n\right)\right)\\ E\left(x\left(n-1\right)s\left(n\right)\right)\\ E\left(x\left(n-2\right)s\left(n\right)\right)\end{pmatrix}
\end{equation}
Please help me move on the right path on this problem. Thank you in advance.


texts: How does shifting a signal in the time domain affect its frequency domain?

texts:
Suppose the signal is shifted by dt (signal 'starts' later, say after 1s instead of 0s), does that correspond to a positive or a negative phase shift df in the frequency domain?

There are certainly very detailed answers to this but I am still having trouble, especially with the sign conventions.

Thanks


texts: Why does a higher sampling frequency mess up my bandpass filter?

texts:
I was designing a bandpass filter in python using some of the scipy.signal modules.

I am plotting the frequency response of my filter to verify that my desired frequency is in the passband. However, when I make the sampling frequency larger, the frequency response of my filter gets completely messed up.

I currently have a signal that I sample >300KSPS and am trying to create a bandpass filter for some fairly low frequencies (1-100hz). Could somebody explain why this happens?

For example, the following code yields this frequency response:

import numpy as np
import matplotlib.pyplot as plt
import scipy.signal

N = 3
fs = 10000.0
low = 100.0
high = 150.0

nyq = fs * 0.5

Wn = [low/nyq, high/nyq]

b, a = scipy.signal.butter(N, Wn, btype='bandpass')
w, h = scipy.signal.freqz(b, a, worN=round(fs/2))

ax = plt.subplot(121)
ax.set(title='filter frequency response',
       xlabel='frequency [hz]',
       ylabel='gain',
       xlim=(low/2, high*2))

ax.plot((nyq / np.pi) * w, abs(h), label='filter freq response')
ax.axvline(x=125.0, linestyle='--', alpha=0.5, c='black', label='f=125.0')
ax.axhline(y=np.sqrt(0.5), linestyle='--', alpha=0.5, c='black', label='sqrt(0.5)')
ax.grid()
ax.legend()

Then when I change my sampling frequency to 100000.0, the response turns out to be this:

fs = 100000.0

EDIT: Outputting the filter as second-order sections and using scipy.signal.sosfreqz yielded the proper filter. See code below for the modified lines:

sos = scipy.signal.butter(N, Wn, btype='bandpass', output='sos')
w, h = scipy.signal.sosfreqz(sos, worN=round(fs/2))


texts: Interpolate/Decimate with a single filter?

texts:
This is not a homework question (I'm out of school now 2 years). I'm thinking, let's say you have 2 systems, one at 32khz and the other at 48khz and you want to go between the two. Is there a way to accomplish this with a single filter? I have a feeling that if you make an FIR where every other coefficient is zero and exploit the fact that if fs = 32khz and 48-32=16=fs/2, then zeroing out every other coefficient of an FIR (but how many taps) would do both the zero-padding and the anti-aliasing simultaneously. Am I on the right track or is there some other trickery involved?

EDIT:

Now that I think about it, to go from 32khz to 48khz you interpolate 3x and decimate 2x (32*3=96khz...96/2=48). So in effect you would pad two zeros first but then take out one in the decimation, but just inserting one zero would yield 64khz decimation (with a 32khz lowpass decimation).

EDIT 2:

Furthermore, wikipedia interpolation:
"Upsampling requires a lowpass filter after increasing the data rate, and downsampling requires a lowpass filter before decimation. Therefore, both operations can be accomplished by a single filter with the lower of the two cutoff frequencies. For the L > M case, the interpolation filter cutoff,  \tfrac{0.5}{L} cycles per intermediate sample, is the lower frequency."


texts: What is the autocorrelation of a Dirac pulse?

texts:
What is the autocorrelation of $x(t) = \delta(t)$?

Can you explain to me how to calculate it?


texts: Maximum Frequency deviation in Frequency Modulation

texts:
I am writing a script to frequency modulate the stereo audio signal, and later calculating the modulation index wrt time.

As we have to modulate the stereo audio signal, I have to first synthesize the composite signal of bandwidth 96KHz and modulate it with carrier frequency of 1MHz(assume here).

We define FM signal as,

$$
y(t) = A * sin \big(2\pi*\int_{-\infty}^t(f_o + k*m(\tau))  d\tau\big)
$$

As per FCC rule, maximum frequency deviation should be 75KHz, here I have to keep k = 75000 and m(t) between -1 to 1.

I have a very big audio file, my script should fetch some samples from the file and modulate it, and repeat the above steps.

Here I am confused about the integration limits. Do I need to take integration from very start for each upcoming sample? If I see the hardware implementation for FM generation, VCO should have some sensitivity. What I understand it, as VCO output cant change abruptly, it will change the frequency as per the cumulative effect of its present and previous inputs of some input voltages. Therefore, In hardware any upcoming sample frequency will depends only on some past message signal samples. Am I right here?

If we see the instantaneous frequency of FM signal, from the above formula, it should be

$
f_i = f_o + k*m(t)
$

It means that maximum frequency which could change is $k*max(|m(t)|)$, equal to 75KHz, but when we do frequency transform of FM signals, there are many sidelobs which is beyond 75Khz.

I am not able to think where my concepts are going wrong.

Thanks.


texts:
How can I extract a signal to baseband?

Rather that just listen to one signal at a time, I want to take advantage of my RTL-SDR's 2mhz bandwidth and listen to multiple FM signals at the same time. I think that what need to do for each signal is filter out everything but the signal, then shift the signal to baseband and reduce the bandwidth. Once it's a baseband, I can take it from there.

Which filter or pair of filters would be a decent way of to filter out all but the signal I want?
Should I be using IIR vs FIR?
What would be a decent way to shift to baseband and reduce bandwidth?
Can shifting to baseband and reducing bandwidth be done at the same time? Should these be done at the same time?

Everything I'm working with is a complex signal. I'm planning on implementing these myself for the greater education value. (IE, I'm not using GNUradio, or existing libraries. Mostly I need to know what to Google.)


texts: How can I cut exactly the first harmonic (H1) from a FFT of an image

texts:
I have 4D( 2D + slices along z axis + time frames) gray-scale image for the heart beating on different moments.
I do like to take Fourier Transform along time axis(for each slice separately), and analyze the fundamental Harmonic (also called H1 component, where H stands for Hilbert Space) so I can determine pixel regions corresponding to ROI which show strongest response to cardiac frequency.
I'm using python for this purpose, and I tried to do that with the following code, but I'm not sure that this is the correct way to do it, because I don't know how to determine the cut-frequency to keep only the fundamental Harmonic.

This link to the image which I'm dealing with

import nibabel as nib
import numpy as np
import matplotlib.pyplot as plt

img = nib.load('patient057_4d.nii.gz')
f = np.fft.fft2(img)
#  Move the DC component of the FFT output to the center of the spectrum
fshift = np.fft.fftshift(f)
fshift_orig = fshift.copy()
# logarithmic transformation
 magnitude_spectrum = 20*np.log(np.abs(fshift))
# Create mask
rows, cols = img.shape
crow, ccol = int(rows/2), int(cols/2)
# Use mask to remove low frequency components
dist1 = 20
dist2 = 10
fshift[crow-dist1:crow+dist1, ccol-dist1:ccol+dist1] = 0
#fshift[crow-dist2:crow+dist2, ccol-dist2:ccol+dist2] = fshift_orig[crow-dist2:crow+dist2, ccol-dist2:ccol+dist2]

# logarithmic transformation
magnitude_spectrum1 = 20*np.log(np.abs(fshift))
f_ishift = np.fft.ifftshift(fshift)
# inverse Fourier transform
img_back = np.fft.ifft2(f_ishift)
# get rid of imaginary part by abs
img_back = np.abs(img_back)
plt.figure(num = 'Im_Back')
plt.imshow(abs(fshift[:,:,2,2]).astype('uint8'),cmap='gray')
plt.show()

```


texts: Which filter makes sense for a triggered event?

texts:
I have a very noisy data from a particle accelerator and I want to improve the signal (in every way it's possible): As background: It's data from an electron accelerator which produced Bremsstrahlung when distracted (so it emitted photons towards our detector). Signals have been recorded by coincidence between a tagger for the electron beam and the readout system when the photons hit our detector. Unfortunately our system had a bad shielding/grounding (one of the things we improved as a result). But nevertheless to get a better overview we want to analyze the signals respectively want to filter the signals. My first step is to implement a low pass filter into the software. Can you advice something else?
From our horizon most of the noise comes from the avalanche photo diodes. So the readout chain is as following: Photon hits detector -> detector produces light -> light hits two neighbouring avalanche photo diodes -> signal is amplified and shaped by an ASIC -> signal is stored after being transmitted through some electronic components.

For a better feeling I attached some signals. Two adjacent signals represent one detector signal. I picked a few very different ones.

I would highly appreciate any help!


texts:
I am aware of the common types of windows, (Hamming, Hanning, Kaiser, Tukey, etc etc). However while many books describe them - almost none tell me just how exactly they were derived.

What is so holy about the hamming window? What about the hanning? I understand that they all play on the ratio of mainlobe width VS sidelobe attenuation, but how exactly were they derived?

The motivation for my question, is because I am trying to figure out if one can design their own windows, that also play off main lobe width and sidelobe energy.


texts: Why not use zero-signal in digital transmission?

texts:
This is something that bothers me from time to time and has always been hand-waved away with some plausible but non-rigorous explanation. For clarity, consider the QPSK case where we have the constellation points $(0,1), (1,0),(-1,0),(0,-1)$. What is the fundamental flaw in using the origin, and then three equidistant points separated by $\frac{2\pi}{3}$ radians? We would have the same minimum distance but with smaller average energy.

I understand the added annoyance in synchronization and differentiating between "no message" and "the zero message". But these should be solvable with preambles and whatnot. I'm curious about the flaws that are more than just annoyances, the ones that makes this constellation a fundamentally bad idea.

EDIT: I spoke without thinking, clearly the minimum distance would not be the same, it would be one in the zero-signal case and $\sqrt{2}$ in the standard case. The number of pairs at min. distance would be... uh... six...?


texts: How would i get the total variation demonising for an X-ray image

texts:
Total Variation for an X-ray image. using rof model
Is there any function to find total variation.

TV with respect to I by
$$\sum\sqrt{i x^2+i y^2}+\lambda\|i-g\|$$

$I$ is the denoised Image
$I x$ and $i y$ are gradient.


texts: Why is pitch detection necessary in pitch correction?

texts: I am trying to understand the process of changing the pitch of a signal. After performing the FFT on a windowed signal, we have the frequency information for the signal. Why can we not simply change these frequencies to change the pitch of the signal? Instead, we must first use pitch detection methods to determine pitches that were present in the time-domain function. How does the FFT not give you this information? What is the frequency information given by the FFT if not the frequencies of the time-domain signal?


texts: Weight vector of an exponential moving average?

texts:
With weight vector I mean the vector with weights that you have to multiply the observations in the window that slides over your data with so if you add those products together it returns the value of the EMA on the right side of the window.

For a linear weighted moving average the formula for finding the weight vector is: (1:n)/sum(1:n) (in R code). This series of length n adds up to 1. For n=10 it will be

  0.01818182
  0.03636364
  0.05454545
  0.07272727
  0.09090909
  0.10909091
  0.12727273
  0.14545455
  0.16363636
  0.18181818

the numbers 1 to 10 / 55, with 55 the sum of the numbers 1 to 10.

How do you calculate the weight vector for an exponential moving average (EMA) of length n?

Wikipedia  tells me:

  if n is the length of the window, then alpha<-2/(n+1) and i<-1:n so EmaWeightVector<-((alpha*(1-alpha)^(1-i)))

Is this correct?

Even though the EMA is not really confined to a window with a start and an end, shouldn't the weights add up to 1 just like with the LWMA?


texts: Sampling fast sinusoidal signal with low sampling rate

texts:
I have sampling problem that I am trying to solve analytically

I have sampling frequency, let say 1kHz.
I have number of target frequencies, let say 10kHz,100kHz,1MHz

For each  target frequency I need to find nearest frequency so that after 20 cycles of
sampling I will have 20 points that will be evenly distributed within cycle of sampled signal.  I mean that for each sample sampling point will be shifted 1/20 of period of sampled signal.  The target is to get approximation of amplitude of fast signal with slow sampling.

Do anyone have any idea how can i solve it?


texts:
I am trying to understand how the Discrete Cosine Transformation works but I am not sure if I am at the right road.

Assuming that I have an 8x8 pixels image and I am applying the DCT to this sample. What I will get as a result is a 8x8 matrix of the DCT Coefficients.

In order to convert from this to the original image I will need to multiply each DCT Coefficient with its corresponding basis function and sum the result. But how do I calculate the basis function if DCT only returns the coefficients?


texts: Wavelet filter coefficients from the Morlet wavelet

texts:
How can I obtain the wavelet filter coefficients ( i.e.       lowpass decomposition filter,        highpass decomposition filter,        lowpass reconstruction filter,        highpass reconstruction filter) for the Morlet wavelet?

For convenience: the wavelet curve follows the equation $$\pi^{1/4}  \exp(jwx) \exp(-0.5x^2)\,.$$


texts: Why harmonic components appear only after a certain level when a signal is clipped?

texts:
I recently observed this phenomenon that when a signal is clipped the harmonics start to appear only after a certain level.

The Python code to reproduce the effect is given below. The signal has 3 components at 30, 60 and 90 Hz. So a maximum possible peak to peak voltage will be 3. I clipped the signal at various levels and observed the magnitude spectrum but the harmonics start to visibly noticable only if the clipping goes below -2.5 and 2.5.

Is this a well-known phenomenon? What is the possible explanation behind this?.

import numpy as np
from scipy import signal
import matplotlib.pyplot as plt
from scipy.io import wavfile

labelsize   =   12
width       =   3.5
height      =   width / 1.618
lwidth      =   0.9

plt.rc('font', family='serif')
plt.rc('text', usetex=True)
plt.rc('xtick', labelsize=labelsize)
plt.rc('ytick', labelsize=labelsize)
plt.rc('axes', labelsize=labelsize)

def MagnitudeSpectrum(data, Fs, clip):
    P = 20*np.log10(np.abs(np.fft.rfft(data)))
    f = np.linspace(0, Fs/2, len(P))

    fig, ax = plt.subplots()
    fig.subplots_adjust(left=.20, bottom=.25, right=.96, top=.90)

    plt.plot(f, P, color='k', ls='solid', linewidth=lwidth, label='')
    plt.xlim(0, 500)
    plt.title('Signal Clipped BW '+str(-1*clip)+' and'+str(clip))
    plt.xlabel('Frequency [Hz]')
    plt.ylabel('Magnitude [dB]')
    # plt.show()
    fig.set_size_inches(width, height)
    fig.savefig('SignalMagSpectro_'+str(clip)+'.png', dpi = 600)

cliplevels = np.arange(2.2, 3.2, 0.1)

for clip in cliplevels:
    Fs = 44100.0
    t = np.arange(0, 10, 1/Fs)
    data = np.sin(2*np.pi*30*t)+np.sin(2*np.pi*60*t)+ np.sin(2*np.pi*90*t) +0.1*np.random.randn(len(t))
    data = np.clip(data, -1*clip, clip)
    MagnitudeSpectrum(data, Fs, clip)


texts: What are i-vectors and x-vectors in the context of Speech Recognition?

texts:
I have read that i-vectors and x-vectors are widely used in speaker recognition tasks but I don't get the difference between them and how exactly they work. Can someone explain it starting from the ground to a bit technical?
I came across following papers talking about these terms:
https://www.danielpovey.com/files/2018_icassp_xvectors.pdf
https://arxiv.org/pdf/1611.00514.pdf
https://dl.acm.org/citation.cfm?id=2846832


texts: Is negative frequency important in calculating Spectral Moments

texts:
A follow on question form this one (What is meant by "spectral moment"?)

In answers to the above referenced question spectral moment is defined as:

$$
m_k=\int_{-\infty}^{\infty} f^k|X(f)|^2\ df
$$

The limits on the integral include negative frequency. So is the negative frequency really important?

If I filter out all negative frequencies before calculating the moments will they be wrong?

If $|X_f|^2$ is symmetrical about zero then does this not mean that $m_k=0$ for all odd values of $k$?


texts: Designing an experiment to show blue noise not adding noise below nyquist and not aliasing above

texts:
I read this paper from 1983 "Spectral Consequences of Photoreceptor
Sampling in the Rhesus Retina".

This paper talks about blue noise sampling patterns in the retina and says that:

  The results
  (Fig. I) indicate that throughout the retina
  the cones provide a novel form of
  optimal spatial sampling: optimal in the
  sense that minimal noise is introduced
  for spatial frequencies below the nominal
  Nyquist limits implied by local receptor
  densities (the limits that would obtain if
  the cones formed a regular lattice), while
  spatial frequencies above the local Nyquist
  limits are not aliased back into
  conspicuous moire patterns but instead
  are scattered into broadband noise.
  Thus, the visual system avoids the aliasing
  distortion of high frequencies inherent
  in any regular arrangement of image
  sampling elements and simultaneously
  minimizes sampling noise for low frequencies
  that fall within its potential
  Nyquist bandwidths. These advantages
  stem from a quasi-random (that is, random
  but not Poisson) spatial sampling
  scheme that apparently has not been
  used in man-made image-recording devices.

I take that to mean that blue noise:

Doesn't add (much) noise when sampling frequencies below nyquist.
Doesn't alias for frequencies above nyquist.

This is in contrast to:

Uniform sampling which doesn't add noise to any frequency, but aliases frequencies above nyquist.
White noise (uniform random) sampling, which adds noise to all frequencies, but doesn't alias for frequencies above nyquist.

That makes sense, but now I'm trying to think of how I could make a simple experiment to show this being true - preferably in the context of 2d sampling and 2d images (image processing / image sampling), but 1d would be ok too.

I get that I could use blue noise to sample sine waves of varying frequencies but am unsure how exactly that sampling would work.

I know how to generate blue noise sample points in any dimension using Mitchel's best candidate algorithm.

I'm guessing I would generate N sample points and then do a reconstruction filter on those sample points, but thinking about that, I can't see how noise would present itself (although, aliasing would just be "missed frequencies"), and frankly I'm not real sure how to do a decent reconstruction filter.

Am I on the right track for making a decent but simple experiment to show these statements being true empirically?  Or should I be doing something different?


texts: Approaching the response of an RC circuit via y=ifft(fft(x)fft(h)). Why is this valid?

texts:
Some textbooks like (Numerical recipes the art of scientific computing) derive the DFT as a Riemann sum of the CTFT. With this in mind it would be natural then to approximate the identity $$y(t)=x*h=\mathcal{F}^{-1}\big\{XH\big\}$$

with the mathlab code y=ifft(fft(x).*fft(h)) which roughly means that my response is the inverse DFT of the product of the DFTs.

I have been reading recently that this approach isn't really valid in the case of the DFT. The relevant identity in the discrete realm is $$\mathcal{F}^{-1}(XH)_{n}=\sum_{l=0}^{N-1} x_l (y_N)_{n-l}$$ which is called a circular convolution.

But so far, my ifft(fft...) approach yields results that are completely compatible with the analytical results.

I also want to mention that I have checked for the well-known result that convolving with a shifted impulse, shifts your response along the domain; and the result that scaling an impulse, scales the response.

I've implemented impulses by inputting the coefficient in the dirac-delta function in some position on a vector, without really justifying why this works.

So therefore I have two questions:

Why is the y=ifft(fft(x).*fft(h)) approach valid and compatible with the theory? Is this the way its supposed to be? How can I justify such a thing? Why aren't the step factors $dt$ involved in this approach?

Why are impulses correctly modeled by only inputting the coefficient that would correspond to the dirac-delta function? (This seems intuitive to me, but I wouldn't like to say my opinion as I would prefer to listen to you mostly).

Thanks!

Edit: This is the problem I am working on

Using MATLAB, I've been told to use the convolution theorem to find the response of an RC circuit given a signal $x(t)=\displaystyle \sum_i \delta(t-t_i)$ and $x(t) = \cos(t)$ (and other similar ones like $x(t)=e^{-t}\cos(t)$, but this isn't important).

The purpose of this exercise is not to solve things analytically, but to use MATLAB. I specifically want to do this with the fft and ifft functions in MATLAB.

The way I'm proceeding is by writing something like:

 t=(-5:.01:5);

x=[zeros(1,500) 1 zeros(1,500)];

h=heaviside(t).*exp(-t);

plot(t,ifft(fft(h).*fft(x)));

Which works perfectly fine. If I want to analyse $x(t)=\cos(t)$

I just modify my code the following way:

t=(-5:.01:5);

x=cos(t);

h=heaviside(t).*exp(-t);

plot(t,.01*ifft(fft(h).*fft(x)));

which again, works fine.

I'll repeat my questions for the purpose of clarity:

Why is this valid? This convolution identity isnt valid in the discrete case. Also, the interval $(-5,5)$ is not at all similar to $(-\infty,\infty)$ so my Riemann approximation should suck (for the cosine case), but it doesn't.

Can anyone explain why using the step only in front of theifft is what works here? Namely why shouldn't I be doing 01*ifft(.01*fft(h).*fft(x)*.01) which seems more in line with the expression of the CTFT.


texts:
I'm trying to understand OFDM by making a simulation. Are these steps correct?

generate M random complex QAM symbols. example: (1+j,1-j,-1-j,1-j....)
Split my M samples into a N 2048 sized arrays
Take IFFT of each array individually
Add cyclic prefix to each array
Make N square shaped signals by oversampling my IFFT arrays
Pulse shape the individual signals with raised cosine
Mix up the signals with frequency separation = 1/symbol_period by multiplying them by $e^{j2\pi ft}$


texts: General question on signal processing guidelines for emergency shutdown applications (i.e. medical devices)

texts:
Disclaimer

This might be a very broad question. I ask it out of curiosity, because the topic came up in a discussion lately. Hence, I do not have any specific applications or even data that I could show.

Question

In many technical applications, emergency shutdown procedures are essential for safety, e.g. in medical devices. Consider for example a Computed Tomography (CT) scanner, or radiotherapy devices, where the amount of ionizing radiation has to be kept at a save level. Or an magnetic resonance imaging (MRI) machine where the deposed radio-frequency energy and the switching speed of the imaging gradients must be monitored and kept below certain thresholds.

All these quantities can be measured redundantly and independently. In case of a technical failure, the measurement system will detect the fault and initiate an emergency shutdown, BUT at the time the measurement system detects the problem, the patient already was exposed to too high/risky amounts of energy/radiation/etc.

How is this situation handled in those systems? Is the reasoning as simple as

Our system needs a time $\Delta t$ to detect the faulty state and to switch off
If $\Delta t$ is short enough, no serious harm is to be expected to happen

or is there a threshold below the real threshold, i.e.

The emergency shutdown has to be initiated when the intensity (i.e. radiation/energy/magnetic field change per time) $I_\textrm{max}$ is reached
To fulfill the safety conditions, the device switches off slightly below, e.g. at $0.98 \times I_\textrm{max}$

In the first case, the patient may be shortly in danger, in the second case the system performance may be reduced.

Or does it work in a completely different way?

EDIT:

It is certainly also possible to simulate the system (e.g. applied RF fields, x-ray intensity, ...), measure the current state and predict the upcoming values. If the currently predicted value is in agreement with the actually measured one, it is a reasonable assumption to assume that the predicted value for the next time-step is also correct. Hence you could base the shutdown trigger on the predicted value: When it is too high, shutdown. Also stick to the rule to switch off the system if the currently simulated value and the measured value do not agree.


texts:
I've been sent here from this question in stackoverflow, please excuse me if the question comes too specific and it's not in the manners in here:)

The task is to find a glass with specific liquid in it. Let me show you the pictures and then describe what i'm trying to achieve and how i was trying to achieve so far in the description below the pictures.

The pictures: (seems i need at least 10 reputation to post pictures and links, so links will have to do :( otherwise you can look at the stack overflow question)

A detailed description:
I was trying to implement an algorithm that would detect a glass of a specific shape in opencv (glass may be transformed by a different camera shot angle/distance). There will be also other glasses of other shapes. The glass i'm searching for will also be filled with some colored liquid that will distinguish it from glasses containing other colors.

So far, i have tried using SIFT feature extractor to try to find some features in the glass and then match them with other photos with the glass in it.

This approach worked only in very specific conditions where i would have glass in a very specific position and the background would be similar to the learning images. The problem also is that the glass is a 3d object and i don't know how to extract features from that (maybe multiple photos from different angles linked-somehow?).

Now i don't know what other approach could i use. I have found some clues on this (here https://stackoverflow.com/questions/10168686/algorithm-improvement-for-coca-cola-can-shape-recognition#answer-10219338 ) but the links seem to be broken.

Another problem would be to detect different "levels of emptiness" in such glass, but i haven't even been able to find the glass itself properly.

What would be your recommendations on the approach in this task? Would it be better to use a different way to find the local 3d object feature? Or would it be better to use other approach altogether? I have heard about algorithms "learning" the object from a set of multiple photos but i have never seen this in practice.

Any advice would be really appreciated


texts: Block by block CCDF and PAPR analysis in MATLAB

texts:
There are few signals (OFDM-like modulation scheme with uniformly distributed data source) generated by my script. I need to compare scheme performance in sense of CCDF (Complementary Cumulative Distribution Function) and PAPR (Peak to Average Power Ratio).
There are MATLAB build-in system object comm.CCDF, and it seems that it needs a full sequence for analyze process. But my signals are generated block by block (for example block may contain ${10}^5$ frames each of 1024 samples). The whole sequence may contain over ${10}^6$ blocks, and i need to reallocate memory just to prevent run out.

Is there any way for my sequence to be analyzed block by block to get PAPR and CCDF properties of the whole sequence?


texts: quantification of histogram equalization improvement

texts:
My project consist of classification of images using ML. The images are microscopic slices. For the feature extraction phase, I am using multiple filters and got a good result.
So I decided to do a preprocessing for the images with the objective to standardize them before feature extraction and it came to me do a hiistogram equalization
Because I am not using this as features, I would like to know how to quantify the improvement of the quality of images.
I've used before a sharpness quantification, DOM if I am not wrong


texts:
Say we have an integrator $y(t)= \int_{- \infty}^{t} x(t) dt$

It is incorrect to use the following method to determine if it is time variant/invariant?

First, when we have input signal $x(t),$

$y_1(t)= \int_{- \infty}^{t} x(t) dt$

Then, we shift $y(t)$ by $t_0$

$y_1(t-t_0)=\int_{- \infty}^{t-t_0} x(\tau-t_0) d\tau$

If we have input signal $x(t-t_0),$ we get

$y_2(t)=\int_{- \infty}^{t} x(\tau-t_0) d\tau$

And since $y_1(t-t_0)\neq y_2(t)$

Then the system must be time variant.


texts: Velocity estimation from distance sensor

texts:
I know it is a generic question but I did not find a specific answer to it online.

My question is:
I have a range sensor based on the time of flight (Infrared Sensor. Transmitter-Reflector-Receiver). I know the time at which I take my range measurements and I would like to get the velocity measurements.

Doing a simple derivative is not enough because the sensor gives me a lot of noise and therefore I would like to add a filter to my distance measurement and I would like to know what is the best way to get velocity measurements from distance measurements (+time), which kind of filter would you use on the distance measurements before doing the derivative.

My simple reply would be: "a low pass filter"
My slightly-more-complicated-reply would be: "a kalman filter, with acceleration equal to zero, which will be an optimal low pass filter if the acceleration is always around zero."

What do you think?

thanks for any advice!


texts: Conceptual question on entropy and its relation to information

texts:
Learning
Informative
Statistics:
A
Nonparametric
Approach  paper presents an approach to parameter estimation by entropy minimization. There are other related works "Minimum-entropy estimation in semi-parametric models"  download link ( http://dl.acm.org/citation.cfm?id=1195853). The rationale provided is that minimization of error entropy is equivalent to maximization of likelihood. I am new to this area and find it hard to understand the intuition behind why entropy of the error minimization will yield the parameters. What happens when entropy is minimized?

What happens when Shannon Entropy is maximized? Entropy (Shannon's) is the uncertainty  = average information or uncertainty (unsure).
And what happens when entropy is minimized and
What is the meaning of minimizing entropy of error?


texts: I know about one application of DSPs ,that is a smart phone such as Samsung S4,but what about normal cell/mobile phone such as nokia3310?Is it also contains a DSP(Digital Signal Processor)?


texts:
I use this FFT and wrote a short program to test it.

package test_FFT;
import org.apache.commons.math3.transform.FastFourierTransformer;
import org.apache.commons.math3.transform.DftNormalization;
import org.apache.commons.math3.transform.TransformType;

public class FFT2 {

public static void main(String[] args) {
    double[][] array=new double[2][8];
    //An array of complex numbers with real part array[0][*]
    //and complex part array[1][*]
    //The output of the transformation will be saved in the input array
    array[0][0]=5.0;
    array[0][1]=2.0;
    array[0][2]=3.0;
    array[0][3]=4.0;
    array[0][4]=5.0;
    array[0][5]=6.0;
    array[0][6]=7.0;
    array[0][7]=9.0;
    FastFourierTransformer.transformInPlace(array,DftNormalization.STANDARD,TransformType.FORWARD);

    for(int i=0;i<8;i++){
        System.out.println("real "+array[0][i]);
        System.out.println("complex "+array[1][i]);
    }

}

}

In the output array I get amplitudes of sin and cos functions. The information about the frequencies should depend on the position within the output array.
After some research on this page, I still don't understand how to calculate frequencies out of array positions.

I learned that there are many flavours of how to perform a FFT. Has anyone of you detailed knowledge on how calculate frequencies out of output of the FFT I use? A code sample computing frequencies for the output of the example below would be greatly appreciated. Thank you


texts:
I'm currently working with BPSK carrier phase and frequency recovery in GNU Radio. I have been able to use Costas loop and Frequency locked loop (four carrier acquisition) which are based on the control_loop class (this class implements a PLL). Until now, I never needed to configure the control_loop class since the wrapper classes (Costas and FLL) do this by default.
As it can be seen below, the control loop (PLL) is based on the proportional-plus-integrator. The control loop constructor takes three variables
control_loop(loop_bw, max_freq, min_freq). max_ and min_freq variables are used to keep the frequency (in the integrator part of the loop) between max_freq and min_freq. I have looked into the Costas and FLL source code and saw how they are configured.

Let's start with Costas loop.

The loop is configured to have max_freq/min_freq of +1 and -1 respectively
The phase error input to the control loop i.e. (Φ_i[n] - Φ_o[n]) is bound between -1 and 1.
After the phase error has been filtered, the output phase i.e. Φ_o[n] is wrapped (between 2pi and -2pi). The frequency is forced into the max_freq and min_freq [1,-1] region.

With the FLL,

The loop is configured to have max_freq/min_freq of (2*PI/samples_per_symbol) and -(2*PI/samples_per_symbol) respectively.
Unlike the Costas loop, the phase error input to the control loop i.e. Φ_i[n] is not bounded.
Like the Costas, the output phase i.e. Φ_o[n] is wrapped (between 2pi and -2pi). The frequency is forced into the max_freq/min_freq of (2*PI/samples_per_symbol) and -(2*PI/samples_per_symbol) region.

I basically have three questions

Why is the input phase error of the Costas loop limited in the [1,-1] region?
How do you choose the frequency region [max_freq and min_freq] of the integrator part of the loop? why do we need to limit the frequency range?
Why is the output phase Φ_o[n] (in both Costas and FLL) wrapped between -2PI and 2PI?

I have added links to the source code of the Costas and the FLL blocks

Costas Loop: https://github.com/gnuradio/gnuradio/blob/master/gr-digital/lib/costas_loop_cc_impl.cc
FLL band-edge : https://github.com/gnuradio/gnuradio/blob/master/gr-digital/lib/fll_band_edge_cc_impl.cc

Regards,
M.


texts: Is it possible to decompose an image into basis images using MATLAB?

texts:
I have read that:

  Using Fourier decomposition any arbitrary image can be represented as
  summation of orthogonal basis images.

I want to see the basis images for any image say Lena or Cameraman, etc.

So can anybody help me to decompose an image into basis images and reconstruct back the same image from basis images using MATLAB?


texts: What is the form of the spectral derivative in the all-positive-frequency notation in DFT?

texts:
The Discrete Fourier Transform (DFT) of a function $u:[0,2\pi] \to \mathbb R$ sampled over $N$ equidistant points $\theta_j = 2\pi j/N,\, j = 0, \dots, N-1,$ is defined by

$$
\tilde U_k = \frac1N \sum_{j=0}^{N-1} u_j e^{-ik\theta_j}\,, \qquad \text{where } k \in [k]_N \in \frac{\mathbb Z}{N\mathbb Z}\,.
$$

The indices $k$ could go from $-N/2+1$ to $N/2$ in one convention and from $0$ to $N-1$ in another. Since $\tilde U_{k + N} = \tilde U_k\,, \forall k \in \mathbb Z$, the negative frequencies can be pushed all the way over to the other side of the positive frequencies to get the all-positive convention. This means that the negative frequencies $k \in \{ -1, -2, \dots, -N/2 + 1\}$ in one convention map to the frequencies $k + N \in \{N-1, N-2, \dots, N/2 + 1\}$ in the other convention.

We know that the derivative of the function $u$ can be calculated as follows:

$$
u'(\theta) = \sum_{k=-N/2 + 1}^{N/2} ik\, \tilde U_k e^{ik\theta}\,.
$$

This would mean that in the all-positive convention,

$$
u'(\theta) = \sum_{k=0}^{N/2} ik\, \tilde U_k e^{ik\theta} + \sum_{k = N/2 + 1}^{N-1} i(k-N)\, \tilde U_k e^{ik\theta} \,.
$$

Is that correct? If yes, why is it that the spectral derivative requires the use of negative frequencies? What goes wrong in the claim that

$$
u'(\theta) = \sum_{k=0}^{N-1} ik\, \tilde U_k e^{ik\theta}\,?
$$


texts: Find a sinusoidal fit from data with fft

texts:
I have a vector with raw data (120 samples). From the frequency spectrum I can tell there is one dominant frequency component. Now I am supposed to use the fft data (magnitude and phase) to find a good sinusoidal fit and offset to fit the original data.

I am completely stuck on this one. Can anyone help?


texts:
This is more of a soft question, I am currently writing a paper for my Master's in Mathematics and my topic of choice has been to focus on the Mathematical techniques behind Spectrum Analysis.

For my initial reading I have focused on Kay & Marple's paper Spectrum Analysis- A Modern Perspective, however "modern" in this context is relative to 1981.

I was wondering if anybody was aware of paper's published in the last few years (2005-onwards) which dealt with more recent developments. Currently I am focusing on Prony and ARMA techniques, with a contrast to Wavelets. However as I am hopefully going to be receiving actual experimental data (analyzing output of power from a laser) I would like to have access to a range of current ideas to analyse the data and present a contrast.

Ideally i am looking for papers that give a treatment of the mathematical concepts behind the techniques.

Thanks

edit: I have been searching IEEE etc, and have a large variety of papers but i was hoping that i could be pointed towards good quality papers before i attempt to read them all to discover which are more helpful.


texts: Designing observer with non-observable system

texts:
I have this state-space system

\begin{align}
\dot{x}&=\begin{bmatrix}1 & 0\\3 & -2\end{bmatrix}x+\begin{bmatrix}10\\0 \end{bmatrix}u\\
y&=\begin{bmatrix}1 & 0\end{bmatrix}x
\end{align}

And I'm asked to design an observer such that its poles are at $-1+j$ and $-1-j$.

The problem I'm having is that the system described above is not observable, as its observability matrix's rank is 1.

Is there anything I can do in a case like this?


texts: Clustering real and imaginary values within a frequency row of an STFT

texts:
I am analyzing a short audio .wav file of a drum and piano for source separation.  (not using interpretable languages like Librosa, Scikit, Matlab, or R, but rather a compilable language in .NET).

When considering the hierarchical clustering approach taken in this report, see Fig. 4, I am wondering whether (within a frequency row of the mixed STFT) whether it would be better to cluster the phase-adjusted reals and imaginaries or the unadjusted values?

By phase-adjusted I mean (matlab):

phi = angle(STFT)
xhat = STFT.*exp(1i*phi);

Also, once the coefficients are agglomerated within rows, would it be advantageous to use a Weiner or binary mask?  I am currently experimenting, but wanted to ask the community in case there are any caveats.

UPDATE

The goal is sound source separation, i.e., separating percussion from piano.

The type of clustering is hierarchical.

What is being clustered: real and imaginary values in the same frequency row (bin) of a mixed STFT -- obtained from numerous DFTs of contiguous windowed (Hann) segments of audio signal.

An example of a Weiner mask involves representing an $F \times T$ STFT matrix, $\bf{V}$, with a basis and gain matrix, i.e. $\underset{F \times T}{\bf{V}}=\underset{F \times K}{\bf{W}} \underset{K \times T}{\bf{H}}  $ derived from using NMF (non-negative matrix factorization) - an unsupervised clustering method for which the assumed number of clusters is $K$.  The $K$ columns of $\bf{W}$ represent $K$ clusters of frequencies and $K$ rows of $\bf{H}$ represent the respective $K$ clusters of activations (over time).  Assuming $K$ total clusters, the modified STFT (MSTFT) for the $k$th cluster, $\mathbf{M}_k$, based on a Weiner mask has elements

$m_{ftk} = \frac{\hat{v}_{ftk}}{\sum_l \hat{v}_{ftl}}$,

where $\hat{v}_{ftk}$ is an element of the estimated STFT for cluster $k$ based on the outer product matrix $\mathbf{\hat{V}}_k = \mathbf{w}_k \mathbf{h}_k$


texts: Weighting function for output error IIR filter design

texts:
I noticed, when I try to fit filter coefficients to a given complex transfer function with the output error method, implemented for example in the MATLAB function invfreqz.m, I get way better results when I use a weighting function that drastically emphasizes the lower frequencies, for example $1/(2\pi f)$.

Can anybody explain or give me a hint in the right direction, why emphasizing the low frequencies in the weighting function gives so much better fitting results?

My frequency vector is logarithmic, in case that makes a difference and I try to get the best fit for "relatively simple" transfer functions with a very low filter order.


texts: Digital low pass filter vs continuous low pass filter,?

texts:
What is difference between both implementations of low pass filter? Discrete/digital implementation and continuous implementation?

As far i am able to understand

In case of discrete implementation, passband spectrum exists between "-pi "and "pi"

While in case of continous implementation, passband spectrum exists between 0 and "f" . Where "f" is upper cut off frequency


texts: Maximum Magnitude Deviation between DFT and DTFT

texts:
Let $x[n]$ be a finite-length discrete-time signal with length $N$. The continuous DTFT $X(\omega)$ is then
$$
X(\omega) = \sum_{n = 0}^{N-1} x[n] e^{-j \omega n}.
$$

The length-$N$ DFT of $x[n]$ is
$$
X[k] = \sum_{n = 0}^{N-1} x[n] e^{-j 2 \pi \frac{k n}{N}}.
$$
For this, the DFT is a sampled version of the DTFT, i.e.,
$$
X[k] = X(2\pi k / N).
$$
Please also see posts here and here. Now, we consider the maximum magnitudes $m_{\textrm{d}} = \max_k |X[k]|$ and $m_{\textrm{c}} = \max_\omega |X(\omega)|$. Because of above, we have $m_{\textrm{d}} \leq m_{\textrm{c}}$.

What is the relation between these maximum values? Is there $\gamma > 1$ such that $\gamma m_{\textrm{d}} \geq m_{\textrm{c}}$?


texts: Can I use independent component analysis if I have two discrete populations of signal sources mixed together?

texts:
I understand (mostly) how independent component analysis (ICA) works on a set of signals from one population, but I am failing to make it work if my observations (X matrix) includes signals from two different populations (having different means) and I am wondering if it is an inherent limitation of ICA or if I can resolve this.  My signals are different than the common type being analyzed in that my source vectors are very short (e.g. 3 values long), but I have many (e.g. 1000's) of observations.  Specifically, I am measuring fluorescence in 3 colors where the broad fluorescence signals can "spillover" into other detectors. I have 3 detectors and using 3 different fluorophores on particles. One could think of this as a very poor resolution spectroscopy.  Any fluorescent particle could have an arbitrary amount of any of the 3 different fluorophors.  However, I have a mixed set of particles which tend to have quite distinct concentrations of fluorophores. For example, one set may generally have lots of fluorophore #1 and little fluorophore #2, while the other set has little of #1 and lots of #2.

Basically, I want to deconvolve the spillover effect to estimate the actual amount of each fluorophore on each particle, rather than having a fraction of signal from one fluorophore add to the signal of another.  It seemed like this would be possible for ICA, but after some significant failures (the matrix transform seems to prioritize separating the populations rather than rotating to optimize signal independence), I am wondering if ICA isn't the right solution or if I need to pre-process my data in some other manner to address this.

The graphs show my synthetic data used to demonstrate the problem.  Starting with "true" sources (panel A) consisting of a mixture of 2 populations, I created a "true" mixing (A) matrix and calculated the observation (X) matrix (panel B).  FastICA estimates the S matrix (shown in panel C) and instead of finding my true sources, it seems to me that it rotates the data to minimize the covariance between the 2 populations.

Looking for any suggestions or insight.


texts: Generating a Sine Signal (for example a voltage sine wave) with changing frequency and changing sample rate (time)?

texts:
i have a measured signal (e.g. voltage sine wave) and i would like to generate a sine wave which matches this meausred signal (with the generated sine wave i remove the harmonics from my measured signal), just like a PLL block in simulink.

for that i have to do the 2 steps:

1- Calculate the frequency of the measured signal from detecting the Zerocrossing.

2- calcualte the sine function using sin(2*pi*f(t)*t).

I have the following problem.

1- calcuating the frequency by counting the samples between two zerocrossing would results in getting the frequency at one point so my calcualted fequency does not match my sampled measured signal.

2- even when interpolating or using the repmat function i am able to get the f(t) to be the same length as the time (t) vector yet my sine wave is not correctly calcualted. i know that:

I am adding the zerocrossing times on my time vector which makes the last one inconsistance which mean the sampling rate is changing also.

so how to genereate a sine wave which changing frequency and changing sampling rate of the time signal?

Best Reagrds


texts: Blais Rioux Detector peak detector implementation

texts:
I'm trying to implement the Blais Rioux detector to find the center of a peak with sub pixel, resolution.

The image shows the results of the implementation in a excel graph.
The blue graph shows the input data with the prominent mountain the center of which I want to detect.
The gray graph is the result of running the data through the Blais Rioux formula.
I'm using the fourth order form here
$
g(x) = f(x-2) + f(x-1) - f(x+1) - f(x+2)
$
This acts like a numerical derivative operator.
Then to find the peak one uses the following
$
\delta = \frac{g(x)}{g(x) - g(x + 1)}
$
I'm unable to determine how to find the center of the peak with the above.
I see to peaks in the output one on the negative side and one one the positive side both close to each other. The max value of these peaks are 42 and -41 so if I apply the above equation that gives me
$
\frac{42}{42 - (-41)}
$
which gives me the result 0.5, which I don't understand what it is.
I found another reference that pictorially depicts the peak detection like so,

I hope the experts here can help.


texts: Transform RGB image to *look like* Infrared

texts:
Context: I'm trying to improve a pose estimation model so that it works better when my camera is in Infrared mode. Unfortunately I only have RGB images to train on.

I realize that you can't convert RGB to IR directly, but my hypothesis is that converting the RGB images to look more like IR, and then training on a dataset of combined RGB and IR images, will lead to better performance.

Are there any libraries that have tried to implement a function like this? I'm essentially looking for a function that something like this ("IR effect") - http://funny.pho.to/infrared/


texts: What should my reference value be when converting FFT bin amplitudes to dB?

texts:
I want to transform my FFT output values into a dB scale, but I'm struggling to determine the function I should run each bin amplitude through.  My understanding of the decibel scale is that a value representing an intensity must be divided by some reference intensity.  The log of this ratio, times 20, will represent the dB scale value:

$$
\text{dB} = 20 \log_{10}\frac{\text{intensity}}{\text{intensity}_{\text{ref}}}
$$

I should be able to pass each an FFT bin amplitude value into this equation as $\text{intensity}$, and the result will be the dB level of that bin.

Unfortunately, I'm not sure what $\text{intensity}_{\text{ref}}$ should be.  Based on my reading, I believe it should represent the maximum possible intensity.  If the readings were samples from a wave, this would be easy (the highest possible reading for 8-bit audio would be 255; for 16-bit it would be 65535, etc).  However, I'm not sure that FFT outputs have such a predictable range or scale.

One option would be normalizing the amplitude values (dividing each value by the maximum amongst all bins for all FFT windows computed for the signal).  This way, the bin with the highest amplitude would be at 0 dB and all others would be negative values relative to that maximum.  However, this would only work if I pre-computed every FFT window for an entire signal.  What if I was trying to compute dB values for an FFT of a just a single window?

So my question is: what is $\text{intensity}_{\text{ref}}$?  I'm still relatively new to signal processing, so if there's an easy way to guarantee some range of FFT amplitude values or any other obvious solution I'm missing please let me know.


texts: convolutional coding with higher order QAM

texts:
I've implemented a simple 1/2 rate convolutional code and a viterbi decoder algorithm. I followed the most-common type of convolutional coding implementation I could find by googling: 1 input bit gets shifted into a shift register, one at a time, and an algorithm of XOR gates generates a 2-bit output.

This 2-bit output worked very nicely to map to QAM4, since 2 bits can represent 4 positions. The viterbi decoder would receive the QAM4 data and process the most-probable branch for each hidden-state, every cycle.

What if instead of a single bit streaming into the convolutional coder, I had 2 bits streaming into the coder? Would I use a different structure that could generate 4 outputs bits, and map this to QAM16? Or would I use the same structure   at twice the rate and then collect 2 sets of 2 outputs? Does the viterbi decoder need to change to implement this?

I guess my goal is to get more bits modulated into a single symbol, but still be able to utilize convolutional coding/error correction. I'd like to keep the 1/2 rate as well.


texts: Using fft in matlab to retrieve input signal magnitude

texts:
I am trying to understand how you use an FFT in matlab to measure/retrieve the magnitude of the input signal.

For my understanding I have put this script together, creating a 15Hz sine wave with a sampling frequency of 1kHz.

fftsize    = 2048;            % How many samples for FFT
fs         = 1000;            % Sampling frequency (Hz)
sim_length = fftsize/fs ;     % run sim for this time
t          = 0:1/fs:sim_length-1/fs;
x          = (0.5)*sin(2*pi*15*t); % 15 Hz component, 0.5 magnitude

Window and FFT:

%% Windowed FFT
data                  = x'; % Assign input data
window                = blackman(fftsize);
windowed_data         = window.*data;

% Perform FFT and take magnitude (of complex result)
fftd_data             = abs( fft(windowed_data, fftsize) );

The input frequency was not coherent, add in the windowing and there is going to be some spectral leakage, therefore I need to sum the power over a few bins around where I expect the fundamental to be.

% Each bin represents
bin_freq = fs/fftsize ;

% 15 Hz fundamental is centred in bin
fundamental_bin = ceil( 15/bin_freq );

% Allow spectral spreading of +-4 bins
lower_limit = fundamental_bin - 4;
upper_limit = fundamental_bin + 4;

Sum of values from fft:

sum( fftd_data(lower_limit:upper_limit) )

ans =

  512.3738

Which is not the 0.5 I was looking for. What is the best way to get the (0.5) input magnitude from the fft result.

After some digging about I have come up with the following but not quite sure why it works or if I have named the calculations appropriately.

incoherent_power_gain = sum(window.^2);
power_spectrum        = fftd_data.^2 ;
power_fftd_data       = (4 * power_spectrum) / (incoherent_power_gain * fftsize);

sum_fundamental_power = sum( power_fftd_data(lower_limit:upper_limit) )

sum_fundamental_power =

    0.2500

We converted to Power so we can take the square root to get back to a signal level.

sqrt( sum_fundamental_power )

ans =

    0.5000

Great, but is there a better way or can some one explain:

If power spectrum is the correct name for fftd_data.^2.

I am also unsure what is happening in (4 * power_spectrum) / (incoherent_power_gain * fftsize).


texts: CIE-Lab changes on Light intensity changes

texts:
I am planning to use CIE-Lab color model for an image segmentaion method.

If the light intensity of sun, some led source changes on the objectm then does it affects the a and b value of the data also?

And if different color of light source is focused in the object, that affect has it on the lab values of given image?


texts: How do I create a polar plot from a multi-channel sound file?

texts:
I have a multi-channel sound file from a microphone array. I want to get the polar plot in Matlab in order to get the directivity patter of the sound source. How do I do this? I did the FFT on the whole recording and I plotted the magnitude in dB but I'm afraid I'm not doing the correct thing.

Can someone tell me how I can get the polar directivity representation?
If I want to plot the directivity in terms of octave bands should I use a filter bank or can I just plot some averaged magnitudes of the frequencies that are on that specific octave band?

Sorry for the newbie questions and thanks a lot in advance.


texts:
I have a very large array (about 500.000 in size). I've plotted the array in chunks and founded at the tail of the array there is a periodic behavior, so I want to know if there is a way to know if it is periodic an if so what is its period?

I don't have any idea about signal processing so I need to know if there is a simple and straight forward method to check it. I'm using Python and Mathlab.

Thanks!


texts:
If the region of convergence (ROC) for system function $H(z)$ is $R_h$, what is the ROC of the inverse function $G(z)=\frac{1}{H(z)}$?

$$$$


texts:
I have an ECG signal, and want to sparsify it using wavelet (DWT) in Matlab.
In some paper they use Daubechies wavelet (DB4) with 8-tap filters.
but i don't know how to extract the wavelet coefficients and plot a figure like this:

tnx.


texts:
What is difference between convolution and correlation?In simple words or in a nut shell?

As far as i am able to study is that Convolution is a mathematical operation used to express the relation between input and output of an LTI system. It relates input, output and impulse response of an LTI system while Correlation is a measure of similarity between two signals


texts:
I wish to do the FFT of streaming audio data coming into a computer. I am just interested in frequencies from 80 Hz up to 1000 Hz but with a frequency resolution of 3 to 4 Hz and no more.

Basically my question is , as my sampling frequency (Fs) is 44100, will my FFT window size have to be no less than 11025 (N) ?  (because spacing of FFT bins = Fs/N). Does this mean that I am completely limited to taking windows of data any higher than 4 times a second with my desired resolution.

Unfortunately I need to be able to capture windows of data 8 times a second and also have a resolution of 3 to 4 Hz.

Is this actually possible? Many thanks in advance.


texts:
I am trying to make a AM modem using Python Numpy and Matplotlib. I am successful in generating the AM Signal but I cannot demodulate it using a lowpass filter function that I made. The demodulation equation that I am using is;

$$A_{c}m(t)\cos(\omega_{c}t)\cdot 2\cos(\omega_{c}t)$$

My modulated output is this;

The demodulated signal is however this;

When it should have been this;

The lowpass filter that I am using is;
$$h(t) = \frac{\sin(2\pi Bt)}{\pi t}$$

Finally, this is my code;

import matplotlib.pyplot as plt
import numpy as np

t = np.arange(0, 100, 0.1)

message_freq = 50
message = np.sin(6.28*message_freq*t)
carrier_freq = 1000

class Filters():
    def LowPassFilter(self, cutoff):
        f = np.sin(6.28*cutoff*t)/(3.14*t)
        return f

class AmplitudeModem:
    def modulate(self, message, fc):
        c = np.cos(6.28*fc*t)

        mod = message*c
        return mod

    def demodulate(self, received_array, fc, fm):
        c = np.cos(6.28*fc*t)

        demod = 2*c*received_array
        baseband = demod #- self.modulate(Ac, received_array, 2*fc)
        return np.convolve(Filters().LowPassFilter(message_freq), baseband)

modulated = AmplitudeModem().modulate(message, carrier_freq)
demodulated = AmplitudeModem().demodulate(modulated, carrier_freq, message_freq)

Another problem that I am facing is that, I cannot plot the convolution (used in demodulate() function) with respect to time, due to their different dimensions.


texts: Beginner question on aperiodic samples and DFT behavior

texts:
I have a strongly aperiodic signal and I get weird artifacts after running a fft, using a low-pass filter, and then doing an inverse fft.  I believe the artifacts are due to the way the signal is assumed to be periodic and "wrapped" at the ends. (Like I said, I'm a complete beginner here.)

I understand the usual way of handling aperiodic signals is via a window function, but applying a window function (say, Hamming) to my data looks like it squishes the data too much and like it would generate worse artifacts.

What sort of seems like it works is to

surround the signal with silence, by prepending and appending a segment of 0s,
doing the fft, applying the filter, etc., and then inverting the fft, then
clipping off the silence segments off the beginning and end.

The result of step 1 looks like applying a rectangular window function to a longer signal, so I think that's ok, but...

Is what I'm doing in any way reasonable?
If so, what are the effects? And what is the best way to determine the length of the segments of 0s? (Currently, 10% of the original signal seems like it's not bad.)
If not, is there another way to do this?


texts: Can someone explain or elaborate on the channel estimation and noise variance estimation algorithms used in HF receiver?

texts:
For different type of communication, there is  different type of algorithms to acquire CSI.
For instance 4G (LTE) network have SRS or DMRS to estimate the channel based on pilots.

I am designing a similar algorithm based on probes (or pilots) in order to have the time based channel estimate of groundwave HF channels (this is for my equalization block).
The Doppler spread measuring the rapidity of channel time variations seldom
exceeds 1 Hz on HF channels.

Let $y(t) = h(t) \ast s(t) + n(t) $, where $s(t)$, the pilots symbols, have an autocorrelation given by
$R_s (t) = \delta (t) $.

The pilot (or training) symbols are chosen so that the intercorrelation between $s(t)$ and $y(t)$ is given by:
$R_{y,s} = R_s (t) \ast h(t)  \approx \delta (t) \ast  h(t) $
if one neglects the noise,

I have 15 kHz of bandwidth and I need 300 estimates. The sampling frequency is $F_e = 30\,\text{kHz}$. That's one channel coefficient every 100 Hz. One estimate takes at least 300/(30 kHz) = 0.01 s.

The channel coherency time (channel span) is about 0.5s up to 1.5s (mean value) .

For a 1800 Bd symbol rate and a maximum time spread of 5 ms, N = 22 coefficients
are needed to (almost) fully represent the channel.

I will make simulation for noise and propagation conditions, with SNR varying between 5 and 15 dB.


texts: Channel Capacity of OFDM with Index Modulation

texts: I am trying to figure out the channel capacity of OFDM with index modulation (OFDM-IM). One of the article reports that the conditional channel capacity of OFDM-IM is $\mathcal{C}_{\mathrm{OFDM-IM}}(\gamma) = \frac{1}{L}\left[I(\boldsymbol{x}_s;\boldsymbol{y}\vert \boldsymbol{x}_c)+I(\boldsymbol{x}_c;\boldsymbol{y})\right]$, where $\gamma$ is the SNR, $L$ is the number of subcarriers available for modulation in one group, $I(\boldsymbol{x}_s;\boldsymbol{y}\vert \boldsymbol{x}_c)$ provides constellation domain information, $I(\boldsymbol{x}_c;\boldsymbol{y})$ is the index domain information and $\boldsymbol{y}$ is the vector of received symbol. I was wondering whether this relation is only valid when we expect a complex-valued signal after IFFT? Secondly, how would this relation change if we need a real-valued signal after IFFT, i.e., when Hermitian symmetry is enforced in the frequency domain prior to IFFT?


texts: What's the state-of-the-art algorithms in image edge detection?

texts:
There are several state-of-the-art algorithms in image denoising including Non-Local Means, BM3D and so on.

I am wondering whether there is some well-known state-of-the-art algorithms in image edge detection (with reproducible code) ?

Thanks a lot for your answering.


texts: Detecting a single frequency in noisy data

texts:
I am not very experienced in signal processing, and it seems like this should be a simple problem. I have two computers, one plays a tone a 19 kHz at a sampling rate of 44.1 kHz, and the other listens with a sampling rate of 44.1 kHz and tries to find if the 19kHz tone is present. The transmission of the signal is in a noisy environment, and I have tried to find the amplitude of the 19 kHz wave using an FFT as well as Goertzel, but neither has given me a conclusive value (the amplitudes are very small).

For the FFT, I am using JTransform, running the forwardFFT, then finding the bin in which 19 kHz lies and getting the amplitude by (imaginary * imaginary + real * real) for the components of that frequency bin.

For Goertzel, I followed the pseudo-code on this site: http://www.mstarlabs.com/dsp/goertzel/goertzel.html. I feel like both the FFT and Goertzel should give the same amplitude if the sample size is the same, but they give different values for that frequency bin.

I expect the amplitude to be greater than 10, but I do not believe this is working. I believe I need to at least filter out the noise below 19 kHz as a first step, but am unsure. Maybe some highpass filtering should be done first? Any suggestions on how to detect the 19 kHz sine wave? Thank you.
Updated:

Here is a plot of the raw data I am getting from the microphone:

I feel like this is just noise, but I am unsure.


texts: How to proceess Image with curved corners and edges to give sharp Corners?

texts:
I have several Images of shape H, F, I, L.. which have curved corners. How do I process them to give sharp right-angled corners? I tried approximating them with inner rectangles, but this takes a LOT of time.. How do I proceed with it?

This is the sample Image. I want to process it such that I get rid of rounded corneres.


texts: wavelet denoising routine for environmental data series

texts:
I have a time series of water temperature, e.g.

y = 1+(30-10).*rand(1,365);

I have previously used the wavelet denoising routine in the wavelet toolbox by matlab to remove unwanted noise from a signal, e.g.

[s_denoised, ~, ~] = wden(y, 'minimaxi', 's', 'sln', 2, 'db4');

However, I am unsure whether I am using this method correctly! If my time series is of water temperature which is characteristic of an environmental data series i.e. high power at low frequency (e.g. seasonal cycle) and low power at high frequency (e.g. diel cycle) and I wish to remove noise caused by internal wave motion in lakes (which cause sudden increases or decreases in temperature), should I be using the wavelet shown here or is there a better wavelet to use?


texts: MFCC window size at different sampling rates

texts:
The general recommendation for window size when calculating MFCC seems to be 20-40 msec. This is most often recommended in a context of 16000 samples per second, so leading to a window containing 320-640 samples.

What if my input is at 8000 samples per second, should the time frame of the window be targeted at 20-40 msec or should the amount of samples be targeted at 320-640?

I understand the window needs to have a minimal duration in order to include lower frequencies and that the maximum duration is limited to have stable sounds (phones). What would be the reason to still prefer 40 msec over 20 msec?

What determines the minimal amount of samples? A 20msec window at 8000 samples per second is 160 samples, is that sufficient?

Context is speech recognition


texts: How does image rotation affect the intrinsic camera parameters?

texts:
I am considering the problem of how to (manually) change camera model parameter to make it "valid" on a rotated image. This question tackles resizing, but does not consider lens distortion.
My problem is this:

Given 3x3 camera parameter matrix + 5 radial distortion coefficients as computed by OpenCV, how do these parameters need to be adapted to be valid on an image which has been rotated by 90° clockwise?

I am reasonably sure that the focal lengths fx, fy need to be flipped, cx replaced by image.height - cy, cy by cx, but I am not sure if I can just keep the radial distortion parameters.
According to my reading of OpenCV's camera model as below,  the radial distortion is symmetric around the principal point. So if all my image coordinates get remapped via image rotation, the distortion coefficients should still apply, since the distortion is  a function of the  distance from the intersection point of optical axis and sensor plane. Assuming no sensor tilt and only radial distortion, no recalibration of the coefficients should be necessary.
Is this assessment correct? If not, why  not?
The question if prompted by the fact that undistorting a rotated image according  to this procedure produces a different result from using the original orientation and original camera matrix. So I must be making a mistake.


texts: Removing an unwanted sinusoidal signal using FIR filter

texts:
I am learning about the $\mathcal Z$-transform and FIR filters and I do have problem with the following exercise:

  There is given signal $$x[n] = s[n]+\sin\left(2\pi f_n n\right)$$ where $s[n]$ is a useful signal, while sinus is an interference. Let's assume, that we use FIR filter to remove the interference. Where should be placed zeros of a transfer function to completely remove sinusoidal signal?

  Sampling frequency: $f_s=10\textrm{ kHz}$

  Sinusoid's frequency: $f=2.5 \textrm{ kHz}$

Here is my attempt:

$$f_n=\frac{f}{f_s}=\frac{1}{4}$$

\begin{align}
y[n]&=x[n]\star h[n]\\
&=s[n]\star h[n]+\sin\left(2\pi f_n n\right)\star h[n]\\
\implies Y(z)&=S(z) \cdot H(z)+ \underbrace{\mathcal{Z}\left\{ \sin\left(2\pi f_n n\right)\right\} \cdot H(z)}_0
\end{align}

thus

$$0=H(z)\cdot\frac{z\sin\left(2\pi f_n\right)}{z^2-2z\cos\left(2\pi f_n\right)+1}$$

In general FIR filter is given by equation

$$H(z)=b_0+b_1z^{-1}+b_2z^{-2}+\dots$$

hence

$$\left(b_0+b_1z^{-1}+b_2z^{-2}+\dots\right)\cdot\frac{z}{z^2+1}=0$$

And I am stuck here. What to do next?


texts:
Why is it $N\cdot N$ a sufficient number of cosine waves equal to the size of the image or to a portion of it to describe it (or a portion of it) completely without losing information applying the DCT.

For example, in the JPEG encoding I divide the image into 8x8 blocks and I will have, for each block, a table of exactly 8x8 coefficients: one for each wave. But... why?


texts: Phase angle operator, Implemention and drawbacks

texts:
Let assume we have a signal as:
$\color{blue} {x(t)=M e^{(-\beta.t)} e^{j(\sigma .t+\delta )}}$
By applying phase angle operator we have:
$\color{blue} {Phase[x(t)]=Phase[M e^{-\beta.t} e^{j(\sigma .t+\delta )}]=\sigma.t+\delta}$
I have two questions:
 1. How can I implement the Phase angle operator, i.e. Phase, in practice ,like a chip.
 2. Does phase angle operator increase the effect of noise in a noisy signal?(for example some operators like derivative operator increases the noise effect in a noisy signal)
Kind Regards


texts: Confused about Hamming window and its relation with frequency response specification

texts: $w(n)= 0.54 + 0.46\cos(2n \pi/(M-1))$ is Hamming window and we have say $f_{s_1}$,$f_{p_1}$,$f_{p_2}$,$f_{s_2}$ with pass and stopband tolerance specifications of the desired filter. From this specification can we get mathematical corresponding frequency response?


texts: Causality, Linearity, and Time Invariance for Systems Described by Linear Constant Coefficient Differential Equations

texts:
I am currently using Signals and Systems by Alan Oppenheim as a reference to learn about LTI systems.

Before introducing systems represented by linear constant coefficient differential equations, the author first considers general systems of the form $x(t) \rightarrow y(t)$. When discussing linearity of systems, he introduces the "zero in-zero out" property of linear systems (not necessarily time invariant or causal), that is, given a linear system, if the input $x(t)$ is zero for all $t$, then the output $y(t)$ must be zero for all $t$. In addition, a linear system is causal if and only if $y(t) = 0$ for all $t < t_0$ if $x(t) = 0$ for all $t < t_0$, a condition known as initial rest, from which I concluded that initial rest for linear systems implies causality but not time invariance.

Now given a linear constant coefficient differential equation $$Ly(t) = x(t),$$ where $L$ is a linear differential operator with constant coefficients, the author emphasizes that although the differential equation is linear, the system that it represents may or may not be linear depending on the initial conditions. I find this confusing because given two input output pairs $x_1(t) \rightarrow y_1(t)$ and $x_2(t) \rightarrow y_2(t)$, we have $L(ay_1(t) + by_2(t)) = ax_1(t) + bx_2(t)$ for any constants $a, b \in \mathbb C$ by virtue of the linearity of the operator $L$. It seems that $ax_1(t) + bx_2(t) \rightarrow ay_1(t) + by_2(t)$ regardless of the initial conditions, why is the system not necessarily linear in that case? What am I missing here?

In addition, the author states that for the system to be linear, the initial conditions have to be zero, and for it to be causal and time invariant in addition to being linear, its initial conditions must obey initial rest. But isn't initial rest in general a condition required for causality, not time invariance? Besides, doesn't this imply that a differential equation can only represent a causal system if the input is zero before some time? Given an input that is nonzero for all time, how do we impose causality via initial conditions that correspond to initial rest? I hope my question makes sense. Thank you in advance.


texts:
I have been reading Signals and Systems (2nd ed.) recently. Chapter 7 is about sampling. Oppenheim uses discrete-time signals and continuous-time signals to explain sampling.

But why do we need discrete-time signals? We use the A/D to receive and convert the continuous-time signal, so the signal is already discrete. In other words, the discrete signals are the sampled version of continuous signals.
Is there any practical meaning to sample discrete-time signals?


texts: ensure stability against coefficient quantization

texts:
for a filter:

$$ H(z)=\frac{1+0.1z^{-1}}{1+0.1z^{-1}+0.9998z^{-2}} $$

Which precautions could be taken to ensure that the filter does not become unstable because of coefficient quantization? I've think that it would depend of the implementation chosen (I've read there are implementations pretty robust against quantization), but not really sure.  Thanks in advance.


texts:
Just wondering what image processing techniques can remove some artifacts of parallel-line like streaks, which are shown in the red box in the above picture.
I was thinking about removing it from Fourier domain operation(I expected to see a strong response other than DC some where in Fourier spectrum, but I could not see anything I expected.)
So I am wondering

how to locate those artifacts in an image,
and what image processing techniques can possibly get rid of them?

Any pointer is highly appreciated. Thank you.


texts:
I have an IQ data of QPSK signal , when I apply a PLL loop I obtain constellation in figure below. What is this phenomenon, and how can I obtain the good constellation??

The second figure is about variation angles, is there any idea about the red countoured effect?

after adding symbol syncronisation , i obtain constellation below , but there  is also sommes error that causes incorrect demapping ;; is there any suggestion ????


texts: I have an EEG data set downloaded from physionet. I want to play that data into a brain monitoring device like for example BIS monitor or Narcotrend or any other similar brain monitoring device.I use Matlab GUI to visualize the data. Can I send it from a Matlab GUI to any one of the brain monitoring devices with a suitable hardware  in between.Any ideas please I am new to EEG signals.