/* @see BaseTiffReader#initMetadataStore() */ protected void initMetadataStore() throws FormatException { super.initMetadataStore(); MetadataStore store = makeFilterMetadata(); MetadataTools.populatePixels(store, this, true); if (date != null) { date = DateTools.formatDate(date, DATE_FORMAT); if (date != null) { store.setImageAcquisitionDate(new Timestamp(date), 0); } } if (getMetadataOptions().getMetadataLevel() != MetadataLevel.MINIMUM) { store.setImageDescription(MAGIC_STRING, 0); if (scaling > 0) { store.setPixelsPhysicalSizeX(new PositiveFloat(scaling), 0); store.setPixelsPhysicalSizeY(new PositiveFloat(scaling), 0); } else { LOGGER.warn("Expected positive value for PhysicalSize; got {}", scaling); } String instrument = MetadataTools.createLSID("Instrument", 0); store.setInstrumentID(instrument, 0); store.setImageInstrumentRef(instrument, 0); store.setObjectiveID(MetadataTools.createLSID("Objective", 0, 0), 0, 0); if (magnification > 0) { store.setObjectiveNominalMagnification(new PositiveInteger(magnification), 0, 0); } else { LOGGER.warn("Expected positive value for NominalMagnification; got {}", magnification); } store.setObjectiveImmersion(getImmersion(immersion), 0, 0); String detector = MetadataTools.createLSID("Detector", 0, 0); store.setDetectorID(detector, 0, 0); store.setDetectorModel(cameraType + " " + cameraName, 0, 0); store.setDetectorType(getDetectorType("CCD"), 0, 0); for (int i = 0; i < getSizeC(); i++) { store.setDetectorSettingsID(detector, 0, i); store.setDetectorSettingsBinning(getBinning(binning), 0, i); } for (int i = 0; i < getImageCount(); i++) { int[] zct = getZCTCoords(i); store.setPlaneExposureTime(exposureTimes.get(zct[1]) / 1000000, 0, i); } } }
/* @see loci.formats.FormatReader#initFile(String) */ protected void initFile(String id) throws FormatException, IOException { // make sure we have the experiment file id = locateExperimentFile(id); super.initFile(id); Location dir = new Location(id).getAbsoluteFile().getParentFile(); for (String file : dir.list(true)) { Location f = new Location(dir, file); if (!f.isDirectory()) { if (checkSuffix(file, META_EXT)) { metadataFiles.add(f.getAbsolutePath()); } } } // parse Experiment metadata IniList experiment = readMetaData(id); if (getMetadataOptions().getMetadataLevel() != MetadataLevel.MINIMUM) { objective = experiment.getTable("Geometry").get("Name"); IniTable camera = experiment.getTable("Camera"); binning = camera.get("BinX") + "x" + camera.get("BinY"); parseChannelData(dir); addGlobalMeta("Objective", objective); addGlobalMeta("Camera binning", binning); } Vector<String> uniqueRows = new Vector<String>(); Vector<String> uniqueColumns = new Vector<String>(); for (String well : wellLabels) { String row = well.substring(0, 1).trim(); String column = well.substring(1).trim(); if (!uniqueRows.contains(row) && row.length() > 0) uniqueRows.add(row); if (!uniqueColumns.contains(column) && column.length() > 0) { uniqueColumns.add(column); } } int nSlices = getSizeZ() == 0 ? 1 : getSizeZ(); int nTimepoints = getSizeT(); int nWells = wellLabels.size(); int nChannels = getSizeC() == 0 ? channelNames.size() : getSizeC(); if (nChannels == 0) nChannels = 1; tiffs = getTiffs(dir.getAbsolutePath()); reader = new MinimalTiffReader(); reader.setId(tiffs[0][0]); int sizeX = reader.getSizeX(); int sizeY = reader.getSizeY(); int pixelType = reader.getPixelType(); boolean rgb = reader.isRGB(); boolean interleaved = reader.isInterleaved(); boolean indexed = reader.isIndexed(); boolean littleEndian = reader.isLittleEndian(); if (getMetadataOptions().getMetadataLevel() != MetadataLevel.MINIMUM) { IniParser parser = new IniParser(); for (String metadataFile : metadataFiles) { String filename = new Location(metadataFile).getName(); if (!checkSuffix(metadataFile, "txt")) { String data = DataTools.readFile(metadataFile); IniList ini = parser.parseINI(new BufferedReader(new StringReader(data))); HashMap<String, String> h = ini.flattenIntoHashMap(); for (String key : h.keySet()) { addGlobalMeta(filename + " " + key, h.get(key)); } } } } for (int i = 0; i < getSeriesCount(); i++) { core[i] = new CoreMetadata(); core[i].sizeC = nChannels; core[i].sizeZ = nSlices; core[i].sizeT = nTimepoints; core[i].sizeX = sizeX / fieldCols; core[i].sizeY = sizeY / fieldRows; core[i].pixelType = pixelType; core[i].rgb = rgb; core[i].interleaved = interleaved; core[i].indexed = indexed; core[i].littleEndian = littleEndian; core[i].dimensionOrder = "XYZTC"; core[i].imageCount = nSlices * nTimepoints * nChannels; } MetadataStore store = makeFilterMetadata(); boolean populatePlanes = getMetadataOptions().getMetadataLevel() != MetadataLevel.MINIMUM; MetadataTools.populatePixels(store, this, populatePlanes); String plateAcqID = MetadataTools.createLSID("PlateAcquisition", 0, 0); store.setPlateAcquisitionID(plateAcqID, 0, 0); if (fieldRows * fieldCols > 0) { store.setPlateAcquisitionMaximumFieldCount(new PositiveInteger(fieldRows * fieldCols), 0, 0); } else { LOGGER.warn("Expected positive value for MaximumFieldCount; got {}", fieldRows * fieldCols); } for (int row = 0; row < wellRows; row++) { for (int col = 0; col < wellCols; col++) { int index = row * wellCols + col; store.setWellID(MetadataTools.createLSID("Well", 0, index), 0, index); store.setWellRow(new NonNegativeInteger(row), 0, index); store.setWellColumn(new NonNegativeInteger(col), 0, index); } } for (int i = 0; i < getSeriesCount(); i++) { int well = i / (fieldRows * fieldCols); int field = i % (fieldRows * fieldCols); MetadataTools.setDefaultCreationDate(store, tiffs[well][0], i); String name = wellLabels.get(well); String row = name.substring(0, 1); Integer col = Integer.parseInt(name.substring(1)); int index = (row.charAt(0) - 'A') * wellCols + col - 1; String wellSampleID = MetadataTools.createLSID("WellSample", 0, index, field); store.setWellSampleID(wellSampleID, 0, index, field); store.setWellSampleIndex(new NonNegativeInteger(i), 0, index, field); String imageID = MetadataTools.createLSID("Image", i); store.setWellSampleImageRef(imageID, 0, index, field); store.setImageID(imageID, i); store.setImageName(name + " Field #" + (field + 1), i); store.setPlateAcquisitionWellSampleRef(wellSampleID, 0, 0, i); } MetadataLevel level = getMetadataOptions().getMetadataLevel(); if (level != MetadataLevel.MINIMUM) { String instrumentID = MetadataTools.createLSID("Instrument", 0); store.setInstrumentID(instrumentID, 0); String objectiveID = MetadataTools.createLSID("Objective", 0, 0); store.setObjectiveID(objectiveID, 0, 0); if (objective != null) { String[] tokens = objective.split(" "); String mag = tokens[0].replaceAll("[xX]", ""); String na = null; int naIndex = 0; for (int i = 0; i < tokens.length; i++) { if (tokens[i].equals("NA")) { naIndex = i + 1; na = tokens[naIndex]; break; } } Integer magnification = new Integer(mag); if (magnification > 0) { store.setObjectiveNominalMagnification(new PositiveInteger(magnification), 0, 0); } else { LOGGER.warn("Expected positive value for NominalMagnification; got {}", magnification); } if (na != null) { na = na.substring(0, 1) + "." + na.substring(1); store.setObjectiveLensNA(new Double(na), 0, 0); } if (naIndex + 1 < tokens.length) { store.setObjectiveManufacturer(tokens[naIndex + 1], 0, 0); } } // populate LogicalChannel data for (int i = 0; i < getSeriesCount(); i++) { store.setImageInstrumentRef(instrumentID, i); store.setObjectiveSettingsID(objectiveID, i); for (int c = 0; c < getSizeC(); c++) { store.setChannelName(channelNames.get(c), i, c); if (emWave[c] > 0) { store.setChannelEmissionWavelength(new PositiveInteger(emWave[c]), i, c); } else { LOGGER.warn("Expected positive value for EmissionWavelength; got {}", emWave[c]); } if (exWave[c] > 0) { store.setChannelExcitationWavelength(new PositiveInteger(exWave[c]), i, c); } else { LOGGER.warn("Expected positive value for ExcitationWavelength; got {}", exWave[c]); } String detectorID = MetadataTools.createLSID("Detector", 0, c); store.setDetectorID(detectorID, 0, c); store.setDetectorSettingsID(detectorID, i, c); store.setDetectorSettingsGain(gain[c], i, c); store.setDetectorSettingsOffset(offset[c], i, c); store.setDetectorSettingsBinning(getBinning(binning), i, c); } long firstPlane = 0; for (int p = 0; p < getImageCount(); p++) { int[] zct = getZCTCoords(p); store.setPlaneExposureTime(exposure[zct[1]], i, p); String file = getFilename(i, p); if (file != null) { long plane = getTimestamp(file); if (p == 0) { firstPlane = plane; } double timestamp = (plane - firstPlane) / 1000.0; store.setPlaneDeltaT(timestamp, i, p); } } } store.setPlateID(MetadataTools.createLSID("Plate", 0), 0); store.setPlateRowNamingConvention(getNamingConvention("Letter"), 0); store.setPlateColumnNamingConvention(getNamingConvention("Number"), 0); store.setPlateName(plateName, 0); store.setPlateDescription(plateDescription, 0); if (level != MetadataLevel.NO_OVERLAYS) { parseROIs(store); } } }
/* @see BaseTiffReader#initMetadataStore() */ @Override protected void initMetadataStore() throws FormatException { super.initMetadataStore(); MetadataStore store = makeFilterMetadata(); MetadataTools.populatePixels(store, this); if (date != null) { date = DateTools.formatDate(date, DATE_FORMAT); if (date != null) { store.setImageAcquisitionDate(new Timestamp(date), 0); } } if (imageName != null) { store.setImageName(imageName, 0); } if (getMetadataOptions().getMetadataLevel() != MetadataLevel.MINIMUM) { if (imageDescription != null) { store.setImageDescription(imageDescription, 0); } if (userName != null) { store.setExperimenterID(MetadataTools.createLSID("Experimenter", 0), 0); store.setExperimenterLastName(userName, 0); } if (microscopeModel != null) { String instrument = MetadataTools.createLSID("Instrument", 0); store.setInstrumentID(instrument, 0); store.setImageInstrumentRef(instrument, 0); store.setMicroscopeModel(microscopeModel, 0); } if (detectors != null && detectors.size() > 0) { String instrument = MetadataTools.createLSID("Instrument", 0); store.setInstrumentID(instrument, 0); store.setImageInstrumentRef(instrument, 0); for (int i = 0; i < detectors.size(); i++) { String detectorID = MetadataTools.createLSID("Detector", 0, i); store.setDetectorID(detectorID, 0, i); store.setDetectorModel(detectors.get(i), 0, i); store.setDetectorType(getDetectorType("Other"), 0, i); } } if (magnification != null) { store.setObjectiveID(MetadataTools.createLSID("Objective", 0, 0), 0, 0); store.setObjectiveNominalMagnification(magnification, 0, 0); store.setObjectiveCorrection(getCorrection("Other"), 0, 0); store.setObjectiveImmersion(getImmersion("Other"), 0, 0); } store.setStageLabelX(stageX, 0); store.setStageLabelY(stageY, 0); store.setStageLabelZ(stageZ, 0); store.setStageLabelName("", 0); Length physicalSizeX = FormatTools.getPhysicalSizeX(sizeX); Length physicalSizeY = FormatTools.getPhysicalSizeY(sizeY); if (physicalSizeX != null) { store.setPixelsPhysicalSizeX(physicalSizeX, 0); } if (physicalSizeY != null) { store.setPixelsPhysicalSizeY(physicalSizeY, 0); } if (timeIncrement != null) { store.setPixelsTimeIncrement(new Time(timeIncrement, UNITS.S), 0); } } }