ROI manger labeling and exporting

Hi :slight_smile:! I am an ImageJ beginner and I am trying to automatize an image analysis, but I am finding some troubles when I try to perform macro programing.

I am able to export the images to analyze from a file but when I add them to the ROI manager and I try to rename each ROI with the name of each picture all ROIs in the manager are renamed with the name of the latest picture. In addition, I would like to have this labels in the excel file that I export with the results if it is possible.

I would appreciate any help. This is my macro;

//Take images
input_path = getDirectory(“path”);
fileList = getFileList(input_path);

//Looping for all images
for (f = 0; f < fileList.length; f++) {
title = getTitle();

run(“Duplicate…”, " ");

run(“Auto Threshold”, “method=MaxEntropy white”);
run(“Gaussian Blur…”, “sigma=2”);
setOption(“BlackBackground”, true);
run(“Make Binary”);
run(“Fill Holes”);

//ROI detection and measuring
run(“Analyze Particles…”, “size=200-Infinity display include add”);

for ( i =0; i< roiManager(“count”); i++) {
roiManager (“select”, i);
roiManager(“Rename”, getTitle());


saveAs(“Results”, “/path.xls”);

run(“Close All”);


you do not need to rename the ROIS to have the name of the image in the results table for each line. Just go to Analyze>Set Measurements... and check the Display label option.

Best regards,