Skip to main content

Questions tagged [python]

Python is a high-level interpreted general programming language. Python has popular numerical and scientific libraries/packages, most notably numpy and scipy. The scipy.signal package is a powerful signal processing software collection. This tag covers the use of numpy, scipy, and other Python packages often used for SP computations.

Filter by
Sorted by
Tagged with
6 votes
3 answers
2k views

Role of window length and overlap in uncertainty principle?

I am trying to predict epilepsy using spectrograms and a convolutional neural network. So far I have achieved a validation accuracy of 86% which i feel like is pretty good. Lots of the papers doing ...
niklas Munkholm Hjort's user avatar
4 votes
1 answer
2k views

PyWavelets CWT: normalization? Vs Scipy?

Related. The equation being implemented normalizes by sqrt(1 / scale): $$ C_{a, b} = \frac{1}{\sqrt{a}} \sum_k s(k)\left( \int_{-\infty}^{k+1} \overline{\psi \left(\...
OverLordGoldDragon's user avatar
22 votes
5 answers
28k views

Fast Cosine Transform via FFT

I want to implement the Fast Cosine Transform. I read on wikipedia, that there is a fast version of the DCT which is similarly computed to the FFT. I tried to read the cited Makhoul* paper, for the ...
Framester's user avatar
  • 321
3 votes
2 answers
1k views

Amplitude extraction using STFT

I'm trying to recover amplitude/magnitude from an audio stream. I'm using FFT to go from time domain to frequency. If I feed in a signal of known amplitude, the results I get from either windowing or ...
dizzy's user avatar
  • 253
31 votes
2 answers
62k views

Applying filter in scipy.signal: Use lfilter or filtfilt?

I saw in a SO thread a suggestion to use filtfilt which performs backwards/forwards filtering instead of lfilter. What is the ...
Bar's user avatar
  • 437
18 votes
1 answer
29k views

What is the phase and magnitude response of white noise?

I would like to create white noise in the frequency domain, and then transform it to the time domain using python. To understand the problem, I simply generated white noise in the time domain, and ...
Uffe's user avatar
  • 355
-3 votes
2 answers
731 views

What is the formula to calculate the frequency response?

I'm newbie of dsp so i have a question for u guys: signal= [ -0.0018225230, -0.0015879294, +0.0000000000, +0.0036977508, +0.0080754303, +0.0085302217, -0.0000000000, -0.0173976984, -0.0341458607, -0....
Tu Le Anh's user avatar
34 votes
3 answers
47k views

Picking the correct filter for accelerometer data

I am fairly new to DSP, and have done some research on possible filters for smoothing accelerometer data in python. An example of the type of data Ill be experiencing can be seen in the following ...
Michael M's user avatar
  • 443
18 votes
4 answers
11k views

Counting the number of groups of 1s in a boolean map of numpy.array

I am right now dealing with some image processing in Python via PIL (Python Image Library). My main aim is counting the number of colored cells in an immunohistochemistry image. I know that there are ...
Ibrahim C. Kurt's user avatar
16 votes
4 answers
5k views

When concatenating sine waves, how do I phase shift in order to prevent "pops" caused by sudden jumps in amplitude?

I'm writing a synthesizer using numpy and python. I've run into a problem where concatenating sine waves causes 'pops' or 'clicks' when they are outputted to audio, say, via ...
Tim's user avatar
  • 161
12 votes
3 answers
5k views

Fail to separate sound signals by FastICA on real-world recording

I have written a program to perform FastICA on a stereo WAV file using the code on Python MDP FastICA Example With the audio examples I get very good results. Then I try to do real world recording ...
Jeremy's user avatar
  • 223
6 votes
2 answers
11k views

Bandpass filters with python for low frequencies

I have a signal, sampled at 1 kHz, that I would like to analyze in third octave bands. For that purpose I defined Butterworth filters with proportional bandwidth. This works well for higher ...
fft_newbie's user avatar
6 votes
1 answer
896 views

Implementing logarithmic AGC (automatic gain control)

I'd like to implement the Log(arithmic) AGC from Understanding Digital Signal Processing But with ...
ge45mue's user avatar
  • 163
6 votes
2 answers
18k views

Am I supposed to normalize FFT in Python?

I'm sorry if this question is posed often, I can't seem to understand the answers already out there. I'm working with several forms of the Fourier transform, including the FFT, PSD, and spectrograms. ...
Petra's user avatar
  • 177
5 votes
4 answers
57k views

FFT to spectrum in decibel

Here is a 10 seconds-long 440hz sine wave normalized at $0\textrm{ dBFS}$. When computing the STFT (with the code below) of this audio file, I noticed that ...
Basj's user avatar
  • 1,277
3 votes
1 answer
349 views

Why does a signal with constant frequency have spots that changes colors at a specific value of scale (and so frequency) in the scalogram?

I am studying the Wavelet transform and I am considering this example that I took from PyWavelets documentation. The signal in time domain has the following shape: Till the value of zero on the ...
User's user avatar
  • 55
2 votes
2 answers
1k views

Chromatography Baseline Placement

I have been looking around on Google, and I have not been able to find an explanation of how to do baseline placement in chromatography. what are some algorithms for placing a baseline on a ...
user avatar
2 votes
1 answer
1k views

Signal amplitude to FFT amplitude

I am using Python to generate a sine wave in order to cancel out part of a signal I'm analyzing. I would like the magnitude of this signal in the FFT to be equal to the magnitude of the signal that I ...
Rometown's user avatar
0 votes
2 answers
4k views

Wav To Spectrogram, Back To Wav

Currently, I'm writing a Python script, which should do the following: read an audio file respectively a wav file via scipy.io.wavfile.read(). calculate the spectrogram of given wav file. write the ...
Nico's user avatar
  • 1
0 votes
2 answers
2k views

How to normalize the FFT?

I want to normalize my FFT signal. From this page it says that we can normalize it by dividing the FFT result by the lenght of the signal in time domain. On the other hand, my supervisor told me that ...
Apinorr's user avatar
  • 125
186 votes
5 answers
66k views

"River" detection in text

Over on the TeX stackexchange, we have been discussing how to detect "rivers" in paragraphs in this question. In this context, rivers are bands of white space that result from accidental alignment ...
Lev Bishop's user avatar
  • 1,633
35 votes
7 answers
27k views

Finding squares in Image

I need to find the squares in an image using OpenCV (no problem in matlab or any other, generally what i expect are some ideas). Consider the test image below : I need to find those coloured squares ...
Abid Rahman K's user avatar
14 votes
3 answers
5k views

STFT and DWT (Wavelets)

STFT can be successfully used on sound data (with a .wav soundfile for example) in order to do some frequency-domain modifications (example : noise removal). With ...
Basj's user avatar
  • 1,277
13 votes
3 answers
1k views

Image processing coding

I was wondering which is the best language for image processing? I know MATLAB has a good library and user community for it. I havent checked it out, its there for python as well. What is the most ...
phoenix's user avatar
  • 131
9 votes
1 answer
9k views

SPL values from FFT of microphone signal

I am trying to get a frequency response vs dB SPL plot for recorded sounds. I have a microphone with a flat response, a sensitivity of 4mV/Pa, and 1 Pa = 94dB. To get the dB SPL, I have the following ...
hackyday's user avatar
  • 195
8 votes
1 answer
9k views

Comparing multiple signals for similarity

I have multiple (between 2 and 100) signals and need to determine when a significant number diverge from the rest. We're exploring machine learning techniques, but we also want tackle this as a signal ...
John Strong's user avatar
7 votes
3 answers
25k views

Continuous Wavelet Transform with Scipy.signal: what is parameter "widths" in cwt() function? How do time-frequency?

I search to display a time-frequency signal with an original discrete temporal signal (sampling step = 0.001sec). I use Python and the library Scipy.signal. I use the function ...
ArnoNoo's user avatar
  • 73
7 votes
1 answer
3k views

Failed to implement Goertzel algorithm in Python

After some questioning on stackoverflow, I tried to implement a Goertzel algorithm in Python. But it doesn't work : https://gist.github.com/4128537 ...
sebpiq's user avatar
  • 283
5 votes
2 answers
2k views

Finding Reference Audio Signal in Test Audio Signal and Cropping Accordingly

As seen in the diagram, below I have a reference audio and a test audio. I want to find at what part of the test clip the reference audio be heard. Once, that is found I want to crop the test file ...
listener's user avatar
5 votes
2 answers
3k views

Signal Processing/FFT gives very high magnitudes for low frequencies

The script essentially pulls PCM data from the sound card and stores them in a buffer. Then I apply fft and graph it. I am looking through this blog post for some examples and ideas on how to ...
skyguy126's user avatar
  • 153
5 votes
2 answers
11k views

Why FFT does not retrieve original amplitude when increasing signal length

I don't understand why FFT return different maximum amplitude as the signal length increase. I would except that with a large signal length according to the frequency, detected amplitude will be very ...
hadim's user avatar
  • 213
5 votes
3 answers
4k views

Simulating analog filter using convolution or converting with fft

My task is simple; I want to simulate analog low-pass filtering of an input signal, using Python. Note that the input signal is an array of values, not an analytical function. My first question is if ...
Uffe's user avatar
  • 355
5 votes
1 answer
7k views

Tracking a Sine Wave with Kalman Filter - How to Account for Offset (DC Signal)?

I am attempting to create a Kalman filter to track a sine wave (I am using a linear Kalman filter example assuming I already know the frequency of the sine wave) - the example I am using is derived on ...
SomeRandomPhysicist's user avatar
4 votes
5 answers
7k views

Python vs Matlab? Which one better for image processing?

I want to learn practical image processing from scratch/basics in easy way. Which software will be helpful in this regard? Matlab or python?
DSP_CS's user avatar
  • 1,884
4 votes
3 answers
2k views

Phase measurement

I have a problem with phase measuring. I'm acquiring two signal with a USRP (complex signals) with a coherent generator and I want to measure the phase different between them.. One is at 150Mhz and ...
hiei's user avatar
  • 41
3 votes
2 answers
9k views

Derivative filter in Python

In Alaa Kharbouch, Ali Shoeb, John Guttag, Sydney S. Cash, An algorithm for seizure onset detection using intracranial EEG, Epilepsy & Behavior, Volume 22, Supplement 1, 2011 (section 2.1, 3rd ...
Pouteri's user avatar
  • 49
3 votes
1 answer
295 views

Convolution and Fourier transform for 1D signals

My problem is the following, I have 3 curves/signals (1D) , the measure, the signal and the resolution of my detector: $\mathcal{M},\mathcal{S},\mathcal{R}$, knowing that : \begin{equation}\label{eq:...
Michael's user avatar
  • 75
3 votes
0 answers
608 views

Unscented Kalman Filter for Parameter Estimation (Tracking) of Amplitude Frequency and Phase of a Multi Component Harmonic Signal

I'm trying to implement an Unscented Kalman Filter that tracks the amplitude, frequency, and phase of a multi-component oscillatory signal. Below is an attempt using the ...
SuperCodeBrah's user avatar
2 votes
3 answers
2k views

Does chirp have constant magnitude frequency response?

Pg. 223 claims so, yet my results via DFT differ: Is the textbook wrong? My attempted explanations: (code) DFT vs DTFT: "frequency response" is computed via latter. Still, DFT should ...
OverLordGoldDragon's user avatar
2 votes
2 answers
8k views

Implementing inverse FFT using forward FFT and time-reversal property

I am trying to implement an inverse FFT using the forward FFT. For clarity: Let S[t] be a signal in time, and S[w] the transformed signal. As per this site, it seems one can reverse S[w], use the ...
Bloodworth's user avatar
2 votes
1 answer
2k views

Resampling time series to regular array, then downsampling (Butterworth)

Long time reader, first time poster. I have a few very simple questions that are troubling me and I am hoping that one of you guys can help me out. Setup & Aim: I have a time series that I want ...
Stev's user avatar
  • 121
1 vote
0 answers
88 views

How can to obtain the hughcut, lowcut and bode constant of a bandpass digital filter?

I need to create a bandpass filter amplifier in python; and determine the transfer function, graph the bode diagram, and print the highcut frequency, lowcut frequency, the bode constant and the ...
Marcia Cocozza's user avatar
1 vote
1 answer
514 views

Why is inverse CWT inexact / inaccurate?

I'm all new to wavelet analysis. I'm trying to get a working understanding of the continuous wavelet transform and its inverse. By "working understanding", I really mean "getting some ...
G. Fougeron's user avatar
0 votes
2 answers
2k views

How to develop a spectrogram (2D array) from audio signal?

I have developed a spectrogram in Python using Scipy.Signal.Spectrogram. But I need a complete understanding of data. Here I am not asking about plotting and color ...
Khubaib Ahmad's user avatar
0 votes
1 answer
1k views

2D FFT Cross-Correlation in Python

How to replicate scipy.signal.correlate2d(x, h) with arbitrarily sized x and h? ...
OverLordGoldDragon's user avatar
0 votes
1 answer
2k views

Symbol timing recovery in Python

My objective is to demodulate QPSK signal. At the receiver I apply RRC filter and interpolate the signal to get the values of the signal (approximately) at the sampling instances. Then I am concerned ...
Python's user avatar
  • 133
25 votes
1 answer
65k views

low pass filter and FFT for beginners with Python

I am new to signal processing and especially to FFT, hence I am not sure if I am doing the correct thing here and I am a bit confused with the result. I have a discrete real function (measurement ...
Till B's user avatar
  • 353
11 votes
4 answers
65k views

Peak Signal to Noise Ratio (PSNR) in Python for an Image

How do I calculate the maximum signal to noise ratio (PSNR) in Python? Is there any library that can calculate PSNR for Image?
Sudip Das's user avatar
  • 211
10 votes
3 answers
7k views

Is it correct to subtract a low-pass filtered signal from the original signal and use the result as a "high-pass"?

I am having a hard time trying to find documentation to implement band-pass or high-pass filter with python/scipy/numpy. I can easily create and apply a low-pass filter, though, so I ask: Would it ...
heltonbiker's user avatar
  • 1,097
10 votes
6 answers
5k views

How to do FFT fractional time delay (SOLVED)

I am trying to time-shift a signal using the FFT, however I have encountered some strange effects that depend on the size of the time-shift. I need to be able to shift the time by an arbitrary amount -...
Axemaster's user avatar
  • 101