Taking All Waves as the Argument of a function?
benlucas
Tue, 08/20/2013 - 12:54 pm
Hi, I'm working on curve fitting a large collection of waves and the data comes in with an offset artifact. Since the curvefit needs the data to begin at the origin, all of the waves need to be zeroed. The function to do this is simple enough, however there are a large number of waves with different naming conventions, and it's going to be laborious to run the function for each wave individually. I'm wondering if there is some shortcut that allows me to take every wave in an experiment as the argument for a function?
Function(AllWaves)
wave=wave_i
wave-=wave[0]
End
Here's a function that will return such a string from a selection in the Data browser
string SelectedWaves=""
variable i
do
if(waveexists($(GetBrowserSelection(i))))
SelectedWaves+=GetBrowserSelection(i)+";"
endif
i+=1
while(strlen(GetBrowserSelection(i))>0)
return SelectedWaves
end
Using this, you can create a function that will accept the returned list as an input, which you can parse and act upon, such as the following:
string list
variable i
for(i=0;i<itemsinlist(list);i+=1)
WAVE wavenm=$stringfromlist(i,list,";")
wavenm=//modify the wave here
endfor
end
To run these, you would then do the following:
1. Make a selection in the Data Browser
2. Run the following command:
ParseList(SelectedWaveList())
August 20, 2013 at 02:20 pm - Permalink
DFREF dfr // : for current data folder
Variable recurse // 0 for just specified data folder, 1 to recurse through sub-data folders
Variable index = 0
do
Wave/Z w = WaveRefIndexedDFR(dfr, index) // Requires Igor Pro 6.30 or later
if (!WaveExists(w))
break // No more waves in this data folder
endif
if (WaveType(w) != 0) // Numeric wave?
Variable initialValue = w[0] // This must be done
w -= initialValue // in two separate statements
endif
index += 1
while(1)
if (recurse)
Variable numChildDataFolders = CountObjectsDFR(dfr, 4)
Variable i
for(i=0; i<numChildDataFolders; i+=1)
String childDFName = GetIndexedObjNameDFR(dfr, 4, i)
DFREF childDFR = dfr:$childDFName
SubtractInitialValueFromWaves(childDFR, 1)
endfor
endif
End
August 20, 2013 at 05:06 pm - Permalink
August 21, 2013 at 07:14 am - Permalink