can't get correct mean values of list of traces
ifahrenfort
I have loaded 10 waves, each consisting of 70,000 values (electrophysiological recordings, representing Current). I am trying to get one wave with the mean values ,between two points, of all the currently loaded waves starting with "Im_".
The output wave (meanValuesWave) has the right dimensions but does not give the same values as Wave Stats AND every second row is a 0 instead of a mean value. I hope you guys can help me...
Here is the code:
#pragma rtGlobals=3 // Use modern global access method and strict wave access.
Function CreateGraphs()
String x_as = "Time1"
String framelist = WaveList("Im_*",";","")
processWaves(framelist, x_as, 43705, 43715)
end
//##########################################
//##########################################
Function processWaves(list, xaxis, firstPoint, lastPoint)
String list // A semicolon-separated list.
String xaxis
Variable firstPoint, lastPoint
String theWaveName
String newWaveName = "MeansBetweenCursors"
Variable meanBC
Variable index=0
Variable numWaves = ItemsInList(list, ";")
Make/N=(numWaves) $(newWaveName)
WAVE meanValuesWave = $(newWaveName)
For (index = 0; index theWaveName = StringFromList(index, list)
WAVE thisWave = $(theWaveName)
meanValuesWave[index] = mean(thisWave,firstPoint, lastPoint)
index += 1
endFor
End
The complete code did not get posted:
Function CreateGraphs()
String x_as = "Time1"
String framelist = WaveList("Im_*",";","")
processWaves(framelist, x_as, 43705, 43715)
end
//##########################################
//##########################################
Function processWaves(list, xaxis, firstPoint, lastPoint)
String list // A semicolon-separated list.
String xaxis
Variable firstPoint, lastPoint
String theWaveName
String newWaveName = "MeansBetweenCursors"
Variable meanBC
Variable index=0
Variable numWaves = ItemsInList(list, ";")
Make/N=(numWaves) $(newWaveName)
WAVE/Z meanValuesWave = $(newWaveName)
For (index = 0; index<numWaves; index += 1)
theWaveName = StringFromList(index, list)
WAVE thisWave = $(theWaveName)
meanValuesWave[index] = mean(thisWave,firstPoint, lastPoint)
index += 1
endFor
End
March 30, 2015 at 12:10 pm - Permalink
Maybe this snippet is what you want:
test=sin(x/100)+gnoise(1)
Duplicate/O test,test_samp
Resample/DOWN=2 test_samp
For details please have a look at
displayhelptopic "resample"
HJ
March 30, 2015 at 01:06 pm - Permalink
Note that the mean function takes X values, not point numbers, as parameters. If you are not sure about the difference between X values and point numbers, execute this:
March 30, 2015 at 01:35 pm - Permalink
March 31, 2015 at 08:30 am - Permalink