Automation of Baseline Subtraction and Smoothing for Multiple Waves

Hi there,

I'm working on a procedure that will allow me to do a baseline subtraction followed by a smoothing of the baseline corrected waves. I have completed the first part by using a "wrapper function" but am unsure how to appropriately add the Smooth portion to it.

Here is the procedure I have so far:

#pragma rtGlobals=3     // Use modern global access method and strict wave access.

Function BaselineSubtraction(w1,leftmark, rightmark,rangetype)

    WAVE w1
    VARIABLE leftmark, rightmark, rangetype
    String outputName= NameOfWave(w1) +"_baselined"
    if (rangetype<1470 || rangetype>1472)
        return -1
    Duplicate/o w1 $outputName
    Wave output = $outputName
    if (rangetype==0)
        WaveStats/Q output
    if (rangetype==1470)
        WaveStats/Q/R=[leftmark,rightmark] output
    if (rangetype==1472)
        WaveStats/Q/R=(leftmark,rightmark) output
    output= output - V_min
    print V_min

FUNCTION SubtractAll(wname, fnum, leftmark, rightmark, rangetype)

    STRING wname
    VARIABLE fnum, leftmark, rightmark, rangetype
    STRING w1
    for(i=1; i<=fnum; i=i+1)
        w1 = wname+num2str(i)
        BaselineSubtraction($(w1),leftmark, rightmark,rangetype)


Let me know if you have any ideas/suggestions.

You just need to add the smooth step in the line after the bg subtraction.

    output -= V_min  // This is better than output = output - V_min
    Smooth 1, output  // I don't know what smoothing you want to do
    print V_min

If you want to keep the "bg subtracted but not smoothed" wave you need to duplicate output and then smooth that wave, otherwise this will work.
As an aside, I would suggest that you look at the range of wave names that you will be dealing with. Igor has a limit of 31 characters for names and your "_baseline" suffix is a bit lengthy. Just to avoid potential problems, I would shorten it to "_BL" or something along the same line.
    String outputName= NameOfWave(w1)[0,27] +"_BL"

--Jim Prouty
Software Engineer, WaveMetrics, Inc.