@Override
    public List<Anomaly> detectAnomalies(Curve rectification) {

        List<Anomaly> result = new ArrayList<Anomaly>();
        long startAnomalyTime = -1;
        long endAnomalyTime = -1;
        long startPotentialAnomaly = -1;
        long endPotentialAnomaly = -1;
        for (Point point : createMeasuresCurve(rectification).getPoints()) {
            if (point.getValue() > verticalExtremalLevel) {
                // anomaly

                if (startPotentialAnomaly != -1) {
                    result.add(new Anomaly(startPotentialAnomaly, endPotentialAnomaly, Anomaly.AnomalyLevel.POTENTIAL));
                    startPotentialAnomaly = -1;
                }
                if (startAnomalyTime == -1) {
                    startAnomalyTime = point.getTime();
                }
                endAnomalyTime = point.getTime();
            } else if (point.getValue() > verticalPotentialLevel) {
                // potential anomaly

                if (startAnomalyTime != -1) {
                    result.add(new Anomaly(startAnomalyTime, endAnomalyTime, Anomaly.AnomalyLevel.ANOMALY));
                    startAnomalyTime = -1;
                }

                if (startPotentialAnomaly == -1) {
                    startPotentialAnomaly = point.getTime();
                }
                endPotentialAnomaly = point.getTime();

            } else {
                // not anomaly

                if (startAnomalyTime != -1) {
                    result.add(new Anomaly(startAnomalyTime, endAnomalyTime, Anomaly.AnomalyLevel.ANOMALY));
                    startAnomalyTime = -1;
                }
                if (startPotentialAnomaly != -1) {
                    result.add(new Anomaly(startPotentialAnomaly, endPotentialAnomaly, Anomaly.AnomalyLevel.POTENTIAL));
                    startPotentialAnomaly = -1;
                }
            }
        }

        return result;
    }