Wavestats on all waves in a graph window

Hi,

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!
If you are able to specify the cursor location numerically as xmin and xmax, you could use something like the following:
Function traceStats(graphNameStr,xmin,xmax)
    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.

I know that you don't want to hear that, but:
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 and StringFromList :-)
Wow, thanks! yes, I can use the xmin, xmax

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".
HJDrescher wrote:
I know that you don't want to hear that, but:
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 and StringFromList :-)


10-4 - wanna be a good sport!
SurleyDoc wrote:
However it's getting hung up on the graphNameStr
For example, if I try "Graph0" it says "got 'Graph 0' instead of a string variable or string function name.

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
if I try "Graph0" it says "got 'Graph 0' instead
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
johnweeks wrote:
SurleyDoc wrote:
However it's getting hung up on the graphNameStr
For example, if I try "Graph0" it says "got 'Graph 0' instead of a string variable or string function name.

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


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"."
SurleyDoc wrote:

Now I get an error that says "While executing a wave read, the following error occured: Index out of range for wave "M_WaveStats"."


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.