Login  Register

Re: Running a Gaussian Fit in a Beanshell Script

Posted by bnorthan on Mar 31, 2014; 8:56am
URL: http://imagej.273.s1.nabble.com/Running-a-Gaussian-Fit-in-a-Beanshell-Script-tp5007134p5007141.html

Hi Burni

You can access the functionality by using the CurveFitter class directly.
http://imagej.nih.gov/ij/developer/api/ij/measure/CurveFitter.html

double[] x = new double [] {0, 1, 2, 3, 4, 5};
double[] y = new double [] {0, 0.9, 4.5, 8, 18, 24};

CurveFitter fitter=new CurveFitter(x, y);

fitter.doFit(1);

double[] results=fitter.getParams();

for (double d:results)
{
    print(d);
}

Brian


On Sun, Mar 30, 2014 at 5:40 PM, Burni <[hidden email]> wrote:

> Greetings,
>
> I'm writing a little programm with Beanshell and at one point I need to fit
> a set of points with a Gaussian function.
> Theoretically, it should look something like this:
>
> double[] x = new double [] {0, 1, 2, 3, 4, 5};
> double[] y = new double [] {0, 0.9, 4.5, 8, 18, 24};
>
> //ij.Fit.doFit("Gaussian", x, y);
> ij.IJ.run("Curve Fitting...");
>
> With the last line, I can at least start the Curve Fitter, but I want to
> automatically use the the values of the arrays x and y. The command I made
> a
> comment would work in the ImageJ macro language, but I don't know how to
> use
> it in Beanshell.
> Also, after the fit is done, I want to automatically extract the values of
> the fitting parameters (a, b, c....).
> Could someone please help me with this?
>
> Burni
>
>
>
> --
> View this message in context:
> http://imagej.1557.x6.nabble.com/Running-a-Gaussian-Fit-in-a-Beanshell-Script-tp5007134.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html