T O P I C R E V I E W |
anje18 |
Posted - 07/23/2002 : 09:37:22 AM How do I access the Savitsky-Golay smoothing function from LabTalk? |
5 L A T E S T R E P L I E S (Newest First) |
CStorey |
Posted - 07/24/2002 : 12:30:22 PM Hello,
The easiest way is to do this is as follows. (Please read the info contained here for more details on running LabTalk scripts - http://www.genevalake.ca/origin/origin_intro.html)
- Look on the origin tool bar for an icon with 3 connected squares in a traingular pattern. Click on it. A message box should appear saying this icon can be used to run your own code if you modify custom.ogs. That's waht we'll do. - Open the custom.ogs file in the Origin directory. - Look under the heading [Main] and delete everything there, but leave the heading. - Add the following code...
curve.data$=PHILBIN1_EMG; curve.result$=PHILBIN1_C; curve.polydeg=2; curve.smoothPts=21; curve.i1=-1; curve.sgsmooth(); Return;
- save the file. - Click on the button and the smoothing should happen.
Note that I changed the way the data columns identified. As you had written it nothing would have happened. %Substitution requires a number to be specified, not the column name.
Good luck.
Craig Storey Origin WebRing Member - http://g.webring.com/hub?ring=originwebring |
anje18 |
Posted - 07/24/2002 : 09:06:04 AM Thank you again. I have written this into LabTalk:
def savitsmooth { %V=PHILBIN1; curve.data$=%(%V,EMG); // fill this in! curve.result$=%(%V,C); //fill this in! curve.polydeg=2; curve.smoothPts=21; curve.i1=-1; curve.sgsmooth(); }
but I am still a bit confused about how to call this macro in Origin. Could you possibly help me with this? |
CStorey |
Posted - 07/23/2002 : 1:52:29 PM Hello again,
Origin does not have a compiler, OriginC code is built either on execution or at start-up and LabTalk is interpretted.
Since you've chosen LabTalk you can run the script a bunch of ways: associate it with a button, a menu item, from a dialog, script window, editor, marco, section.... I suggest you read the Help files on running LabTalk scripts.
The code as you have written it is correct, but will not work unless you specify the following two line somehow.
curve.data$=%(%V,2); curve.result$=%(%V,4);
The %(%V,x) notation is called substitution notation and in this case it is used to select the column from the worksheet name stored in variable %V. So you will have to define %V as the graph you are going to work with. You might even want to add a new column for the results rather then column #4.
Eg. %V=Graph1;
I suggest you create a graph with your data called Graph1 and test the results. (21 points might be too many or too few for your data.) Copy and paste teh following in the script window and execute it, highlight the code and press enter, to test. If it all looks ok then start looking at a more permanent solution.
%V=Graph1; curve.data$=%(%V,); // fill this in! curve.result$=%(%V,); //fill this in! curve.polydeg=2; curve.smoothPts=21; curve.i1=-1; curve.sgsmooth();
If you encounter problems post your results.
Craig Storey Origin WebRing Member - http://g.webring.com/hub?ring=originwebring |
anje18 |
Posted - 07/23/2002 : 1:32:21 PM Thank you for your help. I have written the following code into a LabTalk .ogs file:
def savitsmooth { curve.data$=%(%V,2); curve.result$=%(%V,4); curve.polydeg=2; curve.smoothPts=21; curve.i1=-1; curve.sgsmooth(); }
Now I am wondering if this coding is correct and if so, how do I compile and run this function in Origin. |
CStorey |
Posted - 07/23/2002 : 10:26:17 AM Hello,
You would do something like the following....
[SGsmoother]
curve.data$=%(%V,2); // name of solumn to smooth curve.result$=%(%V,4); // name of column for smoothed data curve.polydeg=2; // degree of polynomial curve.smoothPts=21; // # of points to use in smooth, or set R/L below // curve.smoothLeftPts=NumLPts; // Points left of // curve.smoothRightPts=NumRPts; curve.i1=-1; // start smoothing from first point (-1) or any point (>1) // curve.derivdeg=1; // S-G derivative degree, for S-G derivatives curve.sgsmooth(); // Perform smoothing
Hope this helps!
Craig Storey Origin WebRing Member - http://g.webring.com/hub?ring=originwebring |
|
|