Search in sources :

Example 21 with DistanceUnit

use of uk.ac.sussex.gdsc.smlm.data.config.UnitProtos.DistanceUnit in project GDSC-SMLM by aherbert.

the class CalibrationWriterTest method canWrite.

private static void canWrite(UniformRandomProvider rng) {
    final double qe = rng.nextDouble();
    final double bias = 1 + rng.nextDouble();
    final double exposureTime = 1 + rng.nextDouble();
    final double gain = 1 + rng.nextDouble();
    final double nmPerPixel = 1 + rng.nextDouble();
    final double readNoise = 1 + rng.nextDouble();
    final AngleUnit angleUnit = AngleUnit.values()[rng.nextInt(AngleUnit.values().length - 1)];
    final CameraType cameraType = CameraType.values()[rng.nextInt(CameraType.values().length - 1)];
    final DistanceUnit distanceUnit = DistanceUnit.values()[rng.nextInt(DistanceUnit.values().length - 1)];
    final IntensityUnit intensityUnit = IntensityUnit.values()[rng.nextInt(IntensityUnit.values().length - 1)];
    final CalibrationWriter writer = new CalibrationWriter();
    Assertions.assertEquals(writer.getQuantumEfficiency(), 0);
    Assertions.assertEquals(writer.getBias(), 0);
    Assertions.assertEquals(writer.getExposureTime(), 0);
    Assertions.assertEquals(writer.getCountPerPhoton(), 0);
    Assertions.assertEquals(writer.getNmPerPixel(), 0);
    Assertions.assertEquals(writer.getReadNoise(), 0);
    Assertions.assertFalse(writer.hasQuantumEfficiency());
    Assertions.assertFalse(writer.hasBias());
    Assertions.assertFalse(writer.hasExposureTime());
    Assertions.assertFalse(writer.hasCountPerPhoton());
    Assertions.assertFalse(writer.hasNmPerPixel());
    Assertions.assertFalse(writer.hasReadNoise());
    Assertions.assertEquals(writer.getAngleUnit(), AngleUnit.ANGLE_UNIT_NA);
    Assertions.assertEquals(writer.getCameraType(), CameraType.CAMERA_TYPE_NA);
    Assertions.assertEquals(writer.getDistanceUnit(), DistanceUnit.DISTANCE_UNIT_NA);
    Assertions.assertEquals(writer.getIntensityUnit(), IntensityUnit.INTENSITY_UNIT_NA);
    writer.setQuantumEfficiency(qe);
    writer.setBias(bias);
    writer.setExposureTime(exposureTime);
    writer.setCountPerPhoton(gain);
    writer.setNmPerPixel(nmPerPixel);
    writer.setReadNoise(readNoise);
    writer.setAngleUnit(angleUnit);
    writer.setCameraType(cameraType);
    writer.setDistanceUnit(distanceUnit);
    writer.setIntensityUnit(intensityUnit);
    Assertions.assertEquals(writer.getQuantumEfficiency(), qe);
    Assertions.assertEquals(writer.getBias(), bias);
    Assertions.assertEquals(writer.getExposureTime(), exposureTime);
    Assertions.assertEquals(writer.getCountPerPhoton(), gain);
    Assertions.assertEquals(writer.getNmPerPixel(), nmPerPixel);
    Assertions.assertEquals(writer.getReadNoise(), readNoise);
    Assertions.assertTrue(writer.hasQuantumEfficiency());
    Assertions.assertTrue(writer.hasBias());
    Assertions.assertTrue(writer.hasExposureTime());
    Assertions.assertTrue(writer.hasCountPerPhoton());
    Assertions.assertTrue(writer.hasNmPerPixel());
    Assertions.assertTrue(writer.hasReadNoise());
    Assertions.assertEquals(writer.getAngleUnit(), angleUnit);
    Assertions.assertEquals(writer.getCameraType(), cameraType);
    Assertions.assertEquals(writer.getDistanceUnit(), distanceUnit);
    Assertions.assertEquals(writer.getIntensityUnit(), intensityUnit);
    final CalibrationReader reader = new CalibrationReader(writer.getCalibration());
    Assertions.assertEquals(reader.getQuantumEfficiency(), qe);
    Assertions.assertEquals(reader.getBias(), bias);
    Assertions.assertEquals(reader.getExposureTime(), exposureTime);
    Assertions.assertEquals(reader.getCountPerPhoton(), gain);
    Assertions.assertEquals(reader.getNmPerPixel(), nmPerPixel);
    Assertions.assertEquals(reader.getReadNoise(), readNoise);
    Assertions.assertTrue(reader.hasQuantumEfficiency());
    Assertions.assertTrue(reader.hasBias());
    Assertions.assertTrue(reader.hasExposureTime());
    Assertions.assertTrue(reader.hasCountPerPhoton());
    Assertions.assertTrue(reader.hasNmPerPixel());
    Assertions.assertTrue(reader.hasReadNoise());
    Assertions.assertEquals(reader.getAngleUnit(), angleUnit);
    Assertions.assertEquals(reader.getCameraType(), cameraType);
    Assertions.assertEquals(reader.getDistanceUnit(), distanceUnit);
    Assertions.assertEquals(reader.getIntensityUnit(), intensityUnit);
}
Also used : AngleUnit(uk.ac.sussex.gdsc.smlm.data.config.UnitProtos.AngleUnit) IntensityUnit(uk.ac.sussex.gdsc.smlm.data.config.UnitProtos.IntensityUnit) CameraType(uk.ac.sussex.gdsc.smlm.data.config.CalibrationProtos.CameraType) DistanceUnit(uk.ac.sussex.gdsc.smlm.data.config.UnitProtos.DistanceUnit)

Aggregations

DistanceUnit (uk.ac.sussex.gdsc.smlm.data.config.UnitProtos.DistanceUnit)21 MemoryPeakResults (uk.ac.sussex.gdsc.smlm.results.MemoryPeakResults)7 ExtendedGenericDialog (uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog)6 IntensityUnit (uk.ac.sussex.gdsc.smlm.data.config.UnitProtos.IntensityUnit)6 CalibrationReader (uk.ac.sussex.gdsc.smlm.data.config.CalibrationReader)5 PeakResult (uk.ac.sussex.gdsc.smlm.results.PeakResult)5 IJ (ij.IJ)3 Plot (ij.gui.Plot)3 PlugIn (ij.plugin.PlugIn)3 ArrayList (java.util.ArrayList)3 ConversionException (uk.ac.sussex.gdsc.core.data.utils.ConversionException)3 TypeConverter (uk.ac.sussex.gdsc.core.data.utils.TypeConverter)3 MultiDialog (uk.ac.sussex.gdsc.core.ij.gui.MultiDialog)3 PeakResultProcedure (uk.ac.sussex.gdsc.smlm.results.procedures.PeakResultProcedure)3 ImagePlus (ij.ImagePlus)2 PointRoi (ij.gui.PointRoi)2 Rectangle (java.awt.Rectangle)2 List (java.util.List)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 Test (org.junit.jupiter.api.Test)2