imcflibs.imagej.resultstable

Functions to work with results tables.

 1"""Functions to work with results tables."""
 2
 3from ij.measure import ResultsTable
 4
 5
 6def preset_results_column(results_table, column, value):
 7    """Pre-set all rows in given column of the ResultsTable with desired values.
 8
 9    Parameters
10    ----------
11    results_table : ij.measure.ResultsTable
12        a reference of the IJ-ResultsTable
13    column : str
14        the desired column. will be created if it does not yet exist
15    value : str, float or int
16        the value to be set
17    """
18    for i in range(results_table.size()):
19        results_table.setValue(column, i, value)
20
21    results_table.show("Results")
22
23
24def add_results_to_resultstable(results_table, column, values):
25    """Add values to the ResultsTable starting from row 0 of a given column.
26
27    Parameters
28    ----------
29    results_table : ij.measure.ResultsTable
30        a reference of the IJ-ResultsTable
31    column : string
32        the column in which to add the values
33    values : list(int, double or float)
34        array with values to be added
35    """
36    for index, value in enumerate(values):
37        results_table.setValue(column, index, value)
38
39    results_table.show("Results")
40
41
42def get_resultstable():
43    """Instantiate or get the ResultsTable instance.
44
45    Use to either get the current instance of the IJ ResultsTable or instantiate
46    it if it does not yet exist.
47
48    Returns
49    -------
50    ij.measure.ResultsTable
51        A reference of the IJ-ResultsTable
52    """
53    rt = ResultsTable.getInstance()
54    if not rt:
55        rt = ResultsTable()
56    return rt
def preset_results_column(results_table, column, value):
 7def preset_results_column(results_table, column, value):
 8    """Pre-set all rows in given column of the ResultsTable with desired values.
 9
10    Parameters
11    ----------
12    results_table : ij.measure.ResultsTable
13        a reference of the IJ-ResultsTable
14    column : str
15        the desired column. will be created if it does not yet exist
16    value : str, float or int
17        the value to be set
18    """
19    for i in range(results_table.size()):
20        results_table.setValue(column, i, value)
21
22    results_table.show("Results")

Pre-set all rows in given column of the ResultsTable with desired values.

Parameters
  • results_table (ij.measure.ResultsTable): a reference of the IJ-ResultsTable
  • column (str): the desired column. will be created if it does not yet exist
  • value (str, float or int): the value to be set
def add_results_to_resultstable(results_table, column, values):
25def add_results_to_resultstable(results_table, column, values):
26    """Add values to the ResultsTable starting from row 0 of a given column.
27
28    Parameters
29    ----------
30    results_table : ij.measure.ResultsTable
31        a reference of the IJ-ResultsTable
32    column : string
33        the column in which to add the values
34    values : list(int, double or float)
35        array with values to be added
36    """
37    for index, value in enumerate(values):
38        results_table.setValue(column, index, value)
39
40    results_table.show("Results")

Add values to the ResultsTable starting from row 0 of a given column.

Parameters
  • results_table (ij.measure.ResultsTable): a reference of the IJ-ResultsTable
  • column (string): the column in which to add the values
  • values (list(int, double or float)): array with values to be added
def get_resultstable():
43def get_resultstable():
44    """Instantiate or get the ResultsTable instance.
45
46    Use to either get the current instance of the IJ ResultsTable or instantiate
47    it if it does not yet exist.
48
49    Returns
50    -------
51    ij.measure.ResultsTable
52        A reference of the IJ-ResultsTable
53    """
54    rt = ResultsTable.getInstance()
55    if not rt:
56        rt = ResultsTable()
57    return rt

Instantiate or get the ResultsTable instance.

Use to either get the current instance of the IJ ResultsTable or instantiate it if it does not yet exist.

Returns
  • ij.measure.ResultsTable: A reference of the IJ-ResultsTable