Main Content

msresample

Resample signal with peaks

    Description

    msresample(X,Intensities,N) plots the resampled raw noisy signal data. The output signal has N samples with a spacing that increases linearly within the range [min(X) max(X)]. X can be a linear or a quadratic function of its index. When you set input arguments such that down-sampling takes place, msresample applies a lowpass filter before resampling to minimize aliasing.

    Use msresample with data from any separation technique that produces signal data, such as spectroscopy, NMR, electrophoresis, chromatography, or mass spectrometry.

    [Xout,Intensitiesout] = msresample(X,Intensities,N) resamples raw noisy signal data, Intensities.

    For the antialias filter, msresample uses a linear-phase FIR filter with a least-squares error minimization. The cutoff frequency is set by the largest down-sampling ratio when comparing the same regions in the X and Xout vectors.

    Tip

    msresample is particularly useful when you have signals with different separation-unit vectors and you want to match the scales.

    example

    [Xout,Intensitiesout] = msresample(X,Intensities,N,Name=Value) specifies options using one or more name-value arguments in addition to the arguments in the previous syntaxes.

    example

    Examples

    collapse all

    This example shows how to resample mass spec data.

    Load a MAT-file, included with Bioinformatics Toolbox™, that contains mass spectrometry data, and then extract m/z and intensity value vectors.

    load sample_hi_res;
    mz = MZ_hi_res;
    y = Y_hi_res;

    Plot the original data.

    plot(mz,y,'.')

    Figure contains an axes object. The axes contains a line object which displays its values using only markers.

    Resample the spectrogram to have 10000 samples between 2000 and maximum m/z value in the data set, and show both the resampled and original data.

    [mz1,y1] = msresample(mz,y,10000, ...
                          Range=[2000 max(mz)], ...
                          ShowPlot=true);

    Figure contains an axes object. The axes object with title Signal ID: 1 Cutoff Freq: 0.030859, xlabel Separation Units, ylabel Relative Intensity contains 2 objects of type line. One or more of the lines displays its values using only markers These objects represent Original samples, Up/down-sampled signal.

    Input Arguments

    collapse all

    Separation-unit values for a set of signals with peaks, specified as a vector with the number of elements equal to the number of rows in the matrix Intensities. The separation unit can quantify wavelength, frequency, distance, time, or m/z depending on the instrument that generates the signal data.

    Data Types: double

    Intensity values for a set of peaks that share the same separation-unit range, specified as a matrix. Each row of the matrix corresponds to a separation-unit value, and each column corresponds to either a set of signals with peaks or a retention time. The number of rows equals the number of elements in vector X.

    Data Types: double

    Total number of samples, specified as a positive integer.

    Data Types: double

    Name-Value Arguments

    collapse all

    Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

    Example: Range=[2000 max(mz)]

    Indicator to force X to be uniformly spaced, specified as true or false

    Data Types: logical

    Separation-unit range for the output signal Intensitiesout, specified as a 1-by-2vector within [min(X) max(X)]. If Range values exceed the values in X, msresample extrapolates the signal with zeros and returns a warning message.

    Data Types: double

    Indicator to enable or disable the warning message when the Range values exceed the values in X, specified as true or false

    Data Types: logical

    Indicator to analyze X for dropped samples, specified as true or false. If the down-sample factor is large, checking for dropped samples might not be worth the extra computing time. Dropped samples can only be recovered if the original separation-unit values follow a linear or a quadratic function of the X vector index.

    Data Types: logical

    Window used when calculating parameters for the lowpass filter, specified as "Flattop", "Blackman", "Hamming", or "Hanning".

    Data Types: char | string

    Cutoff frequency, specified as a number from 0 to 1 (Nyquist frequency or half the sampling frequency). By default, msresample estimates the cutoff value by inspecting the separation-unit vectors, X and XOut. The cutoff frequency might be underestimated if X has anomalies.

    Data Types: double

    Indicator to plot the smoothed and original data, specified as:

    • true— Plot the resampled data over the first signal specified in the Intensities argument of the original data.

    • false—Do not plot the data.

    • Positive integer N— Plot the resampled data over the Nth signal specified in the Intensities argument of the original data.

    The default value for plotting depends on the output arguments:

    • For a syntax without the output arguments, the default value is false.

    • For a syntax with the output arguments, the default value is true.

    Data Types: double | logical

    Output Arguments

    collapse all

    Resampled data, returned as vector.

    Resampled intensities, returned as a matrix.

    Tips

    LC/MS data analysis requires extended amounts of memory from the operating system.

    Version History

    Introduced before R2006a