/*------------------------------------------------------------------------------* * File Name: RemoveBaseline * * Creation: ER (07/13/05) * * Purpose: Origin C function to subtract baseline from multiple datasets * * Copyright (c) OriginLab Corp.2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 * * All Rights Reserved * * * * Modification Log: * *------------------------------------------------------------------------------*/ //////////////////////////////////////////////////////////////////////////////////// #include //////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////// // This function assumes a worksheet is active which has multiple datasets with // columns set to type XYXYXY... // It then takes each Y dataset, computes baseline for the data using end-weigthed // option, and then subtracts the baseline from the Y dataset void remove_baseline() { // Point to active worksheet and check validity Worksheet wksData = Project.ActiveLayer(); if( !wksData ) return; // Create a temp wks to hold baseline data WorksheetPage wpgTemp; wpgTemp.Create("Origin", CREATE_HIDDEN); Worksheet wksTemp = wpgTemp.Layers(0); while( wksTemp.DeleteCol(0) ); wksTemp.AddCol("BslnX"); wksTemp.Columns(0).SetType(OKDATAOBJ_DESIGNATION_X); wksTemp.AddCol("BslnY"); // Point to the LabTalk curve object using LTCurve = LabTalk.curve; // Loop over wks assuming the data is organized as XYXYXY... int nCols = wksData.GetNumCols(); for(int ic = 1; ic < nCols; ic += 2) { // Reset the LabTalk curve object LTCurve.Reset(); // Point to the current Y dataset for input data LTCurve.Data$ = wksData.Columns(ic).GetDatasetName(); // Get size of input data and set this as size for baseline Dataset dsData(wksData, ic); LTCurve.baselinePts = dsData.GetSize(); // Point to temp wks cols 1,2 for baseline output LTCurve.basex$ = wpgTemp.GetName() + "_" + wksTemp.Columns(0).GetName(); LTCurve.basey$ = wpgTemp.GetName() + "_" + wksTemp.Columns(1).GetName(); // Set baseline type to 0 - End weighted LTCurve.baseline.fittype = 0; // Compute baseline LTCurve.baseline(); // Subtract the baseline from the raw data Dataset dsBsln(wksTemp, 1); dsData -= dsBsln; } // Destroy the temp worksheet wpgTemp.Destroy(); }