code: def __averaged_mapping(perc_database, s1, s2):
      """
      Map the landmarks of the database to the chosen range
      :param perc_database: perc_database over which to perform the averaging
      :param s1, s2: limits of the mapping range
      :return final_map: the average mapping
      """
      # assuming shape: n_data_points = perc_database.shape[0]
      #                 n_percentiles = perc_database.shape[1]
      slope = (s2 - s1) / (perc_database[:, -1] - perc_database[:, 0])
      slope = np.nan_to_num(slope)
      final_map = slope.dot(perc_database) / perc_database.shape[0]
      intercept = np.mean(s1 - slope * perc_database[:, 0])
      final_map = final_map + intercept
      return final_map
  
file_path: NiftyNet/niftynet/utilities/histogram_standardisation.py
imports: from __future__ import absolute_import, print_function, division
  import os
  import numpy
  import numpy.ma
  import tensorflow
  from niftynet.io.misc_io import touch_folder
  from niftynet.utilities.util_common import look_up_operations, print_progress_bar
label_desc: Use image node_id 5 for calling a global function with example usage: __averaged_mapping(perc_database, s1, s2) and returns: final_map