Posted by
Wayne Rasband-2 on
URL: http://imagej.273.s1.nabble.com/Calling-CurveFitter-from-Java-only-4-fit-functions-work-tp5022103p5022111.html
> On Apr 22, 2019, at 12:13 PM, Tihamer <
[hidden email]> wrote:
>
> Thanks for the quick reply, Wayne.
>
> Executive Summary: I can't get a copy of the 1.52o38 jar file.
The latest daily build (1.52o42) has a better JavaScript curve fitting example (included below) that you can access using the Help>Examples>JavaScript>Curve Fitting command. It does all 25 built in curve fits, plots them and adds the plots to a stack. To upgrade, use the Help>Update ImageJ command and select “daily build” from the drop down menu. To get a maven version, you will need to wait for the release of ImageJ 1.52o (due in a few days) and then wait for Fiji to pick it up.
-wayne
xpoints = [0, 1, 2, 3, 4, 5];
ypoints = [0, 0.9, 4.5, 8, 18, 24];
stack = new ImageStack();
for (fit in CurveFitter.fitList) {
cf = new CurveFitter(xpoints, ypoints);
cf.doFit(fit);
label = cf.getName()+"["+fit+"]";
plot = cf.getPlot();
stack.addSlice(label, plot.getProcessor());
}
new ImagePlus("Curve Fits", stack).show();
> You wrote:
>> The following JavaScript version of your program should work better.
>
> As far as I can tell, your JavaScript is pretty much identical to the Java I
> must use. In psudocode:
> 1. Create a new CurveFitter with the x and y data.
> 2. Call doFit().
> 3. Print the results.
>
>> It requires the latest ImageJ daily build (1.52o38),
>
> Unfortunately, the maven repo at
>
https://mvnrepository.com/artifact/net.imagej/ij only goes up to 1.52n. Do
> you have any idea when that will get updated? Do you push to it every once
> in a while, or do you depend on them to pull?
>
> I found the latest source code (version 1.52o40) at
>
https://github.com/imagej/imagej1/blob/c56624301df300ae7e30c26ad9c71ff9025eae46/ij/measure/CurveFitter.java
> So I tried to download the entire ImageJ 1.x repository from
>
https://github.com/imagej/imagej1/tree/c56624301df300ae7e30c26ad9c71ff9025eae46> but it's a non-maven project that I couldn't pull into Eclipse to generate
> my own jar. I noticed the build.xml file. Um... oh, yeah, ant. I remember
> using ant about a decade or two ago, but it would take me a long time to get
> back up to speed. :-(
>
> So I tried getting ImageJA (the maven version of ImageJ), but that only goes
> up to version 1.52n. :-(
>
> Finally, I tried grabbing just your new CurveFitter.java, but it broke with
> the same array Index Out of Bounds exception. :-( Obviously, there are
> more dependencies here--I would probably need to grab all the files manually
> to make sure I have to entire fix for the Array Out of Bounds problem. :-(
>
>> which fixes a CurveFitter.getResultString() bug that caused it to
> fail when there was a fitting error.
>
> The 1.52n code is breaking during the doFit() step, not during the output
> printing step, though I do see how you improved CurveFitter.getResultString.
>
>> Note that you have to construct a new CurveFitter for each fit.
>
> Yes, I did that. Does it look like I didn't?
>
> I hope you can create a 1.52o38 (or later) jar file for the maven repo, or
> update ImageJA sometime soon.
>
> Thanks again for your help so far.
>
>
>
>
>
>
> --
> Sent from:
http://imagej.1557.x6.nabble.com/>
> --
> ImageJ mailing list:
http://imagej.nih.gov/ij/list.html--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html