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);
}
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));
}
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);
}
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));
}
}
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));
}
Aggregations