use of loci.formats.tiff.TiffRational in project bioformats by openmicroscopy.
the class BaseTiffReader method initMetadataStore.
/**
* Populates the metadata store using the data parsed in
* {@link #initStandardMetadata()} along with some further parsing done in
* the method itself.
*
* All calls to the active <code>MetadataStore</code> should be made in this
* method and <b>only</b> in this method. This is especially important for
* sub-classes that override the getters for pixel set array size, etc.
*/
protected void initMetadataStore() throws FormatException {
LOGGER.info("Populating OME metadata");
// the metadata store we're working with
MetadataStore store = makeFilterMetadata();
IFD firstIFD = ifds.get(0);
IFD exif = null;
if (ifds.get(0).containsKey(IFD.EXIF)) {
try {
IFDList exifIFDs = tiffParser.getExifIFDs();
if (exifIFDs.size() > 0) {
exif = exifIFDs.get(0);
}
tiffParser.fillInIFD(exif);
} catch (IOException e) {
LOGGER.debug("Could not read EXIF IFDs", e);
}
}
MetadataTools.populatePixels(store, this, exif != null);
// format the creation date to ISO 8601
String creationDate = getImageCreationDate();
String date = DateTools.formatDate(creationDate, DATE_FORMATS, ".");
if (creationDate != null && date == null) {
LOGGER.warn("unknown creation date format: {}", creationDate);
}
creationDate = date;
if (creationDate != null) {
store.setImageAcquisitionDate(new Timestamp(creationDate), 0);
}
if (getMetadataOptions().getMetadataLevel() != MetadataLevel.MINIMUM) {
// populate Experimenter
String artist = firstIFD.getIFDTextValue(IFD.ARTIST);
if (artist != null) {
String firstName = null, lastName = null;
int ndx = artist.indexOf(' ');
if (ndx < 0)
lastName = artist;
else {
firstName = artist.substring(0, ndx);
lastName = artist.substring(ndx + 1);
}
String email = firstIFD.getIFDStringValue(IFD.HOST_COMPUTER);
store.setExperimenterFirstName(firstName, 0);
store.setExperimenterLastName(lastName, 0);
store.setExperimenterEmail(email, 0);
store.setExperimenterID(MetadataTools.createLSID("Experimenter", 0), 0);
}
store.setImageDescription(firstIFD.getComment(), 0);
// set the X and Y pixel dimensions
double pixX = firstIFD.getXResolution();
double pixY = firstIFD.getYResolution();
String unit = getResolutionUnitFromComment(firstIFD);
Length sizeX = FormatTools.getPhysicalSizeX(pixX, unit);
Length sizeY = FormatTools.getPhysicalSizeY(pixY, unit);
if (sizeX != null) {
store.setPixelsPhysicalSizeX(sizeX, 0);
}
if (sizeY != null) {
store.setPixelsPhysicalSizeY(sizeY, 0);
}
store.setPixelsPhysicalSizeZ(null, 0);
if (exif != null) {
if (exif.containsKey(IFD.EXPOSURE_TIME)) {
Object exp = exif.get(IFD.EXPOSURE_TIME);
if (exp instanceof TiffRational) {
Time exposure = new Time(((TiffRational) exp).doubleValue(), UNITS.SECOND);
for (int i = 0; i < getImageCount(); i++) {
store.setPlaneExposureTime(exposure, 0, i);
}
}
}
}
}
}
use of loci.formats.tiff.TiffRational in project bioformats by openmicroscopy.
the class TiffRationalTest method testNotEqual.
@Test
public void testNotEqual() {
TiffRational a = new TiffRational(1, 4);
TiffRational b = new TiffRational(1, 5);
assertTrue(!(a.equals(b)));
}
use of loci.formats.tiff.TiffRational in project bioformats by openmicroscopy.
the class TiffRationalTest method testLessThan.
@Test
public void testLessThan() {
TiffRational a = new TiffRational(1, 5);
TiffRational b = new TiffRational(1, 4);
assertEquals(-1, a.compareTo(b));
}
use of loci.formats.tiff.TiffRational in project bioformats by openmicroscopy.
the class TiffRationalTest method testEqualObject.
@Test
public void testEqualObject() {
TiffRational a = new TiffRational(1, 4);
Object b = new Object();
assertTrue(!(a.equals(b)));
}
use of loci.formats.tiff.TiffRational in project bioformats by openmicroscopy.
the class TiffRationalTest method testGreaterThan.
@Test
public void testGreaterThan() {
TiffRational a = new TiffRational(1, 4);
TiffRational b = new TiffRational(1, 5);
assertEquals(1, a.compareTo(b));
}
Aggregations