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
24
votes
2answers
34k 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 ...
16
votes
1answer
21k 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 ...
28
votes
3answers
32k 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 ...
16
votes
4answers
10k 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 ...
2
votes
2answers
6k views

Implementing inverse FFT using forward FFT

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 ...
4
votes
2answers
7k 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 ...
2
votes
2answers
922 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 ...
0
votes
2answers
3k 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 ...
34
votes
7answers
20k 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 ...
12
votes
3answers
4k 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 ...
12
votes
3answers
4k 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 ...
7
votes
1answer
2k 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 ...
12
votes
3answers
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 ...
5
votes
2answers
3k 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 ...
3
votes
2answers
2k 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 ...
2
votes
2answers
1k 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 ...
1
vote
1answer
848 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 ...
0
votes
2answers
124 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 ...
24
votes
1answer
51k 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 ...
8
votes
3answers
5k 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 ...
5
votes
1answer
7k views

Working backwards from PSD to possible signal

I have been trying to reconstruct a random signal from its PSD and am running into trouble. I know that many different signals in the time or spatial domains can result in the same PSD-- I am ...
5
votes
1answer
5k views

Signal filtering using Python

I'm trying to create an application using python that is capable of recording an audio signal and detecting short glitches in the signal. For example, I could be recording a 1000Hz sine wave and ...
6
votes
1answer
9k views

Taking audio frequency and picking out peaks (Peak Detection)

So I have a unique challenge. I want to take an audio file, and pick out the peaks in the samples and plot that onto a graph. Each point based on the amplitude/pitch(?) will be represented as either a ...
8
votes
4answers
3k views

How to perform a Rubberband-Correction on spectroscopic data?

I basicaly understood how the Rubberband/Baseline-correction works. The given spectrum is divided into (N) ranges. The lowest points in every range are determined. The initial baseline is built out ...
4
votes
3answers
5k views

Understanding overlapping in STFT

I understand the concept of the STFT. In order to avoid spectral leakage, you use a Hann window that overlaps by 50%. However, the problem that I have, is that the example code online does not account ...
2
votes
1answer
1k views

Scale FFT frequency range for a bars graph

I'm trying to show frequency spectrum for audio data as a bars graph using FFT. If I have data for a sine wave at 440 Hz and with sampling rate 44100 Hz and analyze its first 1024 samples I get an ...
0
votes
2answers
4k 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 ...
5
votes
2answers
12k views

Negative values of the FFT

I try to describe a simple signal in the frequency domain with the use of FFT function: ...
4
votes
4answers
27k 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?
4
votes
2answers
2k views

Iterative Hard Thresholding (Python Implementation) [closed]

I'm trying to implement the Iterative Hard Thresholding recovery algorithm for compressive sensing in python. It is a very simple algorithm, given $ \mathbf{y}( = \mathbf{A}\mathbf{x}), \mathbf{A}$, ...
4
votes
1answer
4k 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 ...
3
votes
2answers
1k views

How to identify useful elements of audio recording and ignore lulls?

I assume this is a relatively simple DSP task, but I'm having trouble finding any information on how to approach my problem. Hopefully someone with more experience and brain power can help me out: I ...
2
votes
1answer
7k views

Deconvolution in Python

I'm trying to use and understand SciPy's deconvolve for a project I'm working on. I'm having some trouble understanding how to use it. What I would like to do is to take two PMFs from discrete ...
2
votes
1answer
527 views

What are best practices to compute an audio spectrogram?

The spectrogram if generally defined with the squared magnitude of the fft. However, in lots of implementation, it seems that people just use the magnitude without square. Moreover an audio signal is ...
2
votes
0answers
540 views

Shifting of Shift-Invariant Wavelet Transforms

Main Question: Why would iterative wavelet/inverse-wavelet transforms cause a shift along the x-axis for undecimated (shift-invariant) wavelet transforms? I am attempting to remove backgrounds from ...
2
votes
2answers
88 views

Deconvolution of an Image Acquired by a Square Uniform Detector

So, I acquired some images by scanning a radiation source with a square detector like in the following gif. Where the dashed grid represents reality, the 3x3 square my detector, and the 4x4 my ...
1
vote
1answer
215 views

Error in using Kalman Filter for 2D Position Estimation in Python

This is my first question on DSP Stack exchange, so I apologise if it is poorly worded. I have some positioning data from a vehicle (GPX Format, collected through Strava) and want to use a Kalman ...
1
vote
1answer
4k views

How to find the inflection point in a noisy curve?

I have the the noisy curve defined by numpy 2D array: As you can see, it has the first flat segment, then rise, peak and decay phases. I need to find the starting point of the rise phase, marked here ...
0
votes
2answers
11k views

Remove background noise from audio file (python or matlab)

I am implementing a project for infant cry detection and the audio set contains background noises. So for preprocessing i need to remove the background noise from the audio.I am not able to get a ...
0
votes
3answers
203 views

Using different algorithms/formulas to create spectrograms

On the internet, I have seen people use Matplotlib/Python and short-time fourier transformations to create spectrograms. Are their other formula/algorithms to create spectrograms? And are they ...
4
votes
1answer
1k views

How to generate random samples of Gaussian distribution directly in the frequency domain?

One can easily draw (pseudo-)random samples from a normal (Gaussian) distribution by using, say, NumPy: ...
3
votes
2answers
760 views

Initial state recognition in HMM

I am building a speech recognition system using Hidden Markov Model in python. I referred to this and this question and its answers, which were very helpful. In my approach, I split the continuous ...
2
votes
3answers
5k views

Librosa stft + istft - Understanding my output (which always seems too perfect) at varying window lengths

I've just started to use Python with Librosa for a DSP project I'll be working on. First thing I've been trying to do is determine my preferred parameters for the FFT window size, and hop-distance. ...
2
votes
2answers
2k views

Why does python's scipy.signal.dimpulse introduce delay in impulse response?

Consider a simple linear, time invariant system of the form: $y_k = cy_{k-1} + (1-c)x_k$ The impulse response of this system can be computed by either dimpulse or by applying lfilter to a vector ...
2
votes
2answers
92 views

Contradictory results from power spectral densities and autocorrelation in shot noise

I have a white noise generator circuit which involves a Zener diode meant to undergo breakdown across a resistor $R1$, and am trying to compare power spectral densities and autocorrelation of the ...
2
votes
1answer
236 views

What's the relationship between the parameters of this noise generator and the gaussian curve it produces in the frequency domain?

This algorithm produces a sequence $y$ having a magnitude spectrum that resembles a normal distribution, peaking at frequency $\omega$: $$b[n]=(1-\sigma)b[n-1]+\frac{\sigma}{\omega} C$$ $$p[n]=p[n-1]+...
2
votes
1answer
2k views

Triaxial accelerometer to single signal

I have some smartphone recorded accelerometer data, so I have acceleration along 3 axes: $$a_{x}, a_{y}, a_{z}$$ The accelerometer data was collected by securing a phone to a walking subject. I'm ...
2
votes
1answer
4k views

Apply AWGN noise to QPSK-OFDM symbol

I'm working on an OFDM-QPSK based system and I'm having some trouble to match the BER of my system with the theoretical curve. My OFDM implementation fills all the subcarriers and have t_symbol s ...
2
votes
1answer
227 views

Extract approximation and detail coefficients

I am a student and would like to know how to extract the approximation and detail coefficients (A5, D5, D4, D3, D2 and D1) after an applied DWT decomposition dB5 (Daubechies 5, level = 5)?
2
votes
2answers
469 views

How to extract features of individual spikes in non-negative signal?

I have data of non-negative (in the sense there's no signal below baseline) spiking waveforms, which are in the form of a 1D array of numbers: Spikes that cross some threshold are considered real ...