From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to implement an Exponentially Modified Gaussian Fit?

Solved!
Go to solution

Hello, I am trying to find a way to create an Exponentially Modified Gaussian Fit to an array of data. According to labview (http://www.ni.com/white-paper/6954/en/) it's possible to do through the Nonlinear Curve Fit VI and the Error Function VI, but I can't figure out a way to implement it, the formula is available in the link as well. I am looking at chromatography data if that makes a difference.

 

Has anyone found a way to do this? Or would anyone be willing to take a crack at it? I've seen a previous post on the topic where the solution was a polynomial expansion or other numerical approximation of the erf, but my skills are developing and I don't know how to do this either.

 

Attached is a sample array that I would like to be able to fit with the EMG function.

 

Thanks for your time!

 

0 Kudos
Message 1 of 10
(3,951 Views)

What part of the documentation you referenced didn't you understand?  They described non-linear LM Curve-fitting, they provided the EMG (which, to me, means ElectroMyoGram) formula, what else do you need?

 

I notice you don't quite "get" graphs -- it is much simpler to (simply) plot the Y array on a Waveform (not an XY) graph.

 

Spend a little more time with the LabVIEW Tutorials.

 

Bob Schor

0 Kudos
Message 2 of 10
(3,928 Views)

Thanks for the reply Bob, there is no block diagram in the reference, I don't know how and in which order they are connecting the Nonlinear Curve Fit and the Error Function VIs. I appreciate the feedback to check out the tutorials, I will look into that, but still no closer to solving my problem here.

 

My issue is that I can't figure out how and where to wire the error function. And unless its syntax as the issue, the formula I am entering in the modelling description doesn't work with erf in it. So as far as I am concerned I have to find a way to utilize the Error Function vi but can't figure out how.

 

Any more help would be appreciated.

0 Kudos
Message 3 of 10
(3,898 Views)

@EC-Dan wrote:

Hello, I am trying to find a way to create an Exponentially Modified Gaussian Fit to an  


First, you need to define what a "Exponentially Modified Gaussian" is. Do you have a formula? What are the parameters?

 

(HINT: if you change the mapping of the x-axis to logarithmic, it almost looks like a symmetric Gaussian. Three parameters might be sufficient: position, width, area)

 

Your code makes not much sense. You don't need the FOR loop, the "bundle", or the "built array" or the xy graph. A plain waveform graph is sufficient.

 

Anyway, once you have the model for your function, follow the help for nonlinear fit and create a model VI that calculates your function based on X and the parameters. Given reasonable parameter guesses, the nonlinear curve fit will find a set of parameters that best fits your data.

 

For more examples, have a look at my nonlinear fitting group page.

0 Kudos
Message 4 of 10
(3,887 Views)

Here's a very rough draft (parameter units are arbitrary for simplicity, so scale accordingly)

 

ExpGaussFit.png

Message 5 of 10
(3,884 Views)

Christian,

 

     If you follow the link the OP cites to LabVIEW's Help documentation, there is an explicit section on Exponentially Modified Gaussian Fit where they even write down the Fitting Function explicitly.

 

     I hope that between your excellent tutorials on Non-Linear Fitting (with good examples) and documentation on the desired Fitting Function, the OP can finish this chore by himself and credit at least you with providing the Solution.

 

Bob Schor

Message 6 of 10
(3,864 Views)

Thanks Bob.

I did not read that far in the linked page. I was not aware that "exponentially modified gaussian" has a specific meaning, because I can think of many ways to "modify" a Gaussian. 😄 (I also do not include an offset.) Whatever the data was, it looked quite symmetric once I use a log x-axis and as you can see, the fit is quite nice. 🙂

 

I am sure the OP has no problems modifying the model according to the much more complicated formula if desired. The code skeleton stays the same. 😄

Message 7 of 10
(3,858 Views)

Thank you both for the replies. You would be surprised what I can have trouble with! The project I am working on is chromatographic data. The example I provided is a simple example, I need to figure out how to do the easy stuff before I move on to more complex peaks, ie overlapping peaks, shoulders, no valleys etc.

 

I will go through the documentation and links you've provided and see if I can implement what I need. I will be back here later if I still need guidance. It is that built in error function vi that i think is confounding me the most, and how to implement it into my curve fit model. But hopefully by going through your examples I will get a better understanding for how the curve fit model should be constructed.

 

Thanks,

 

Dan

 

0 Kudos
Message 8 of 10
(3,855 Views)
Solution
Accepted by topic author EC-Dan

The model subVI just calculates the corresponding Y values for all X, given the array of parameters. The error function is here, and you can just drop it in the right place.

 

The model subVI needs to be strictly typed, so don't delete any controls or indicators that you think you don't need. They all need to be there.

 

Make sure that the array size of parameter guesses corresponds to the number of parameters used in the model and that the values are somewhat reasonable. I always graph the function based on the initial parameters, just to see if it resembles the data at all. If not, adjust as needed.

Message 9 of 10
(3,848 Views)

Thank you both for your help. I was able to figure it with your direction. Its neat to see how sensitive it is to the initial parameters.

 

Cheers,

 

Dan

0 Kudos
Message 10 of 10
(3,838 Views)