Search in sources :

Example 61 with Length

use of ome.units.quantity.Length in project bioformats by openmicroscopy.

the class LociFunctions method getPixelsPhysicalSizeY.

public void getPixelsPhysicalSizeY(Double[] sizeY) {
    int imageIndex = r.getSeries();
    MetadataRetrieve retrieve = (MetadataRetrieve) r.getMetadataStore();
    Length y = retrieve.getPixelsPhysicalSizeY(imageIndex);
    if (y != null) {
        sizeY[0] = y.value(UNITS.MICROMETER).doubleValue();
    }
    if (sizeY[0] == null)
        sizeY[0] = new Double(Double.NaN);
}
Also used : Length(ome.units.quantity.Length) MetadataRetrieve(loci.formats.meta.MetadataRetrieve)

Example 62 with Length

use of ome.units.quantity.Length in project bioformats by openmicroscopy.

the class LociFunctions method getPlanePositionZ.

public void getPlanePositionZ(Double[] positionZ, Double no) {
    int imageIndex = r.getSeries();
    int planeIndex = getPlaneIndex(r, no.intValue());
    MetadataRetrieve retrieve = (MetadataRetrieve) r.getMetadataStore();
    Length val = null;
    if (planeIndex >= 0) {
        val = retrieve.getPlanePositionZ(imageIndex, planeIndex);
    }
    if (val == null) {
        val = new Length(Double.NaN, UNITS.REFERENCEFRAME);
    }
    positionZ[0] = val == null ? Double.NaN : val.value(UNITS.REFERENCEFRAME).doubleValue();
}
Also used : Length(ome.units.quantity.Length) MetadataRetrieve(loci.formats.meta.MetadataRetrieve)

Example 63 with Length

use of ome.units.quantity.Length in project bioformats by openmicroscopy.

the class LociFunctions method getPlanePositionX.

public void getPlanePositionX(Double[] positionX, Double no) {
    int imageIndex = r.getSeries();
    int planeIndex = getPlaneIndex(r, no.intValue());
    MetadataRetrieve retrieve = (MetadataRetrieve) r.getMetadataStore();
    Length val = null;
    if (planeIndex >= 0) {
        val = retrieve.getPlanePositionX(imageIndex, planeIndex);
    }
    positionX[0] = val == null ? Double.NaN : val.value(UNITS.REFERENCEFRAME).doubleValue();
}
Also used : Length(ome.units.quantity.Length) MetadataRetrieve(loci.formats.meta.MetadataRetrieve)

Example 64 with Length

use of ome.units.quantity.Length in project bioformats by openmicroscopy.

the class FormatReaderTest method testEmissionWavelengths.

@Test(groups = { "all", "fast", "automated" })
public void testEmissionWavelengths() {
    if (config == null)
        throw new SkipException("No config tree");
    String testName = "EmissionWavelengths";
    if (!initFile())
        result(testName, false, "initFile");
    IMetadata retrieve = (IMetadata) reader.getMetadataStore();
    for (int i = 0; i < reader.getSeriesCount(); i++) {
        config.setSeries(i);
        for (int c = 0; c < config.getChannelCount(); c++) {
            Length realWavelength = retrieve.getChannelEmissionWavelength(i, c);
            Length expectedWavelength = config.getEmissionWavelength(c);
            if (realWavelength == null && expectedWavelength == null) {
                continue;
            }
            if (!isAlmostEqual(expectedWavelength, realWavelength)) {
                result(testName, false, "Series " + i + " channel " + c + " (expected " + expectedWavelength + ", actual " + realWavelength + ")");
            }
        }
    }
    result(testName, true);
}
Also used : IMetadata(loci.formats.meta.IMetadata) Length(ome.units.quantity.Length) SkipException(org.testng.SkipException) Test(org.testng.annotations.Test)

Example 65 with Length

use of ome.units.quantity.Length in project bioformats by openmicroscopy.

the class FormatReaderTest method testPhysicalSizeX.

@Test(groups = { "all", "fast", "automated" })
public void testPhysicalSizeX() {
    if (config == null)
        throw new SkipException("No config tree");
    String testName = "PhysicalSizeX";
    if (!initFile())
        result(testName, false, "initFile");
    IMetadata retrieve = (IMetadata) reader.getMetadataStore();
    for (int i = 0; i < reader.getSeriesCount(); i++) {
        config.setSeries(i);
        Length expectedSize = config.getPhysicalSizeX();
        Length realSize = retrieve.getPixelsPhysicalSizeX(i);
        if (!isAlmostEqual(realSize, expectedSize)) {
            result(testName, false, "Series " + i + " (expected " + expectedSize + ", actual " + realSize + ")");
        }
    }
    result(testName, true);
}
Also used : IMetadata(loci.formats.meta.IMetadata) Length(ome.units.quantity.Length) SkipException(org.testng.SkipException) Test(org.testng.annotations.Test)

Aggregations

Length (ome.units.quantity.Length)154 MetadataStore (loci.formats.meta.MetadataStore)82 CoreMetadata (loci.formats.CoreMetadata)74 Timestamp (ome.xml.model.primitives.Timestamp)52 RandomAccessInputStream (loci.common.RandomAccessInputStream)48 Time (ome.units.quantity.Time)46 FormatException (loci.formats.FormatException)39 Location (loci.common.Location)34 ArrayList (java.util.ArrayList)29 IMetadata (loci.formats.meta.IMetadata)13 NonNegativeInteger (ome.xml.model.primitives.NonNegativeInteger)13 ServiceFactory (loci.common.services.ServiceFactory)12 IOException (java.io.IOException)11 DependencyException (loci.common.services.DependencyException)11 PositiveInteger (ome.xml.model.primitives.PositiveInteger)11 MetadataRetrieve (loci.formats.meta.MetadataRetrieve)10 ElectricPotential (ome.units.quantity.ElectricPotential)9 Test (org.testng.annotations.Test)9 Element (org.w3c.dom.Element)9 NodeList (org.w3c.dom.NodeList)9