All Downloads are FREE. Search and download functionalities are using the official Maven repository.

uk.ac.sussex.gdsc.smlm.results.PeakResultHelper Maven / Gradle / Ivy

Go to download

Genome Damage and Stability Centre SMLM Package Software for single molecule localisation microscopy (SMLM)

The newest version!
/*-
 * #%L
 * Genome Damage and Stability Centre SMLM Package
 *
 * Software for single molecule localisation microscopy (SMLM)
 * %%
 * Copyright (C) 2011 - 2023 Alex Herbert
 * %%
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public
 * License along with this program.  If not, see
 * .
 * #L%
 */

package uk.ac.sussex.gdsc.smlm.results;

/**
 * Contains helper functions for working with peak results.
 */
public final class PeakResultHelper {
  /**
   * No public constructor.
   */
  private PeakResultHelper() {}

  /**
   * Convert the local background to an estimate of noise. Local background and noise are in ADU
   * count units.
   *
   * 

This assumes the local background is photon shot noise. The background is first converted to * photons using the gain. The shot noise is taken assuming a Poisson distribution (thus the * variance equals the number of photons). This is amplified by 2 if the data was taken on an * EM-CCD camera. The square root is the noise in photons. This is converted back to ADUs using * the gain. E.G. * *

   * return Math.sqrt((background / gain) * ((emCcd) ? 2 : 1)) * gain;
   * 
* * @param background the background * @param gain the gain * @param emCcd True if an emCcd camera * @return the noise estimate */ public static double localBackgroundToNoise(double background, double gain, boolean emCcd) { if (background <= 0) { return 0; } return Math.sqrt((background / gain) * ((emCcd) ? 2 : 1)) * gain; } /** * Convert the local background to an estimate of noise. Local background and noise are in photons * units. * *

This assumes the local background is photon shot noise. The shot noise is taken assuming a * Poisson distribution (thus the variance equals the number of photons). This is amplified by 2 * if the data was taken on an EM-CCD camera. The square root is the noise in photons. * *

   * return Math.sqrt((background) * ((emCcd) ? 2 : 1));
   * 
* * @param background the background * @param emCcd True if an emCcd camera * @return the noise estimate */ public static double localBackgroundToNoise(double background, boolean emCcd) { if (background <= 0) { return 0; } return Math.sqrt((background) * ((emCcd) ? 2 : 1)); } /** * Convert the noise to local background. Local background and noise are in ADU count units. * *

This assumes the local background is photon shot noise. This is the opposite conversion to * {@link #localBackgroundToNoise(double, double, boolean)}. * * @param noise the noise * @param gain the gain * @param emCcd True if an emCcd camera * @return the local background estimate */ public static double noiseToLocalBackground(double noise, double gain, boolean emCcd) { if (noise <= 0) { return 0; } noise /= gain; noise *= noise; if (emCcd) { noise /= 2; } return noise * gain; } /** * Convert the noise to local background. Local background and noise are in ADU count units. * *

This assumes the local background is photon shot noise. This is the opposite conversion to * {@link #localBackgroundToNoise(double, boolean)}. * * @param noise the noise * @param emCcd True if an emCcd camera * @return the local background estimate */ public static double noiseToLocalBackground(double noise, boolean emCcd) { if (noise <= 0) { return 0; } noise *= noise; if (emCcd) { noise /= 2; } return noise; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy