Package systole.domain.signals

Examples of systole.domain.signals.Segment


     *
     * @param segments list of segment selected
     * @return the final segment
     */
    public Segment process(Collection<SelectedSegment> segments) {
        Segment finalSegment = new Segment();
        int amountOfSements = segments.size();
         Iterator<SelectedSegment> it = segments.iterator();
         int minAmount = Integer.MAX_VALUE;
         while(it.hasNext()){
         int current = it.next().getSegment().size();
         minAmount = (minAmount>current)?current:minAmount;
         }
        int j = 0;
        BigDecimal prom;
        while ((minAmount>j)) {
            prom = BigDecimal.ZERO;
            Iterator<SelectedSegment> itSegments = segments.iterator();
            while (itSegments.hasNext()) {
                SelectedSegment selectedSegment = itSegments.next();
                if ((selectedSegment.getSegment().size() > j)) {
                    prom = prom.add(selectedSegment.getSegment().elementAt(j));
                }
            }
            finalSegment.add(prom.divide(new BigDecimal(amountOfSements),MathUtils.CONTEXT));
            j++;
        }
        finalSegment = finalSegment.removeTrend();
        return finalSegment;
    }
View Full Code Here


    private Segment obtainNextSegment(Segment rawSignal, Integer initPos) {
        int initOfActalSegment = this.obtainTheStartOfSegment(rawSignal,
                initPos);
        int endOfActualSegment = this.obtainTheEndOfSegment(rawSignal, initOfActalSegment + this.maxLengthOfSegment);//initOfActalSegment+this.maxLengthOfSegment;
        Segment segment = rawSignal.subSegment(initOfActalSegment,
                endOfActualSegment);       
        segment = segment.normalize();
        int posOfMax = segment.getPosOfMax();
        int fiftyPos = segment.looksPositionOfNearestValueOnSubSegment(fifty, 0, posOfMax);
        int dif = fiftyPos - 10;
        if (dif > 0) {
            segment = segment.subSegment(dif, endOfActualSegment);
        } else if (dif < 0) {
            BigDecimal firstValue = segment.get(0);
            while (dif != 0) {
                segment.add(0, firstValue);
                dif++;
            }
        }
        segment = segment.normalize();
        return segment;
    }
View Full Code Here

     * @return Signal
     */
    public Signal sliceSignal(Segment rawSignal) {
        Signal processed = new Signal();
        int relativeInitOfSegment = this.initOfSegment;
        Segment segment;
        int i = 0;
        while (relativeInitOfSegment < rawSignal.size()) {
            segment = this.obtainNextSegment(rawSignal, relativeInitOfSegment);
            processed.getSegments().add(segment);
            relativeInitOfSegment = relativeInitOfSegment + segment.size() + this.offset;
            i++;
        }
        return processed;
    }
View Full Code Here

     * @param settings
     * @return pulse wave filtered
     */
    public static Segment filterPulseWave(Segment rawSignal, FilterSettings settings){

        Segment filtered = rawSignal;

        int maxIterations = settings.getDefaultIterations();
        Filter filt = settings.getFilt();
        FilterConfiguration fConfig = settings.getFConfig();
        FilterAlgorithm fAlg = settings.getFAlg();
View Full Code Here

                freqResponse[i] += data[i+j]*coeffs[j];
            }

        }

        return new Segment(freqResponse);
   
    }
View Full Code Here

                + this.finalSignal.getSecondDerivative().getPosOfMax(this.posOfMax + BEGIN_OF_WINDOW_TIME_FOR_DIASTOLE, this.posOfMax + END_OF_WINDOW_TIME_FOR_DIASTOLE);
    }

    private int obtainIntersection(Segment firstSegment, Segment SecondSegment, int init) {
        int intersection = init;
        Segment majorSegment;
        Segment minorSegment;
        if ((init >= firstSegment.size()) || (init >= SecondSegment.size())) {
            return init;
        }
        if ((firstSegment.elementAt(init).doubleValue()) > (SecondSegment.elementAt(init).doubleValue())) {
            majorSegment = firstSegment;
            minorSegment = SecondSegment;
        } else {
            minorSegment = firstSegment;
            majorSegment = SecondSegment;
        }

        while (((majorSegment.size() > intersection) && (minorSegment.size() > intersection)) && (majorSegment.elementAt(intersection).doubleValue() > minorSegment.elementAt(intersection).doubleValue())) {
            intersection++;
        }

        return intersection;
    }
View Full Code Here

    }

    @SuppressWarnings("unused")
    private int obtainIntersectionDownTo(Segment firstSegment, Segment SecondSegment, int endPos) {
        int intersection = endPos;
        Segment majorSegment;
        Segment minorSegment;
        if ((endPos >= firstSegment.size()) || (endPos >= SecondSegment.size())) {
            return endPos;
        }
        if ((firstSegment.elementAt(endPos).doubleValue()) > (SecondSegment.elementAt(endPos).doubleValue())) {
            majorSegment = firstSegment;
            minorSegment = SecondSegment;
        } else {
            minorSegment = firstSegment;
            majorSegment = SecondSegment;
        }

        while (((majorSegment.size() > intersection) && (minorSegment.size() > intersection)) && (majorSegment.elementAt(intersection).doubleValue() > minorSegment.elementAt(intersection).doubleValue())) {
            intersection--;
        }

        return intersection;
    }
View Full Code Here

        if (file == null) {
            throw new ExceptionIO("Archivo inálido");
        }

        Segment points = new Segment();
        String cadena = "";
        BigDecimal value;
        int currentLine = 1;
        try {
            this.fileReader = new FileReader(file);
            BufferedReader bf = new BufferedReader(this.fileReader);
            while ((cadena = (bf.readLine())) != null) {
                value = new BigDecimal(new Double(cadena),MathUtils.CONTEXT);
                points.add(value);
                currentLine++;
            }
            this.fileReader.close();
            return points;
        } catch (IOException e) {
View Full Code Here

  public Segment readFile(String path) throws ExceptionIO {

        if (path == null) {
            throw new ExceptionIO("Path inválido");
        }
        Segment points = new Segment();
        String cadena = "";
        BigDecimal value;
        int currentLine = 1;
        try {
            this.fileReader = new FileReader(path);
            BufferedReader bf = new BufferedReader(this.fileReader);
            while ((cadena = (bf.readLine())) != null) {
                value = new BigDecimal(new Double(cadena),MathUtils.CONTEXT);
                points.add(value);
                currentLine++;
            }
            this.fileReader.close();
            return points;
        } catch (IOException e) {
View Full Code Here

        }
        return result;
    }

    private Segment stringToSegment(String points) {
        Segment segment = new Segment();
        if (points != null) {
            StringTokenizer parser = new StringTokenizer(points, "|", false);
            while (parser.hasMoreElements()) {
                segment.add(new BigDecimal(parser.nextToken()));
            }
        }
        return segment;
    }
View Full Code Here

TOP

Related Classes of systole.domain.signals.Segment

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.