use of loci.formats.meta.IMetadata in project bioformats by openmicroscopy.
the class Jpeg2000GrindTest method initializeWriter.
/**
* Initializes the writer.
* @param output The file where to write the compressed data.
* @param compression The compression to use.
* @param bigTiff Pass <code>true</code> to set the <code>bigTiff</code>
* flag, <code>false</code> otherwise.
* @throws Exception Thrown if an error occurred.
*/
private void initializeWriter(String output, String compression, boolean bigTiff) throws Exception {
ServiceFactory sf = new ServiceFactory();
OMEXMLService service = sf.getInstance(OMEXMLService.class);
IMetadata metadata = service.createOMEXMLMetadata();
metadata.setImageID("Image:0", 0);
metadata.setPixelsID("Pixels:0", 0);
metadata.setPixelsBinDataBigEndian(true, 0, 0);
metadata.setPixelsDimensionOrder(DimensionOrder.XYZCT, 0);
metadata.setPixelsType(ome.xml.model.enums.PixelType.fromString(PIXEL_TYPE), 0);
metadata.setPixelsSizeX(new PositiveInteger(SIZE_X), 0);
metadata.setPixelsSizeY(new PositiveInteger(SIZE_Y), 0);
metadata.setPixelsSizeZ(new PositiveInteger(1), 0);
metadata.setPixelsSizeC(new PositiveInteger(1), 0);
metadata.setPixelsSizeT(new PositiveInteger(SIZE_Z * SIZE_C * SIZE_T), 0);
metadata.setChannelID("Channel:0", 0, 0);
metadata.setChannelSamplesPerPixel(new PositiveInteger(1), 0, 0);
writer = new TiffWriter();
writer.setMetadataRetrieve(metadata);
writer.setCompression(compression);
writer.setWriteSequentially(false);
writer.setInterleaved(true);
writer.setBigTiff(bigTiff);
writer.setId(output);
bytesPerPixel = FormatTools.getBytesPerPixel(PIXEL_TYPE);
}
use of loci.formats.meta.IMetadata in project bioformats by openmicroscopy.
the class MetadataConfigurableTest method testSetId.
@Test
public void testSetId() throws FormatException, IOException {
long t0 = System.currentTimeMillis();
pixelsOnly.setId(id);
assertEquals(MetadataLevel.MINIMUM, pixelsOnly.getMetadataOptions().getMetadataLevel());
long t1 = System.currentTimeMillis();
all.setId(id);
assertEquals(MetadataLevel.ALL, all.getMetadataOptions().getMetadataLevel());
assertFalse(0 == all.getSeriesMetadata().size() + all.getGlobalMetadata().size());
long t2 = System.currentTimeMillis();
System.err.println(String.format("Pixels only: %d -- All: %d", t1 - t0, t2 - t1));
IMetadata metadata = null;
try {
ServiceFactory factory = new ServiceFactory();
OMEXMLService service = factory.getInstance(OMEXMLService.class);
metadata = service.createOMEXMLMetadata();
noOverlays.setMetadataStore(metadata);
} catch (Exception e) {
throw new FormatException("Cannot initialize OMEXML metadata store");
}
noOverlays.setId(id);
assertEquals(MetadataLevel.NO_OVERLAYS, noOverlays.getMetadataOptions().getMetadataLevel());
assertEquals(metadata.getROICount(), 0);
}
use of loci.formats.meta.IMetadata in project bioformats by openmicroscopy.
the class FormatReaderTest method testExposureTimes.
@Test(groups = { "all", "fast", "automated" })
public void testExposureTimes() {
if (config == null)
throw new SkipException("No config tree");
String testName = "ExposureTimes";
if (!initFile())
result(testName, false, "initFile");
IMetadata retrieve = (IMetadata) reader.getMetadataStore();
for (int i = 0; i < reader.getSeriesCount(); i++) {
reader.setSeries(i);
config.setSeries(i);
if (reader.getImageCount() != retrieve.getPlaneCount(i)) {
continue;
}
for (int c = 0; c < config.getChannelCount(); c++) {
if (config.hasExposureTime(c)) {
Time exposureTime = config.getExposureTime(c);
for (int p = 0; p < reader.getImageCount(); p++) {
int[] zct = reader.getZCTCoords(p);
if (zct[1] == c && p < retrieve.getPlaneCount(i)) {
Time planeExposureTime = retrieve.getPlaneExposureTime(i, p);
if (exposureTime == null && planeExposureTime == null) {
continue;
}
if (exposureTime == null || planeExposureTime == null || !exposureTime.equals(planeExposureTime)) {
result(testName, false, "Series " + i + " plane " + p + " channel " + c + " (got " + planeExposureTime + ", expected " + exposureTime + ")");
}
}
}
}
}
}
result(testName, true);
}
use of loci.formats.meta.IMetadata in project bioformats by openmicroscopy.
the class FormatReaderTest method testDetectors.
@Test(groups = { "all", "fast", "automated" })
public void testDetectors() {
if (config == null)
throw new SkipException("No config tree");
String testName = "Detectors";
if (!initFile())
result(testName, false, "initFile");
IMetadata retrieve = (IMetadata) reader.getMetadataStore();
for (int i = 0; i < reader.getSeriesCount(); i++) {
config.setSeries(i);
for (int c = 0; c < config.getChannelCount(); c++) {
String expectedDetector = config.getDetector(c);
String realDetector = null;
try {
realDetector = retrieve.getDetectorSettingsID(i, c);
} catch (NullPointerException e) {
}
if (!(expectedDetector == null && realDetector == null)) {
if ((expectedDetector == null || !expectedDetector.equals(realDetector)) && (realDetector == null || !realDetector.equals(expectedDetector))) {
result(testName, false, "Series " + i + " channel " + c + " (expected " + expectedDetector + ", actual " + realDetector + ")");
}
}
}
}
result(testName, true);
}
use of loci.formats.meta.IMetadata in project bioformats by openmicroscopy.
the class FormatReaderTest method testImageNames.
@Test(groups = { "all", "fast", "automated" })
public void testImageNames() {
if (config == null)
throw new SkipException("No config tree");
String testName = "ImageNames";
if (!initFile())
result(testName, false, "initFile");
IMetadata retrieve = (IMetadata) reader.getMetadataStore();
for (int i = 0; i < reader.getSeriesCount(); i++) {
config.setSeries(i);
String realName = retrieve.getImageName(i);
String expectedName = config.getImageName();
if (!expectedName.equals(realName) && !(realName == null && expectedName.equals("null"))) {
result(testName, false, "Series " + i + " (got '" + realName + "', expected '" + expectedName + "')");
}
}
result(testName, true);
}
Aggregations