PeakFinderCWT Type

Peak finder using continuous wavelet transformation.

References:

[1] P.Du, W.A. Kibbe, S.M.Lin, "Improved peak detection in mass spectrum by incorporating continuous wavelet transform-based pattern matching", Bioinformatics (2006) 22 (17): pp. 2059-2065, doi: 10.1093/bioinformatics/btl355

Constructors

Constructor Description

PeakFinderCWT()

Full Usage: PeakFinderCWT()

Static members

Static member Description

PeakFinderCWT.ContinuousWaveletTransformation(data, wavelet, widths)

Full Usage: PeakFinderCWT.ContinuousWaveletTransformation(data, wavelet, widths)

Parameters:
    data : float[] - The data to transform.
    wavelet : Func<float, float, float> - The wavelet function. First parameter is the x value of the function, second parameter is the width.
    widths : IEnumerable<float> - Enumeration of widths to evaluate. The values should be increasing.

Returns: float[,] A matrix in which each row represents the waveform transformation at a certain width.

Executes a continuous wavelet transform over the data data.

data : float[]

The data to transform.

wavelet : Func<float, float, float>

The wavelet function. First parameter is the x value of the function, second parameter is the width.

widths : IEnumerable<float>

Enumeration of widths to evaluate. The values should be increasing.

Returns: float[,]

A matrix in which each row represents the waveform transformation at a certain width.

PeakFinderCWT.Execute(vector, widths, ?wavelet, ?max_distances, ?gap_thresh)

Full Usage: PeakFinderCWT.Execute(vector, widths, ?wavelet, ?max_distances, ?gap_thresh)

Parameters:
    vector : float[] - 1-D array in which to find the peaks.
    widths : IEnumerable<float> - Enumeration of widths to use for calculating the CWT matrix. In general, this range should cover the expected width of peaks of interest.
    ?wavelet : Func<float, float, float> - Should take two parameters and return a 1-D array to convolve with `vector`. The first parameter determines the number of points of the returned wavelet array, the second parameter is the scale (`width`) of the wavelet.Should be normalized and symmetric. Default is the ricker wavelet.
    ?max_distances : Func<int, int> - At each row, a ridge line is only connected if the relative max at row[n] is within ``max_distances[n]`` from the relative max at ``row[n + 1]``. Default value is ``widths/4``.
    ?gap_thresh : float - If a relative maximum is not found within `max_distances`, there will be a gap.A ridge line is discontinued if there are more than `gap_thresh` points without connecting a new relative maximum. Default is the first value of the widths array i.e.widths[0].

Returns: List<RidgeLine> * float[,] A tuple: all ridge lines that were found, and the matrix of Cwt coefficients. The list of ridge lines is not sorted. Use a filter function (e.g. PeakFinderCWT.FilterRidgeLines) in order to filter out the not essential lines.

Find peaks in a 1-D array with wavelet transformation. The general approach is to smooth `vector` by convolving it with wavelet(width) for each width in widths. Relative maxima which appear at enough length scales, and with sufficiently high SNR, are accepted.

vector : float[]

1-D array in which to find the peaks.

widths : IEnumerable<float>

Enumeration of widths to use for calculating the CWT matrix. In general, this range should cover the expected width of peaks of interest.

?wavelet : Func<float, float, float>

Should take two parameters and return a 1-D array to convolve with `vector`. The first parameter determines the number of points of the returned wavelet array, the second parameter is the scale (`width`) of the wavelet.Should be normalized and symmetric. Default is the ricker wavelet.

?max_distances : Func<int, int>

At each row, a ridge line is only connected if the relative max at row[n] is within ``max_distances[n]`` from the relative max at ``row[n + 1]``. Default value is ``widths/4``.

?gap_thresh : float

If a relative maximum is not found within `max_distances`, there will be a gap.A ridge line is discontinued if there are more than `gap_thresh` points without connecting a new relative maximum. Default is the first value of the widths array i.e.widths[0].

Returns: List<RidgeLine> * float[,]

A tuple: all ridge lines that were found, and the matrix of Cwt coefficients. The list of ridge lines is not sorted. Use a filter function (e.g. PeakFinderCWT.FilterRidgeLines) in order to filter out the not essential lines.

PeakFinderCWT.FilterRidgeLines(cwt, ridge_lines, ?window_sizen, ?min_lengthn, ?min_snr, ?noise_perc)

Full Usage: PeakFinderCWT.FilterRidgeLines(cwt, ridge_lines, ?window_sizen, ?min_lengthn, ?min_snr, ?noise_perc)

Parameters:
    cwt : IROMatrix<float> - Continuous wavelet transform from which the ridge_lines were defined.
    ridge_lines : List<RidgeLine> - The ridge lines. Each line consist of a list of tuples (row, column).
    ?window_sizen : int - Size of window to use to calculate noise floor. Default is cwt.NumberOfColumns/20.
    ?min_lengthn : int - Minimum length a ridge line needs to be acceptable. Default is cwt.NumberOfRows / 4.
    ?min_snr : float - Minimum SNR ratio. Default 1. The signal is the value of the cwt matrix at the shortest length scale(``cwt[0, loc]``), the noise is the `noise_perc`th percentile of datapoints contained within a window of `window_size` around ``cwt[0, loc]``.
    ?noise_perc : float - When calculating the noise floor, percentile of data points (0..1) examined below which to consider noise. Calculated using scoreatpercentile. Default value: 0.1

Returns: List<RidgeLine> Only those ridge lines that match the criteria.

Filter ridge lines according to prescribed criteria. Intended to be used for finding relative maxima.

cwt : IROMatrix<float>

Continuous wavelet transform from which the ridge_lines were defined.

ridge_lines : List<RidgeLine>

The ridge lines. Each line consist of a list of tuples (row, column).

?window_sizen : int

Size of window to use to calculate noise floor. Default is cwt.NumberOfColumns/20.

?min_lengthn : int

Minimum length a ridge line needs to be acceptable. Default is cwt.NumberOfRows / 4.

?min_snr : float

Minimum SNR ratio. Default 1. The signal is the value of the cwt matrix at the shortest length scale(``cwt[0, loc]``), the noise is the `noise_perc`th percentile of datapoints contained within a window of `window_size` around ``cwt[0, loc]``.

?noise_perc : float

When calculating the noise floor, percentile of data points (0..1) examined below which to consider noise. Calculated using scoreatpercentile. Default value: 0.1

Returns: List<RidgeLine>

Only those ridge lines that match the criteria.

PeakFinderCWT.GetNoiseLevel(cwt, ?window_size, ?noise_perc)

Full Usage: PeakFinderCWT.GetNoiseLevel(cwt, ?window_size, ?noise_perc)

Parameters:
    cwt : IROMatrix<float> - The matrix with the continuous wavelet transformation. Only the first row (stage 0) of that matrix is used for evaluating the noise.
    ?window_size : int - Size of the sliding window to evaluate the noise.
    ?noise_perc : float - The percentile (but given in value from 0..1) at which the noise level is evaluated.

Returns: float[] Array with a noise level for each point of the spectrum.

Gets the noise level along the x-axis.

cwt : IROMatrix<float>

The matrix with the continuous wavelet transformation. Only the first row (stage 0) of that matrix is used for evaluating the noise.

?window_size : int

Size of the sliding window to evaluate the noise.

?noise_perc : float

The percentile (but given in value from 0..1) at which the noise level is evaluated.

Returns: float[]

Array with a noise level for each point of the spectrum.

PeakFinderCWT.GetRelativeExtrema(data, comparator, ?order)

Full Usage: PeakFinderCWT.GetRelativeExtrema(data, comparator, ?order)

Parameters:
    data : IReadOnlyList<float> - The data array.
    comparator : Func<float, float, bool> - The comparator. To find maxima, use the greater operator ((x,y)=>x>y)
    ?order : int - The order. Must at least 1. The order are the number of points to the left and right of the point under consideration, that must fullfill the comparator condition.

Returns: bool[] An array in which points where a local extrema was found are marked with true.

Gets a boolean array, in which local extrema in a spectrum are marked as true.

data : IReadOnlyList<float>

The data array.

comparator : Func<float, float, bool>

The comparator. To find maxima, use the greater operator ((x,y)=>x>y)

?order : int

The order. Must at least 1. The order are the number of points to the left and right of the point under consideration, that must fullfill the comparator condition.

Returns: bool[]

An array in which points where a local extrema was found are marked with true.

PeakFinderCWT.GetRelativeExtrema(data, comparator, ?axis, ?order)

Full Usage: PeakFinderCWT.GetRelativeExtrema(data, comparator, ?axis, ?order)

Parameters:
    data : IROMatrix<float> - The data matrix.
    comparator : Func<float, float, bool> - The comparator function.
    ?axis : int - The axis which is iterated over. 0: for each column, the maxima of the row values will be evaluated. 1: for each row, the maxima of the column values will be evaluated.
    ?order : int - The number of points to compare to the left and right of the considered point Must be >=1.

Returns: bool[,]

Gets a boolean matrix of the same dimensions as the provided data matrix, in which the points at which a relative extrema is found, are set to true.

data : IROMatrix<float>

The data matrix.

comparator : Func<float, float, bool>

The comparator function.

?axis : int

The axis which is iterated over. 0: for each column, the maxima of the row values will be evaluated. 1: for each row, the maxima of the column values will be evaluated.

?order : int

The number of points to compare to the left and right of the considered point Must be >=1.

Returns: bool[,]

NotImplementedException

PeakFinderCWT.IdentifyRidgeLines(matr, max_distances, maximalGap)

Full Usage: PeakFinderCWT.IdentifyRidgeLines(matr, max_distances, maximalGap)

Parameters:
    matr : IROMatrix<float> - The continuous wavelet transformation (Cwt) matrix. Each row in the matrix represents the transformation for one width. It is assumed that the width increases with increasing row number.
    max_distances : Func<int, int> - A function, using the row number as argument, and returning the maximal distance (in points) that is allowed between the current x value of the ridge line and the x-position of a maximum identified in the Cwt matrix.
    maximalGap : int - The maximal number of rows that is allowed to bridge between the end of a ridge line and a maximum in the Cwt matrix.

Returns: List<RidgeLine> List of ridge lines. Each ridge line is represented by a list of tuples (row number, column number, and Cwt coefficient).

Identifies the ridge lines in a continous wavelet transformation matrix

matr : IROMatrix<float>

The continuous wavelet transformation (Cwt) matrix. Each row in the matrix represents the transformation for one width. It is assumed that the width increases with increasing row number.

max_distances : Func<int, int>

A function, using the row number as argument, and returning the maximal distance (in points) that is allowed between the current x value of the ridge line and the x-position of a maximum identified in the Cwt matrix.

maximalGap : int

The maximal number of rows that is allowed to bridge between the end of a ridge line and a maximum in the Cwt matrix.

Returns: List<RidgeLine>

List of ridge lines. Each ridge line is represented by a list of tuples (row number, column number, and Cwt coefficient).

PeakFinderCWT.Ricker(x, w)

Full Usage: PeakFinderCWT.Ricker(x, w)

Parameters:
    x : float - The argument x.
    w : float - The width of the wavelet.

Returns: float The function value for the argument x.

Ricker wavelet function, also known as the "Mexican hat wavelet".

It models the function:

            A* (1 - (x/a)**2) * exp(-0.5*(x/a)**2),
            where A = 2/(sqrt(3*a)*(pi**0.25)).

x : float

The argument x.

w : float

The width of the wavelet.

Returns: float

The function value for the argument x.

PeakFinderCWT.Ricker2ndDerivative(x, w)

Full Usage: PeakFinderCWT.Ricker2ndDerivative(x, w)

Parameters:
    x : float - The argument x.
    w : float - The width of the wavelet.

Returns: float The function value for the argument x.

Normalized 2nd derivative of the Ricker wavelet function.

It models the function:

            A* (3 - 6*(x/a)**2 + (x/a)**4) * exp(-0.5*(x/a)**2),
            where A = 4/(sqrt(105*a)*(pi**0.25)).

x : float

The argument x.

w : float

The width of the wavelet.

Returns: float

The function value for the argument x.

PeakFinderCWT.ScoreAtPercentile(arr, percentile)

Full Usage: PeakFinderCWT.ScoreAtPercentile(arr, percentile)

Parameters:
    arr : List<float>
    percentile : float

Returns: float

arr : List<float>
percentile : float
Returns: float