ij-macro-programming-workshop

Previous            Solution            Next

Exercise 18.1 - Show the rois of selected measurements

Aim:

Open the image from the folder images/17 in ImageJ! Manually use the Threshold-Adjuster and the Particle-Analyzer to add the rois of the nuclei to the roi-manager! Measure the rois in the roi-manager! Select a number of lines in the results table before running the macro!

Complete the macro below, that will create a selection on the image from the measurements selected in the results table.

After running the macro deselect the Show all option of the roi-manager to be able to see the selected result rois.

String.copyResults();				// Copies the result table into the clipboard
selection = String.paste;			// String.paste answers the content of the clipboard
// Your code starts after this line
lines = // split the content of selection by the newline character "\n" 
indices = newArray(0);				// This array is initially empty. It will contain the indices of the rois that
									// correspond to the selected measurements.
for(i=0; i<lines.length; i++) {		// For each line in the results table...
	line = lines[i];				// Get the ith line
	columns = // split the line into its columns by using the tabulator ("\t" ) 
	index = parseInt(columns[0]) - 1;	// Get the value of column 0 which contains the line-number of the measurement
										// Indices in the roi-manager start with 0, those written in the result table with 1
	indices = Array.concat(indices, index);	// Append the new index to the array indices.
}
// Select the indices in the roi-manager
if (indices.length>1) // If multiple rois are selected, use the combine command of the roi-manager to show them

Your code ends before this line

Previous            Solution            Next