Skip to contents

These functions are used to register new metrics in the segmetric database.

  • sm_list_metrics(): List all registered metrics.

  • sm_new_metric(): Create a new metric entry to be registered in the database.

  • sm_reg_metric(): Register a new metric in the database.

  • sm_unreg_metric(): Remove a metric entry from the database.

  • sm_desc_metric(): Describe a metric registered from the database.

Usage

.db_list()

.db_set(key, value)

.db_del(key)

.db_get(key)

sm_list_metrics()

sm_new_metric(
  fn,
  fn_subset,
  name = "",
  optimal = 0,
  summarizable = TRUE,
  description = "",
  reference = ""
)

sm_reg_metric(metric_id, entry)

sm_unreg_metric(metric_id)

sm_desc_metric(metric_id)

Arguments

fn

A function that receives a segmetric object and returns the metric values.

fn_subset

A function that returns a subset.

name

A character containing the metric name (Defaults to "").

description

A character containing a description of the metric (Defaults to "").

reference

A character with the reference to a scientific literature describing the metric.

metric_id

A character value containing a unique metric identification.

entry

A metric_entry object returned by new_metric() function.

Value

  • sm_list_metrics(): Return character vector with supported metrics.

  • sm_new_metric(): Return a metric_entry object containing the metric function (fn), name (name), description (description), and reference (reference).

  • sm_reg_metric(), sm_unreg_metric(): No return value, called to (un)register a metric.

  • sm_desc_metric(): No return value, called to print a metric description.

Examples

sm_reg_metric(
    metric_id = "Example",
    entry = sm_new_metric(
        fn = function(m, ...) {
            sm_area(sm_ytilde(m)) / 
                sm_area(sm_ref(m), order = sm_ytilde(m))
        },
        fn_subset = sm_ytilde,
        name = "Metric name example",
        description = paste("Values range from A to B.",
                            "Optimal value is C"),
        reference = "Author (Year)"
    ))

sm_desc_metric("Example")
#> * Example (Metric name example)
#>   Values range from A to B. Optimal value is C
#>   reference: Author (Year)
sm_list_metrics()
#>  [1] "AFI"       "D_index"   "Dice"      "E"         "ED3"       "Example"  
#>  [7] "F_measure" "Fitness"   "IoU"       "M"         "OI2"       "OMerging" 
#> [13] "OS1"       "OS2"       "OS3"       "PI"        "QR"        "RAsub"    
#> [19] "RAsuper"   "RPsub"     "RPsuper"   "SimSize"   "UMerging"  "US1"      
#> [25] "US2"       "US3"       "precision" "qLoc"      "recall"