Search in sources :

Example 36 with LocalList

use of uk.ac.sussex.gdsc.core.utils.LocalList in project GDSC-SMLM by aherbert.

the class Shape3DHelper method createSolidOutline.

/**
 * Creates the solid with the defined faces and vertices on a unit sphere.
 *
 * @param vertices the vertices
 * @param normalise the normalise
 * @return the list of vertices for the triangles
 */
private static List<Point3f> createSolidOutline(float[][] vertices, boolean normalise) {
    final List<Point3f> ps = new LocalList<>();
    for (int i = 0; i < vertices.length; i++) {
        ps.add(new Point3f(vertices[i]));
    }
    // Make continuous
    ps.add(new Point3f(vertices[0]));
    if (normalise) {
        normalise(ps);
    }
    return ps;
}
Also used : LocalList(uk.ac.sussex.gdsc.core.utils.LocalList) Point3f(org.scijava.vecmath.Point3f)

Example 37 with LocalList

use of uk.ac.sussex.gdsc.core.utils.LocalList in project GDSC-SMLM by aherbert.

the class CustomContentHelper method createIndexedObject.

/**
 * Creates an indexed object from a list of triangle vertices.
 *
 * @param list the list of triangle vertices
 * @return the vertices and faces of the the object
 */
public static Pair<Point3f[], int[]> createIndexedObject(List<Point3f> list) {
    // Compact the vertices to a set of vertices and faces
    final TObjectIntHashMap<Point3f> map = new TObjectIntHashMap<>(list.size(), 0.5f, -1);
    final LocalList<Point3f> vertices = new LocalList<>(list.size());
    final TIntArrayList faces = new TIntArrayList(list.size());
    int index = 0;
    // Process triangles
    for (int i = 0; i < list.size(); i += 3) {
        index = addFace(map, vertices, faces, list.get(i), index);
        index = addFace(map, vertices, faces, list.get(i + 1), index);
        index = addFace(map, vertices, faces, list.get(i + 2), index);
    }
    return Pair.of(vertices.toArray(new Point3f[0]), faces.toArray());
}
Also used : LocalList(uk.ac.sussex.gdsc.core.utils.LocalList) Point3f(org.scijava.vecmath.Point3f) TObjectIntHashMap(gnu.trove.map.hash.TObjectIntHashMap) TIntArrayList(gnu.trove.list.array.TIntArrayList)

Example 38 with LocalList

use of uk.ac.sussex.gdsc.core.utils.LocalList in project GDSC-SMLM by aherbert.

the class ItemMesh method createGeometryArray.

/**
 * Creates the geometry array.
 *
 * @param sourceGa the source geometry array
 * @param format the format
 * @return the geometry array
 */
protected GeometryArray createGeometryArray(GeometryArray sourceGa, int format) {
    // Create using reflection
    final GeometryArray ga;
    try {
        final Class<?> clazz = sourceGa.getClass();
        // clazz = clazz.asSubclass(clazz);
        final LocalList<Class<?>> paramTypes = new LocalList<>(4);
        final LocalList<Object> paramValues = new LocalList<>(4);
        paramTypes.add(int.class);
        paramTypes.add(int.class);
        paramValues.add(vertexCount * points.length);
        paramValues.add(vertexFormat | format);
        if (isIndexGeometryArray()) {
            paramTypes.add(int.class);
            paramValues.add(indexCount * points.length);
        }
        // Handle strips
        int numStrips = 0;
        int[] objectStripCounts = null;
        int[] allStripCounts = null;
        if (sourceGa instanceof IndexedGeometryStripArray) {
            final IndexedGeometryStripArray igsa = (IndexedGeometryStripArray) sourceGa;
            numStrips = igsa.getNumStrips();
            objectStripCounts = new int[numStrips];
            igsa.getStripIndexCounts(objectStripCounts);
        } else if (sourceGa instanceof GeometryStripArray) {
            final GeometryStripArray gsa = (GeometryStripArray) sourceGa;
            numStrips = gsa.getNumStrips();
            objectStripCounts = new int[numStrips];
            gsa.getStripVertexCounts(objectStripCounts);
        }
        if (objectStripCounts != null) {
            allStripCounts = new int[numStrips * points.length];
            duplicate(objectStripCounts, 0, numStrips, points.length, allStripCounts, 0);
            paramTypes.add(int[].class);
            paramValues.add(allStripCounts);
        }
        final Class<?>[] paramTypes2 = paramTypes.toArray(new Class<?>[0]);
        final Object[] paramValues2 = paramValues.toArray();
        ga = (GeometryArray) clazz.getConstructor(paramTypes2).newInstance(paramValues2);
    } catch (final Exception ex) {
        ex.printStackTrace();
        return null;
    }
    ga.setCapability(GeometryArray.ALLOW_COUNT_WRITE);
    ga.setCapability(GeometryArray.ALLOW_COUNT_READ);
    ga.setCapability(GeometryArray.ALLOW_FORMAT_READ);
    ga.setCapability(Geometry.ALLOW_INTERSECT);
    return ga;
}
Also used : IndexedGeometryArray(org.scijava.java3d.IndexedGeometryArray) GeometryArray(org.scijava.java3d.GeometryArray) NotImplementedException(uk.ac.sussex.gdsc.core.data.NotImplementedException) LocalList(uk.ac.sussex.gdsc.core.utils.LocalList) IndexedGeometryStripArray(org.scijava.java3d.IndexedGeometryStripArray) GeometryStripArray(org.scijava.java3d.GeometryStripArray) IndexedGeometryStripArray(org.scijava.java3d.IndexedGeometryStripArray)

Example 39 with LocalList

use of uk.ac.sussex.gdsc.core.utils.LocalList in project GDSC-SMLM by aherbert.

the class TcPalmAnalysis method createBurstLocalisations.

/**
 * Creates the burst localisations using the ranges of the current bursts.
 *
 * @param clusters the clusters
 * @param bursts the bursts
 * @return the burst localisations
 */
private static LocalList<LocalList<PeakResult>> createBurstLocalisations(LocalList<ClusterData> clusters, LocalList<int[]> bursts) {
    final LocalList<LocalList<PeakResult>> burstsLocalisations = new LocalList<>();
    // TODO: Make more efficient. Order clusters by frame and burst by frame
    // Do a single sweep over the clusters and extract the peaks within the burst ranges.
    bursts.forEach(range -> {
        final int min = range[0];
        final int max = range[1];
        final LocalList<PeakResult> list = new LocalList<>();
        // Build from the current selection
        clusters.forEach(cluster -> {
            cluster.results.forEach(peak -> {
                final int t = peak.getFrame();
                if (t >= min && t <= max) {
                    list.add(peak);
                }
            });
        });
        burstsLocalisations.add(list);
    });
    return burstsLocalisations;
}
Also used : LocalList(uk.ac.sussex.gdsc.core.utils.LocalList) Point(java.awt.Point) PeakResult(uk.ac.sussex.gdsc.smlm.results.PeakResult)

Example 40 with LocalList

use of uk.ac.sussex.gdsc.core.utils.LocalList in project GDSC-SMLM by aherbert.

the class TcPalmAnalysis method runBurstAnalysis.

/**
 * Run the burst analysis on the activation counts. Identifies continuous bursts of activations
 * that are connected within the dark time tolerance and above the minimum cluster size.
 *
 * @param settings the settings
 */
private static LocalList<int[]> runBurstAnalysis(TcPalmAnalysisSettings settings, CumulativeCountData data) {
    final LocalList<int[]> bursts = new LocalList<>();
    final int[] frames = data.frames;
    final int[] counts = data.counts;
    if (frames.length != 0) {
        final int gap = settings.getDarkTimeTolerance() + 1;
        final int size = settings.getMinClusterSize();
        int start = frames[0];
        int end = start;
        int count = counts[0];
        for (int i = 1; i < frames.length; i++) {
            final int t = frames[i];
            if (t - end > gap) {
                // Save the burst
                if (count >= size) {
                    bursts.add(new int[] { start, end });
                }
                start = end = t;
                count = counts[i];
            } else {
                end = t;
                count += counts[i];
            }
        }
        if (count >= size) {
            bursts.add(new int[] { start, end });
        }
    }
    return bursts;
}
Also used : LocalList(uk.ac.sussex.gdsc.core.utils.LocalList) Point(java.awt.Point)

Aggregations

LocalList (uk.ac.sussex.gdsc.core.utils.LocalList)70 PeakResult (uk.ac.sussex.gdsc.smlm.results.PeakResult)19 ExtendedGenericDialog (uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog)15 MemoryPeakResults (uk.ac.sussex.gdsc.smlm.results.MemoryPeakResults)14 ImagePlus (ij.ImagePlus)13 Point (java.awt.Point)13 Future (java.util.concurrent.Future)13 Plot (ij.gui.Plot)11 ExecutorService (java.util.concurrent.ExecutorService)11 WindowOrganiser (uk.ac.sussex.gdsc.core.ij.plugin.WindowOrganiser)11 TIntArrayList (gnu.trove.list.array.TIntArrayList)10 IJ (ij.IJ)10 PlugIn (ij.plugin.PlugIn)10 Rectangle (java.awt.Rectangle)10 AtomicReference (java.util.concurrent.atomic.AtomicReference)10 ImageJUtils (uk.ac.sussex.gdsc.core.ij.ImageJUtils)10 DistanceUnit (uk.ac.sussex.gdsc.smlm.data.config.UnitProtos.DistanceUnit)10 Color (java.awt.Color)9 Arrays (java.util.Arrays)9 Ticker (uk.ac.sussex.gdsc.core.logging.Ticker)9