use of uk.ac.sussex.gdsc.core.utils.rng.SplitMix in project GDSC-SMLM by aherbert.
the class ImageJ3DResultsViewer method getPoints.
/**
* Gets the points.
*
* @param results the results
* @param settings the settings
* @return the points
*/
static LocalList<Point3f> getPoints(MemoryPeakResults results, ImageJ3DResultsViewerSettingsOrBuilder settings) {
final LocalList<Point3f> points = new LocalList<>(results.size());
if (results.is3D()) {
results.forEach(DistanceUnit.NM, (XyzResultProcedure) (x, y, z) -> {
points.push(new Point3f(x, y, z));
});
} else {
results.forEach(DistanceUnit.NM, (XyResultProcedure) (x, y) -> {
points.push(new Point3f(x, y, 0));
});
final double range = settings.getDepthRange();
if (range > 0 && results.size() > 1) {
final DepthMode mode = DepthMode.forNumber(settings.getDepthMode());
final double min = -settings.getDepthRange() / 2;
switch(mode) {
case DITHER:
final SplitMix r = SplitMix.new64(settings.getDitherSeed());
for (int i = points.size(); i-- > 0; ) {
points.unsafeGet(i).z += (min + r.nextDouble() * range);
}
break;
case INTENSITY:
// Rank by intensity, highest first
final StandardResultProcedure p = new StandardResultProcedure(results);
p.getI();
final int[] indices = SimpleArrayUtils.natural(results.size());
SortUtils.sortIndices(indices, p.intensity, true);
final double inc = range / indices.length;
for (int i = 0; i < indices.length; i++) {
// The standard rendering has +z going away so put the highest rank at min
points.unsafeGet(indices[i]).z += (min + i * inc);
}
break;
case NONE:
break;
default:
throw new IllegalStateException("Unknown depth mode: " + mode);
}
}
}
return points;
}
use of uk.ac.sussex.gdsc.core.utils.rng.SplitMix in project GDSC-SMLM by aherbert.
the class PeakResultTableModelFrameDemo method main.
/**
* Launch the application.
*
* @param args the arguments
*/
public static void main(String[] args) {
final SplitMix r = SplitMix.new64(System.currentTimeMillis());
final int n = 20;
final ListSelectionModel selectionModel = new DefaultListSelectionModel();
EventQueue.invokeLater((Runnable) () -> {
try {
final PeakResultStoreList store = new ArrayPeakResultStore(10);
for (int i = n; i-- > 0; ) {
store.add(new PeakResult(r.nextInt(), r.nextInt(), r.nextInt(), r.nextFloat(), r.nextDouble(), r.nextFloat(), r.nextFloat(), PeakResult.createParams(r.nextFloat(), r.nextFloat(), r.nextFloat(), r.nextFloat(), r.nextFloat()), null));
}
final CalibrationWriter cw = new CalibrationWriter();
cw.setNmPerPixel(100);
cw.setCountPerPhoton(10);
cw.setDistanceUnit(DistanceUnit.PIXEL);
cw.setIntensityUnit(IntensityUnit.COUNT);
final ResultsTableSettings.Builder tableSettings = ResultsTableSettings.newBuilder();
tableSettings.setDistanceUnit(DistanceUnit.NM);
tableSettings.setIntensityUnit(IntensityUnit.PHOTON);
tableSettings.setShowFittingData(true);
tableSettings.setShowNoiseData(true);
tableSettings.setShowPrecision(true);
tableSettings.setRoundingPrecision(4);
final PeakResultTableModel model = new PeakResultTableModel(store, cw.getCalibration(), null, tableSettings.build());
final PeakResultTableModelFrame d = new PeakResultTableModelFrame(model, null, selectionModel);
d.setTitle("D");
d.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
d.setVisible(true);
// Selecting in one list activates the other list
final PeakResultTableModelFrame d2 = new PeakResultTableModelFrame(model, null, selectionModel);
d2.setTitle("D2");
// Since we have the same selection model we need the same row sorter,
// otherwise the selection is scrambled by sorting.
// The alternative would be to get the source for the selection event (the table)
// and get the row sorter to do the mapping.
// However this breaks deletion of data as the row sorter double processes the deletion.
// Basically only one table can use the same selection model when sorting is desired.
// d2.table.setRowSorter(d.table.getRowSorter())
d2.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
d2.setVisible(true);
} catch (final Exception ex) {
ex.printStackTrace();
}
});
}
Aggregations