Saving or Exporting Multiple results files
Posted by javila0624 on Jul 22, 2014; 11:04pm
URL: http://imagej.273.s1.nabble.com/Saving-or-Exporting-Multiple-results-files-tp5008855.html
Hello all,
Can someone help with figuring out a more efficient way of exporting values from the results window? I've made a macro that gives me custom histogram counts for three respective channels. I am running batch-processing using this macro on 20 samples. Below is the final edit for it. As you can see, I placed a waitforUser command so I can paste data onto an excel sheet.
When I try to save with saveAs("Results", "Directory...), my data is overwritten by the most recent file data. I've tried variations of (...,Directory/getTitle().txt") with no luck.
Ideally, I'd like to have either one results window with all data points for all 20 samples (20*3=60 separate histogram distributions), one .txt file with all data, or 20 separate .txt files (or 60 of them).
The most perfect solution would be someway to export to excel with the macro, while preventing over-writing of data (which I've experienced with print(x, ...) commands). I think I'm missing a line or some code to skip columns in excel iteratively.
Can someone offer assistance?
title=getTitle()
c1Title = "C1-" + title;
c2Title = "C2-" + title;
c3Title = "C3-" + title;
run("Split Channels");
row = 0;
selectWindow( "C3-" + title);
getHistogram(Values, counts, nBins, min,max);
for (k=0; k<nBins; k++) {
setResult("Channel", row,"C3-" + title);
setResult("Count", row, counts[k]);
row++;
}
updateResults();
selectWindow( "C2-" + title);
getHistogram(Values, counts, nBins, min,max);
for (k=0; k<nBins; k++) {
setResult("Channel", row,"C3-" + title);
setResult("Count", row, counts[k]);
row++;
}
updateResults();
selectWindow ("C1-" + title);
getHistogram(Values, counts, nBins, min,max);
for (k=0; k<nBins; k++) {
setResult("Channel", row,"C3-" + title);
setResult("Count", row, counts[k]);
row++;
}
updateResults();
selectWindow ("Results");
String.copyResults
waitForUser