Main Content

mzcdf2peaks

Convert mzCDF structure to peak list

    Description

    [Peaklist,Times] = mzcdf2peaks(mzCDFStruct) extracts peak information from mzCDFStruct and returns mass/charge (m/z) values, ion intensity values, and retention times associated with a liquid chromatography/mass spectrometry (LC/MS) or gas chromatography/mass spectrometry (GC/MS) data set.

    example

    Examples

    collapse all

    Convert mzCDF structure to peak list. In this example, the file results.cdf is not provided.

    Use the mzcdfread function to read a netCDF file into the MATLAB® software as a structure. Then extract the peak information from the structure.

    mzcdf_struct = mzcdfread("results.cdf");
    [peaks,time] = mzcdf2peaks(mzcdf_struct)
    peaks = 
    
        [7008x2 single]
        [7008x2 single]
        [7008x2 single]
        [7008x2 single]
    
    time =
    
        8.3430
       12.6130
       16.8830
       21.1530
    

    Create a color map containing a color for each peak list (retention time).

    colors = hsv(numel(peaks));
    

    Create a 3-D figure of the peaks and add labels to it.

    figure
    hold on
    
    for i = 1:numel(peaks)
        t = repmat(time(i),size(peaks{i},1),1);
        plot3(t,peaks{i}(:,1),peaks{i}(:,2),Color=colors(i,:))
    end
    
    view(70,60)
    xlabel('Time')
    ylabel(mzcdf_struct.mass_axis_label)
    zlabel(mzcdf_struct.intensity_axis_label)
    

    3-D plot showing peaks: the x-axis shows retention times, the y-axis shows m/z values, and the z-axis shows abundance

    Input Arguments

    collapse all

    Information from a netCDF file, specified as a MATLAB structure array, such as an array created by the mzcdfread function. Its fields correspond to the variables and global attributes in a netCDF file. If a netCDF variable contains local attributes, an additional field is created, with the name of the field being the variable name appended with _attributes. The number and names of the fields will vary, depending on the mass spectrometer software, but typically there are mass_values and intensity_values fields.

    Data Types: struct

    Output Arguments

    collapse all

    Mass/charge (m/z) and ion intensity, returned as one of these values:

    • Two-column matrix, where the first column contains mass/charge (m/z) values and the second column contains ion intensity values.

    • Cell array of peak lists, where each element is a two-column matrix of m/z values and ion intensity values, and each element corresponds to a spectrum or retention time.

    Retention times, returned as a scalar of vector associated with a liquid chromatography/mass spectrometry (LC/MS) or gas chromatography/mass spectrometry (GC/MS) data set. If Times is a vector, the number of elements equals the number of peak lists contained in Peaklist.

    Version History

    Introduced in R2008b