# SAM SAGE Igor Tool

SAM SAGE - Software for Analysis of GCMS and EGA - was developed to aid
in the analysis of SAM flight model data. SAGE will be used to model
undersampled GCMS and complicated EGA data, calculate mass spectra based
on modeled GCMS data, and determine peak onset temperature, peak maximum
temperature, and peak area of modeled EGA data.

## Latest 

Use the #igorpro channel of the SAM-MSL Slack for help requests and
discussion.

Igor 8 requires SAGE 1.8.4 or higher.

Software:
[SAGE1.8.4.pxp](https://smce-xina.s3.us-east-1.amazonaws.com/dist/wiki/SAGE1.8.4.pxp)

## Documentation/History

Manual:
[SAGEManualv1.3.pdf](https://smce-xina.s3.us-east-1.amazonaws.com/dist/wiki/SAGEManualv1.3.pdf)

[SAGE new
features.pptx](
https://smce-xina.s3.us-east-1.amazonaws.com/dist/wiki/SAGE+new+features.pptx)
in 1.7

Selected new features in 1.2, presented at the GCMS focus group meeting:
[SAGE_update_09_20_12.pptx](https://smce-xina.s3.us-east-1.amazonaws.com/dist/wiki/SAGE_update_09_20_12.pptx)

[SAGE Release History](#bkmrk-release-history)

## Data Preparation 

The data that SAGE requires can be checked out from XINA and takes the
form of a file named IGORdata.zip. Use \'Checkout All\' or \'Checkout
Secondary\' to retrieve it. Unzip the archive inside the TID folder, and
then load the TID folder from SAGE using the \"Macros/Load TID Folder\"
menu item.

All SAM runs with QMS data should have an IGORdata.zip file generated
and available alongside the tm.sam file. If there is one missing let
the PDL team know.

## Quickstart 

1.  If you don\'t have IGOR Pro, install it from
    [Wavemetrics](http://www.wavemetrics.com/)
2.  Double-click the .pxp file of the latest version of SAGE
3.  Save the .pxp file with a new name
4.  Under the Macro menu select \"Load TID Folder\" and navigate to the
    TID folder you want to look at
5.  Try out SAGE\'s data processing capabilities
    -   Check the TM Msgs to determine which EM was used, in order to
        select the correct coefficients for deadtime correction (v1.2
        only)
    -   Optionally display TM markers and other overlay data
    -   Drag the vertical lines to set a background region
    -   Display different data corrections with the dropdown menu at the
        top left
    -   Use the Plot tab to add/remove bands and masses from the graph
    -   Select peak regions in the Peak tab
    -   Open Peak Graph window with the Magnify button
        -   In Time tab, adjust time range of peak region, if necessary
        -   In Mass tab, select set of masses and bands to use in fit
        -   In Fit tab, select fit function, choose initial peak
            parameters, and click Fit
        -   Display mass spectra of fitted peaks, with options to output
            to NIST 11 format text file
        -   In Review tab (\> tab, v1.2 only), quickly compare the
            \"raw\" data to the fitted data of a single mass (or a
            single band) at a time
    -   Export all fitted peaks to a chromatogram (in a .jdx format text
        file, which is compatible with ACD), with gaps between fitted
        peaks modeled with either a line fit or a moving average or
        connect data points.
6.  Send any feedback to Micah Johnson and Anna Brunner

## IGOR Tips 

-   Graph Interface
    -   Click and drag marquee on plot, click inside marquee for
        Expand/Shrink options
    -   Hover cursor over axis, scroll wheel to zoom in an out (side
        scroll slides data)
    -   Option-Click to slide data with inertia, click to stop if it\'s
        still moving
    -   Command-I shows cursors (drag cursors onto a wave in the graph
        to see info about the data point)
    -   Command-T shows graph tools such as line or shape drawing
        capabilities
-   KBColorizer Interface
    -   If you close the \'Make Traces Different\' window, newly added
        traces will be black.
    -   Bring up the window again by selecting the last menu item in the
        Graph menu.
    -   Nudging any of the three scroll bars in the Color Wheel section
        of that window will differentiate trace colors.
-   Global Fit
    -   If the fit does not converge, adjust the cursors if they seem
        off, or vary the value of the EMG modification factor. The
        following Igor-generated error messages are common and do not
        necessarily mean there is anything wrong with the data set or
        the program - they usually just mean the initial guesses
        weren\'t quite right. If you see these errors do not panic, just
        tweak the parameters. If they continue to occur, however, there
        may be something wrong besides the parameters.
        -   \"While executing FuncFit the following error occurred:
            singular matrix or other numeric error\"
        -   \"While executing FuncFit the following error occurred: The
            fitting function returned NaN for at least one X value.\"
    -   Global Fit does not do well if the peak you are trying to fit is
        not lined up precisely amongst the masses/bands - if there are
        slight time shifts, the fits do not look as good

## Release History 

### Preview 1 

-   Import QMS count rates and marker data into waves
-   Perform simple dead time correction
-   Plot band data
-   Selection of time range for background calculation

### Preview 2 

-   Band and mass selection interface in Plot tab
    -   Add/remove masses or bands by checking/unchecking the boxes
    -   Highlighting a band automatically scrolls to corresponding mass
        range
    -   Press up/down buttons to scroll quickly through masses and bands
    -   Press spacebar when a mass or band is highlighted to quickly add
        or remove it

### Preview 3 

-   In the Plot tab:
    -   Quickly navigate between selected bands/masses by pressing j and
        k
    -   In the mass list, masses corresponding to the highlighted band
        are color coded
-   Peak selection interface in Peak tab:
    -   Press \"New\" to select the time range of a peak using cursors
    -   Rename peaks in peak list
    -   Check box next to a peak name to highlight that range on the
        graph
    -   Press \"Magnify\" to make a new Peak Graph window with a
        zoomed-in plot of the selected time range
-   Peak Graph window:
    -   In the Time tab, adjust time range of peak with cursors or text
        fields
    -   In the Mass tab:
        -   Set the sigma multiplier to specify a detection level
            (standard deviations above background)
        -   Select/deselect masses and bands until the graph contains
            only the data with peaks at that time
    -   In the Fit tab:
        -   Select the peak center with the green square cursor, and the
            boundaries of the full-width half-maximum with the purple
            circle cursors
        -   Press Reset to get cursors back if one gets accidentally
            dragged off the plot
        -   Enter a modification (skew) factor if fitting to an
            Exponentially Modified Gaussian
        -   Press Calc. Coeffs to generate guesses for the fit
            coefficients
        -   Use calculated coefficients to perform a Global Fit

### Version 1.0 

-   New peak fit functions: Lorentzian, exponentially-modified Gaussian
-   Interface for entering initial guesses for multi-peak fit functions
-   Simplified interface for calling Global Fit
-   Method for quickly culling mass data that can't be fit
-   Interpolation of GCMS data using fit coefficients
-   Export file in JCAMP DX format, compatible with ACDLabs software
-   Quick mass spectrum plot from fitted peak

### Version 1.1 

-   Added peak fit check tab for looking at individual fit compared to
    mass data

### Version 1.2 

-   Dead time correction interface and support for EM1/2 and custom
    coeffs
-   Selective plotting of telemetry markers
-   Implemented export tab
    -   Set time range of export with cursor or time field
    -   Snap cursor to visible marker
    -   Fill-in data with line-fit or averaging option
    -   Re-add background back to exported data
    -   Show offset time as top axis of plot
-   Remove bad fits from peak fit check tab
-   Add prefix name to fit output waves so multiple fits can be saved

### Version 1.3 

-   Support for IGORdata.zip archive
-   Simple pyrolysis ramp temperature plotting from pyro_temp.log file
-   EMG peak improvements
-   Added "connect-the-dots" export capability for data that is not fit
-   Command window readout for multiplier usage to assist with dead-time
    configuration
-   Log/Linear plot toggle checkbox

### Version 1.4 

-   Added \'Show Overlays\' feature
    -   Pyrolysis oven and sample temp plotting
    -   GC temperatures and TCD signal plotting
-   Plot mass vs temperature for EGA analysis from Pyro overlay tab

### Version 1.5 

-   New overlays added
    -   Low speed mux (HK1-154) data
    -   Heater temperatures
    -   MOT housekeeping data
    -   Valve operations
-   Support for dt.prms file
-   Peak area calculations
-   Support of band table update (1.5.2)

### Version 1.6.1 

-   TLS housekeeping data overlay added

### Version 1.7 

-   New macros: Smooth Data and Compare TIDs
-   Additional option for custom_pyro_temp.txt file to define sample
    temperature

### Version 1.8.1 

-   Igor 7 compatibility
-   Pyro polyfit equations updated for TB and FM

### Version 1.8.3 

-   Support for special files in TID
    -   dt.prms - Dead time parameters
    -   band_template.txt - Define masses that are contained in bands
    -   fracmass.txt - Define special fractional masses that should
        appear in list checkbox interface
    -   maptounit.txt - Defined fractional masses that should be mapped
        to unit masses

### Version 1.8.4 

-   Igor 8 compatibility