Search in sources :

Example 46 with Measurement

use of io.github.mianalysis.mia.object.Measurement in project mia by mianalysis.

the class ColourFactoryTest method testGetHuesIDColour.

@ParameterizedTest
@EnumSource(VolumeType.class)
public void testGetHuesIDColour(VolumeType volumeType) {
    // Setting calibration parameters
    double dppXY = 0.02;
    double dppZ = 0.1;
    String calibratedUnits = "µm";
    SpatCal calibration = new SpatCal(dppXY, dppZ, calibratedUnits, 1, 1, 1);
    // Creating the Objs
    Objs collection = new Objs("Obj", calibration, 1, 0.02, UNITS.SECOND);
    // Adding objects
    Obj obj = collection.createAndAddNewObject(volumeType, 0);
    Measurement meas = new Measurement("Meas", 3.2);
    obj.addMeasurement(meas);
    collection.add(obj);
    obj = collection.createAndAddNewObject(volumeType, 1);
    meas = new Measurement("Meas", -0.1);
    obj.addMeasurement(meas);
    collection.add(obj);
    obj = collection.createAndAddNewObject(volumeType, 2);
    meas = new Measurement("Meas", Double.NaN);
    obj.addMeasurement(meas);
    collection.add(obj);
    HashMap<Integer, Float> actual = ColourFactory.getIDHues(collection, false);
    // For random numbers we don't know what value they will have
    assertEquals(3, actual.size());
    assertEquals(0f, actual.get(0), tolerance);
    assertEquals(1f, actual.get(1), tolerance);
    assertEquals(2f, actual.get(2), tolerance);
}
Also used : Measurement(io.github.mianalysis.mia.object.Measurement) Obj(io.github.mianalysis.mia.object.Obj) Objs(io.github.mianalysis.mia.object.Objs) SpatCal(io.github.sjcross.common.object.volume.SpatCal) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 47 with Measurement

use of io.github.mianalysis.mia.object.Measurement in project mia by mianalysis.

the class ColourFactoryTest method testGetColoursMeasurementColourNormalised.

@ParameterizedTest
@EnumSource(VolumeType.class)
public void testGetColoursMeasurementColourNormalised(VolumeType volumeType) {
    // Setting calibration parameters
    double dppXY = 0.02;
    double dppZ = 0.1;
    String calibratedUnits = "µm";
    SpatCal calibration = new SpatCal(dppXY, dppZ, calibratedUnits, 1, 1, 1);
    // Creating the Objs
    Objs collection = new Objs("Obj", calibration, 1, 0.02, UNITS.SECOND);
    // Adding objects
    Obj obj = collection.createAndAddNewObject(volumeType, 0);
    Measurement meas = new Measurement("Meas", 3.2);
    obj.addMeasurement(meas);
    collection.add(obj);
    obj = collection.createAndAddNewObject(volumeType, 1);
    meas = new Measurement("Meas", -0.1);
    obj.addMeasurement(meas);
    collection.add(obj);
    obj = collection.createAndAddNewObject(volumeType, 2);
    meas = new Measurement("Meas", Double.NaN);
    obj.addMeasurement(meas);
    collection.add(obj);
    HashMap<Integer, Float> hues = ColourFactory.getMeasurementValueHues(collection, "Meas", true, new double[] { Double.NaN, Double.NaN });
    HashMap<Integer, Color> actual = ColourFactory.getColours(hues, 100);
    // For random numbers we don't know what value they will have
    assertEquals(3, actual.size());
    assertEquals(Color.getHSBColor(0.4706f, 1f, 1f), actual.get(0));
    assertEquals(Color.getHSBColor(0f, 1f, 1f), actual.get(1));
    assertEquals(Color.getHSBColor(1f, 1f, 1f), actual.get(2));
}
Also used : Measurement(io.github.mianalysis.mia.object.Measurement) Obj(io.github.mianalysis.mia.object.Obj) Objs(io.github.mianalysis.mia.object.Objs) SpatCal(io.github.sjcross.common.object.volume.SpatCal) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 48 with Measurement

use of io.github.mianalysis.mia.object.Measurement in project mia by mianalysis.

the class ColourFactoryTest method testGetHuesMeasurementColourNormalised.

@ParameterizedTest
@EnumSource(VolumeType.class)
public void testGetHuesMeasurementColourNormalised(VolumeType volumeType) {
    // Setting calibration parameters
    double dppXY = 0.02;
    double dppZ = 0.1;
    String calibratedUnits = "µm";
    SpatCal calibration = new SpatCal(dppXY, dppZ, calibratedUnits, 1, 1, 1);
    // Creating the Objs
    Objs collection = new Objs("Obj", calibration, 1, 0.02, UNITS.SECOND);
    // Adding objects
    Obj obj = collection.createAndAddNewObject(volumeType, 0);
    Measurement meas = new Measurement("Meas", 3.2);
    obj.addMeasurement(meas);
    collection.add(obj);
    obj = collection.createAndAddNewObject(volumeType, 1);
    meas = new Measurement("Meas", -0.1);
    obj.addMeasurement(meas);
    collection.add(obj);
    obj = collection.createAndAddNewObject(volumeType, 2);
    meas = new Measurement("Meas", Double.NaN);
    obj.addMeasurement(meas);
    collection.add(obj);
    HashMap<Integer, Float> actual = ColourFactory.getMeasurementValueHues(collection, "Meas", true, new double[] { Double.NaN, Double.NaN });
    // For random numbers we don't know what value they will have
    assertEquals(3, actual.size());
    assertEquals(0.47f, actual.get(0), tolerance);
    assertEquals(0f, actual.get(1), tolerance);
    assertEquals(Double.NaN, actual.get(2), tolerance);
}
Also used : Measurement(io.github.mianalysis.mia.object.Measurement) Obj(io.github.mianalysis.mia.object.Obj) Objs(io.github.mianalysis.mia.object.Objs) SpatCal(io.github.sjcross.common.object.volume.SpatCal) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 49 with Measurement

use of io.github.mianalysis.mia.object.Measurement in project mia by mianalysis.

the class CalculateNearestNeighbour method addMeasurements.

public void addMeasurements(Obj inputObject, Obj nearestNeighbour, String referenceMode, String nearestNeighbourName) {
    // Adding details of the nearest neighbour to the input object's measurements
    if (nearestNeighbour != null) {
        double dppXY = inputObject.getDppXY();
        double minDist = 0;
        switch(referenceMode) {
            default:
            case ReferenceModes.CENTROID_3D:
                minDist = inputObject.getCentroidSeparation(nearestNeighbour, true);
                break;
            case ReferenceModes.SURFACE_3D:
                minDist = inputObject.getSurfaceSeparation(nearestNeighbour, true);
                break;
        }
        String name = getFullName(Measurements.NN_ID, nearestNeighbourName);
        inputObject.addMeasurement(new Measurement(name, nearestNeighbour.getID()));
        name = getFullName(Measurements.NN_DISTANCE_PX, nearestNeighbourName);
        inputObject.addMeasurement(new Measurement(name, minDist));
        name = getFullName(Measurements.NN_DISTANCE_CAL, nearestNeighbourName);
        inputObject.addMeasurement(new Measurement(name, minDist * dppXY));
    } else {
        String name = getFullName(Measurements.NN_ID, nearestNeighbourName);
        inputObject.addMeasurement(new Measurement(name, Double.NaN));
        name = getFullName(Measurements.NN_DISTANCE_PX, nearestNeighbourName);
        inputObject.addMeasurement(new Measurement(name, Double.NaN));
        name = getFullName(Measurements.NN_DISTANCE_CAL, nearestNeighbourName);
        inputObject.addMeasurement(new Measurement(name, Double.NaN));
    }
}
Also used : Measurement(io.github.mianalysis.mia.object.Measurement)

Example 50 with Measurement

use of io.github.mianalysis.mia.object.Measurement in project mia by mianalysis.

the class MeasureObjectCurvature method initialiseObjectMeasurements.

private void initialiseObjectMeasurements(Obj inputObject, boolean absoluteCurvature, boolean signedCurvature, boolean useReference) {
    if (absoluteCurvature) {
        inputObject.addMeasurement(new Measurement(Measurements.MEAN_ABSOLUTE_CURVATURE_PX, Double.NaN));
        inputObject.addMeasurement(new Measurement(Measurements.MIN_ABSOLUTE_CURVATURE_PX, Double.NaN));
        inputObject.addMeasurement(new Measurement(Measurements.MAX_ABSOLUTE_CURVATURE_PX, Double.NaN));
        inputObject.addMeasurement(new Measurement(Measurements.STD_ABSOLUTE_CURVATURE_PX, Double.NaN));
        inputObject.addMeasurement(new Measurement(Measurements.MEAN_ABSOLUTE_CURVATURE_CAL, Double.NaN));
        inputObject.addMeasurement(new Measurement(Measurements.MIN_ABSOLUTE_CURVATURE_CAL, Double.NaN));
        inputObject.addMeasurement(new Measurement(Measurements.MAX_ABSOLUTE_CURVATURE_CAL, Double.NaN));
        inputObject.addMeasurement(new Measurement(Measurements.STD_ABSOLUTE_CURVATURE_CAL, Double.NaN));
    }
    if (signedCurvature) {
        inputObject.addMeasurement(new Measurement(Measurements.MEAN_SIGNED_CURVATURE_PX, Double.NaN));
        inputObject.addMeasurement(new Measurement(Measurements.MIN_SIGNED_CURVATURE_PX, Double.NaN));
        inputObject.addMeasurement(new Measurement(Measurements.MAX_SIGNED_CURVATURE_PX, Double.NaN));
        inputObject.addMeasurement(new Measurement(Measurements.STD_SIGNED_CURVATURE_PX, Double.NaN));
        inputObject.addMeasurement(new Measurement(Measurements.MEAN_SIGNED_CURVATURE_CAL, Double.NaN));
        inputObject.addMeasurement(new Measurement(Measurements.MIN_SIGNED_CURVATURE_CAL, Double.NaN));
        inputObject.addMeasurement(new Measurement(Measurements.MAX_SIGNED_CURVATURE_CAL, Double.NaN));
        inputObject.addMeasurement(new Measurement(Measurements.STD_SIGNED_CURVATURE_CAL, Double.NaN));
    }
    if (useReference) {
        inputObject.addMeasurement(new Measurement(Measurements.FIRST_POINT_X_PX, Double.NaN));
        inputObject.addMeasurement(new Measurement(Measurements.FIRST_POINT_Y_PX, Double.NaN));
        inputObject.addMeasurement(new Measurement(Measurements.REL_LOC_OF_MIN_CURVATURE, Double.NaN));
        inputObject.addMeasurement(new Measurement(Measurements.REL_LOC_OF_MAX_CURVATURE, Double.NaN));
    }
    inputObject.addMeasurement(new Measurement(Measurements.SPLINE_LENGTH_PX, Double.NaN));
    inputObject.addMeasurement(new Measurement(Measurements.SPLINE_LENGTH_CAL, Double.NaN));
    inputObject.addMeasurement(new Measurement(Measurements.HEAD_TAIL_ANGLE_DEGS, Double.NaN));
}
Also used : Measurement(io.github.mianalysis.mia.object.Measurement)

Aggregations

Measurement (io.github.mianalysis.mia.object.Measurement)105 Obj (io.github.mianalysis.mia.object.Obj)60 Objs (io.github.mianalysis.mia.object.Objs)35 Point (io.github.sjcross.common.object.Point)19 Image (io.github.mianalysis.mia.object.Image)17 ImagePlus (ij.ImagePlus)13 SpatCal (io.github.sjcross.common.object.volume.SpatCal)12 CumStat (io.github.sjcross.common.mathfunc.CumStat)11 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)8 EnumSource (org.junit.jupiter.params.provider.EnumSource)8 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)7 Timepoint (io.github.sjcross.common.object.tracks.Timepoint)5 HashMap (java.util.HashMap)5 IntegerOverflowException (io.github.sjcross.common.exceptions.IntegerOverflowException)4 PointOutOfRangeException (io.github.sjcross.common.object.volume.PointOutOfRangeException)4 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)4 ImageStack (ij.ImageStack)3 Duplicator (ij.plugin.Duplicator)3 ProjectImage (io.github.mianalysis.mia.module.images.transform.ProjectImage)3 Interpreter (ij.macro.Interpreter)2