Decimal precision of imported results

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Decimal precision of imported results

Jan Eglinger
Dear Wayne,

I've noticed that when you import results via
"File > Import > Results...", the decimal precision of the opened
ResultsTable seems to be always set to 3 decimal places.

May I suggest to change the ResultsTable#open method to either respect
the setting via "Analyze > Set Measurements...", or - even better - to
respect the precision that is found in the file to be opened?

To reproduce, run the following macro code and compare the number of
decimal places in the mean before saving and after re-importing:

*****
homedir = getDirectory("home");
run("Blobs (25K)");
run("Set Measurements...", "area mean redirect=None decimal=9");
run("Measure");
waitForUser("Please notice the decimal precision before saving");
saveAs("Results", homedir + File.separator + "Results.xls");
open(homedir + File.separator + "Results.xls");
*****

Best regards,
Jan

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Decimal precision of imported results

Adrian Daerr-2
> I've noticed that when you import results via
> "File>  Import>  Results...", the decimal precision of the opened
> ResultsTable seems to be always set to 3 decimal places.

And it's not even 3 significant digits, it is literally 3 decimal
places. Add two lines to Jan's test macro to witness a 33% error on
saving/loading:

homedir = getDirectory("home");
run("Blobs (25K)");
run("Set Measurements...", "area mean redirect=None decimal=9");
run("32-bit", "");
run("Divide...", "value=70000");
run("Measure");
waitForUser("Please notice the decimal precision before saving");
saveAs("Results", homedir + File.separator + "Results.xls");
open(homedir + File.separator + "Results.xls");

Oooops, only the order of magnitude of our measurement remains...

> May I suggest to change the ResultsTable#open method to either respect
> the setting via "Analyze>  Set Measurements...", or - even better - to
> respect the precision that is found in the file to be opened?

I would really advocate the second method. Loosing precision upon
loading a file is unexpected.

Adrian


For an even more striking illustration of the rounding error, try this
code which plots an intensity histogram along a line, saves+loads the
data and replots the (same?) histogram...:

homedir = getDirectory("home");
filename = homedir + File.separator + "Results.xls";
run("Blobs (25K)");
run("Set Measurements...", "area mean redirect=None decimal=9");
run("32-bit", "");
run("Divide...", "value=50000");
makeLine(0, 0, 256, 254);
run("Plot Profile");
Plot.getValues(x, y);
run("Clear Results");
for (i=0; i<y.length; i++) {
        setResult("Y", i, y[i]);
}
updateResults();
selectWindow("Results");
saveAs("Results", filename);
open(filename);
run("Distribution...", "parameter=Y or=100 and=0-0.005");
saveAs("Results", filename);
open(filename);
run("Distribution...", "parameter=Y or=100 and=0-0.005");
waitForUser("The two histograms are from the same data,\n"+
   "except that in between the data has been\n"+
   " saved to disk and reread.");

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Decimal precision of imported results

Jan Eglinger
Hi Adrian,

wow, thanks for the illustrative code!
The case of 0.001-like measurements was exactly what made me aware of
this issue.

Jan


On 26.04.2013 4:35 PM, Adrian Daerr wrote:

>> I've noticed that when you import results via
>> "File>  Import>  Results...", the decimal precision of the opened
>> ResultsTable seems to be always set to 3 decimal places.
>
> And it's not even 3 significant digits, it is literally 3 decimal
> places. Add two lines to Jan's test macro to witness a 33% error on
> saving/loading:
>
> homedir = getDirectory("home");
> run("Blobs (25K)");
> run("Set Measurements...", "area mean redirect=None decimal=9");
> run("32-bit", "");
> run("Divide...", "value=70000");
> run("Measure");
> waitForUser("Please notice the decimal precision before saving");
> saveAs("Results", homedir + File.separator + "Results.xls");
> open(homedir + File.separator + "Results.xls");
>
> Oooops, only the order of magnitude of our measurement remains...
>
>> May I suggest to change the ResultsTable#open method to either respect
>> the setting via "Analyze>  Set Measurements...", or - even better - to
>> respect the precision that is found in the file to be opened?
>
> I would really advocate the second method. Loosing precision upon
> loading a file is unexpected.
>
> Adrian
>
>
> For an even more striking illustration of the rounding error, try this
> code which plots an intensity histogram along a line, saves+loads the
> data and replots the (same?) histogram...:
>
> homedir = getDirectory("home");
> filename = homedir + File.separator + "Results.xls";
> run("Blobs (25K)");
> run("Set Measurements...", "area mean redirect=None decimal=9");
> run("32-bit", "");
> run("Divide...", "value=50000");
> makeLine(0, 0, 256, 254);
> run("Plot Profile");
> Plot.getValues(x, y);
> run("Clear Results");
> for (i=0; i<y.length; i++) {
>     setResult("Y", i, y[i]);
> }
> updateResults();
> selectWindow("Results");
> saveAs("Results", filename);
> open(filename);
> run("Distribution...", "parameter=Y or=100 and=0-0.005");
> saveAs("Results", filename);
> open(filename);
> run("Distribution...", "parameter=Y or=100 and=0-0.005");
> waitForUser("The two histograms are from the same data,\n"+
>   "except that in between the data has been\n"+
>   " saved to disk and reread.");

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Decimal precision of imported results

Rasband, Wayne (NIH/NIMH) [E]
In reply to this post by Jan Eglinger
On Apr 26, 2013, at 8:09 AM, Jan Eglinger wrote:

> Dear Wayne,
>
> I've noticed that when you import results via
> "File > Import > Results...", the decimal precision of the opened
> ResultsTable seems to be always set to 3 decimal places.
>
> May I suggest to change the ResultsTable#open method to either respect
> the setting via "Analyze > Set Measurements...", or - even better - to
> respect the precision that is found in the file to be opened?
>
> To reproduce, run the following macro code and compare the number of
> decimal places in the mean before saving and after re-importing:
>
> *****
> homedir = getDirectory("home");
> run("Blobs (25K)");
> run("Set Measurements...", "area mean redirect=None decimal=9");
> run("Measure");
> waitForUser("Please notice the decimal precision before saving");
> saveAs("Results", homedir + File.separator + "Results.xls");
> open(homedir + File.separator + "Results.xls");
> *****

This bug is fixed in the ImageJ 1.47o daily build.

-wayne

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