P3trus
P3trus

Reputation: 7215

Clustering of 1D signal

I've got several 1D signals, showing two or more bands. An example is shown below. raw data

I need to extract the datapoints belonging to a single band.


My first simple approach was taking a moving average of the data, and get the indices where the data is larger than the average.

def seperate(x):
    average = scipy.ndimage.gaussian_filter(x, 10)
    # this gives me a boolean array with the indices of the upper band.
    idx = x > average
    # return the indices of the upper and lower band
    return idx, ~idx

plotting these and the average curve would look like this, where red denotes the upper and blue the lower band. selected bands

This works quite well for this example, but fails when more then two bands are present and/or the bands are not that well separated.

I'm looking for a more robust and general solution. I was looking into scikit-learn and was wondering if one of the clustering algorithms can be used to achieve this.

Upvotes: 1

Views: 1073

Answers (1)

Has QUIT--Anony-Mousse
Has QUIT--Anony-Mousse

Reputation: 77454

Have a look a time series similarity measures.

Indeed, I have seen this binary thresholding you tried there called "threshold crossing", and many more.

In general, there is no "one size fits all" time series similarity. Different types of signals require different measures. This can probably best be seen by the fact that some are much better analyzed after FFT, while for others FFT makes absolutely no sense.

Upvotes: 3

Related Questions