mzcdfread

Read mass spectrometry data from netCDF file

Syntax

mzCDFStruct = mzcdfread(File)

mzCDFStruct = mzcdfread(File, ...'TimeRange', TimeRangeValue, ...)
mzCDFStruct = mzcdfread(File, ...'ScanIndices', ScanIndicesValue, ...)
mzCDFStruct = mzcdfread(File, ...'Verbose', VerboseValue, ...)

Input Arguments

File

String containing a file name, or a path and file name, of a netCDF file that contains mass spectrometry data and conforms to the ANDI/MS or the ASTM E2077-00 (2005) standard specification or earlier specifications.

If you specify only a file name, that file must be on the MATLAB® search path or in the current folder.

TimeRangeValue

Two-element numeric array [Start End] that specifies the time range in File for which to read spectra. Default is to read spectra from all times [0 Inf].

    Tip   Time units are indicated in the netCDF global attributes. For summary information about the time ranges in a netCDF file, use the mzcdfinfo function.

    Note:   If you specify a TimeRangeValue, you cannot specify a ScanIndicesValue.

ScanIndicesValue

Positive integer, vector of integers, or a two-element numeric array [Start_Ind End_Ind] that specifies a scan, multiple scans, or a range of scans in File to read. Start_Ind and End_Ind are each positive integers indicating a scan index number. Start_Ind must be less than End_Ind. Default is to read all scans.

    Tip   For information about the scan indices in a netCDF file, check the NumberOfScans field in the structure returned by the mzcdfinfo function.

    Note:   If you specify a ScanIndicesValue, you cannot specify TimeRangeValue.

VerboseValue

Controls the display of the progress of the reading of File. Choices are true (default) or false.

Output Arguments

mzCDFStruct

MATLAB structure containing mass spectrometry information from a netCDF file. 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 the _attributes string. 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.

Description

mzCDFStruct = mzcdfread(File) reads a netCDF file, File, and then creates a MATLAB structure, mzCDFStruct.

File is a string containing a file name, or a path and file name, of a netCDF file that contains mass spectrometry data. The file must conform to the ANDI/MS or the ASTM E2077-00 (2005) standard specification or earlier specifications.

mzCDFStruct contains fields that 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 the _attributes string. 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.

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

    • If you receive errors related to memory, try the following:

      • Increase the virtual memory (swap space) for your operating system (with a recommended initial size of 3,069 and a maximum size of 16,368) as described in Memory Usage.

      • Set the 3 GB switch (32-bit Windows® XP only) as described in Memory Usage.

    • If you receive errors related to Java® heap space, increase your Java heap space:

mzCDFStruct = mzcdfread(File, ...'PropertyName', PropertyValue, ...) calls mzcdfread with optional properties that use property name/property value pairs. You can specify one or more properties in any order. Each PropertyName must be enclosed in single quotation marks and is case insensitive. These property name/property value pairs are as follows:


mzCDFStruct = mzcdfread(File, ...'TimeRange', TimeRangeValue, ...)
specifies the range of time in File to read. TimeRangeValue is a two-element numeric array [Start End]. Default is to read spectra from all times [0 Inf].

    Tip   Time units are indicated in the netCDF global attributes. For summary information about the time ranges in a netCDF file, use the mzcdfinfo function.

    Note:   If you specify a TimeRangeValue, you cannot specify ScanIndicesValue.

mzCDFStruct = mzcdfread(File, ...'ScanIndices', ScanIndicesValue, ...) specifies a scan, multiple scans, or range of scans in File to read. ScanIndicesValue is a positive integer, vector of integers, or a two-element numeric array [Start_Ind End_Ind]. Start_Ind and End_Ind are each positive integers indicating a scan index number. Start_Ind must be less than End_Ind. Default is to read all scans.

    Tip   For information about the scan indices in a netCDF file, check the NumberOfScans field in the structure returned by the mzcdfinfo function.

    Note:   If you specify a ScanIndicesValue, you cannot specify a TimeRangeValue.

mzCDFStruct = mzcdfread(File, ...'Verbose', VerboseValue, ...) controls the progress display when reading File. Choices are true (default) or false.

Examples

In the following example, the file results.cdf is not provided.

  1. Read a netCDF file into the MATLAB software as a structure.

    out = mzcdfread('results.cdf');
    
  2. View the second scan in the netCDF file by creating separate variables containing the intensity and m/z values, and then plotting these values. Add a title and x- and y-axis labels using fields in the output structure.

    idx1 = out.scan_index(2)+1;
    idx2 = out.scan_index(3);
    y = out.intensity_values(idx1:idx2);
    z = out.mass_values(idx1:idx2);
    stem(z,y,'marker','none')
    
    title(sprintf('Time: %f',out.scan_acquisition_time(2)))
    xlabel(out.mass_axis_units)
    ylabel(out.intensity_axis_units)

Was this topic helpful?