I have been using the Peak Areas.ipf Macros to identify the peaks and valleys. The maximums are represented in the table by the W_PkY wave, but I cannot seem to get the table to display only the minimum values in one column. Is there a way to display the W_MinKnots in a table? Thanks in advance.
The minima are at W_PkX1 and W_PkX2, so use them to access the Y value of your data.
If your data is a waveform, just use minAtX1 = data(W_PkX1[0]) for the first peak, etc.
For X-Y data you'll need to locate that x value in your x wave and get the Y value there.
BinarySearchInterp and FindLevel can do that for you, depending on whether your X values are nicely monotonic increasing or not.
Is there a way to do this without going point by point? I have upwards of 150 minimums and to go point by point would take a long time. Also, could you give me an example of minAtX1=data(W_PkX1[0])? I seem to keep getting a error.
Is there a way to do this without going point by point? I have upwards of 150 minimums and to go point by point would take a long time. Also, could you give me an example of minAtX1=data(W_PkX1[0])?
That's why we write programs :-).
But to write the correct program you need to be clear on which of the two values you wish to use as the minimum.
Bear in mind that Peak Areas subtracts the straight-line baseline drawn from the area start at W_PkX1[peakIndex] to the area end at W_PkX2[peakIndex].
Yes, one of these is less than the other, but keeping only one of them is throwing away information about the peak.
// choose the min at W_PkX1 or W_PkX2 Duplicate/O W_PkX1, W_PkMin Variablei=0, n= numpnts(W_PkX1) if( n ) Variable y1 do if(exists(g_wx)==1) // FindPX is an old routine that uses FindLevel on the X wave. // FindPX sets V_peakP, V_peakX corresponding to the point in the Y wave
FindPX(g_w,g_wx,W_PkX1[i])
W_PkMin[i] = $g_w[V_peakP]
FindPX(g_w,g_wx,W_PkX2[i])
y1 = $g_w[V_peakP] else
W_PkMin[i] = $g_w(W_PkX1[i])
y1 = $g_w(W_PkX2[i]) endif if( y1 < W_PkMin[i])
W_PkMin[i] = y1 endif i += 1 while(i< n) endif
if( doAppend ) AppendToTable/W=PeakReportTable W_PkMin.d endif End
If your data is a waveform, just use minAtX1 = data(W_PkX1[0]) for the first peak, etc.
For X-Y data you'll need to locate that x value in your x wave and get the Y value there.
BinarySearchInterp and FindLevel can do that for you, depending on whether your X values are nicely monotonic increasing or not.
--Jim Prouty
Software Engineer, WaveMetrics, Inc.
July 15, 2014 at 12:38 pm - Permalink
July 15, 2014 at 02:06 pm - Permalink
That's why we write programs :-).
But to write the correct program you need to be clear on which of the two values you wish to use as the minimum.
Bear in mind that Peak Areas subtracts the straight-line baseline drawn from the area start at W_PkX1[peakIndex] to the area end at W_PkX2[peakIndex].
Yes, one of these is less than the other, but keeping only one of them is throwing away information about the peak.
That said, here's something that may be useful:
"Append Peak Min To Table"
"-"
End
Macro AppendPeakMinToTable()
if( exists("W_PkX1") != 1 || exists("W_PkX2") != 1 )
Abort "Run Measure Identified Peaks, first!"
endif
DoWindow/F PeakReportTable
if( !V_Flag )
PeakReportTable()
endif
Variable haveWave = exists("W_PkMin") == 1
Variable doAppend
if( haveWave )
CheckDisplayed/W=PeakReportTable W_PkMin
doAppend = V_flag == 0
else
doAppend = 1
endif
// choose the min at W_PkX1 or W_PkX2
Duplicate/O W_PkX1, W_PkMin
Variable i=0, n= numpnts(W_PkX1)
if( n )
Variable y1
do
if(exists(g_wx)==1)
// FindPX is an old routine that uses FindLevel on the X wave.
// FindPX sets V_peakP, V_peakX corresponding to the point in the Y wave
FindPX(g_w,g_wx,W_PkX1[i])
W_PkMin[i] = $g_w[V_peakP]
FindPX(g_w,g_wx,W_PkX2[i])
y1 = $g_w[V_peakP]
else
W_PkMin[i] = $g_w(W_PkX1[i])
y1 = $g_w(W_PkX2[i])
endif
if( y1 < W_PkMin[i] )
W_PkMin[i] = y1
endif
i += 1
while(i < n)
endif
if( doAppend )
AppendToTable/W=PeakReportTable W_PkMin.d
endif
End
This statement conveys no useful information.
Please read this:
http://stackoverflow.com/help/how-to-ask
--Jim Prouty
Software Engineer, WaveMetrics, Inc.
July 15, 2014 at 06:16 pm - Permalink