如何保存多个摘要文件批处理宏imageJ [英] how to save multiple summary files batch process macro imageJ
问题描述
对于imageJ中的批处理图像处理,我还很陌生.我有一个宏,可让我在单个目录中处理多个图像.问题在于该宏为每个处理的图像生成一个单独的摘要窗口,让我手动将所有输出数据编译为单个.csv或.xls.我希望将所有摘要数据自动编译到一个文件中.虽然我发现了一些资料显示如何执行此操作,但是对于我的情况,它并不是特别有用.
I am pretty new to batch image processing in imageJ. I have a macro that allows me to process several images in a single directory. The problem is that the macro generates an individual summary window for each processed image, leaving me to manually compile all the output data into a single .csv or .xls. I would prefer that all the summary data be automatically compiled into one file. While I have found several sources showing how to do this, it has not been particularly helpful in my situation.
如果能帮助您,我将不胜感激.
If you could help, I'd be very grateful.
以下是该代码的缩写示例:
Here is an abbreviated example of the code:
dir1 = getDirectory("Choose Source Directory ");
dir2 = getDirectory("Choose Destination directory");
list = getFileList(dir1);
setBatchMode(true);
for (i=0; i<list.length; i++){
print (list[i]);
open(dir1+list[i]);
name=File.nameWithoutExtension;
//Prepare the image by removing any scale and making 8-bit
run("Set Scale...", "distance=237.3933 known=1 pixel=1 unit=cm
global");
makeRectangle(4068, 5940, 1572, 1320);
run("Crop");
// Convert the image into RGB channels for proper thresholding
run("RGB Stack");
setSlice(3);
//Threshold
setAutoThreshold("Default");
// Analyze particles
// Provides total area of number of cotyledons in image
run("Analyze Particles...", "size=60-Infinity pixel display include
summarize");
run("Revert");
}
//Save the results
selectWindow("Summary");
saveAs("Results", dir2+"Results.xls");
推荐答案
在我的测试中(在macOS 10.12.6上使用ImageJ 2.0.0-rc-61/1.51n),重复执行带有"summary"选项选中的"Analyze Particles"将摘要添加到现有的摘要"窗口中,然后可以在末尾将其另存为单个文件.
In my tests (with ImageJ 2.0.0-rc-61/1.51n on macOS 10.12.6), repeatedly executing Analyze Particles with the summarize option checked appends the summary to the existing Summary window, which can then be saved as a single file at the end.
例如,以下宏生成两条摘要行,然后保存它们:
For example, the following macro generates two summary lines and then saves them:
setBatchMode(true);
run("Blobs (25K)");
setAutoThreshold("Default");
run("Analyze Particles...", "size=60-Infinity pixel display include summarize");
run("Boats (356K)");
setAutoThreshold("Default");
run("Analyze Particles...", "size=60-Infinity pixel display include summarize");
selectWindow("Summary");
saveAs("Results", "/Users/curtis/Desktop/Results.xls");
这篇关于如何保存多个摘要文件批处理宏imageJ的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!