Search in sources :

Example 6 with Frequency

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

the class NikonElementsTiffReader method initMetadataStore.

/* @see BaseTiffReader#initMetadataStore() */
@Override
protected void initMetadataStore() throws FormatException {
    super.initMetadataStore();
    MetadataStore store = makeFilterMetadata();
    MetadataTools.populatePixels(store, this, true);
    String date = handler.getDate();
    if (date != null) {
        store.setImageAcquisitionDate(new Timestamp(date), 0);
    }
    if (getMetadataOptions().getMetadataLevel() == MetadataLevel.MINIMUM) {
        return;
    }
    Length sizeX = FormatTools.getPhysicalSizeX(handler.getPixelSizeX());
    Length sizeY = FormatTools.getPhysicalSizeY(handler.getPixelSizeY());
    Length sizeZ = FormatTools.getPhysicalSizeZ(handler.getPixelSizeZ());
    if (sizeX != null) {
        store.setPixelsPhysicalSizeX(sizeX, 0);
    }
    if (sizeY != null) {
        store.setPixelsPhysicalSizeY(sizeY, 0);
    }
    if (sizeZ != null) {
        store.setPixelsPhysicalSizeZ(sizeZ, 0);
    }
    String instrument = MetadataTools.createLSID("Instrument", 0);
    store.setInstrumentID(instrument, 0);
    store.setImageInstrumentRef(instrument, 0);
    ArrayList<Double> exposureTimes = handler.getExposureTimes();
    ArrayList<Length> posX = handler.getXPositions();
    ArrayList<Length> posY = handler.getYPositions();
    ArrayList<Length> posZ = handler.getZPositions();
    for (int i = 0; i < getImageCount(); i++) {
        int c = getZCTCoords(i)[1];
        if (c < exposureTimes.size() && exposureTimes.get(c) != null) {
            store.setPlaneExposureTime(new Time(exposureTimes.get(c), UNITS.SECOND), 0, i);
        }
        if (i < posX.size()) {
            store.setPlanePositionX(posX.get(i), 0, i);
        }
        if (i < posY.size()) {
            store.setPlanePositionY(posY.get(i), 0, i);
        }
        if (i < posZ.size()) {
            store.setPlanePositionZ(posZ.get(i), 0, i);
        }
    }
    String detector = MetadataTools.createLSID("Detector", 0, 0);
    store.setDetectorID(detector, 0, 0);
    store.setDetectorModel(handler.getCameraModel(), 0, 0);
    store.setDetectorType(getDetectorType("Other"), 0, 0);
    ArrayList<String> channelNames = handler.getChannelNames();
    ArrayList<String> modality = handler.getModalities();
    ArrayList<String> binning = handler.getBinnings();
    ArrayList<Double> speed = handler.getSpeeds();
    ArrayList<Double> gain = handler.getGains();
    ArrayList<Double> temperature = handler.getTemperatures();
    ArrayList<Double> exWave = handler.getExcitationWavelengths();
    ArrayList<Double> emWave = handler.getEmissionWavelengths();
    ArrayList<Integer> power = handler.getPowers();
    ArrayList<Hashtable<String, String>> rois = handler.getROIs();
    Double pinholeSize = handler.getPinholeSize();
    for (int c = 0; c < getEffectiveSizeC(); c++) {
        if (pinholeSize != null) {
            store.setChannelPinholeSize(new Length(pinholeSize, UNITS.MICROMETER), 0, c);
        }
        if (c < channelNames.size()) {
            store.setChannelName(channelNames.get(c), 0, c);
        }
        if (c < modality.size()) {
            store.setChannelAcquisitionMode(getAcquisitionMode(modality.get(c)), 0, c);
        }
        if (c < emWave.size()) {
            Length em = FormatTools.getEmissionWavelength(emWave.get(c));
            if (em != null) {
                store.setChannelEmissionWavelength(em, 0, c);
            }
        }
        if (c < exWave.size()) {
            Length ex = FormatTools.getExcitationWavelength(exWave.get(c));
            if (ex != null) {
                store.setChannelExcitationWavelength(ex, 0, c);
            }
        }
        if (c < binning.size()) {
            store.setDetectorSettingsBinning(getBinning(binning.get(c)), 0, c);
        }
        if (c < gain.size()) {
            store.setDetectorSettingsGain(gain.get(c), 0, c);
        }
        if (c < speed.size()) {
            store.setDetectorSettingsReadOutRate(new Frequency(speed.get(c), UNITS.HERTZ), 0, c);
        }
        store.setDetectorSettingsID(detector, 0, c);
    }
    if (temperature.size() > 0) {
        store.setImagingEnvironmentTemperature(new Temperature(temperature.get(0), UNITS.CELSIUS), 0);
    }
    Double voltage = handler.getVoltage();
    if (voltage != null) {
        store.setDetectorSettingsVoltage(new ElectricPotential(voltage, UNITS.VOLT), 0, 0);
    }
    Double na = handler.getNumericalAperture();
    if (na != null)
        store.setObjectiveLensNA(na, 0, 0);
    Double mag = handler.getMagnification();
    if (mag != null)
        store.setObjectiveCalibratedMagnification(mag, 0, 0);
    store.setObjectiveModel(handler.getObjectiveModel(), 0, 0);
    String immersion = handler.getImmersion();
    if (immersion == null)
        immersion = "Other";
    store.setObjectiveImmersion(getImmersion(immersion), 0, 0);
    String correction = handler.getCorrection();
    if (correction == null || correction.length() == 0)
        correction = "Other";
    store.setObjectiveCorrection(getCorrection(correction), 0, 0);
    String objective = MetadataTools.createLSID("Objective", 0, 0);
    store.setObjectiveID(objective, 0, 0);
    store.setObjectiveSettingsID(objective, 0);
    Double refractiveIndex = handler.getRefractiveIndex();
    if (refractiveIndex != null) {
        store.setObjectiveSettingsRefractiveIndex(refractiveIndex, 0);
    }
    if (getMetadataOptions().getMetadataLevel() == MetadataLevel.NO_OVERLAYS) {
        return;
    }
    handler.populateROIs(store);
}
Also used : Temperature(ome.units.quantity.Temperature) Hashtable(java.util.Hashtable) Time(ome.units.quantity.Time) Timestamp(ome.xml.model.primitives.Timestamp) ElectricPotential(ome.units.quantity.ElectricPotential) MetadataStore(loci.formats.meta.MetadataStore) Length(ome.units.quantity.Length) Frequency(ome.units.quantity.Frequency)

Aggregations

Frequency (ome.units.quantity.Frequency)6 MetadataStore (loci.formats.meta.MetadataStore)5 Length (ome.units.quantity.Length)5 Time (ome.units.quantity.Time)5 Location (loci.common.Location)4 Temperature (ome.units.quantity.Temperature)4 Timestamp (ome.xml.model.primitives.Timestamp)4 ArrayList (java.util.ArrayList)3 Hashtable (java.util.Hashtable)2 RandomAccessInputStream (loci.common.RandomAccessInputStream)2 CoreMetadata (loci.formats.CoreMetadata)2 FormatException (loci.formats.FormatException)2 ElectricPotential (ome.units.quantity.ElectricPotential)2 IOException (java.io.IOException)1 BigDecimal (java.math.BigDecimal)1 MathContext (java.math.MathContext)1 AbstractMap (java.util.AbstractMap)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1