Author |
Topic  |
|
zknauss
USA
72 Posts |
Posted - 09/18/2022 : 4:51:34 PM
|
Hello, for several weeks now I have been attempting to build a new fitting function to analyze my data in peak analyzer. Below I've have included several examples of my data: a single peak, a larger example of what the data looks like with multiple peaks and an examples of peaks with low peak to peak resolution. After a large amount of trial and error I've determined that the rising phase of my peaks can be fit using a Boltzmann function and the falling phase is most closely fit using a two-phase exponential decay function both of which I've listed below from the prebuilt functions in Origin. Overall, the function I need to build is a three-part piecewise function Rising phase, plateau phase, and falling phase (the plateau phase is usually very short but can vary greatly among my data sets. I believe the plateau phase could be set to a function of a straight-line y = a+b*x but I’m not completely sure. Where I seem to be getting stuck is the parameter initialization and setup steps no matter how I structure the function I get no fitting, or the function seems to not correctly mesh with the peak detection data. I am on a very tight deadline with this and under a large amount of pressure to complete this fitting function by the end of the week if anyone would be able to assist me in its creation, I'd greatly appreciate it. Thanks in advance, ZTK
Boltzmann function: Parameters: A1,A2,x0,dx Meanings = init value,final value,center,time const function: y = A2 + (A1-A2)/(1 + exp((x-x0)/dx)) Parameter Initialization sort(x_y_curve); //smooth(x_y_curve, 2); x0 = xaty50( x_y_curve ); double xmin, xmax; x_data.GetMinMax(xmin, xmax); dx = (xmax - xmin) / 20.0; if( yatxmin( x_y_curve ) > yatxmax( x_y_curve ) ) { A1 = max( y_data ); A2 = min( y_data ); } else { A1 = min( y_data ); A2 = max( y_data ); }
Two-phase exponential decay function with time constant parameters Parameters: y0,A1,t1,A2,t2 Meaning: offset,amplitude,time constant,amplitude,time constant Function: y = y0 + A1*exp(-(x-x0)/t1) + A2*exp(-(x-x0)/t2) Parameter Initialization: x0 = min(x_data); int sign; t1 = get_exponent_cuv(x_y_curve, &y0, &A1, &sign); if (t1 > 0) { int nSize = x_data.GetSize(); y0 = y_data[0] + y_data[nSize-1] - y0; A1 = A2 = -0.5 * sign * exp(A1+t1*(x_data[0]+x_data[nSize-1])- x0*t1); t1 = t2 = 1 / t1; } else { t1 = t2 = -1 / t1; A1 = A2 = 0.5 * sign * exp(A1 - x0/t1); } t1 = t1 * 0.9; t2 = t2 * 1.1; https://www.dropbox.com/s/klqf5sf51tdf54i/Single%20Peak.ogwu?dl=0 https://www.dropbox.com/s/rwthf0s2x787ej1/Multipeak.ogwu?dl=0 https://www.dropbox.com/s/qrwwn5k2txz461u/Multi2.ogwu?dl=0 https://www.dropbox.com/s/838dmu5xh6l17dm/multi3.ogwu?dl=0
ZTK |
|
Shirley_GZ
China
Posts |
Posted - 09/19/2022 : 04:47:07 AM
|
Hi ZTK,
Would you please show us a sketch map with the single peak data to let us know how to divide the three parts of the piecewise function?
To define a piecewise function, you can refer to this tutorial, https://www.originlab.com/doc/Tutorials/Fitting-Piecewise Just as you can see, to initialize the parameters of of each part, you have to consider the range partition of the parts.
Thanks, Shirley
Originlab Technical Service Team |
 |
|
zknauss
USA
72 Posts |
Posted - 09/19/2022 : 08:09:25 AM
|
Shirley,
Thank you for the fast reply this is one of the issues I was running into. Unfortunatly, my peaks are not consistently paced on the x-axis so, unless I'm mistaken, for the function to operate in the peak analyser these points will need to be determined off of the point of maximum peak height. I thought of a few ideas on how to do this:
1. Set inital lenght of the center component +/-1 point from the point of max peak height. Obviously this would need to be set as a parameter for adjustment
2. The points of component separation could be determined using the derivative of the curve to find where the slope changes. This could also help solve the problem of peaks which show zero resolution (see multi3 data).
Below are the X points from the single peak of the three components Component 1 Boltzmann function: 157.936-158.086 Component 2 plateau: 158.086-158.116 Component 3 Two-phase exponential decay function: 158.116 -314
Best, ZTK
ZTK |
Edited by - zknauss on 09/19/2022 08:10:41 AM |
 |
|
zknauss
USA
72 Posts |
Posted - 09/19/2022 : 09:03:29 AM
|
On the tutorial I'm not very expreienced with either the programing language or math functions. I had already looked over these tutorials and found myself often completely lost or unable to get even the examples to work correctly. I know what I want to do it's more that I'm not sure how to execute it.
ZTK |
 |
|
Shirley_GZ
China
Posts |
Posted - 09/20/2022 : 02:48:40 AM
|
Hi ZTK,
We have looked into you files and your requirement. 1. In the three components you defined, the second component, there are only two points in this range. It is very difficult to find these two data points when you do peak fitting even there are only one such peak. 2. In the app "Fitting Function Library", https://www.originlab.com/FileExchange/details.aspx?fid=490 There is a function "FitConvExp2P8" which matchs your data well in my opinion, you can use it to do peak fitting and get a good result. You can check the project below: https://www.originlab.com/FTP/forum_and_kbase/files/Exp2Conv.zip In this project, we tried many times to get a good parameter initialization; for the data with multiple peaks, you may need more patience to find the initial values.
Thanks, Shirley
Originlab Technical Service Team |
 |
|
|
Topic  |
|
|
|