如何保存多个摘要文件批处理宏imageJ

时间:2017-09-15 19:12:39

标签: macros analysis imagej

我对imageJ中的批量图像处理很新。我有一个宏,允许我在一个目录中处理几个图像。问题是宏为每个处理过的图像生成一个单独的摘要窗口,让我手动将所有输出数据编译成单个.csv或.xls。我希望将所有摘要数据自动编译到一个文件中。虽然我找到了几个显示如何执行此操作的消息来源,但在我的情况下它并没有特别有用。

如果你能提供帮助,我将非常感激。

以下是代码的缩写示例:

        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"); 

1 个答案:

答案 0 :(得分:0)

在我的测试中(使用macOS 10.12.6上的ImageJ 2.0.0-rc-61 / 1.51n),重复执行带有摘要选项的Analyze Particles将摘要附加到现有的Summary窗口,然后可以将其保存为最后一个文件。

例如,以下宏生成两个摘要行,然后保存它们:

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");