Questions tagged [scipy]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
20 views

How to implement Matlab welch in python with the same result?

I want to implement Matlab pwelch function in python. The Matlab code is shown blew: [PSD,f] = pwelch(data,length(data),[],[],2000); which data is a row vector ...
1
vote
0answers
39 views

Why are low frequency peaks not sharp in scipy fft?

I am using numpy/scipy to plot graphs of sine waves. frequencies at 15 Hz or higher give nice, sharp peaks, but at lower frequencies, the peaks are smeared and the actual peak frequency can't be seen ...
0
votes
1answer
24 views

Can't seem to get welch function in scipy work correctly

I'm trying to learn DSP through using Python's scipy package. I have measure some 200Hz signal from a machine. Now I want to inspect the spectral density of the signal. Here's the signal plotted out: ...
0
votes
0answers
8 views

Logical Steps to segmenting Lung Fissure Structures

I am given the task to do the Lung Major Fissure Segmentation in a CT image to find it's position in an image. This is what a Major Fissue looks like: https://www.med-ed.virginia.edu/courses/rad/cxr/...
0
votes
2answers
115 views

Python Hilbert does not seem to calculate the envelope

I am following the example from: https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.hilbert.html And although I can replicate their example, it does not work with my data. This is the ...
0
votes
0answers
30 views

Spectrogram using SciPy - bad scaling of the timeline [duplicate]

I have a real value signal which has 197 samples (every 1 second). I made its spectrogram using the SciPy library: ...
0
votes
1answer
79 views

Bandpass filter with very high sampling rate

Consider a bandpass filter with Low Cut 17Hz, High Cut 22 Hz, Fs = 45000 Hz and Order = 6. When I pass a mixture of multiple sinusoidal waves through this filter (with a sine wave of frequency 20 Hz), ...
0
votes
0answers
51 views

Negative Exponential Filter SciPy

I'm trying to transform a time series with a recursive filter to model a feedback. I was able to do a simple filter like : ...
0
votes
1answer
199 views

How to convert a spectrogram back to a signal [duplicate]

I'm converting a signal to a spectrogram, manipulating that (nonlinear stuff), and then want to use the modified audio signal. I can make it so the segments are not overlapping, but am unsure how to ...
0
votes
0answers
41 views

Losing lowest Frequencies in frequency modulated signal, rest of spectrum is fine

For several reasons I am attempting to re-modulate a de-modulated FM (as in WFM Radio) signal using python. Demodulating the initial signal goes well, it produces the PSD chart below which looks just ...
0
votes
1answer
26 views

How to pad a array representing music to pad the stft of this array?

I have an array named samples of size (2, 1321967) representing an audio file. When I pass it to scipy stft with ...
0
votes
2answers
123 views

Delay in Savitzky-Golay filtering

I am applying a Savitzky-Golay filter to a signal, using the scipy function. I need to calculate the lag of the filtered signal, and how much is it behind the original signal. Could someone shed ...
0
votes
0answers
43 views

Scipy Deconvolve help

I was playing with the deconvolve method in scipy and I can't seem to get it working properly (I am still really new to DSP/deconvolution). I convolved a gaussian with a fwhm of 2.0e-9 with a ...
0
votes
0answers
74 views

Filtering out different narrow-band frequencies at once

I have asked a closely related question on SO at https://stackoverflow.com/questions/55168460/python-implementation-for-filtering-out-multiple-distinct-narrow-band-frequencie but I am still unclear ...
0
votes
1answer
361 views

Third octave bandpass filter with python

I am very new to signal processing and coding which is why my questions might be really basic. I have a signal of the acoustic pressure p'(t) and I would like to use a third octave bandpass filter in ...
1
vote
2answers
91 views

Checking Parseval's Theorem for Gaussian Signal by Using Scipy

I'm trying to check Parseval's theorm for Gaussian signal. It's well known that fourier transform of $\exp(-t^2)$ is $\sqrt{\pi}\exp(-\pi^2 k^2)$. So I implement it by using quad and simps. I think ...
0
votes
0answers
42 views

Scipy Welch's gives different first element

I've re-implemented Welch's method and want to compare it to scipy.signal.welch. However, the first two and last elements of the resulting array are different. My ...
2
votes
2answers
190 views

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

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, ...
0
votes
2answers
459 views

How to calculate the PSD from the complex calculated STFT?

I have calculated the STFT with scipy python library: ...
0
votes
0answers
76 views

How to know the time of my window to calculate the STFT with python knowing only the length?

I am trying to implement a work presented in an IEEE paper where they have mentioned that the STFT was performed on the signal measurements to obtain a spectrogram with no overlap window of 3 min : I ...
0
votes
0answers
54 views

how to detrend a carrier phase with butterworth filter?

I am new with detrending techniques, I have a carrier phase measurements and I want to detrend it by 6th order butterworth digital filter. After creating the digital filter I get its numerator (...
1
vote
1answer
3k views

Write a 440 Hz Sine Wave to .wav-File using Python and SciPy [closed]

This is my first post on DSP.SE! I'm a student in Computer Sciences and am just getting started with Signals and Systems, thus getting in touch with discrete signals and analyzing them. I wanted to ...
3
votes
1answer
924 views

Scipy resample, “fourier method” explanation

I am seeking explanation of what "Fourier method" is that is described for resampling in documentation of resample() method. I want to downsample an array. I know what decimation is and how it works, ...
2
votes
0answers
360 views

real refractive index from Kramers Kronig relation

I have a measurement of the complex part of the refractive index $k$ (where the refractive index is $m = n + i\,k$) measured at a nonlinear grid of wavelengths or frequencies that span several orders ...
1
vote
1answer
2k views

How to filter out those outliers

I'm struggling to filter some data from an accelerometer. I need to do it in python (and not just on the device collecting the data) to fix the data I have, so that I can build some classification ...
1
vote
1answer
1k views

Amplitude of frequency bin in FFT doesn't match time-domain amplitude

I have a sinusoidal current that I am sampling at about 357k SPS. The current signal is about 3A pk-pk @ 750hz (top figure). I am wondering why when I take the fft using numpy/scipy's fft function, ...
0
votes
0answers
792 views

How does the Scipy implementation of CWT actually work?

I'm trying to use the SciPy implementation of the Continuous Wavelet Transform to analyze EEG data. I am using The problem is that I have no idea what the width parameter should be. It says that it's ...
0
votes
1answer
424 views

How to Apply Gaussian Filter to Raw Audio Files in Python?

I am recording raw files in python to later break them into phonemes, but the noise in the surrounding environment is hampering the result. So, there is a need to apply a filter to the recorded raw ...
2
votes
3answers
314 views

Decreasing Sample Rate in DFT (FFT) for Audio Analysis

I'm working with audio data analysis through FFT algorithm. My example audio is a sine wave at 440 Hz and 44100 Hz sampling rate. FFT methods in programming, like ...
5
votes
1answer
214 views

Morphing between two FFTs

I'm a musician and I'm making a script that takes a wave file and snaps each of its frequencies from the fourier transforms to the nearest musical harmonic. Thanks to help from another question I ...
0
votes
1answer
55 views

Unexpected peaks in power density following downsampling and filtering

I first applied a 100 Hz lowpass filter to my data, which was recorded at 30000 Hz: ...
0
votes
1answer
349 views

Should scipy.signal.coherence be 1 for single input and output signals?

I am trying to calculate the coherence between input and output signals. I thought I could work with a single input and a single output time series and calculate the coherence $\gamma^2$ between them. ...
1
vote
1answer
63 views

Help generating coefficients for basic FIR LPF

I'm trying to generate coefficients for a FIR low pass filter to be used in an FPGA. I'm using python (scipy.signal) to attempt to do this, but am having trouble getting coefficients in a usable form....
0
votes
1answer
249 views

Outlier Detection after Detrending a Time Series With Missing Values or NaN

Goal Substitute outliers in a time series by most recent valid data Problem The time series (end-of-day stock prices) has several 'uncomfortable' properties: It is non-stationary and can have ...
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: ...
0
votes
2answers
100 views

Can I combine an IIR (an EWMA) with a maximum?

I'd like to have a exponentially weighted moving average (EWMA) which is raised to the value of the input signal whenever this is higher than the filter output. This taking of the maximum shall take ...
0
votes
2answers
6k views

Avoiding “RuntimeWarning: invalid value encountered in log10” when converting FFT data to dBFS

I've attached some code below that I'm having some issues with. Basically, I need to write a function to get the dBFS value of a signal at a specified Hz value, at a given channel in a .wav file. ...
4
votes
3answers
5k views

Why is Scipy implementation of Hilbert() function different from Matlab implementation of the function?

I am trying to fit Hilbert envelop to a high frequency ultrasonic signal of frequency 250 KHZ and sampling rate 12000000. Raw signal looks like below: . I used hilbert() function from scipy.signal ...
1
vote
1answer
616 views

Trying to implement MATLAB $\tt pwelch$ in Python

I'm implementing an existing MATLAB script in Python and noticing some differences in the behaviour of MATLAB's pwelch function compared to ...
0
votes
1answer
251 views

Delay filters in Python using for loop and $\tt lfilter$

I have these two filters as given in recursive form: \begin{align} y_1[i] &= y[i] - y[i-d] + 1.2y_1[i-d] - 0.8y_1[i-2d]\\ y_2[i] &= y[i] - 2y[i-d] + y[i-2d] \end{align} where $d$ is an ...
3
votes
1answer
2k views

How to compute the power bands of an eeg signal using python?

so I have an eeg signal (edf format) that has 25 channels and 248832 entries, sampling frequency of 512Hz. I have to compute the frequency bands: – Delta: 0.1-4Hz – Theta: 4-8Hz – Alpha: 8-12Hz – ...
3
votes
0answers
6k views

Downsampling and upsampling of a signal in Python

If I want to downsample a signal in Python, is it better to use method resample from SciPy Signal Processing module or method decimate from the same module? What is the difference between these two ...
0
votes
1answer
673 views

Welch spectrogram

I have been using scipy's spectrogram function (STFT) to compute a PSD spectrogram for a non-stationary signal. I provide X length window (with nperseg = X/10) each ...
1
vote
0answers
204 views

Understanding why spectral flatness cannot be computed

I have a real signal recorded 512Hz for 1s. After resampling the signal at 256Hz, I would like to compute its spectral flatness. To do so, I start by taking its discrete Fourier transform with ...
0
votes
1answer
26k views

Convert RGB Image to Grayscale and Display It (Python + Matplotlib) [closed]

I just started learning image processing and I was trying to read a RGB image then convert it to grayscale. I was hoping for something like this: However, what I get was: I tried using both scipy ...
2
votes
1answer
195 views

consecutive filtered blocks with filtfilt

I'm doing basic signal processing in Python. I'm filtering consecutive blocks of a signal with scipy's filtfilt (to get zero phase). I would like to concatenate several blocks after filtering, however,...
3
votes
1answer
883 views

Python different autocorrelation with FFT and non-FFT

Im trying to calculate the autocorrelation of soundwaves when I noticed that I get different results with scipys FFT based and with numpys methods. The 4 functions Im using: ...
-1
votes
1answer
523 views

Forward Backward filter Scipy - $\tt signal.filtfilt$ changes the amplitude when $\tt signal.butter$ is used with $\tt btype='high'$

In the plot below the blue wave is the original signal. The orange wave is after the low pass filter. The green wave is after the high pass filter. I have a noisy ECG signal stored in the ...
1
vote
1answer
164 views

Issue with the time vector returned by $\tt signal.spectrogram$ function

I'm puzzled by some very simple concept with building up a spectrogram. Here is a toy example of the issue: ...
3
votes
1answer
1k views

How to implement bandpass filter on complex valued signal?

I am using Scipy to implement bandpass filter but it assumes that positive normalized frequency is passed but I & Q samples range from [Fc-Fs/2,Fc+Fs/2] where Fs is sampling frequency & Fc is ...