Importing Wave
kachy_89P
I created a funazione "highpass" to apply a filter to my data.
I created a simple GUI, but I can not load and set the best parameters.
I wish every time I load a wave, this has an automatic renaming, and that this name be scelato for example chosen by the operator, as in the box that I created. so every time you load a new wave, the first will have to remain still in memory and plotted, without being overwritten.
This is my procedure:
#pragma rtGlobals=3 // Use modern global access method and strict wave access.
Menu "Vibration Filter"
"FTT", VRB(); VF()
EndMacro
Function VRB()
variable/G win
string/G waveoutname
string/g wm
wave wavein = wm
end
Window VF() : Panel
PauseUpdate; Silent 1 // building window...
NewPanel /W=(10,60,260,540)
SetVariable setvar_hf title="win", pos={23,112}, size={133, 20}, value=win; DelayUpdate
SetVariable setvar_hf limits={-inf,inf,0}
SetDrawEnv fsize= 12; DelayUpdate
SetDrawEnv fname="Calibri"
SetVariable setvar_waven title="wave in", pos={23, 88}, size={130, 20}, value=wm; DelayUpdate
SetDrawEnv fname= "Calibri"
SetDrawEnv fsize= 10;DelayUpdate
Button button_HFF, pos={64,212}, size={99,41}, proc=VFB, title="High PSS"
SetDrawEnv fname= "Calibri"
Button button_HFF, fSize=14, fStyle=1
SetVariable setvar_WOUT title="waveout name",pos={10, 140},size={174,16}, value=waveoutname; DelayUpdate
SetDrawEnv fname= "Calibri"
Button button_loadwave, pos={18,28}, size={88,28}, proc=ButtonLWin, title="LOAD Wavein"
end
Function VFB(ctrlName) : ButtonControl
string ctrlName
NVAR win
SVAR waveoutname
SVAR wm
wave/z wavein
highpass(wavein, win, waveoutname)
end
Function/WAVE highpass(wavein, win, waveoutname)
wave wavein
variable win
String waveoutname
make/O/N=(numpnts(wavein)-win+1) wavetmp, waveout, waveout2
wavetmp= wavein[win/2+p-1]
waveout=sum(wavein, pnt2x(wavein, p), pnt2x(wavein, p+win-1))/win // moving average 1 Hz
waveout2=wavetmp-waveout
duplicate/O waveout2, $waveoutname
Wave wOut=$waveoutname
wOut=waveout2
end
// LOAD WAVE
Function loadewavein()
loadwave/G/N/O/L={0,0,0,1,1}
end
Function ButtonLWin(ctrlName) : ButtonControl
string ctrlName
loadewavein()
end
Menu "Vibration Filter"
"FTT", VRB(); VF()
EndMacro
Function VRB()
variable/G win
string/G waveoutname
string/g wm
wave wavein = wm
end
Window VF() : Panel
PauseUpdate; Silent 1 // building window...
NewPanel /W=(10,60,260,540)
SetVariable setvar_hf title="win", pos={23,112}, size={133, 20}, value=win; DelayUpdate
SetVariable setvar_hf limits={-inf,inf,0}
SetDrawEnv fsize= 12; DelayUpdate
SetDrawEnv fname="Calibri"
SetVariable setvar_waven title="wave in", pos={23, 88}, size={130, 20}, value=wm; DelayUpdate
SetDrawEnv fname= "Calibri"
SetDrawEnv fsize= 10;DelayUpdate
Button button_HFF, pos={64,212}, size={99,41}, proc=VFB, title="High PSS"
SetDrawEnv fname= "Calibri"
Button button_HFF, fSize=14, fStyle=1
SetVariable setvar_WOUT title="waveout name",pos={10, 140},size={174,16}, value=waveoutname; DelayUpdate
SetDrawEnv fname= "Calibri"
Button button_loadwave, pos={18,28}, size={88,28}, proc=ButtonLWin, title="LOAD Wavein"
end
Function VFB(ctrlName) : ButtonControl
string ctrlName
NVAR win
SVAR waveoutname
SVAR wm
wave/z wavein
highpass(wavein, win, waveoutname)
end
Function/WAVE highpass(wavein, win, waveoutname)
wave wavein
variable win
String waveoutname
make/O/N=(numpnts(wavein)-win+1) wavetmp, waveout, waveout2
wavetmp= wavein[win/2+p-1]
waveout=sum(wavein, pnt2x(wavein, p), pnt2x(wavein, p+win-1))/win // moving average 1 Hz
waveout2=wavetmp-waveout
duplicate/O waveout2, $waveoutname
Wave wOut=$waveoutname
wOut=waveout2
end
// LOAD WAVE
Function loadewavein()
loadwave/G/N/O/L={0,0,0,1,1}
end
Function ButtonLWin(ctrlName) : ButtonControl
string ctrlName
loadewavein()
end
February 19, 2016 at 07:44 pm - Permalink
February 20, 2016 at 01:06 am - Permalink
If I understand your question... one method is to add a Set Variable control to the panel and use
ControlInfo
to get the value entered in the control. The output variable "S_value" will hold this. You will have to be careful in entering wave names or providing error checking to be sure the string will be a legal name.February 20, 2016 at 10:21 am - Permalink
SetDrawEnv fsize= 10;DelayUpdate
commands? They're not doing anything, because there are no DrawText, etc commands that would be affected by them.
If you want to set the controls font and size use the Control dialogs to set them.
Also, this in this code:
variable/G win
string/G waveoutname
string/g wm
wave wavein = wm
end
The wave wavein = wm part isn't useful: once the function ends the wavein wave reference disappears (it is local to the function.)
If that is just an unfinished part of the code and you intend to use the wavein reference, it should probably be something more like
// do something with the wave
--Jim Prouty
Software Engineer, WaveMetrics, Inc.
February 20, 2016 at 10:47 am - Permalink
Yes, in fact those lines come from another part of the code which I then deleted .
I took your advice inserting $ wm in that function , but whenever I try to avvire " highpass " from the window that I created me always comes out the same mistake :
"Whilw excuting Make, the following error occurred: the numeber of points in a wave must be between 0 and 2147 milion.
February 20, 2016 at 11:13 am - Permalink
"FTT", VRB(); VF()
EndMacro
Function VRB()
variable/G win
string/G waveoutname
string/g wm
wave wavein
end
Window VF() : Panel
PauseUpdate; Silent 1 // building window...
NewPanel /W=(10,60,260,540)
SetVariable setvar_hf title="win", pos={23,112}, size={133, 20}, value=win; DelayUpdate
SetVariable setvar_hf limits={-inf,inf,0}
SetVariable setvar_waven title="wave in", pos={23, 88}, size={130, 20}, value=wm; DelayUpdate
Button button_HFF, pos={64,212}, size={99,41}, proc=VFB, title="High PSS"
Button button_HFF, fSize=14, fStyle=1
SetVariable setvar_WOUT title="waveout name",pos={10, 140},size={174,16}, value=waveoutname; DelayUpdate
Button button_loadwave, pos={18,28}, size={88,28}, proc=ButtonLWin, title="LOAD Wavein"
end
Function VFB(ctrlName) : ButtonControl
string ctrlName
NVAR win
SVAR waveoutname
wave/z wavein
highpass(wavein, win, waveoutname)
end
Function/WAVE highpass(wavein, win, waveoutname)
wave wavein
variable win
String waveoutname
Svar wm
wave wavein= $wm
make/O/N=(numpnts(wavein)-win+1) wavetmp, waveout, waveout2
wavetmp= wavein[win/2+p-1]
waveout=sum(wavein, pnt2x(wavein, p), pnt2x(wavein, p+win-1))/win // moving average 1 Hz
waveout2=wavetmp-waveout
duplicate/O waveout2, $waveoutname
Wave wOut=$waveoutname
wOut=waveout2
display $waveoutname
end
// LOAD WAVE
Function loadewavein()
loadwave/G/N/O/L={0,0,0,1,1}
end
Function ButtonLWin(ctrlName) : ButtonControl
string ctrlName
loadewavein()
end
February 22, 2016 at 09:21 am - Permalink