public static int[] getCommonRangeIndicies(IDataset x1, IDataset x2) {
    // TODO checks for no overlap etc
    double max1 = x1.max().doubleValue();
    double min1 = x1.min().doubleValue();

    double max2 = x2.max().doubleValue();
    double min2 = x2.min().doubleValue();

    double max = max1 < max2 ? max1 : max2;
    double min = min1 > min2 ? min1 : min2;
    // TODO max needs to be 1 lower, min needs to be 1 higher
    int maxpos = ROISliceUtils.findPositionOfClosestValueInAxis(x1, max);
    int minpos = ROISliceUtils.findPositionOfClosestValueInAxis(x1, min);

    return new int[] {minpos + 1, maxpos - 1};
  }