Search for approximate local highs with noisy data in Matlab

The Matlab FAQ describes a one-line method for finding local maxims:

index = find( diff( sign( diff([0; x(:); 0]) ) ) < 0 );

But I believe that this only works if the data is more or less smooth. Suppose you have data that jumps up and down at small intervals, but at the same time have approximate local maxima. How would you decide to find these points? You can divide the vector into n parts and find the greatest value not on the edge of each, but there should be a more elegant and quick solution.

A single line solution would also be great.

Edit: I work with noisy biological images that I am trying to split into separate sections.

+3
source share
4 answers

Depending on what you want, it is often useful to filter noisy data. Take a look at MEDFILT1 or using CONV with FSPECIAL . In the latter approach, you probably want to use the "same" argument for CONV and the "Gaussian" filter created by FSPECIAL.

After you have done the filtering, skip it through the search for highs.

EDIT: runtime complexity

Let say that the input vector has a length of X, and the length of the filter core is K.

The median of the filter can work by sorting the insert, so it should be O (XK + K log K). I did not look at the source code, and other implementations are possible, but basically it should be O (XK).

K , conv O (X * K). X K , . O (X log X + K log K). Matlab , .

+2

, , , , . : HILBERT, BUTTER FILTFILT.

data = (...the waveform of noisy data...);
Fs = (...the sampling rate of the data...);
[b,a] = butter(5,20/(Fs/2),'low');  % Create a low-pass butterworth filter;
                                    %   adjust the values as needed.
smoothData = filtfilt(b,a,abs(hilbert(data)));  % Apply a hilbert transform
                                                %   and filter the data.

smoothDataโ€‹โ€‹strong > . HILBERT , FILTFILT BUTTER .

, , , . - , - ( HILBERT), - . - .

alt text

- , :

, ... , :

index = find(diff(sign(diff([0; x(:); 0]))) < 0);
maxIndex = index(find(diff(sign(diff([0; x(index); 0]))) < 0));

, /, , , , . . =)

MAXIMA FINDING:

, , ( , ):

index = find((x > [x(1) x(1:(end-1))]) & (x >= [x(2:end) x(end)]));
+3

, . , . , ? , .

, , , , . .

+1

. , , , , . - . ( , , pchip.Pchip, , "" interp1, , .)

- , . - . , , . , , โ€‹โ€‹ , . - . , . . spline, spap2 , . fnmin . ( .)

Smoothing schemes that use filtering techniques are usually simple when the data points are evenly distributed. The unevenness of the intervals can lead to a least squares spline model. On the other hand, node placement can be a problem in least-square splines. My point is to suggest that any of these approaches has its merits and can be done to provide viable results.

+1
source

Source: https://habr.com/ru/post/1707982/


All Articles