Tuesday, October 2, 2012

Matlab

MATLAB is a useful tool for vector and matrix manipulations
To read CDF, AIA you need "Mexcdf" download and test.
To visually inspect for exampled 002.CDF file
ncdisp('002.cdf');
the large number of samples, it's specified by name in number To hide attributes
ncdisp('002.cdf','/','min');

Read and display the data in the intensity(Total ion count in Ms) variable in the example file.
ncdisp('002.cdf','intensity_values');
intensity  = ncread('002.cdf','intensity_values');
intensitypeak  = ncreadatt('002.cdf','intensity_values','description');
surf(double(intensity));
title(peaksDesc);

to see the information of cdf file exported from mass platform
info= mzcdfinfo('002.cdf')

Read a netCDF file into the MATLAB software as a structure.
out = mzcdfread('002.cdf');
information provided is something like
out =

           dataset_completeness: 'C1+C2'
           ms_template_revision: '1.0.1'
                netcdf_revision: '2.3.2'
                      languages: 'English'
                 dataset_origin: 'Santa Clara, CA'
    netcdf_file_date_time_stamp: '20120817142255+0200'
               experiment_title: 'Berceli'
     experiment_date_time_stamp: '20120529114700+0200'
                  operator_name: 'Lorenz Gerber'
            external_file_ref_0: 'PYMS.M'
                experiment_type: 'Centroided Mass Spectrum'
      number_of_times_processed: 1
     number_of_times_calibrated: 0
                   sample_state: 'Other State'
           test_separation_type: 'No Chromatography'
                  test_ms_inlet: 'Capillary Direct'
           test_ionization_mode: 'Electron Impact'
       test_ionization_polarity: 'Positive Polarity'
             test_detector_type: 'Electron Multiplier'
           test_resolution_type: 'Constant Resolution'
             test_scan_function: 'Mass Scan'
            test_scan_direction: 'Up'
                  test_scan_law: 'Linear'
           raw_data_mass_format: 'Float'
           raw_data_time_format: 'Short'
      raw_data_intensity_format: 'Float'
                      error_log: ''
              a_d_sampling_rate: [413x1 double]
          a_d_coaddition_factor: [413x1 int16]
          scan_acquisition_time: [413x1 double]
                  scan_duration: [413x1 double]
                inter_scan_time: [413x1 double]
                     resolution: [413x1 double]
             actual_scan_number: [413x1 int32]
                total_intensity: [413x1 double]
     total_intensity_attributes: [1x1 struct]
                 mass_range_min: [413x1 double]
                 mass_range_max: [413x1 double]
                 time_range_min: [413x1 double]
                 time_range_max: [413x1 double]
                     scan_index: [413x1 int32]
                    point_count: [413x1 int32]
                     flag_count: [413x1 int32]
                    mass_values: [49680x1 single]
         mass_values_attributes: [1x1 struct]
                    time_values: [49680x1 single]
         time_values_attributes: [1x1 struct]
               intensity_values: [49680x1 single]
    intensity_values_attributes: [1x1 struct]
                instrument_name: 'Gas Chromatograph'
                  instrument_id: ''
                 instrument_mfr: ''
               instrument_model: ''
           instrument_serial_no: ''
          instrument_sw_version: ''
          instrument_fw_version: ''
          instrument_os_version: ''
         instrument_app_version: ''
            instrument_comments: ''
To create variables: intensity and m/z values and plot intensity vs m/x , view the second scan, Add a title and x- and y-axis labels using fields in the output structure.
idx1 = out.scan_index(2)+1; "time start for scan"
idx2 = out.scan_index(3);   "time end can"  
y = out.intensity_values(idx1:idx2);  "the intensity values from start scan 2 to end"
z = out.mass_values(idx1:idx2);    "the intensity values from start scan 2 to end"      
stem(z,y,'marker','none')
title(sprintf('Time: %f',out.scan_acquisition_time(2)))
xlabel(out.mass_axis_units)
ylabel(out.intensity_axis_units)
 
(xlabel or ylabel to show the variable on x or y axis)
To view ms spectra in 3D
ms_contruct=mzcdfread('002.cdf')
[peaks,time] = mzcdf2peaks(ms_struct)
>> colors = hsv(numel(peaks));
>> 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(ms_struct.mass_axis_label)
zlabel(ms_struct.intensity_axis_label)
 
a hue-saturation-value (HSV) 
 

No comments:

Post a Comment

Bạn cần thêm thông tin hay có câu hỏi vui lòng comment