use of uk.ac.sussex.gdsc.smlm.model.LocalisationModel in project GDSC-SMLM by aherbert.
the class CreateData method showSummary.
private double showSummary(List<? extends FluorophoreSequenceModel> fluorophores, List<LocalisationModel> localisations) {
IJ.showStatus("Calculating statistics ...");
final Statistics[] stats = new Statistics[NAMES.length];
for (int i = 0; i < stats.length; i++) {
stats[i] = (settings.getShowHistograms() || alwaysRemoveOutliers[i]) ? new StoredDataStatistics() : new Statistics();
}
// Find the largest timepoint
final ImagePlus outputImp = WindowManager.getImage(benchmarkImageId);
int frameCount;
if (outputImp == null) {
sortLocalisationsByTime(localisations);
frameCount = localisations.get(localisations.size() - 1).getTime();
} else {
frameCount = outputImp.getStackSize();
}
final int[] countHistogram = new int[frameCount + 1];
// Use the localisations that were drawn to create the sampled on/off times
rebuildNeighbours(localisations);
// Assume that there is at least one localisation
final LocalisationModel first = localisations.get(0);
// The current localisation
int currentId = first.getId();
// The last time this localisation was on
int lastT = first.getTime();
// Number of blinks
int blinks = 0;
// On-time of current pulse
int currentT = 0;
double signal = 0;
final double centreOffset = settings.getSize() * 0.5;
// Used to convert the sampled times in frames into seconds
final double framesPerSecond = 1000.0 / settings.getExposureTime();
// final double gain = new CreateDataSettingsHelper(settings).getTotalGainSafe();
for (final LocalisationModel l : localisations) {
final double[] data = l.getData();
if (data == null) {
throw new IllegalStateException("No localisation data. This should not happen!");
}
final double noise = data[1];
final double sx = data[2];
final double sy = data[3];
final double intensityInPhotons = data[4];
// Q. What if the noise is zero, i.e. no background photon / read noise?
// Just ignore it at current. This is only an approximation to the SNR estimate
// if this is not a Gaussian spot.
final double snr = Gaussian2DPeakResultHelper.getMeanSignalUsingP05(intensityInPhotons, sx, sy) / noise;
stats[SIGNAL].add(intensityInPhotons);
stats[NOISE].add(noise);
if (noise != 0) {
stats[SNR].add(snr);
}
// if (l.isContinuous())
if (l.getNext() != null && l.getPrevious() != null) {
stats[SIGNAL_CONTINUOUS].add(intensityInPhotons);
if (noise != 0) {
stats[SNR_CONTINUOUS].add(snr);
}
}
final int id = l.getId();
// Check if this a new fluorophore
if (currentId != id) {
// Add previous fluorophore
stats[SAMPLED_BLINKS].add(blinks);
stats[SAMPLED_T_ON].add(currentT / framesPerSecond);
stats[TOTAL_SIGNAL].add(signal);
// Reset
blinks = 0;
currentT = 1;
currentId = id;
signal = intensityInPhotons;
} else {
signal += intensityInPhotons;
// Check if the current fluorophore pulse is broken (i.e. a blink)
if (l.getTime() - 1 > lastT) {
blinks++;
stats[SAMPLED_T_ON].add(currentT / framesPerSecond);
currentT = 1;
stats[SAMPLED_T_OFF].add(((l.getTime() - 1) - lastT) / framesPerSecond);
} else {
// Continuous on-time
currentT++;
}
}
lastT = l.getTime();
countHistogram[lastT]++;
stats[X].add((l.getX() - centreOffset) * settings.getPixelPitch());
stats[Y].add((l.getY() - centreOffset) * settings.getPixelPitch());
stats[Z].add(l.getZ() * settings.getPixelPitch());
}
// Final fluorophore
stats[SAMPLED_BLINKS].add(blinks);
stats[SAMPLED_T_ON].add(currentT / framesPerSecond);
stats[TOTAL_SIGNAL].add(signal);
// Samples per frame
for (int t = 1; t < countHistogram.length; t++) {
stats[SAMPLES].add(countHistogram[t]);
}
if (fluorophores != null) {
for (final FluorophoreSequenceModel f : fluorophores) {
stats[BLINKS].add(f.getNumberOfBlinks());
// On-time
for (final double t : f.getOnTimes()) {
stats[T_ON].add(t);
}
// Off-time
for (final double t : f.getOffTimes()) {
stats[T_OFF].add(t);
}
}
} else {
// show no blinks
stats[BLINKS].add(0);
stats[T_ON].add(1);
}
if (results != null) {
// Convert depth-of-field to pixels
final double depth = settings.getDepthOfField() / settings.getPixelPitch();
try {
// Get widths
final WidthResultProcedure wp = new WidthResultProcedure(results, DistanceUnit.PIXEL);
wp.getW();
stats[WIDTH].add(wp.wx);
} catch (final DataException ex) {
ImageJUtils.log("Unable to compute width: " + ex.getMessage());
}
try {
// Get z depth
final StandardResultProcedure sp = new StandardResultProcedure(results, DistanceUnit.PIXEL);
sp.getXyz();
// Get precision
final PrecisionResultProcedure pp = new PrecisionResultProcedure(results);
pp.getPrecision();
stats[PRECISION].add(pp.precisions);
for (int i = 0; i < pp.size(); i++) {
if (Math.abs(sp.z[i]) < depth) {
stats[PRECISION_IN_FOCUS].add(pp.precisions[i]);
}
}
} catch (final DataException ex) {
ImageJUtils.log("Unable to compute LSE precision: " + ex.getMessage());
}
// Compute density per frame. Multi-thread for speed
if (settings.getDensityRadius() > 0) {
final int threadCount = Prefs.getThreads();
final Ticker ticker = ImageJUtils.createTicker(results.getLastFrame(), threadCount, "Calculating density ...");
final ExecutorService threadPool = Executors.newFixedThreadPool(threadCount);
final List<Future<?>> futures = new LinkedList<>();
final TFloatArrayList coordsX = new TFloatArrayList();
final TFloatArrayList coordsY = new TFloatArrayList();
final Statistics densityStats = stats[DENSITY];
final float radius = (float) (settings.getDensityRadius() * getHwhm());
final Rectangle bounds = results.getBounds();
final double area = (double) bounds.width * bounds.height;
// Store the density for each result.
final int[] allDensity = new int[results.size()];
final FrameCounter counter = results.newFrameCounter();
results.forEach((PeakResultProcedure) result -> {
if (counter.advance(result.getFrame())) {
counter.increment(runDensityCalculation(threadPool, futures, coordsX, coordsY, densityStats, radius, area, allDensity, counter.getCount(), ticker));
}
coordsX.add(result.getXPosition());
coordsY.add(result.getYPosition());
});
runDensityCalculation(threadPool, futures, coordsX, coordsY, densityStats, radius, area, allDensity, counter.getCount(), ticker);
ConcurrencyUtils.waitForCompletionUnchecked(futures);
threadPool.shutdown();
ImageJUtils.finished();
// Split results into singles (density = 0) and clustered (density > 0)
final MemoryPeakResults singles = copyMemoryPeakResults("No Density");
final MemoryPeakResults clustered = copyMemoryPeakResults("Density");
counter.reset();
results.forEach((PeakResultProcedure) result -> {
final int density = allDensity[counter.getAndIncrement()];
result.setOrigValue(density);
if (density == 0) {
singles.add(result);
} else {
clustered.add(result);
}
});
}
}
final StringBuilder sb = new StringBuilder();
sb.append(datasetNumber).append('\t');
if (settings.getCameraType() == CameraType.SCMOS) {
sb.append("sCMOS (").append(settings.getCameraModelName()).append(") ");
final Rectangle bounds = cameraModel.getBounds();
sb.append(" ").append(bounds.x).append(",").append(bounds.y);
final int size = settings.getSize();
sb.append(" ").append(size).append("x").append(size);
} else if (CalibrationProtosHelper.isCcdCameraType(settings.getCameraType())) {
sb.append(CalibrationProtosHelper.getName(settings.getCameraType()));
final int size = settings.getSize();
sb.append(" ").append(size).append("x").append(size);
if (settings.getCameraType() == CameraType.EMCCD) {
sb.append(" EM=").append(settings.getEmGain());
}
sb.append(" CG=").append(settings.getCameraGain());
sb.append(" RN=").append(settings.getReadNoise());
sb.append(" B=").append(settings.getBias());
} else {
throw new IllegalStateException();
}
sb.append(" QE=").append(settings.getQuantumEfficiency()).append('\t');
sb.append(settings.getPsfModel());
if (psfModelType == PSF_MODEL_IMAGE) {
sb.append(" Image").append(settings.getPsfImageName());
} else if (psfModelType == PSF_MODEL_ASTIGMATISM) {
sb.append(" model=").append(settings.getAstigmatismModel());
} else {
sb.append(" DoF=").append(MathUtils.rounded(settings.getDepthOfFocus()));
if (settings.getEnterWidth()) {
sb.append(" SD=").append(MathUtils.rounded(settings.getPsfSd()));
} else {
sb.append(" λ=").append(MathUtils.rounded(settings.getWavelength()));
sb.append(" NA=").append(MathUtils.rounded(settings.getNumericalAperture()));
}
}
sb.append('\t');
sb.append((fluorophores == null) ? localisations.size() : fluorophores.size()).append('\t');
sb.append(stats[SAMPLED_BLINKS].getN() + (int) stats[SAMPLED_BLINKS].getSum()).append('\t');
sb.append(localisations.size()).append('\t');
sb.append(frameCount).append('\t');
sb.append(MathUtils.rounded(areaInUm)).append('\t');
sb.append(MathUtils.rounded(localisations.size() / (areaInUm * frameCount), 4)).append('\t');
sb.append(MathUtils.rounded(getHwhm(), 4)).append('\t');
double sd = getPsfSd();
sb.append(MathUtils.rounded(sd, 4)).append('\t');
sd *= settings.getPixelPitch();
final double sa = PsfCalculator.squarePixelAdjustment(sd, settings.getPixelPitch()) / settings.getPixelPitch();
sb.append(MathUtils.rounded(sa, 4)).append('\t');
// Width not valid for the Image PSF.
// Q. Is this true? We can approximate the FHWM for a spot-like image PSF.
final int nStats = (psfModelType == PSF_MODEL_IMAGE) ? stats.length - 1 : stats.length;
for (int i = 0; i < nStats; i++) {
final double centre = (alwaysRemoveOutliers[i]) ? ((StoredDataStatistics) stats[i]).getStatistics().getPercentile(50) : stats[i].getMean();
sb.append(MathUtils.rounded(centre, 4)).append('\t');
}
createSummaryTable().accept(sb.toString());
// Show histograms
if (settings.getShowHistograms() && !java.awt.GraphicsEnvironment.isHeadless()) {
IJ.showStatus("Calculating histograms ...");
final boolean[] chosenHistograms = getChoosenHistograms();
final WindowOrganiser wo = new WindowOrganiser();
final HistogramPlotBuilder builder = new HistogramPlotBuilder(TITLE);
for (int i = 0; i < NAMES.length; i++) {
if (chosenHistograms[i]) {
builder.setData((StoredDataStatistics) stats[i]).setName(NAMES[i]).setIntegerBins(integerDisplay[i]).setRemoveOutliersOption((settings.getRemoveOutliers() || alwaysRemoveOutliers[i]) ? 2 : 0).setNumberOfBins(settings.getHistogramBins()).show(wo);
}
}
wo.tile();
}
IJ.showStatus("");
return stats[SIGNAL].getMean();
}
use of uk.ac.sussex.gdsc.smlm.model.LocalisationModel in project GDSC-SMLM by aherbert.
the class CreateData method getIds.
private int[] getIds(List<LocalisationModel> localisations) {
if (localisations.isEmpty()) {
return new int[0];
}
final TIntArrayList ids = new TIntArrayList(settings.getParticles());
// Assume the localisations are sorted by id
int id = localisations.get(0).getId();
ids.add(id);
for (final LocalisationModel l : localisations) {
if (id != l.getId()) {
id = l.getId();
ids.add(id);
}
}
return ids.toArray();
}
use of uk.ac.sussex.gdsc.smlm.model.LocalisationModel in project GDSC-SMLM by aherbert.
the class CreateData method run.
@Override
public void run(String arg) {
SmlmUsageTracker.recordPlugin(this.getClass(), arg);
extraOptions = ImageJUtils.isExtraOptions();
simpleMode = (arg != null && arg.contains("simple"));
benchmarkMode = (arg != null && arg.contains("benchmark"));
spotMode = (arg != null && arg.contains("spot"));
trackMode = (arg != null && arg.contains("track"));
if ("load".equals(arg)) {
loadBenchmarkData();
return;
}
// Each localisation set is a collection of localisations that represent all localisations
// with the same ID that are on in the same image time frame (Note: the simulation
// can create many localisations per fluorophore per time frame which is useful when
// modelling moving particles)
List<LocalisationModelSet> localisationSets = null;
// Each fluorophore contains the on and off times when light was emitted
List<? extends FluorophoreSequenceModel> fluorophores = null;
if (simpleMode || benchmarkMode || spotMode) {
if (!showSimpleDialog()) {
return;
}
resetMemory();
// 1 second frames
settings.setExposureTime(1000);
areaInUm = settings.getSize() * settings.getPixelPitch() * settings.getSize() * settings.getPixelPitch() / 1e6;
// Number of spots per frame
int count = 0;
int[] nextN = null;
SpatialDistribution dist;
if (benchmarkMode) {
// --------------------
// BENCHMARK SIMULATION
// --------------------
// Draw the same point on the image repeatedly
count = 1;
dist = createFixedDistribution();
try {
reportAndSaveFittingLimits(dist);
} catch (final Exception ex) {
// This will be from the computation of the CRLB
IJ.error(TITLE, ex.getMessage());
return;
}
} else if (spotMode) {
// ---------------
// SPOT SIMULATION
// ---------------
// The spot simulation draws 0 or 1 random point per frame.
// Ensure we have 50% of the frames with a spot.
nextN = new int[settings.getParticles() * 2];
Arrays.fill(nextN, 0, settings.getParticles(), 1);
RandomUtils.shuffle(nextN, UniformRandomProviders.create());
// Only put spots in the central part of the image
final double border = settings.getSize() / 4.0;
dist = createUniformDistribution(border);
} else {
// -----------------
// SIMPLE SIMULATION
// -----------------
// The simple simulation draws n random points per frame to achieve a specified density.
// No points will appear in multiple frames.
// Each point has a random number of photons sampled from a range.
// We can optionally use a mask. Create his first as it updates the areaInUm
dist = createDistribution();
// Randomly sample (i.e. not uniform density in all frames)
if (settings.getSamplePerFrame()) {
final double mean = areaInUm * settings.getDensity();
ImageJUtils.log("Mean samples = %f", mean);
if (mean < 0.5) {
final GenericDialog gd = new GenericDialog(TITLE);
gd.addMessage("The mean samples per frame is low: " + MathUtils.rounded(mean) + "\n \nContinue?");
gd.enableYesNoCancel();
gd.hideCancelButton();
gd.showDialog();
if (!gd.wasOKed()) {
return;
}
}
final PoissonSampler poisson = new PoissonSampler(createRandomGenerator(), mean);
final StoredDataStatistics samples = new StoredDataStatistics(settings.getParticles());
while (samples.getSum() < settings.getParticles()) {
samples.add(poisson.sample());
}
nextN = new int[samples.getN()];
for (int i = 0; i < nextN.length; i++) {
nextN[i] = (int) samples.getValue(i);
}
} else {
// Use the density to get the number per frame
count = (int) Math.max(1, Math.round(areaInUm * settings.getDensity()));
}
}
UniformRandomProvider rng = null;
localisationSets = new ArrayList<>(settings.getParticles());
final int minPhotons = (int) settings.getPhotonsPerSecond();
final int range = (int) settings.getPhotonsPerSecondMaximum() - minPhotons + 1;
if (range > 1) {
rng = createRandomGenerator();
}
// Add frames at the specified density until the number of particles has been reached
int id = 0;
int time = 0;
while (id < settings.getParticles()) {
// Allow the number per frame to be specified
if (nextN != null) {
if (time >= nextN.length) {
break;
}
count = nextN[time];
}
// Simulate random positions in the frame for the specified density
time++;
for (int j = 0; j < count; j++) {
final double[] xyz = dist.next();
// Ignore within border. We do not want to draw things we cannot fit.
// if (!distBorder.isWithinXy(xyz))
// continue;
// Simulate random photons
final int intensity = minPhotons + ((rng != null) ? rng.nextInt(range) : 0);
final LocalisationModel m = new LocalisationModel(id, time, xyz, intensity, LocalisationModel.CONTINUOUS);
// Each localisation can be a separate localisation set
final LocalisationModelSet set = new LocalisationModelSet(id, time);
set.add(m);
localisationSets.add(set);
id++;
}
}
} else {
if (!showDialog()) {
return;
}
resetMemory();
areaInUm = settings.getSize() * settings.getPixelPitch() * settings.getSize() * settings.getPixelPitch() / 1e6;
int totalSteps;
double correlation = 0;
ImageModel imageModel;
if (trackMode) {
// ----------------
// TRACK SIMULATION
// ----------------
// In track mode we create fixed lifetime fluorophores that do not overlap in time.
// This is the simplest simulation to test moving molecules.
settings.setSeconds((int) Math.ceil(settings.getParticles() * (settings.getExposureTime() + settings.getTOn()) / 1000));
totalSteps = 0;
final double simulationStepsPerFrame = (settings.getStepsPerSecond() * settings.getExposureTime()) / 1000.0;
imageModel = new FixedLifetimeImageModel(settings.getStepsPerSecond() * settings.getTOn() / 1000.0, simulationStepsPerFrame, createRandomGenerator());
} else {
// ---------------
// FULL SIMULATION
// ---------------
// The full simulation draws n random points in space.
// The same molecule may appear in multiple frames, move and blink.
//
// Points are modelled as fluorophores that must be activated and then will
// blink and photo-bleach. The molecules may diffuse and this can be simulated
// with many steps per image frame. All steps from a frame are collected
// into a localisation set which can be drawn on the output image.
final SpatialIllumination activationIllumination = createIllumination(settings.getPulseRatio(), settings.getPulseInterval());
// Generate additional frames so that each frame has the set number of simulation steps
totalSteps = (int) Math.ceil(settings.getSeconds() * settings.getStepsPerSecond());
// Since we have an exponential decay of activations
// ensure half of the particles have activated by 30% of the frames.
final double eAct = totalSteps * 0.3 * activationIllumination.getAveragePhotons();
// Q. Does tOn/tOff change depending on the illumination strength?
imageModel = new ActivationEnergyImageModel(eAct, activationIllumination, settings.getStepsPerSecond() * settings.getTOn() / 1000.0, settings.getStepsPerSecond() * settings.getTOffShort() / 1000.0, settings.getStepsPerSecond() * settings.getTOffLong() / 1000.0, settings.getNBlinksShort(), settings.getNBlinksLong(), createRandomGenerator());
imageModel.setUseGeometricDistribution(settings.getNBlinksGeometricDistribution());
// Only use the correlation if selected for the distribution
if (PHOTON_DISTRIBUTION[PHOTON_CORRELATED].equals(settings.getPhotonDistribution())) {
correlation = settings.getCorrelation();
}
}
imageModel.setPhotonBudgetPerFrame(true);
imageModel.setDiffusion2D(settings.getDiffuse2D());
imageModel.setRotation2D(settings.getRotate2D());
IJ.showStatus("Creating molecules ...");
final SpatialDistribution distribution = createDistribution();
final List<CompoundMoleculeModel> compounds = createCompoundMolecules();
if (compounds == null) {
return;
}
final List<CompoundMoleculeModel> molecules = imageModel.createMolecules(compounds, settings.getParticles(), distribution, settings.getRotateInitialOrientation());
// Activate fluorophores
IJ.showStatus("Creating fluorophores ...");
// Note: molecules list will be converted to compounds containing fluorophores
fluorophores = imageModel.createFluorophores(molecules, totalSteps);
if (fluorophores.isEmpty()) {
IJ.error(TITLE, "No fluorophores created");
return;
}
// Map the fluorophore ID to the compound for mixtures
if (compounds.size() > 1) {
idToCompound = new TIntIntHashMap(fluorophores.size());
for (final FluorophoreSequenceModel l : fluorophores) {
idToCompound.put(l.getId(), l.getLabel());
}
}
IJ.showStatus("Creating localisations ...");
// TODO - Output a molecule Id for each fluorophore if using compound molecules. This allows
// analysis
// of the ratio of trimers, dimers, monomers, etc that could be detected.
totalSteps = checkTotalSteps(totalSteps, fluorophores);
if (totalSteps == 0) {
return;
}
imageModel.setPhotonDistribution(createPhotonDistribution());
try {
imageModel.setConfinementDistribution(createConfinementDistribution());
} catch (final ConfigurationException ex) {
// We asked the user if it was OK to continue and they said no
return;
}
// This should be optimised
imageModel.setConfinementAttempts(10);
final List<LocalisationModel> localisations = imageModel.createImage(molecules, settings.getFixedFraction(), totalSteps, settings.getPhotonsPerSecond() / settings.getStepsPerSecond(), correlation, settings.getRotateDuringSimulation());
// Re-adjust the fluorophores to the correct time
if (settings.getStepsPerSecond() != 1) {
final double scale = 1.0 / settings.getStepsPerSecond();
for (final FluorophoreSequenceModel f : fluorophores) {
f.adjustTime(scale);
}
}
// Integrate the frames
localisationSets = combineSimulationSteps(localisations);
localisationSets = filterToImageBounds(localisationSets);
}
datasetNumber.getAndIncrement();
final List<LocalisationModel> localisations = drawImage(localisationSets);
if (localisations == null || localisations.isEmpty()) {
IJ.error(TITLE, "No localisations created");
return;
}
fluorophores = removeFilteredFluorophores(fluorophores, localisations);
final double signalPerFrame = showSummary(fluorophores, localisations);
if (!benchmarkMode) {
final boolean fullSimulation = (!(simpleMode || spotMode));
saveSimulationParameters(localisations.size(), fullSimulation, signalPerFrame);
}
IJ.showStatus("Saving data ...");
saveFluorophores(fluorophores);
saveImageResults(results);
saveLocalisations(localisations);
// The settings for the filenames may have changed
SettingsManager.writeSettings(settings.build());
IJ.showStatus("Done");
}
use of uk.ac.sussex.gdsc.smlm.model.LocalisationModel in project GDSC-SMLM by aherbert.
the class CreateData method rebuildNeighbours.
/**
* Sort by id then time, then rebuild the neighbour pointers.
*
* @param localisations the localisations
*/
private static void rebuildNeighbours(List<LocalisationModel> localisations) {
sortLocalisationsByIdThenTime(localisations);
int id = 0;
int time = 0;
LocalisationModel previous = null;
for (final LocalisationModel l : localisations) {
if (l.getId() != id || l.getTime() > time + 1) {
// New spot so no previous neighbour OR
// Discontinuous time so no previous neighbour
previous = null;
}
l.setPrevious(previous);
l.setNext(null);
id = l.getId();
time = l.getTime();
previous = l;
}
}
use of uk.ac.sussex.gdsc.smlm.model.LocalisationModel in project GDSC-SMLM by aherbert.
the class CreateData method savePulses.
/**
* Create a set of results that represent the molecule continuous on-times (pulses).
*
* @param localisations the localisations
* @param results the results
*/
@SuppressWarnings("null")
private void savePulses(List<LocalisationModel> localisations, MemoryPeakResults results) {
sortLocalisationsByIdThenTime(localisations);
final MemoryPeakResults traceResults = copyMemoryPeakResults("Pulses");
LocalisationModel start = null;
int currentId = -1;
int count = 0;
float[] params = Gaussian2DPeakResultHelper.createTwoAxisParams(0, 0, 0, 0, 0, 0, 0);
final int isx = Gaussian2DPeakResultHelper.INDEX_SX;
final int isy = Gaussian2DPeakResultHelper.INDEX_SY;
double noise = 0;
int lastT = -1;
for (final LocalisationModel localisation : localisations) {
if (currentId != localisation.getId() || lastT + 1 != localisation.getTime()) {
if (count > 0) {
params[PeakResult.BACKGROUND] /= count;
params[PeakResult.X] /= count;
params[PeakResult.Y] /= count;
params[isx] /= count;
params[isy] /= count;
final ExtendedPeakResult p = new ExtendedPeakResult(start.getTime(), (int) Math.round(start.getX()), (int) Math.round(start.getY()), 0, 0, (float) (Math.sqrt(noise)), 0, params, null, lastT, currentId);
// if (p.getPrecision(107, 1) > 2000)
// {
// System.out.printf("Weird precision = %g (%d)\n", p.getPrecision(107, 1), n);
// }
traceResults.add(p);
}
start = localisation;
currentId = localisation.getId();
count = 0;
params = new float[7];
noise = 0;
}
final double[] data = localisation.getData();
params[PeakResult.BACKGROUND] += data[0];
params[PeakResult.X] += localisation.getX();
params[PeakResult.Y] += localisation.getY();
params[PeakResult.INTENSITY] += localisation.getIntensity();
noise += data[1] * data[1];
params[isx] += data[2];
params[isy] += data[3];
count++;
lastT = localisation.getTime();
}
// Final pulse
if (count > 0) {
params[PeakResult.BACKGROUND] /= count;
params[PeakResult.X] /= count;
params[PeakResult.Y] /= count;
params[isx] /= count;
params[isy] /= count;
traceResults.add(new ExtendedPeakResult(start.getTime(), (int) Math.round(start.getX()), (int) Math.round(start.getY()), 0, 0, (float) (Math.sqrt(noise)), 0, params, null, lastT, currentId));
}
traceResults.end();
}
Aggregations