2

The problem:

I have a signal that contains multiple, relatively stable frequency components and I want to extract only one of them. I attached a plot that illustrates the situation with a simple example. The top plot shows the raw signal and the lower one the spectrogram for the signal.

Example with two frequency bands

The emphasis here is on "relatively", since individual frequency bands are sometimes modulated upwards, crossing other frequency bands. By tracking the frequency bands on a spectrogram, I can approximate this frequency change. But this leaves me with a signal with a much lower sampling rate constrained by the nfft of the spectrogram. However what I want is the raw signal for just the frequency component of interest. Ideally, I would be able to compute the instantaneous frequencies for every frequency band. I am aware that this will be very noisy in situations where the frequency bands cross, but the majority of the signal would be useful at least. Hence, I need a filter, that can filter in boundaries (illustrated by the black dashed lines) that change over time.

What I've tried

I've naively tried implementing a rolling bandpass filter using scipy.signal, which obviously didn't work. I have also found another question that asked something similar but my research in that direction, particularly into Kalman filters, was not all that successful.

I am not looking for a finished solution but maybe a hint or resources to learn more from that might lead me into the right direction.

PS: I am a biologist by training and have very limited background in signal processing so please be nice to me :)

weygoldt
  • 21
  • 1
  • 1
    Perfectly doable: 1, 2 (Ctrl + F practical) – OverLordGoldDragon Mar 07 '23 at 15:47
  • 1
    @OverLordGoldDragon thank you very much! I've spend the afternoon reading your code and examples, very nice! Am I right that I need to (1) do a ssq-cwt, then (2) come up with a reconstruction band (center frequency and a width around that) and (3) apply the issq-cwt to get back a reconstructed signal that only contains what is inside my reconstruction band. Is this correct? I'll try to implement this tomorrow ... – weygoldt Mar 08 '23 at 19:39
  • That's exactly right, and it can also work with cwt with a few differences that can be seen in icwt vs issq_cwt. In the second link I provide a tool that allows manually drawing curves on a saved image, and converting that to an array as coordinates, though it's unfinished. – OverLordGoldDragon Mar 09 '23 at 12:04
  • @OverLordGoldDragon Nice! I experimented a bit and all goes well until I try to invert the signal back. I always get the error 'Could not find converging or non-negligibly-valued bounds of integration for int_fn'. I've played with a bunch of different parameters and I do not seem to get past that point. Do you have any hints on how to deal with this? The code can be found here. – weygoldt Mar 09 '23 at 16:05
  • Sounds like a bug report, not so much a deal for StackExchange comments. – OverLordGoldDragon Mar 09 '23 at 16:29

0 Answers0