Wavestats on all waves in a graph window
SurleyDoc
Using a graph window, I am placing cursors and repeatedly performing Wavestats on each of the tracings in the window to get the average of points between the cursors for each of the waves. I would really appreciate some help with a function or macro that could automate this, ideally making a new wave out of the successive averages for each wave.
Thanks!
String graphNameStr
Variable xmin,xmax
String list=TraceNameList(graphNameStr, ";",1)
Variable cols=ItemsInList(list,";")
Make/O/N=(33,cols) w_traceStats=nan
Variable i
for(i=0;i<cols;i+=1)
wave w=tracenametowaveref(graphNameStr,stringfromlist(i,list))
WaveStats/Q/W/R=(xmin,xmax) w
Wave M_WaveStats
w_traceStats[][i]=M_WaveStats[p]
endfor
End
I hope this helps,
A.G.
WaveMetrics, Inc.
October 24, 2016 at 12:31 pm - Permalink
I'd recommend to do the tour and read the chapters about programming in Igor first.
Later on, several keywords might become handy
Wave, $, For ... EndFor, Make, TraceNameList, TraceNameToWaveRef, WaveStats, xCsr, pCsr, InsertPoints
and their documentation can be found in the online help.
As a fist step, try to understand, what happens in the history window. I gives a good idea what should be in your procedure (basically wrap it in a loop).
If the position of the cursors varies from trace to trace, it might get tricky.
If you are lost at some point, please feel free to ask again. If you need a complete procedure, some sample data would be useful --- but let's be honest, that would be unsportsmanlike.
HJ
PS: AG was faster and I missed
ItemsInList
andStringFromList
:-)October 24, 2016 at 12:41 pm - Permalink
However it's getting hung up on the graphNameStr
For example, if I am looking at Graph0 and input "traceStats(Graph0,100,200)",
I get "Got 'Graph 0' instead of a string variable or string function name".
October 24, 2016 at 01:29 pm - Permalink
10-4 - wanna be a good sport!
October 24, 2016 at 12:51 pm - Permalink
You need to invoke like this:
traceStats("Graph0",0,10) // 0 and 10, of course, are arbitrarily chosen for the example
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
October 24, 2016 at 01:18 pm - Permalink
is strange: where does the blank come from -- maybe it's just a typo?
As far as I see it should be invoked like
traceStats("Graph0",5,42)
HJ
PS:OK, I give up and go to bed now
October 24, 2016 at 01:21 pm - Permalink
Thanks! I was leaving out the parentheses. Getting closer!
Now I get an error that says "While executing a wave read, the following error occured: Index out of range for wave "M_WaveStats"."
October 24, 2016 at 01:41 pm - Permalink
I'm guessing that is because you are using an older version of Igor where M_WaveStats did not contain 33 points (as in IP7).
I would strongly second HJ Drescher's suggestion above and in the meantime replace 33 by 27 and your code should run.
A.G.
WaveMetrics, Inc.
October 24, 2016 at 04:10 pm - Permalink