ij-macro-programming-workshop

Previous            Solution            Next

Exercise 15.1 - Measure objects on all images in a folder

Aim:

Complete the macro below and run it on the images in the folder 15.

Useful commands:

Your code starts after this line


// set the measurements here 

path = getDirectory("Input directory");			// Ask the user for the input directory
print("\\Clear");
print("batch measure nuclei started");
setBatchMode(true);
files = getFileList(path);						// get an array containing the names of all files in the directory path
File.mkdir(path + "out");						// create the output directory
for(i=0; i<files.length; i++) {					// iterate over all files
	image = files[i];							// get the name of the current file
	print("\\Update1: processing file " + (i+1) +"/" + files.length);
	if (indexOf(image, ".tif") != -1) {			// if the current file is a an image...
		open(path + image);
		// set the threshold here

		// run the particle analyzer here 

		save(path + "out/" + image);
		close();
	}
}
// Save the results table here 

Your code ends before this line

run("Close");
print("batch measure nuclei finished");

The code below is for automatically checking the result. Please ignore it!

ok = (nImages==0);
ok = (ok && File.exists(path+"/out"));
files = getFileList(path+"/out");
ok = (ok && files.length==4);
if (ok)
	showMessage("That's right. Great, you did it!");
else 
	showMessage("Your result is wrong! Please check your macro and try again!");

Previous            Solution            Next