|
Bugzilla – Bug 987 |
saveAs("Results", "...") does not work |
Last modified: 2015-01-15 20:28:55 CST |
| ⚠ |
NOTICE! This is a static HTML version of a legacy Fiji BugZilla bug. The Fiji project now uses GitHub Issues for issue tracking. Please file all new issues there. |
|
|
|
||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
I'm trying to save some results as a csv file in a macro. When I run it using ImageJ 1.49m it works fine, using 1.49n no files are saved. Here's a mini macro to help with my issue, including my initialization steps. setBatchMode(true); setOption("ShowRowNumbers", false); requires("1.49m"); run("Set Measurements...", "area mean standard min median redirect=None decimal=3"); run("Input/Output...", "jpeg=85 gif=-1 file=.csv save_column"); run("Table...", "name=Points width=400 height=200"); print("[Points]", "Header1, Header2, Header3"); print("[Points]", "Data1, Data2, Data3"); selectWindow("Points"); saveAs("Results", "C:\\Users\\tokamoto\\Desktop\\Results_Points.csv"); run("Close"); My final Points table usually looks similar to the following... Points Filename, 1, 2, 3, 4, 5, 6 Filename, 1, 2, 3, 4, 5, 6 In my macro, I'm transferring results from the results table to the "Points" table, with each row containing a filename, then numbers all separated by commas. The "Points" table is full when it is saved, but no file is created. I've had to downgrade to 1.49m in the mean time. Information about your version of Java: os.arch => amd64 os.name => Windows 7 os.version => 6.1 java.version => 1.6.0_24 java.vendor => New Oracle java.runtime.name => Java(TM) SE Runtime Environment java.runtime.version => 1.6.0_24-b07 java.vm.name => Java HotSpot(TM) 64-Bit Server VM java.vm.version => 19.1-b02 java.vm.vendor => Sun Microsystems Inc. java.vm.info => mixed mode java.awt.graphicsenv => sun.awt.Win32GraphicsEnvironment java.specification.name => Java Platform API Specification java.specification.version => 1.6 sun.cpu.endian => little sun.desktop => windows file.separator => \ The up-to-date check says: CHECK_TURNED_OFF Information relevant to JAVA_HOME related problems: JAVA_HOME is set to: C:\Fiji.app/java/win64/jdk1.6.0_24//jre imagej.dir => C:\Fiji.app Information about the version of each plugin: Activated update sites: ImageJ: http://update.imagej.net/ (last check:20141222150235) Fiji: http://fiji.sc/update/ (last check:20150108023217) Files not up-to-date: a6fb0af8 (MODIFIED) 20150113125324 jars/ij-1.49m.jar 1aebacaa (LOCAL_ONLY) 20150113130207 macros/Individual/SNR.ijm 7e29c562 (LOCAL_ONLY) 20150109131628 macros/Individual/Startup/StartupMacros.fiji.ijm f6de9c64 (LOCAL_ONLY) 20150109133030 macros/Individual/automerge.ijm ed5b891e (LOCAL_ONLY) 20150109133039 macros/Individual/autominmaxtif.ijm 0eb63eff (LOCAL_ONLY) 20150109133044 macros/Individual/openzproject.ijm 78d356ac (LOCAL_ONLY) 20150109133047 macros/Individual/regexmerge.ijm b730eee9 (MODIFIED) 20150113130514 macros/StartupMacros.fiji.ijmYour mini macro works as expected when I run it on ImageJ 1.49n. As a work around, try writing directly to the Results table, as in this example: run("Clear Results"); for (i=1; i<=3; i++) setResult("Header"+i, 0, "Data"+i); setOption("ShowRowNumbers", false); updateResults; saveAs("Results", "/Users/wayne/Results.csv"); run("Close");Do you have a small test macro that reproduces this problem? The following macro works as expected when I run it on ImageJ 1.49n. run("Table...", "name=Points width=400 height=200"); print("[Points]", "Header1, Header2, Header3"); print("[Points]", "Data1, Data2, Data3"); saveAs("Results", "/Users/wayne/Results.csv"); run("Close");I've re-created the issue in a macro that emulates my macro, and the steps that it takes through functions and saving to the tables. In my macro, I'm running the Measure tool on three separate selections on an image (emulated here by creating some random data) and then doing some calculations based on the results (emulated here by calculating the ratio and half ratio). The results are saved on the first row in their own column, and then all three rows are printed to the Points table, replacing the space between data with commas. Since I still have the ratios stored in variables, I print just the results to another table that excludes the raw measure data from earlier. After it runs on all images in a directory(emulated here by just running it ten times) it selects the tables, saves them, and then closes them. The macro below works on 1.49m, but not 1.49n. If you comment out the close commands after the saveAs commands, you can see the tables have data in them. setBatchMode(true); setOption("ShowRowNumbers", false); requires("1.49m"); run("Set Measurements...", "area mean standard min median redirect=None decimal=3"); run("Input/Output...", "jpeg=85 gif=-1 file=.csv save_column"); print("\\Clear"); run("Clear Results"); ratiovalue = 0; half = 0; //Initialize Tables run("Table...", "name=Points width=400 height=200"); run("Table...", "name=Condensed width=400 height=200"); print("[Points]", "Double, Value, Ratio, Ratio2"); print("[Condensed]", "Number, Ratio, Ratio2"); //Run main function testfunction(); updateResults; //Save Tables selectWindow("Points"); saveAs("Results", "C:\\Users\\tokamoto\\Desktop\\Results_Points.csv"); run("Close"); selectWindow("Condensed"); saveAs("Results", "C:\\Users\\tokamoto\\Desktop\\Results_Condensed.csv"); run("Close"); function testfunction() { for (i = 0; i < 10; i++) { for (n = 0; n < 3; n++) { //Create three sets of random data setResult("Double", n, (n+1)*2); setResult("Value", n, random * 10); } updateResults(); //Run the ratio function which separates the data and condenses it into the two tables ratio(); } } function ratio() { //Calculate ratio ratiovalue = getResult("Double", nResults - 3) / getResult("Value", nResults - 3); half = ratiovalue / 2; //Set Results setResult("Ratio", 0, ratiovalue); setResult("Ratio2", 0, half); updateResults(); //String manipulation and writing to table String.resetBuffer; String.copyResults; String.append(String.paste); print("[Points]", replace(String.buffer, " ", ", ")); run("Clear Results"); //Save Condensed results (Just the ratio) setResult("Number", nResults, i); setResult("Ratio", 0, ratiovalue); setResult("Ratio2", 0, half); updateResults(); String.resetBuffer; String.copyResults; String.append(String.paste); print("[Condensed]", replace(String.buffer, " ", ", ")); run("Clear Results"); }