Search in sources :

Example 1 with Pulse

use of gdsc.core.match.Pulse in project GDSC-SMLM by aherbert.

the class TraceMatchCalculator method addTripleResult.

private void addTripleResult(Triple triple) {
    StringBuilder sb = new StringBuilder();
    Pulse p1 = triple.p1;
    Pulse p2 = triple.p2;
    Pulse p3 = triple.p3;
    addPoint(sb, p1);
    addResult(sb, p1, p2);
    addResult(sb, p1, p3);
    triplesWindow.append(sb.toString());
}
Also used : Pulse(gdsc.core.match.Pulse)

Example 2 with Pulse

use of gdsc.core.match.Pulse in project GDSC-SMLM by aherbert.

the class TraceMatchCalculator method extractPulses.

private Pulse[] extractPulses(MemoryPeakResults results) {
    if (results == null)
        return null;
    Pulse[] pulses = new Pulse[results.size()];
    int i = 0;
    for (PeakResult p : results.getResults()) {
        pulses[i++] = new Pulse(p.getXPosition(), p.getYPosition(), p.getFrame(), p.getEndFrame());
    }
    return pulses;
}
Also used : Pulse(gdsc.core.match.Pulse) Point(java.awt.Point) PeakResult(gdsc.smlm.results.PeakResult)

Example 3 with Pulse

use of gdsc.core.match.Pulse in project GDSC-SMLM by aherbert.

the class TraceMatchCalculator method addPairResult.

private void addPairResult(PointPair pair) {
    StringBuilder sb = new StringBuilder();
    Pulse p1 = (Pulse) pair.getPoint1();
    Pulse p2 = (Pulse) pair.getPoint2();
    addPoint(sb, p1);
    addResult(sb, p1, p2);
    pairsWindow.append(sb.toString());
}
Also used : Pulse(gdsc.core.match.Pulse)

Example 4 with Pulse

use of gdsc.core.match.Pulse in project GDSC-SMLM by aherbert.

the class TraceMatchCalculator method compareCoordinates.

private void compareCoordinates(MemoryPeakResults results1, MemoryPeakResults results2, MemoryPeakResults results3, double dThreshold) {
    Pulse[] p1 = extractPulses(results1);
    Pulse[] p2 = extractPulses(results2);
    Pulse[] p3 = extractPulses(results3);
    List<Pulse> TP = null;
    List<Pulse> FP = null;
    List<Pulse> FN = null;
    List<PointPair> pairs = null;
    List<Pulse> TP2 = null;
    List<Pulse> FP2 = null;
    List<Pulse> FN2 = null;
    List<PointPair> pairs2 = null;
    if (showPairs) {
        pairs = new LinkedList<PointPair>();
        FP = new LinkedList<Pulse>();
        FN = new LinkedList<Pulse>();
        pairs2 = new LinkedList<PointPair>();
        FP2 = new LinkedList<Pulse>();
        FN2 = new LinkedList<Pulse>();
    }
    MatchResult result = MatchCalculator.analyseResults2D(p1, p2, dThreshold, TP, FP, FN, pairs);
    MatchResult result2 = MatchCalculator.analyseResults2D(p1, p3, dThreshold, TP2, FP2, FN2, pairs2);
    // Create output
    if (!java.awt.GraphicsEnvironment.isHeadless()) {
        if (resultsWindow == null || !resultsWindow.isShowing()) {
            resultsWindow = new TextWindow(TITLE + " Results", createResultsHeader(), "", 900, 300);
        }
        if (showPairs) {
            if (p3 == null) {
                // Produce a pairs output
                if (pairsWindow == null || !pairsWindow.isShowing()) {
                    pairsWindow = new TextWindow(TITLE + " Pairs", createPairsHeader(), "", 900, 300);
                    Point p = resultsWindow.getLocation();
                    p.y += resultsWindow.getHeight();
                    pairsWindow.setLocation(p);
                    pairPainter = new ImageROIPainter(pairsWindow.getTextPanel(), results1.getSource().getOriginal().getName(), this);
                }
                pairsWindow.getTextPanel().clear();
                pairPainter.setTitle(results1.getSource().getOriginal().getName());
                // Add the unmatched points
                for (Coordinate c : FN) pairs.add(new PointPair(c, null));
                for (Coordinate c : FP) pairs.add(new PointPair(null, c));
                List<? extends PointPair> sortedPairs = sort(pairs);
                for (PointPair pair : sortedPairs) addPairResult(pair);
            } else {
                // Produce a triple output
                if (triplesWindow == null || !triplesWindow.isShowing()) {
                    triplesWindow = new TextWindow(TITLE + " Triples", createTriplesHeader(), "", 900, 300);
                    Point p = resultsWindow.getLocation();
                    p.y += resultsWindow.getHeight();
                    triplesWindow.setLocation(p);
                    triplePainter = new ImageROIPainter(triplesWindow.getTextPanel(), results1.getSource().getName(), this);
                }
                triplesWindow.getTextPanel().clear();
                triplePainter.setTitle(results1.getSource().getOriginal().getName());
                HashMap<Pulse, Triple> map = new HashMap<Pulse, Triple>();
                ArrayList<Triple> triples = new ArrayList<Triple>(pairs.size());
                for (PointPair pair : pairs) {
                    Pulse p = (Pulse) pair.getPoint1();
                    Triple t = new Triple(p, (Pulse) pair.getPoint2(), null);
                    triples.add(t);
                    map.put(p, t);
                }
                // Complete the reference set of points
                for (Coordinate c : FN) {
                    Pulse p = (Pulse) c;
                    Triple t = new Triple(p, null, null);
                    triples.add(t);
                    map.put(p, t);
                }
                // Add the unmatched points
                for (Coordinate c : FP) triples.add(new Triple(null, (Pulse) c, null));
                for (Coordinate c : FP2) triples.add(new Triple(null, null, (Pulse) c));
                // Add the results from the second match
                for (PointPair pair : pairs2) {
                    Pulse p = (Pulse) pair.getPoint1();
                    Pulse pp = (Pulse) pair.getPoint2();
                    Triple t = map.get(p);
                    if (t != null) {
                        t.p3 = pp;
                    } else {
                        triples.add(new Triple(null, null, pp));
                    }
                }
                List<? extends Triple> sortedTriples = sort(triples);
                for (Triple t : sortedTriples) addTripleResult(t);
            }
        }
    } else {
        if (writeHeader) {
            writeHeader = false;
            IJ.log(createResultsHeader());
        }
    }
    addResult(inputOption1, inputOption2, dThreshold, result);
    if (p3 != null)
        addResult(inputOption1, inputOption3, dThreshold, result2);
}
Also used : HashMap(java.util.HashMap) Pulse(gdsc.core.match.Pulse) ArrayList(java.util.ArrayList) Point(java.awt.Point) MatchResult(gdsc.core.match.MatchResult) TextWindow(ij.text.TextWindow) Coordinate(gdsc.core.match.Coordinate) PointPair(gdsc.core.match.PointPair) ImageROIPainter(gdsc.smlm.ij.utils.ImageROIPainter)

Aggregations

Pulse (gdsc.core.match.Pulse)4 Point (java.awt.Point)2 Coordinate (gdsc.core.match.Coordinate)1 MatchResult (gdsc.core.match.MatchResult)1 PointPair (gdsc.core.match.PointPair)1 ImageROIPainter (gdsc.smlm.ij.utils.ImageROIPainter)1 PeakResult (gdsc.smlm.results.PeakResult)1 TextWindow (ij.text.TextWindow)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1