LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I do second derivative for X and Y arrays


@DougFerguson wrote:

I have basically a Gaussian peak that I need to take the 2nd derivative of. The polynomial solution doesn't fit well.


If you know you have a Gausian peak, then you should fit the raw data to a Gaussian. You would reduce the data to three parameters (area, position, width)

Why do you need the second derivative?

 

Once you have the best fit paramters, you can generate the second derivative noise-free and perfectly.

0 Kudos
Message 11 of 21
(1,916 Views)

Using the 2nd derivate of a Gaussian peak is a technique used to identify peaks in a noisy signals typical in HPLC, GC, and TLC speration methods.

 

Thats what I am investigating now. The peak shape is a puesdo Gaussian. Due to the physical method of pushing the sample through a column, the leading edge is steeper than Gaussian and the trailing edge is shallower. I am suspecting that perhaps I need to adjust the raw data to fit a true gaussian peak then take the 2nd derivative, but worry that doing so would aryficially shift the peak identification and thus the alter the calculated area under that curve.

Doug Ferguson

www.southerndaqsolutions.com
0 Kudos
Message 12 of 21
(1,901 Views)

@DougFerguson wrote:

Using the 2nd derivate of a Gaussian peak is a technique used to identify peaks in a noisy signals typical in HPLC, GC, and TLC speration methods.

 


Do you have some references that describe the method? (If you have a noisy signal, the second derivative will be even noisier!)


@DougFerguson wrote:

Thats what I am investigating now. The peak shape is a puesdo Gaussian. Due to the physical method of pushing the sample through a column, the leading edge is steeper than Gaussian and the trailing edge is shallower. I am suspecting that perhaps I need to adjust the raw data to fit a true gaussian peak then take the 2nd derivative, but worry that doing so would aryficially shift the peak identification and thus the alter the calculated area under that curve.


If you have a mathematical model for the pseudo-Gaussian, you can still fit, but maybe you need one or two additional parameters for the asymmetry.

 

As Gerd already mentioned, it would really help to see some typical data. How many points do you have covering the peak? (a dozen? a million?)

 

I also assume that your data is spaced equally in x. This thread originally was for unevenly spaced data so you should probably have started a new thread instead.

 

0 Kudos
Message 13 of 21
(1,892 Views)

Methods for using the 2nd derivate as it relays to HPLC techniques aren't overly forthcoming. Typically it is either industry confidential or buried in Journals for chromatography. I don't have access to those journals first hand and have been working through our radiochemist.

 

Here is an example of a Gaussian peak. http://research.stowers-institute.org/efg/R/Statistics/MixturesOfDistributions/

 

But as I said my peaks aren't quite Gaussian, so I am currently working to rehsape them to see if I can reproduce the expected shape of the 2nd derivative.

 

I have attached a smaple data set

Doug Ferguson

www.southerndaqsolutions.com
0 Kudos
Message 14 of 21
(1,880 Views)

Hi Doug,

 

Its kind of insulting to assume I did not.

Is it insulting to ask for sample data when the OP and the other follower both offered data they want to get fitted - but you didn't?

 

As you now follow my advice: There are 4 peaks in your data set. Do you want to fit them all?

(And I would recommend to use a format like "%.3e" for saving the data instead of "%.3f".)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 15 of 21
(1,871 Views)

Ok, I refitted data to be a best fit Gaussian and then took the 1st and 2nd derivatives. The plot looks as expected to publications. As I suspected, the puesdo gaussian shape distores the result of the 2nd derivative to be less conclusive. I guess if I want to pursue the use of this method to identify the peaks then I will need to refit the data to a gaussian peak.

Doug Ferguson

www.southerndaqsolutions.com
0 Kudos
Message 16 of 21
(1,862 Views)

If it is not a gaussian, then you need to fit to a distorted Gaussian.

 

As Gerd mentioned, you need to save with more significant digits. Currently, the data is quantized to three decimal digits, which seems below the noise.

 

How many bits does the detector produce?

 

You have plenty of data across the peak and the current noise is below the resolution of the saved data.

 

I assume you are interested in the central peak. Are you?. I think taking an accurate second derivate should be possible directly. Adjacent points are highly correlated, so you can apply significant filtering. Can you show us what you tried?

0 Kudos
Message 17 of 21
(1,846 Views)

I simply use the Write to Spreadsheet file.vi to upload data here. By default the format is %.3f. The actual raw data is in a larger data set being sent back from the device and I didn't feel it was super important to the gist of the question asked to present the data in its raw format.

 

As I have explained, the unexpected behavior in the 2nd derivative is due to the peak not actually being a Gaussian peak. Once I fit the original peak to a Gaussian fit the method works well to identify the peak, start and end. I suspect that users of this method heavily fit the peaks to handle this. However with a single resolved peak this is quite over kill. This method do becomes pretty useful when two adjacent peaks don't resolve.

 

Capture.JPG

Doug Ferguson

www.southerndaqsolutions.com
Message 18 of 21
(1,838 Views)

Even with the noise, you see all main features in the raw second derivative. Isn't that sufficient?

0 Kudos
Message 19 of 21
(1,826 Views)

After convoluting with a 25 point wide cosine peak (or similar), the derivatives seems quite nice, even the third derivative looks quite good.

 

(Sorrry, using my own tools. Cannot attach, but the above information should be sufficient).

 

 

Message 20 of 21
(1,818 Views)