static Dataset getLabelsFromLabels(Dataset xl, RectangularROI bounds, int axisIndex) { try { int fromIndex = (int) bounds.getPoint()[axisIndex]; int toIndex = (int) bounds.getEndPoint()[axisIndex]; int step = toIndex > fromIndex ? 1 : -1; final Dataset slice = xl.getSlice(new int[] {fromIndex}, new int[] {toIndex}, new int[] {step}); return slice; } catch (Exception ne) { return null; } }