Search in sources :

Example 1 with Measurement

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

the class ManualThreshold method setImageMeasurements.

public void setImageMeasurements(Image image, HashMap<String, Double> measurements, String imageName1, String imageName2) {
    for (String measurementName : measurements.keySet()) {
        String fullName = getFullName(imageName1, imageName2, measurementName);
        image.addMeasurement(new Measurement(fullName, measurements.get(measurementName)));
    }
}
Also used : Measurement(io.github.mianalysis.mia.object.Measurement)

Example 2 with Measurement

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

the class MeasureImageDimensions method process.

@Override
public Status process(Workspace workspace) {
    String inputImageName = parameters.getValue(INPUT_IMAGE);
    Image inputImage = workspace.getImage(inputImageName);
    ImagePlus inputImagePlus = inputImage.getImagePlus();
    int width = inputImagePlus.getWidth();
    inputImage.addMeasurement(new Measurement(getFullName(Measurements.WIDTH), width));
    int height = inputImagePlus.getHeight();
    inputImage.addMeasurement(new Measurement(getFullName(Measurements.HEIGHT), height));
    int nChannels = inputImagePlus.getNChannels();
    inputImage.addMeasurement(new Measurement(getFullName(Measurements.N_CHANNELS), nChannels));
    int nSlices = inputImagePlus.getNSlices();
    inputImage.addMeasurement(new Measurement(getFullName(Measurements.N_SLICES), nSlices));
    int nFrames = inputImagePlus.getNFrames();
    inputImage.addMeasurement(new Measurement(getFullName(Measurements.N_FRAMES), nFrames));
    double distXY = inputImagePlus.getCalibration().pixelWidth;
    inputImage.addMeasurement(new Measurement(getFullName(Measurements.DIST_PER_PX_XY), distXY));
    double distZ = inputImagePlus.getCalibration().pixelDepth;
    inputImage.addMeasurement(new Measurement(getFullName(Measurements.DIST_PER_SLICE_Z), distZ));
    double frameIntervalSecs = inputImagePlus.getCalibration().frameInterval;
    inputImage.addMeasurement(new Measurement(getFullName(Measurements.FRAME_INTERVAL), frameIntervalSecs));
    double fps = inputImagePlus.getCalibration().fps;
    inputImage.addMeasurement(new Measurement(getFullName(Measurements.FPS), fps));
    if (showOutput)
        inputImage.showMeasurements(this);
    return Status.PASS;
}
Also used : Measurement(io.github.mianalysis.mia.object.Measurement) Image(io.github.mianalysis.mia.object.Image) ImagePlus(ij.ImagePlus)

Example 3 with Measurement

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

the class MeasureImageTexture method process.

@Override
public Status process(Workspace workspace) {
    // Getting input image
    String inputImageName = parameters.getValue(INPUT_IMAGE);
    Image inputImage = workspace.getImages().get(inputImageName);
    ImagePlus inputImagePlus = inputImage.getImagePlus();
    // Getting parameters
    int xOffs = parameters.getValue(X_OFFSET);
    int yOffs = parameters.getValue(Y_OFFSET);
    int zOffs = parameters.getValue(Z_OFFSET);
    boolean calibratedOffset = parameters.getValue(CALIBRATED_OFFSET);
    // If using calibrated offset values, determining the closest pixel offset
    if (calibratedOffset) {
        Calibration cal = inputImagePlus.getCalibration();
        xOffs = (int) Math.round((double) xOffs / cal.pixelWidth);
        yOffs = (int) Math.round((double) yOffs / cal.pixelWidth);
        zOffs = (int) Math.round((double) zOffs / cal.pixelDepth);
    }
    // Running texture measurement
    TextureCalculator textureCalculator = new TextureCalculator();
    textureCalculator.calculate(inputImagePlus.getStack(), xOffs, yOffs, zOffs);
    // Acquiring measurements
    Measurement ASMMeasurement = new Measurement(Measurements.ASM, textureCalculator.getASM());
    inputImage.addMeasurement(ASMMeasurement);
    writeStatus("ASM = " + ASMMeasurement.getValue());
    Measurement contrastMeasurement = new Measurement(Measurements.CONTRAST, textureCalculator.getContrast());
    inputImage.addMeasurement(contrastMeasurement);
    writeStatus("Contrast = " + contrastMeasurement.getValue());
    Measurement correlationMeasurement = new Measurement(Measurements.CORRELATION, textureCalculator.getCorrelation());
    inputImage.addMeasurement(correlationMeasurement);
    writeStatus("Correlation = " + correlationMeasurement.getValue());
    Measurement entropyMeasurement = new Measurement(Measurements.ENTROPY, textureCalculator.getEntropy());
    inputImage.addMeasurement(entropyMeasurement);
    writeStatus("Entropy = " + entropyMeasurement.getValue());
    if (showOutput)
        inputImage.showMeasurements(this);
    return Status.PASS;
}
Also used : Measurement(io.github.mianalysis.mia.object.Measurement) TextureCalculator(io.github.sjcross.common.analysis.TextureCalculator) Calibration(ij.measure.Calibration) Image(io.github.mianalysis.mia.object.Image) ImagePlus(ij.ImagePlus)

Example 4 with Measurement

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

the class ImageMeasurementCalculator method process.

@Override
protected Status process(Workspace workspace) {
    String inputImageName = parameters.getValue(INPUT_IMAGE);
    Image inputImage = workspace.getImage(inputImageName);
    String valueMode1 = parameters.getValue(VALUE_MODE_1);
    double fixedValue1 = parameters.getValue(FIXED_VALUE_1);
    String measurementName1 = parameters.getValue(MEASUREMENT_1);
    String valueMode2 = parameters.getValue(VALUE_MODE_2);
    double fixedValue2 = parameters.getValue(FIXED_VALUE_2);
    String measurementName2 = parameters.getValue(MEASUREMENT_2);
    String outputMeasurementName = getFullName(parameters.getValue(OUTPUT_MEASUREMENT));
    String calculationMode = parameters.getValue(CALCULATION_MODE);
    // Getting value 1
    double value1 = 0;
    switch(valueMode1) {
        case ValueModes.FIXED:
            value1 = fixedValue1;
            break;
        case ValueModes.MEASUREMENT:
            value1 = inputImage.getMeasurement(measurementName1).getValue();
            break;
    }
    // Getting value 2
    double value2 = 0;
    switch(valueMode2) {
        case ValueModes.FIXED:
            value2 = fixedValue2;
            break;
        case ValueModes.MEASUREMENT:
            value2 = inputImage.getMeasurement(measurementName2).getValue();
            break;
    }
    // Performing calculation
    double result = doCalculation(value1, value2, calculationMode);
    // Adding the new measurement
    inputImage.addMeasurement(new Measurement(outputMeasurementName, result));
    // Showing results
    if (showOutput)
        inputImage.showMeasurements(this);
    return Status.PASS;
}
Also used : Measurement(io.github.mianalysis.mia.object.Measurement) Image(io.github.mianalysis.mia.object.Image)

Example 5 with Measurement

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

the class MIA_GetImageMeasurement method action.

@Override
public String action(Object[] objects, Workspace workspace, Modules modules) {
    String imageName = (String) objects[0];
    String measurementName = (String) objects[1];
    // Getting the object set
    Image image = workspace.getImage(imageName);
    if (image == null)
        return "";
    // Getting the measurement
    Measurement measurement = image.getMeasurement(measurementName);
    if (measurement == null)
        return "";
    // Returning measurement value
    return String.valueOf(measurement.getValue());
}
Also used : Measurement(io.github.mianalysis.mia.object.Measurement) Image(io.github.mianalysis.mia.object.Image)

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