private void extractContextNormAttributes(Region r, ContextFrame window) {
    Double max = window.getMax();
    Double min = window.getMin();
    Double mean = window.getMean();
    Double stdev = window.getStdev();

    String context_feature_prefix = attribute_name + "_" + context.getLabel();
    String stored_feature_prefix = attribute_name + "__";

    if (r.getAttribute(attribute_name) instanceof Double) {
      Double value = (Double) r.getAttribute(attribute_name);
      // Z Score
      if (Math.abs(stdev) > EPSILON) {
        r.setAttribute(context_feature_prefix + "__zNorm", (value - mean) / stdev);
      }
      // Range Normalization
      if ((max - min) > EPSILON) {
        r.setAttribute(context_feature_prefix + "__rNorm", (value - min) / (max - min));
      }
    } else if (r.getAttribute(attribute_name) instanceof Contour) {
      // Calculate Z Score normalization
      if (Math.abs(stdev) > EPSILON) {
        if (r.hasAttribute(stored_feature_prefix + "min"))
          r.setAttribute(context_feature_prefix + "__zMin", (
              (Double) r.getAttribute(stored_feature_prefix + "min") - mean) / stdev);
        if (r.hasAttribute(stored_feature_prefix + "max"))
          r.setAttribute(context_feature_prefix + "__zMax", (
              (Double) r.getAttribute(stored_feature_prefix + "max") - mean) / stdev);
        if (r.hasAttribute(stored_feature_prefix + "mean"))
          r.setAttribute(context_feature_prefix + "__zMean", (
              (Double) r.getAttribute(stored_feature_prefix + "mean") - mean) / stdev);
      }
    }
  }