The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Pkfind X-function
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

sperling

14 Posts

Posted - 05/10/2018 :  11:26:00 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
I've found that when using the pkfind X-function, the peak locations aren't interpolated between values of x. This is even the case using the first derivative and smoothing. This leads to data that's discretized along the x-axis spacing.

Am I doing something wrong? Is there an alternate method?

yuki_wu

896 Posts

Posted - 05/10/2018 :  11:51:14 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

Peak in theory is the data point that has the maximum y value, so it should be the existing point of the data. An existing point must have its y value and the corresponding x value, so I am not sure why you need interpolation.

Could you show me your data? It will help me to understand your question fully.

Regards,
Yuki
OriginLab
Go to Top of Page

sperling

14 Posts

Posted - 05/14/2018 :  1:08:16 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks for replying, Yuki.

quote:
Originally posted by yuki_wu
Could you show me your data? It will help me to understand your question fully.



I'll demonstrate:

1) Fill the first column with 1 to 100. Set the second as Gauss(Col(1),0,43.5,15,1)

2) Use
pkFind iy:=col(2) smooth:=5 method:=first ocenter:=Col(3) ocenter_x:=Col(4)


The reported center index is 44 as is the center in this case.

The problem is that the Savitzky-Golay method is supposed to interpolate to get the zero-crossings. If instead of the above X-function, I use

differentiate iy:=Col(2) order:=1 smooth:=1 poly:=2 npts:=5 oy:=Col(3);
dataset xset=Col(1)[30:60], dyset=Col(3)[30:60];
xset(0,dyset)=


Then I get 43.5, which is what's specified. The problem is that I had to artificially limit the dataset to avoid the ends. Also, if there were more than one peak, this code wouldn't return all the zero-crossings (peak locations).

I was hoping pkFind would include some kind of algorithm to address these issues. However, the pkFind function seems to operate in a non-standard manner. Is there some easy way to make Origin interpolate the peak locations?
Go to Top of Page

yuki_wu

896 Posts

Posted - 05/15/2018 :  02:09:57 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

So far, the basic idea of the First Derivative Method is as follow:
https://www.originlab.com/doc/X-Function/ref/pkFind

1) A positive peak center locates in a position x_c, where the first derivative at x_c-1 is positive while the first derivative at x_c+1 is negative;
2) A negative peak center locates in a position x_c, where the first derivative at -1 is negative while the first derivative at +1 is positive.

After performing differentiation, we could see that:

Based on the method above, so we pick the point index = 44.

For now, it seems that we don’t have a good method to pick all the zero-crossing value as you desired by pkFind X-Function, but levelcrossing X-Function could help after you perform differentiation:
https://www.originlab.com/doc/X-Function/ref/levelcrossing

Hope it helps.

Regards,
Yuki
OriginLab
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000