use of loci.formats.meta.MetadataStore in project bioformats by openmicroscopy.
the class WlzReader method initFile.
// -- Internal FormatReader API methods --
/* @see loci.formats.FormatReader#initFile(String) */
@Override
protected void initFile(String id) throws FormatException, IOException {
super.initFile(id);
try {
ServiceFactory factory = new ServiceFactory();
wlz = factory.getInstance(WlzService.class);
} catch (DependencyException e) {
throw new FormatException(NO_WLZ_MSG, e);
}
if (wlz != null) {
wlz.open(id, "r");
CoreMetadata md = core.get(0);
MetadataStore store = makeFilterMetadata();
md.rgb = wlz.isRGB();
md.interleaved = false;
md.indexed = false;
md.sizeX = wlz.getSizeX();
md.sizeY = wlz.getSizeY();
md.sizeZ = wlz.getSizeZ();
md.sizeC = wlz.getSizeC();
md.sizeT = wlz.getSizeT();
md.dimensionOrder = "XYZCT";
md.imageCount = wlz.getSizeZ();
md.pixelType = wlz.getPixelType();
PositiveFloat x = new PositiveFloat(Math.abs(wlz.getVoxSzX()));
PositiveFloat y = new PositiveFloat(Math.abs(wlz.getVoxSzY()));
PositiveFloat z = new PositiveFloat(Math.abs(wlz.getVoxSzZ()));
store.setPixelsPhysicalSizeX(FormatTools.createLength(x, UNITS.MICROMETER), 0);
store.setPixelsPhysicalSizeY(FormatTools.createLength(y, UNITS.MICROMETER), 0);
store.setPixelsPhysicalSizeZ(FormatTools.createLength(z, UNITS.MICROMETER), 0);
store.setStageLabelName(wlz.getWlzOrgLabelName(), 0);
store.setStageLabelX(new Length(wlz.getOrgX(), UNITS.REFERENCEFRAME), 0);
store.setStageLabelY(new Length(wlz.getOrgY(), UNITS.REFERENCEFRAME), 0);
store.setStageLabelZ(new Length(wlz.getOrgZ(), UNITS.REFERENCEFRAME), 0);
MetadataTools.populatePixels(store, this);
}
}
use of loci.formats.meta.MetadataStore in project bioformats by openmicroscopy.
the class ZeissLMSReader method initFile.
// -- Internal FormatReader API methods --
/* @see loci.formats.FormatReader#initFile(String) */
public void initFile(String id) throws FormatException, IOException {
super.initFile(id);
in = new RandomAccessInputStream(id);
CoreMetadata m = core.get(0);
CoreMetadata thumb = new CoreMetadata();
m.littleEndian = true;
thumb.littleEndian = true;
in.order(m.littleEndian);
in.seek(18);
double magnification = in.readInt();
// all assumed to be constant based upon the CSM 700 data sheet
thumb.sizeX = 1280;
thumb.sizeY = 1024;
thumb.pixelType = FormatTools.UINT8;
thumb.sizeC = 3;
thumb.rgb = true;
thumb.interleaved = true;
thumb.dimensionOrder = "XYCZT";
m.sizeX = 1280;
m.sizeY = 1024;
m.pixelType = FormatTools.UINT16;
m.sizeC = 1;
m.rgb = false;
m.dimensionOrder = "XYCZT";
m.indexed = true;
// each image can be found using the "BM6" marker
seekToNextMarker();
in.skipBytes(50);
offsets.add(in.getFilePointer());
in.skipBytes(thumb.sizeX * thumb.sizeY * thumb.sizeC);
seekToNextMarker();
in.skipBytes(50);
lut = new byte[3][256];
for (int i = 0; i < lut[0].length; i++) {
for (int j = 0; j < lut.length; j++) {
lut[j][i] = in.readByte();
}
// skip alpha channel
in.skipBytes(1);
}
offsets.add(in.getFilePointer());
// again, Z stack is assumed based upon the CSM 700 data sheet
thumb.sizeZ = 1;
thumb.sizeT = 1;
thumb.imageCount = thumb.sizeZ * thumb.sizeT;
long availableBytes = in.length() - offsets.get(1);
int planeSize = m.sizeX * m.sizeY * FormatTools.getBytesPerPixel(m.pixelType);
m.sizeZ = (int) (availableBytes / planeSize);
m.sizeT = 1;
m.imageCount = m.sizeZ * m.sizeT;
core.add(thumb);
MetadataStore store = makeFilterMetadata();
MetadataTools.populatePixels(store, this);
store.setInstrumentID(MetadataTools.createLSID("Instrument", 0), 0);
String objective = MetadataTools.createLSID("Objective", 0, 0);
store.setObjectiveID(objective, 0, 0);
store.setObjectiveNominalMagnification(magnification, 0, 0);
store.setObjectiveSettingsID(objective, 0);
store.setObjectiveSettingsID(objective, 1);
}
use of loci.formats.meta.MetadataStore in project bioformats by openmicroscopy.
the class TrestleReader method initMetadataStore.
/* @see loci.formats.BaseTiffReader#initMetadataStore() */
@Override
protected void initMetadataStore() throws FormatException {
super.initMetadataStore();
MetadataStore store = makeFilterMetadata();
for (int i = 0; i < getSeriesCount(); i++) {
store.setImageName("Series " + (i + 1), i);
}
MetadataLevel level = getMetadataOptions().getMetadataLevel();
if (level != MetadataLevel.MINIMUM) {
// will not be stored with the mask dimensions
if (level != MetadataLevel.NO_OVERLAYS && !(getMetadataStore() instanceof OMEXMLMetadata)) {
try {
parseROIs(store);
} catch (IOException e) {
LOGGER.debug("Could not parse ROIs", e);
}
}
}
}
use of loci.formats.meta.MetadataStore in project bioformats by openmicroscopy.
the class VGSAMReader method initFile.
// -- Internal FormatReader API methods --
/* @see loci.formats.FormatReader#initFile(String) */
@Override
protected void initFile(String id) throws FormatException, IOException {
super.initFile(id);
in = new RandomAccessInputStream(id);
CoreMetadata m = core.get(0);
in.seek(348);
m.sizeX = in.readInt();
m.sizeY = in.readInt();
in.skipBytes(4);
int bpp = in.readInt();
addGlobalMeta("Bytes per pixel", bpp);
m.pixelType = FormatTools.pixelTypeFromBytes(bpp, false, bpp == 4);
m.littleEndian = false;
m.sizeZ = 1;
m.sizeC = 1;
m.sizeT = 1;
m.imageCount = 1;
m.rgb = false;
m.interleaved = false;
m.dimensionOrder = "XYZCT";
MetadataStore store = makeFilterMetadata();
MetadataTools.populatePixels(store, this);
}
use of loci.formats.meta.MetadataStore in project bioformats by openmicroscopy.
the class VectraReader method initMetadataStore.
/* @see loci.formats.BaseTiffReader#initMetadataStore() */
@Override
protected void initMetadataStore() throws FormatException {
super.initMetadataStore();
MetadataStore store = makeFilterMetadata();
for (int i = 0; i < getSeriesCount(); i++) {
int coreIndex = seriesToCoreIndex(i);
store.setImageName(getImageName(coreIndex), i);
store.setImageDescription("", i);
int ifdIndex = getIFDIndex(coreIndex, 0);
IFD ifd = ifds.get(ifdIndex);
double x = ifd.getXResolution();
double y = ifd.getYResolution();
store.setPixelsPhysicalSizeX(FormatTools.getPhysicalSizeX(x), i);
store.setPixelsPhysicalSizeY(FormatTools.getPhysicalSizeY(y), i);
}
for (int c = 0; c < getSizeC(); c++) {
String xml = getIFDComment(c);
try {
Element root = XMLTools.parseDOM(xml).getDocumentElement();
NodeList children = root.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
if (!(children.item(i) instanceof Element)) {
continue;
}
Element e = (Element) children.item(i);
String name = e.getNodeName();
String value = e.getTextContent();
if (name.equals("ScanProfile")) {
try {
Document profileRoot = XMLTools.createDocument();
Node tmp = profileRoot.importNode(e, true);
profileRoot.appendChild(tmp);
profileXML = XMLTools.getXML(profileRoot);
// scan profile XML is usually too long to be saved
// when original metadata filtering is enabled, but there
// is an API method below to retrieve it
addGlobalMeta(name, profileXML);
} catch (Exception ex) {
LOGGER.debug("Could not preserve scan profile metadata", ex);
}
} else {
addGlobalMetaList(name, value);
}
if (name.equals("Name")) {
if (hasFlattenedResolutions()) {
for (int series = 0; series < pyramidDepth; series++) {
store.setChannelName(value, series, c);
}
} else {
store.setChannelName(value, 0, c);
}
} else if (name.equals("Color")) {
String[] components = value.split(",");
Color color = new Color(Integer.parseInt(components[0]), Integer.parseInt(components[1]), Integer.parseInt(components[2]), 255);
if (hasFlattenedResolutions()) {
for (int series = 0; series < pyramidDepth; series++) {
store.setChannelColor(color, series, c);
}
} else {
store.setChannelColor(color, 0, c);
}
} else if (name.equals("Objective") && c == 0) {
String instrument = MetadataTools.createLSID("Instrument", 0);
String objective = MetadataTools.createLSID("Objective", 0, 0);
store.setInstrumentID(instrument, 0);
store.setObjectiveID(objective, 0, 0);
store.setObjectiveModel(value, 0, 0);
try {
String mag = value.toLowerCase().replace("x", "");
Double magFactor = DataTools.parseDouble(mag);
store.setObjectiveNominalMagnification(magFactor, 0, 0);
} catch (NumberFormatException ex) {
LOGGER.info("Could not determine magnification: {}", value);
}
for (int series = 0; series < getSeriesCount(); series++) {
store.setImageInstrumentRef(instrument, series);
store.setObjectiveSettingsID(objective, series);
}
} else if (name.equals("ExposureTime")) {
Time exposure = new Time(DataTools.parseDouble(value), UNITS.MICROSECOND);
store.setPlaneExposureTime(exposure, 0, c);
store.setPlaneTheZ(new NonNegativeInteger(0), 0, c);
store.setPlaneTheT(new NonNegativeInteger(0), 0, c);
store.setPlaneTheC(new NonNegativeInteger(c), 0, c);
}
}
} catch (ParserConfigurationException | SAXException | IOException e) {
LOGGER.warn("Could not parse XML for channel {}", c);
LOGGER.debug("", e);
}
}
}
Aggregations