0

我是 ImageJ 的新用户。

我阅读了类似问题的答案:

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

https://forum.image.sc/t/add-results-of-plugin-as-new-row-in-results-table/11464

https://forum.image.sc/t/combining-several-summary-of-image-title-into-a-single-results-table/40152

https://forum.image.sc/t/printing-text-to-analysis-particles-summary-table-and-save-the-table/355

https://forum.image.sc/t/issues-saving-a-summary-file-within-marcro/1094/10

我不明白如何同时使用两个分叉代码:这个成功使用批处理模式但分别打开所有摘要窗口(我需要每个切片的摘要):

################################################# ##################################

// Macro to measure Area, Intensity, Perimeter, and Shape of directory of images

run("Clear Results"); // clear the results table of any previous measurements

// The next line prevents ImageJ from showing the processing steps during 
// processing of a large number of images, speeding up the macro
setBatchMode(true); 

// Show the user a dialog to select a directory of images
inputDirectory = getDirectory("Choose a Directory of Images");

// Get the list of files from that directory
// NOTE: if there are non-image files in this directory, it may cause the macro to crash
fileList = getFileList(inputDirectory);

for (i = 0; i < fileList.length; i++)
{
    processImage(fileList[i]);
}

setBatchMode(false); // Now disable BatchMode since we are finished




updateResults();  // Update the results table so it shows the filenames


// Show a dialog to allow user to save the results file
outputFile = File.openDialog("Save results file");
// Save the results data

saveAs("results",outputFile);

function processImage(imageFile)
{
    // Store the number of results before executing the commands,
    // so we can add the filename just to the new results
    prevNumResults = nResults;  
    
    open(imageFile);
    // Get the filename from the title of the image that's open for adding to the results table
    // We do this instead of using the imageFile parameter so that the
    // directory path is not included on the table
    filename = getTitle();
    
    
    
    setThreshold(257, 65535);
    
    run("Analyze Particles...", "size=1-200 summarize stack");



    
    // You should modify the size parameter in the line below based
    // on the calibration of your images

    // Now loop through each of the new results, and add the filename to the "Filename" column
    for (row = prevNumResults; row < nResults; row++)
    {
        setResult("Filename", row, filename);
    }

    close("*");  // Closes all images
}

################################################# ##################################

这个设法将第 2 个切片放入结果中,但该批次不再起作用:

################################################# ##################################

        // Macro to measure Area, Intensity, Perimeter, and Shape of directory of images

run("Clear Results"); // clear the results table of any previous measurements

        // The next line prevents ImageJ from showing the processing steps during 
        // processing of a large number of images, speeding up the macro

setBatchMode(true); 

        // Show the user a dialog to select a directory of images

inputDirectory = getDirectory("Choose a Directory of Images");

        // Get the list of files from that directory
        // NOTE: if there are non-image files in this directory, it may cause the macro to crash

fileList = getFileList(inputDirectory);

for (i = 0; i < fileList.length; i++)
{
    processImage(fileList[i]);

}

setBatchMode(false); // Now disable BatchMode since we are finished

updateResults();  // Update the results table so it shows the filenames


        / Show a dialog to allow user to save the results file
outputFile = File.openDialog("Save results file");
        // Save the results data

saveAs("results",outputFile);

function processImage(imageFile)
{
            // Store the number of results before executing the commands,
          // so we can add the filename just to the new results
    prevNumResults = nResults;  
    
    open(imageFile);
         // Get the filename from the title of the image that's open for adding to the results table
          // We do this instead of using the imageFile parameter so that the
         // directory path is not included on the table
    filename = getTitle();

    setThreshold(257, 65535);
    
    run("Analyze Particles...", "size=1-200 show=Nothing summarize stack");


    macro "Cell_quant [q]"{
    
    
    
    tableTitle = Table.title;
    Table.rename(tableTitle, "Results"); //can only get text from this table if it is a Results table
    headings = Table.headings;
    headingsArray = split(headings, "\t");
    
    for (i=0; i<headingsArray.length; i++){
        //selectWindow(""+tableTitle);
        //data = Table.get(headingsArray[i], 0);
        data = getResultString(headingsArray[i], 0);
        
        Table.update;
    }


    
    //close(""+tableTitle);



   
ResultsTable()
finalTable = ResultsTable()

for table in range(len(results)):
    for row in range(results[table].size()):
        finalTable.incrementCounter()
        for column in range(len(results[table].getHeadings())-1):
            finalTable.addValue(column, results[table].getValue(column, row))

# Add the headings...
for column in range(len(results[0].getHeadings())-1):
    finalTable.setHeading(column, results[0].getColumnHeading(column))

# Show the table...
finalTable.show("All Results")







    
          // You should modify the size parameter in the line below based
         // on the calibration of your images

           // Now loop through each of the new results, and add the filename to the "Filename" column
    for (row = prevNumResults; row < nResults; row++)
    {
    
        setResult("Filename", row, filename);
    }

    close("*");  // Closes all images
}



    
}   

4

0 回答 0