class_docstr: This class defines a simple aggregator that groups metrics and applies an
  aggregating function. Grouping is determined by the set difference
  between an original `group_by` term and a subset `new_group_py` term.
class_docstr_tok: ["This","class","defines","a","simple","aggregator","that","groups","metrics","and","applies","an","aggregating","function",".","Grouping","is","determined","by","the","set","difference","between","an","original","`","group_by","`","term","and","a","subset","`","new_group_py","`","term","."]
docstr: :param key: metric heading name with values to aggregate
  :param group_by: level at which original metric was computed,
      e.g. ('subject_id', 'label')
  :param new_group_by: level at which metric after aggregation is
      computed, e.g. ('label')
  :param func: function (iterable=>scalar) to aggregate the collected
  values e.g., np.mean
  :param name: new heading name for the aggregated metric
docstr_tok: [":","param","key",":","metric","heading","name","with","values","to","aggregate",":","param","group_by",":","level","at","which","original","metric","was","computed",",","e.g",".","(","'subject_id","'",",","'label","'",")",":","param","new_group_by",":","level","at","which","metric","after","aggregation","is","computed",",","e.g",".","(","'label","'",")",":","param","func",":","function","(","iterable=",">","scalar",")","to","aggregate","the","collected","values","e.g.",",","np.mean",":","param","name",":","new","heading","name","for","the","aggregated","metric"]
code: def __init__(self, key, group_by, new_group_by, func, name):
      """
  
      :param key: metric heading name with values to aggregate
      :param group_by: level at which original metric was computed,
          e.g. ('subject_id', 'label')
      :param new_group_by: level at which metric after aggregation is
          computed, e.g. ('label')
      :param func: function (iterable=>scalar) to aggregate the collected
      values e.g., np.mean
      :param name: new heading name for the aggregated metric
      """
      self.key = key
      self.name = name
      self.group_by = group_by
      self.new_group_by = new_group_by
      self.scalar_func = func
      super(ScalarAggregator, self).__init__(
          group_by, self.scalar_wrapper_
      )
  
imports: from __future__ import absolute_import, division, print_function
  import itertools
  from itertools import groupby
  from collections import defaultdict
  import pandas
  from niftynet.engine.application_factory import EvaluationFactory
  from niftynet.utilities.util_common import cache
label_desc: Use image node_id 1 to create a new ScalarAggregator object from inherited base classes: DataFrameAggregator with example: obj = ScalarAggregator(key, group_by, new_group_by, func, name)