Java Code Examples for ij.measure.ResultsTable#getCounter()

The following examples show how to use ij.measure.ResultsTable#getCounter() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ResultsBuilder.java    From MorphoLibJ with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Add a results table to the already existing table.
 * @param rt table to add
 * @return current results builder
 */
public ResultsBuilder addResult (ResultsTable rt) {
	// Keep the label and everything in the same order as before, but just append whatever columns do not exist yet
	if(allResults.size() == rt.size() ) {
		for(int c=0; c<=rt.getLastColumn(); c++) {
			String colName = rt.getColumnHeading(c);
			if( !allResults.columnExists(colName)) {
				for(int i=0; i<rt.getCounter(); i++) {
					allResults.setValue(colName, i, rt.getValue(colName, i)); // Currently only supports numbered results...
				}
			}
		}
	} else { // Overwrite
		this.allResults = rt;
	}
	
	return this;
}
 
Example 2
Source File: LabelImages.java    From MorphoLibJ with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Get the false negative error between two label images (source and target)
 * per each individual labeled region.
 * <p>
 * False Negative Error (for each individual labeled region r) $FN_r = \frac{ |T_r \setminus S_r| }{ |T_r| }$.
 * @param sourceImage source label image
 * @param targetImage target label image
 * @return false negative error per label or null if error
 * @see <a href="http://www.insight-journal.org/browse/publication/707">http://www.insight-journal.org/browse/publication/707</a>
 */
public static final ResultsTable getFalseNegativeErrorPerLabel(
		ImageProcessor sourceImage,
		ImageProcessor targetImage )
{
	if( sourceImage.getWidth() != targetImage.getWidth() ||
			sourceImage.getHeight() != targetImage.getHeight() )
		return null;

	ResultsTable toTable = LabelImages.getTargetOverlapPerLabel( sourceImage, targetImage );
	// create data table
 		ResultsTable fneTable = new ResultsTable();
 		for (int i = 0; i < toTable.getCounter(); i++) {
 			fneTable.incrementCounter();
 			fneTable.addLabel( toTable.getLabel( i ) );
 			fneTable.addValue( "FalseNegativeError", 1.0 - toTable.getValue("TargetOverlap", i) );
 		}
 	    return fneTable;
}
 
Example 3
Source File: LabelImages.java    From MorphoLibJ with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Get the false negative error between two label images (source and target)
 * per each individual labeled region.
 * <p>
 * False Negative Error (for each individual labeled region r) $FN_r = \frac{ |T_r \setminus S_r| }{ |T_r| }$.
 * @param sourceImage source label image
 * @param targetImage target label image
 * @return false negative error per label or null if error
 * @see <a href="http://www.insight-journal.org/browse/publication/707">http://www.insight-journal.org/browse/publication/707</a>
 */
public static final ResultsTable getFalseNegativeErrorPerLabel(
		ImageStack sourceImage,
		ImageStack targetImage )
{
	ResultsTable toTable = LabelImages.getTargetOverlapPerLabel( sourceImage, targetImage );
	// create data table
 		ResultsTable fneTable = new ResultsTable();
 		for (int i = 0; i < toTable.getCounter(); i++) {
 			fneTable.incrementCounter();
 			fneTable.addLabel( toTable.getLabel( i ) );
 			fneTable.addValue( "FalseNegativeError", 1.0 - toTable.getValue("TargetOverlap", i) );
 		}
 	    return fneTable;
}
 
Example 4
Source File: InteractivePlotter.java    From Scripts with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Generates abscissae from row numbers of the specified ResultsTable.
 * Useful for datasets in which only Y-values need to be plotted.
 */
private double[] generateX(final ResultsTable table) {
	final int size = table.getCounter();
	final double[] incX = new double[size];
	for (int i = 0; i < size; i++)
		incX[i] = i;
	return incX;
}
 
Example 5
Source File: Utils.java    From Scripts with GNU General Public License v3.0 4 votes vote down vote up
/** Checks if table in the "Results" window contains valid data */
private static boolean validResultsTable() {
	final ResultsTable rt = ResultsTable.getResultsTable();
	return (ResultsTable.getResultsWindow() != null && rt != null && rt.getCounter() != 0);
}
 
Example 6
Source File: Utils.java    From Scripts with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Opens a tab or comma delimited text file.
 *
 * @param path
 *            The absolute pathname string of the file. A file open dialog
 *            is displayed if path is {@code null} or an empty string.
 * @param title
 *            The title of the window in which data is displayed. The
 *            filename is used if title is null or an empty string. To avoid
 *            windows with duplicated titles, title is made unique by
 *            {@link WindowManager} .
 * @param listener
 *            The {@link WindowListener} to be added to the window
 *            containing data if retrieval was successful. It is ignored
 *            when {@code null}.
 * @throws IOException
 *             if file could not be opened
 * @return A reference to the opened {link ResultsTable} or {@code null} if
 *         table was empty.
 *
 * @see #getTable()
 * @see ij.io.Opener#openTable(String)
 */
public static ResultsTable openAndDisplayTable(final String path, final String title, final WindowListener listener)
		throws IOException {
	ResultsTable rt = null;
	rt = ResultsTable.open(path);
	if (rt == null || rt.getCounter() == 0) // nothing to be displayed
		return null;
	rt.showRowNumbers(false);
	String rtTitle = (title != null && !title.isEmpty()) ? title : OpenDialog.getLastName();
	rtTitle = WindowManager.makeUniqueName(rtTitle);
	rt.show(rtTitle);
	final TextWindow rtWindow = (TextWindow) WindowManager.getFrame(rtTitle);
	if (rtWindow != null && listener != null)
		rtWindow.addWindowListener(listener);
	return rt;
}
 
Example 7
Source File: Utils.java    From Scripts with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Returns a reference to the default IJ Results table. It the Results table
 * is not displayed or is empty, prompts the user for data to populate it
 * (by using {@link #getTable(boolean, WindowListener)} to display data in
 * the "Results" window). This method is thought for IJ macros, since the IJ
 * macro language can only interact with the "Results" window. Note that any
 * previous data in the "Results" window will be lost.
 *
 * @return A reference to the populated {@code ResultsTable} in the
 *         "Results" window or {@code null} if chosen source did not contain
 *         valid data. Note that the IJ1 macro interpreter converts all
 *         returned objects into their String values
 *
 * @see #getTable()
 */
public static ResultsTable getResultsTable() {
	try {
		ResultsTable table = ResultsTable.getResultsTable();
		if (table == null || table.getCounter() == 0)
			table = getTable(true, null);
		return table;
	} catch (final Exception ignored) { // useful for IJM calls
		return null;
	}
}