Search in sources :

Example 41 with PositiveInteger

use of ome.xml.model.primitives.PositiveInteger in project bioformats by openmicroscopy.

the class OperettaReader method initFile.

// -- Internal FormatReader API methods --
/* @see loci.formats.FormatReader#initFile(String) */
@Override
protected void initFile(String id) throws FormatException, IOException {
    if (!checkSuffix(id, "xml")) {
        Location parent = new Location(id).getAbsoluteFile().getParentFile();
        Location xml = new Location(parent, XML_FILE);
        if (!xml.exists()) {
            throw new FormatException("Could not find XML file " + xml.getAbsolutePath());
        }
        initFile(xml.getAbsolutePath());
        return;
    } else {
        super.initFile(id);
    }
    // parse plate layout and image dimensions from the XML file
    String xmlData = DataTools.readFile(id);
    OperettaHandler handler = new OperettaHandler();
    XMLTools.parseXML(xmlData, handler);
    // sort the list of images by well and field indices
    ArrayList<Plane> planeList = handler.getPlanes();
    ArrayList<Integer> uniqueRows = new ArrayList<Integer>();
    ArrayList<Integer> uniqueCols = new ArrayList<Integer>();
    ArrayList<Integer> uniqueFields = new ArrayList<Integer>();
    ArrayList<Integer> uniqueZs = new ArrayList<Integer>();
    ArrayList<Integer> uniqueTs = new ArrayList<Integer>();
    ArrayList<Integer> uniqueCs = new ArrayList<Integer>();
    for (Plane p : planeList) {
        if (!uniqueRows.contains(p.row)) {
            uniqueRows.add(p.row);
        }
        if (!uniqueCols.contains(p.col)) {
            uniqueCols.add(p.col);
        }
        if (!uniqueFields.contains(p.field)) {
            uniqueFields.add(p.field);
        }
        if (!uniqueZs.contains(p.z)) {
            uniqueZs.add(p.z);
        }
        if (!uniqueCs.contains(p.c)) {
            uniqueCs.add(p.c);
        }
        if (!uniqueTs.contains(p.t)) {
            uniqueTs.add(p.t);
        }
    }
    Integer[] rows = uniqueRows.toArray(new Integer[uniqueRows.size()]);
    Integer[] cols = uniqueCols.toArray(new Integer[uniqueCols.size()]);
    Integer[] fields = uniqueFields.toArray(new Integer[uniqueFields.size()]);
    Integer[] zs = uniqueZs.toArray(new Integer[uniqueZs.size()]);
    Integer[] cs = uniqueCs.toArray(new Integer[uniqueCs.size()]);
    Integer[] ts = uniqueTs.toArray(new Integer[uniqueTs.size()]);
    Arrays.sort(rows);
    Arrays.sort(cols);
    Arrays.sort(fields);
    Arrays.sort(zs);
    Arrays.sort(ts);
    Arrays.sort(cs);
    int seriesCount = rows.length * cols.length * fields.length;
    core.clear();
    planes = new Plane[seriesCount][zs.length * cs.length * ts.length];
    int nextSeries = 0;
    for (int row = 0; row < rows.length; row++) {
        for (int col = 0; col < cols.length; col++) {
            for (int field = 0; field < fields.length; field++) {
                int nextPlane = 0;
                for (int t = 0; t < ts.length; t++) {
                    for (int z = 0; z < zs.length; z++) {
                        for (int c = 0; c < cs.length; c++) {
                            for (Plane p : planeList) {
                                if (p.row == rows[row] && p.col == cols[col] && p.field == fields[field] && p.t == ts[t] && p.z == zs[z] && p.c == cs[c]) {
                                    planes[nextSeries][nextPlane] = p;
                                    break;
                                }
                            }
                            nextPlane++;
                        }
                    }
                }
                nextSeries++;
            }
        }
    }
    reader = new MinimalTiffReader();
    for (int i = 0; i < seriesCount; i++) {
        CoreMetadata ms = new CoreMetadata();
        core.add(ms);
        ms.sizeZ = uniqueZs.size();
        ms.sizeC = uniqueCs.size();
        ms.sizeT = uniqueTs.size();
        ms.dimensionOrder = "XYCZT";
        ms.rgb = false;
        ms.imageCount = getSizeZ() * getSizeC() * getSizeT();
        int planeIndex = 0;
        while (planeIndex < planes[i].length && planes[i][planeIndex] == null) {
            LOGGER.debug("skipping null plane series = {}, plane = {}", i, planeIndex);
            planeIndex++;
        }
        if (planeIndex >= planes[i].length) {
            if (i > 0) {
                ms.sizeX = core.get(i - 1).sizeX;
                ms.sizeY = core.get(i - 1).sizeY;
                ms.pixelType = core.get(i - 1).pixelType;
                ms.littleEndian = core.get(i - 1).littleEndian;
            } else {
                LOGGER.warn("Could not find valid plane for series 0");
            }
        } else {
            ms.sizeX = planes[i][planeIndex].x;
            ms.sizeY = planes[i][planeIndex].y;
            String filename = planes[i][planeIndex].filename;
            while ((filename == null || !new Location(filename).exists()) && planeIndex < planes[i].length - 1) {
                LOGGER.debug("Missing TIFF file: {}", filename);
                planeIndex++;
                filename = planes[i][planeIndex].filename;
            }
            if (filename != null && new Location(filename).exists()) {
                RandomAccessInputStream s = new RandomAccessInputStream(filename, 16);
                TiffParser parser = new TiffParser(s);
                parser.setDoCaching(false);
                IFD firstIFD = parser.getFirstIFD();
                ms.littleEndian = firstIFD.isLittleEndian();
                ms.pixelType = firstIFD.getPixelType();
                s.close();
            } else if (i > 0) {
                LOGGER.warn("Could not find valid TIFF file for series {}", i);
                ms.littleEndian = core.get(0).littleEndian;
                ms.pixelType = core.get(0).pixelType;
            } else {
                LOGGER.warn("Could not find valid TIFF file for series 0; pixel type may be wrong");
            }
        }
    }
    addGlobalMeta("Plate name", handler.getPlateName());
    addGlobalMeta("Plate description", handler.getPlateDescription());
    addGlobalMeta("Plate ID", handler.getPlateIdentifier());
    addGlobalMeta("Measurement ID", handler.getMeasurementID());
    // populate the MetadataStore
    MetadataStore store = makeFilterMetadata();
    MetadataTools.populatePixels(store, this, true);
    String instrument = MetadataTools.createLSID("Instrument", 0);
    store.setInstrumentID(instrument, 0);
    String objective = MetadataTools.createLSID("Objective", 0, 0);
    store.setObjectiveID(objective, 0, 0);
    if (planes[0][0] != null) {
        store.setObjectiveNominalMagnification(planes[0][0].magnification, 0, 0);
        store.setObjectiveLensNA(planes[0][0].lensNA, 0, 0);
    }
    store.setPlateID(MetadataTools.createLSID("Plate", 0), 0);
    store.setPlateRows(new PositiveInteger(handler.getPlateRows()), 0);
    store.setPlateColumns(new PositiveInteger(handler.getPlateColumns()), 0);
    String plateAcqID = MetadataTools.createLSID("PlateAcquisition", 0, 0);
    store.setPlateAcquisitionID(plateAcqID, 0, 0);
    PositiveInteger fieldCount = FormatTools.getMaxFieldCount(fields.length);
    if (fieldCount != null) {
        store.setPlateAcquisitionMaximumFieldCount(fieldCount, 0, 0);
    }
    for (int row = 0; row < rows.length; row++) {
        for (int col = 0; col < cols.length; col++) {
            int well = row * cols.length + col;
            store.setWellID(MetadataTools.createLSID("Well", 0, well), 0, well);
            store.setWellRow(new NonNegativeInteger(rows[row]), 0, well);
            store.setWellColumn(new NonNegativeInteger(cols[col]), 0, well);
            for (int field = 0; field < fields.length; field++) {
                int imageIndex = well * fields.length + field;
                String wellSampleID = MetadataTools.createLSID("WellSample", 0, well, field);
                store.setWellSampleID(wellSampleID, 0, well, field);
                store.setWellSampleIndex(new NonNegativeInteger(imageIndex), 0, well, field);
                String imageID = MetadataTools.createLSID("Image", imageIndex);
                store.setImageID(imageID, imageIndex);
                store.setWellSampleImageRef(imageID, 0, well, field);
                store.setImageInstrumentRef(instrument, imageIndex);
                store.setObjectiveSettingsID(objective, imageIndex);
                String name = "Well " + (well + 1) + ", Field " + (field + 1);
                store.setImageName(name, imageIndex);
                store.setPlateAcquisitionWellSampleRef(wellSampleID, 0, 0, imageIndex);
                if (planes[imageIndex][0] != null && planes[imageIndex][0].absoluteTime != null) {
                    store.setImageAcquisitionDate(planes[imageIndex][0].absoluteTime, imageIndex);
                }
            }
        }
    }
    if (getMetadataOptions().getMetadataLevel() != MetadataLevel.MINIMUM) {
        store.setPlateName(handler.getPlateName(), 0);
        store.setPlateDescription(handler.getPlateDescription(), 0);
        store.setPlateExternalIdentifier(handler.getPlateIdentifier(), 0);
        String experimenterID = MetadataTools.createLSID("Experimenter", 0);
        store.setExperimenterID(experimenterID, 0);
        store.setExperimenterLastName(handler.getExperimenterName(), 0);
        for (int i = 0; i < getSeriesCount(); i++) {
            store.setImageExperimenterRef(experimenterID, i);
            for (int c = 0; c < getSizeC(); c++) {
                if (planes[i][c] != null && planes[i][c].channelName != null) {
                    store.setChannelName(planes[i][c].channelName, i, c);
                }
                if (planes[i][c] != null) {
                    store.setChannelEmissionWavelength(FormatTools.getEmissionWavelength(planes[i][c].emWavelength), i, c);
                    store.setChannelExcitationWavelength(FormatTools.getExcitationWavelength(planes[i][c].exWavelength), i, c);
                }
            }
            if (planes[i][0] != null) {
                store.setPixelsPhysicalSizeX(FormatTools.getPhysicalSizeX(planes[i][0].resolutionX), i);
                store.setPixelsPhysicalSizeY(FormatTools.getPhysicalSizeY(planes[i][0].resolutionY), i);
            }
            for (int p = 0; p < getImageCount(); p++) {
                if (planes[i][p] != null) {
                    store.setPlanePositionX(planes[i][p].positionX, i, p);
                    store.setPlanePositionY(planes[i][p].positionY, i, p);
                    store.setPlanePositionZ(planes[i][p].positionZ, i, p);
                    store.setPlaneExposureTime(planes[i][p].exposureTime, i, p);
                    store.setPlaneDeltaT(planes[i][p].deltaT, i, p);
                }
            }
        }
    }
}
Also used : PositiveInteger(ome.xml.model.primitives.PositiveInteger) IFD(loci.formats.tiff.IFD) NonNegativeInteger(ome.xml.model.primitives.NonNegativeInteger) ArrayList(java.util.ArrayList) CoreMetadata(loci.formats.CoreMetadata) FormatException(loci.formats.FormatException) PositiveInteger(ome.xml.model.primitives.PositiveInteger) NonNegativeInteger(ome.xml.model.primitives.NonNegativeInteger) MetadataStore(loci.formats.meta.MetadataStore) TiffParser(loci.formats.tiff.TiffParser) RandomAccessInputStream(loci.common.RandomAccessInputStream) Location(loci.common.Location)

Example 42 with PositiveInteger

use of ome.xml.model.primitives.PositiveInteger in project bioformats by openmicroscopy.

the class InCellReader method initFile.

// -- Internal FormatReader API methods --
/* @see loci.formats.FormatReader#initFile(String) */
@Override
protected void initFile(String id) throws FormatException, IOException {
    // make sure that we have the .xdce (or .xml) file
    if (checkSuffix(id, PIXELS_SUFFIXES) || checkSuffix(id, "xlog")) {
        Location currentFile = new Location(id).getAbsoluteFile();
        Location parent = currentFile.getParentFile();
        String[] list = parent.list(true);
        for (String f : list) {
            if (checkSuffix(f, new String[] { "xdce", "xml" })) {
                String path = new Location(parent, f).getAbsolutePath();
                if (isThisType(path)) {
                    // make sure that the .xdce file references the current file
                    // this ensures that the correct file is chosen if multiple
                    // .xdce files are the same directory
                    String data = DataTools.readFile(path);
                    if (data.indexOf(currentFile.getName()) >= 0) {
                        id = path;
                        break;
                    }
                }
            }
        }
    }
    super.initFile(id);
    in = new RandomAccessInputStream(id);
    channelNames = new ArrayList<String>();
    emWaves = new ArrayList<Double>();
    exWaves = new ArrayList<Double>();
    channelsPerTimepoint = new ArrayList<Integer>();
    metadataFiles = new ArrayList<String>();
    // parse metadata from the .xdce or .xml file
    wellCoordinates = new HashMap<Integer, int[]>();
    posX = new HashMap<Integer, Length>();
    posY = new HashMap<Integer, Length>();
    offsetPointCounter = 0;
    byte[] b = new byte[(int) in.length()];
    in.read(b);
    CoreMetadata ms0 = core.get(0);
    ms0.dimensionOrder = "XYZCT";
    MetadataStore store = makeFilterMetadata();
    DefaultHandler handler = new MinimalInCellHandler();
    XMLTools.parseXML(b, handler);
    if (getSizeZ() == 0)
        ms0.sizeZ = 1;
    if (getSizeC() == 0)
        ms0.sizeC = 1;
    if (getSizeT() == 0)
        ms0.sizeT = 1;
    if (totalImages == 0) {
        ms0.imageCount = getSizeC() * getSizeZ() * getSizeT();
        totalImages = getImageCount() * wellRows * wellCols * fieldCount;
        Location parent = new Location(currentId).getAbsoluteFile().getParentFile();
        for (int row = 0; row < wellRows; row++) {
            for (int col = 0; col < wellCols; col++) {
                plateMap[row][col] = true;
                for (int field = 0; field < fieldCount; field++) {
                    for (int t = 0; t < getSizeT(); t++) {
                        for (int image = 0; image < getSizeC() * getSizeZ(); image++) {
                            // this could be expanded to allow for timepoint indexes
                            // in the file name, as well as allowing the filter names to
                            // be omitted
                            int channel = getZCTCoords(image)[1];
                            Image plane = new Image();
                            String filename = (char) ('A' + row) + " - " + (col + 1) + "(fld " + (field + 1) + " wv " + exFilters.get(channel) + " - " + emFilters.get(channel) + ").tif";
                            Location path = new Location(parent, filename);
                            if (path.exists()) {
                                plane.filename = path.getAbsolutePath();
                            } else {
                                LOGGER.debug("Missing file {}", filename);
                            }
                            imageFiles[row * wellCols + col][field][t][image] = plane;
                        }
                    }
                }
            }
        }
    }
    for (int t = imageFiles[0][0].length - 1; t >= 0; t--) {
        boolean allNull = true;
        for (int well = 0; well < imageFiles.length; well++) {
            for (int field = 0; field < imageFiles[well].length; field++) {
                for (int p = 0; p < imageFiles[well][field][t].length; p++) {
                    if (imageFiles[well][field][t][p] != null) {
                        allNull = false;
                        break;
                    }
                }
            }
        }
        if (allNull) {
            ms0.sizeT--;
        }
    }
    int seriesCount = 0;
    if (exclude != null) {
        for (int row = 0; row < wellRows; row++) {
            for (int col = 0; col < wellCols; col++) {
                if (!exclude[row][col]) {
                    int well = row * wellCols + col;
                    boolean hasNonNullImage = false;
                    for (int field = 0; field < imageFiles[well].length; field++) {
                        for (int t = 0; t < imageFiles[well][field].length; t++) {
                            for (int p = 0; p < imageFiles[well][field][t].length; p++) {
                                if (imageFiles[well][field][t][p] != null) {
                                    hasNonNullImage = true;
                                    break;
                                }
                            }
                        }
                    }
                    if (hasNonNullImage) {
                        seriesCount += imageFiles[well].length;
                    }
                }
            }
        }
        int expectedSeries = totalImages / (getSizeZ() * getSizeC() * getSizeT());
        if (expectedSeries > 0) {
            seriesCount = (int) Math.min(seriesCount, expectedSeries);
        }
    } else
        seriesCount = totalImages / (getSizeZ() * getSizeC() * getSizeT());
    totalChannels = getSizeC();
    oneTimepointPerSeries = false;
    for (int i = 1; i < channelsPerTimepoint.size(); i++) {
        if (!channelsPerTimepoint.get(i).equals(channelsPerTimepoint.get(i - 1))) {
            oneTimepointPerSeries = true;
            break;
        }
    }
    if (oneTimepointPerSeries) {
        int imageCount = 0;
        for (Integer timepoint : channelsPerTimepoint) {
            imageCount += timepoint.intValue() * getSizeZ();
        }
        seriesCount = (totalImages / imageCount) * getSizeT();
    }
    int sizeT = getSizeT();
    int sizeC = getSizeC();
    int z = getSizeZ();
    int t = oneTimepointPerSeries ? 1 : getSizeT();
    core.clear();
    for (int i = 0; i < seriesCount; i++) {
        int c = oneTimepointPerSeries ? channelsPerTimepoint.get(i % sizeT).intValue() : sizeC;
        CoreMetadata ms = new CoreMetadata();
        core.add(ms);
        ms.sizeZ = z;
        ms.sizeC = c;
        ms.sizeT = t;
        ms.imageCount = z * c * t;
        ms.dimensionOrder = "XYZCT";
    }
    int wellIndex = getWellFromSeries(0);
    int fieldIndex = getFieldFromSeries(0);
    String filename = imageFiles[wellIndex][fieldIndex][0][0].filename;
    boolean isTiff = imageFiles[wellIndex][fieldIndex][0][0].isTiff;
    if (isTiff && filename != null) {
        tiffReader = new MinimalTiffReader();
        tiffReader.setId(filename);
        for (int i = 0; i < seriesCount; i++) {
            CoreMetadata ms = core.get(i);
            ms.sizeX = tiffReader.getSizeX();
            ms.sizeY = tiffReader.getSizeY();
            ms.interleaved = tiffReader.isInterleaved();
            ms.indexed = tiffReader.isIndexed();
            ms.rgb = tiffReader.isRGB();
            ms.pixelType = tiffReader.getPixelType();
            ms.littleEndian = tiffReader.isLittleEndian();
        }
    } else {
        for (int i = 0; i < seriesCount; i++) {
            CoreMetadata ms = core.get(i);
            ms.sizeX = imageWidth;
            ms.sizeY = imageHeight;
            ms.interleaved = false;
            ms.indexed = false;
            ms.rgb = false;
            ms.pixelType = FormatTools.UINT16;
            ms.littleEndian = true;
        }
    }
    MetadataTools.populatePixels(store, this, true);
    if (getMetadataOptions().getMetadataLevel() != MetadataLevel.MINIMUM) {
        handler = new InCellHandler(store);
        XMLTools.parseXML(b, handler);
    }
    String rowNaming = Character.isDigit(rowName.charAt(0)) ? "Number" : "Letter";
    String colNaming = Character.isDigit(colName.charAt(0)) ? "Number" : "Letter";
    String plateName = currentId;
    int begin = plateName.lastIndexOf(File.separator) + 1;
    int end = plateName.lastIndexOf(".");
    plateName = plateName.substring(begin, end);
    store.setPlateID(MetadataTools.createLSID("Plate", 0), 0);
    store.setPlateName(plateName, 0);
    store.setPlateRowNamingConvention(getNamingConvention(rowNaming), 0);
    store.setPlateColumnNamingConvention(getNamingConvention(colNaming), 0);
    store.setPlateRows(new PositiveInteger(wellRows), 0);
    store.setPlateColumns(new PositiveInteger(wellCols), 0);
    String plateAcqID = MetadataTools.createLSID("PlateAcquisition", 0, 0);
    store.setPlateAcquisitionID(plateAcqID, 0, 0);
    PositiveInteger maxFieldCount = FormatTools.getMaxFieldCount(fieldCount);
    if (maxFieldCount != null) {
        store.setPlateAcquisitionMaximumFieldCount(maxFieldCount, 0, 0);
    }
    // populate Image data
    String instrumentID = MetadataTools.createLSID("Instrument", 0);
    String experimentID = MetadataTools.createLSID("Experiment", 0);
    store.setInstrumentID(instrumentID, 0);
    store.setExperimentID(experimentID, 0);
    String objectiveID = MetadataTools.createLSID("Objective", 0, 0);
    store.setObjectiveID(objectiveID, 0, 0);
    String detectorID = MetadataTools.createLSID("Detector", 0, 0);
    store.setDetectorID(detectorID, 0, 0);
    int prevWell = -1;
    for (int i = 0; i < seriesCount; i++) {
        store.setObjectiveSettingsID(objectiveID, i);
        if (refractive != null) {
            store.setObjectiveSettingsRefractiveIndex(refractive, i);
        }
        if (x != null) {
            store.setPixelsPhysicalSizeX(x, i);
        }
        if (y != null) {
            store.setPixelsPhysicalSizeY(y, i);
        }
        int well = getWellFromSeries(i);
        int field = getFieldFromSeries(i);
        int totalTimepoints = oneTimepointPerSeries ? channelsPerTimepoint.size() : 1;
        int timepoint = oneTimepointPerSeries ? (i % totalTimepoints) + 1 : -1;
        String imageID = MetadataTools.createLSID("Image", i);
        store.setImageID(imageID, i);
        store.setImageInstrumentRef(instrumentID, i);
        store.setImageExperimentRef(experimentID, i);
        int wellRow = well / wellCols;
        int wellCol = well % wellCols;
        wellIndex = i / (fieldCount * totalTimepoints);
        if (well != prevWell) {
            String wellID = MetadataTools.createLSID("Well", 0, wellIndex);
            store.setWellID(wellID, 0, wellIndex);
            store.setWellRow(new NonNegativeInteger(wellRow), 0, wellIndex);
            store.setWellColumn(new NonNegativeInteger(wellCol), 0, wellIndex);
            prevWell = well;
        }
        char rowChar = rowName.charAt(rowName.length() - 1);
        char colChar = colName.charAt(colName.length() - 1);
        String row = rowName.substring(0, rowName.length() - 1);
        String col = colName.substring(0, colName.length() - 1);
        if (Character.isDigit(rowChar)) {
            row += wellRow + Integer.parseInt(String.valueOf(rowChar));
        } else
            row += (char) (rowChar + wellRow);
        if (Character.isDigit(colChar)) {
            col += wellCol + Integer.parseInt(String.valueOf(colChar));
        } else
            col += (char) (colChar + wellCol);
        String imageName = "Well " + row + "-" + col + ", Field #" + (field + 1);
        if (timepoint >= 0) {
            imageName += ", Timepoint #" + timepoint;
        }
        store.setImageName(imageName, i);
        if (creationDate != null) {
            store.setImageAcquisitionDate(new Timestamp(creationDate), i);
        }
        timepoint--;
        if (timepoint < 0)
            timepoint = 0;
        int sampleIndex = field * totalTimepoints + timepoint;
        String wellSampleID = MetadataTools.createLSID("WellSample", 0, wellIndex, sampleIndex);
        store.setWellSampleID(wellSampleID, 0, wellIndex, sampleIndex);
        store.setWellSampleIndex(new NonNegativeInteger(i), 0, wellIndex, sampleIndex);
        store.setWellSampleImageRef(imageID, 0, wellIndex, sampleIndex);
        if (posX.containsKey(field)) {
            store.setWellSamplePositionX(posX.get(field), 0, wellIndex, sampleIndex);
        }
        if (posY.containsKey(field)) {
            store.setWellSamplePositionY(posY.get(field), 0, wellIndex, sampleIndex);
        }
        store.setPlateAcquisitionWellSampleRef(wellSampleID, 0, 0, i);
    }
    if (getMetadataOptions().getMetadataLevel() != MetadataLevel.MINIMUM) {
        for (int i = 0; i < seriesCount; i++) {
            setSeries(i);
            int well = getWellFromSeries(i);
            int field = getFieldFromSeries(i);
            int timepoint = oneTimepointPerSeries ? i % channelsPerTimepoint.size() : 0;
            for (int time = 0; time < getSizeT(); time++) {
                if (!oneTimepointPerSeries)
                    timepoint = time;
                int c = channelsPerTimepoint.get(timepoint).intValue();
                for (int q = 0; q < getSizeZ() * c; q++) {
                    Image img = imageFiles[well][field][timepoint][q];
                    if (img == null)
                        continue;
                    int plane = time * getSizeZ() * c + q;
                    if (img.deltaT != null) {
                        store.setPlaneDeltaT(new Time(img.deltaT, UNITS.SECOND), i, plane);
                    }
                    if (img.exposure != null) {
                        store.setPlaneExposureTime(new Time(img.exposure, UNITS.SECOND), i, plane);
                    }
                    store.setPlanePositionX(posX.get(field), i, plane);
                    store.setPlanePositionY(posY.get(field), i, plane);
                    store.setPlanePositionZ(img.zPosition, i, plane);
                }
            }
            // populate LogicalChannel data
            for (int q = 0; q < getEffectiveSizeC(); q++) {
                if (q < channelNames.size()) {
                    store.setChannelName(channelNames.get(q), i, q);
                }
                if (q < emWaves.size()) {
                    Double wave = emWaves.get(q);
                    Length emission = FormatTools.getEmissionWavelength(wave);
                    if (emission != null) {
                        store.setChannelEmissionWavelength(emission, i, q);
                    }
                }
                if (q < exWaves.size()) {
                    Double wave = exWaves.get(q);
                    Length excitation = FormatTools.getExcitationWavelength(wave);
                    if (excitation != null) {
                        store.setChannelExcitationWavelength(excitation, i, q);
                    }
                }
                if (detectorID != null) {
                    store.setDetectorSettingsID(detectorID, i, q);
                    if (bin != null) {
                        store.setDetectorSettingsBinning(bin, i, q);
                    }
                    if (gain != null) {
                        store.setDetectorSettingsGain(gain, i, q);
                    }
                }
            }
            if (temperature != null) {
                store.setImagingEnvironmentTemperature(new Temperature(temperature, UNITS.CELSIUS), i);
            }
        }
        setSeries(0);
        // populate Plate data
        store.setPlateWellOriginX(new Length(0.5, UNITS.MICROMETER), 0);
        store.setPlateWellOriginY(new Length(0.5, UNITS.MICROMETER), 0);
    }
}
Also used : Temperature(ome.units.quantity.Temperature) Time(ome.units.quantity.Time) Timestamp(ome.xml.model.primitives.Timestamp) PositiveInteger(ome.xml.model.primitives.PositiveInteger) NonNegativeInteger(ome.xml.model.primitives.NonNegativeInteger) CoreMetadata(loci.formats.CoreMetadata) DefaultHandler(org.xml.sax.helpers.DefaultHandler) PositiveInteger(ome.xml.model.primitives.PositiveInteger) NonNegativeInteger(ome.xml.model.primitives.NonNegativeInteger) MetadataStore(loci.formats.meta.MetadataStore) Length(ome.units.quantity.Length) RandomAccessInputStream(loci.common.RandomAccessInputStream) Location(loci.common.Location)

Aggregations

PositiveInteger (ome.xml.model.primitives.PositiveInteger)42 NonNegativeInteger (ome.xml.model.primitives.NonNegativeInteger)17 FormatException (loci.formats.FormatException)16 ServiceFactory (loci.common.services.ServiceFactory)14 OMEXMLService (loci.formats.services.OMEXMLService)14 Location (loci.common.Location)13 CoreMetadata (loci.formats.CoreMetadata)13 MetadataStore (loci.formats.meta.MetadataStore)13 ServiceException (loci.common.services.ServiceException)11 Time (ome.units.quantity.Time)11 ArrayList (java.util.ArrayList)10 Length (ome.units.quantity.Length)10 IOException (java.io.IOException)9 DependencyException (loci.common.services.DependencyException)9 Image (ome.xml.model.Image)7 Timestamp (ome.xml.model.primitives.Timestamp)7 OMEXMLMetadata (loci.formats.ome.OMEXMLMetadata)6 EnumerationException (ome.xml.model.enums.EnumerationException)6 RandomAccessInputStream (loci.common.RandomAccessInputStream)5 TiffWriter (loci.formats.out.TiffWriter)5