Search in sources :

Example 1 with TLongObjectHashMap

use of gnu.trove.map.hash.TLongObjectHashMap in project GDSC-SMLM by aherbert.

the class ResultsImageSampler method createResultSamples.

/**
	 * Creates the result samples.
	 * Do this by storing the coordinates at the region index.
	 */
private void createResultSamples() {
    TLongObjectHashMap<ResultsSample> map = new TLongObjectHashMap<ResultsSample>(results.size());
    ResultsSample next = ResultsSample.create(-1);
    for (PeakResult p : results) {
        // Avoid invalid slices
        if (p.getFrame() < 1 || p.getFrame() > stack.getSize())
            continue;
        long index = getIndex(p.getXPosition(), p.getYPosition(), p.getFrame());
        ResultsSample current = map.putIfAbsent(index, next);
        if (current == null) {
            // If the return value is null then this is a new insertion.
            // Set the current value as the one we just added and create the next insertion object.
            current = next;
            current.index = index;
            next = ResultsSample.create(-1);
        }
        current.add(p);
    }
    // Create an array of all the sample entries.
    // This is used to sample regions by density.
    data = new ResultsSample[map.size()];
    map.values(data);
}
Also used : TLongObjectHashMap(gnu.trove.map.hash.TLongObjectHashMap) PeakResult(gdsc.smlm.results.PeakResult)

Aggregations

PeakResult (gdsc.smlm.results.PeakResult)1 TLongObjectHashMap (gnu.trove.map.hash.TLongObjectHashMap)1