Search in sources :

Example 1 with OMETiffReader

use of loci.formats.in.OMETiffReader in project bioformats by openmicroscopy.

the class OMETiffWriterTest method testCompanion.

@Test
public void testCompanion() throws Exception {
    Path wd = Files.createTempDirectory(this.getClass().getName());
    File outFile = wd.resolve("test.ome.tif").toFile();
    File cFile = wd.resolve("test.companion.ome").toFile();
    String companion = cFile.getAbsolutePath();
    DynamicMetadataOptions options = new DynamicMetadataOptions();
    options.set(OMETiffWriter.COMPANION_KEY, companion);
    int planeCount = WriterUtilities.SIZE_Z * WriterUtilities.SIZE_C * WriterUtilities.SIZE_T;
    OMETiffWriter cwriter = new OMETiffWriter();
    cwriter.setMetadataOptions(options);
    cwriter.setMetadataRetrieve(metadata);
    cwriter.setId(outFile.getAbsolutePath());
    cwriter.setSeries(0);
    byte[] img = new byte[WriterUtilities.SIZE_X * WriterUtilities.SIZE_Y];
    for (int i = 0; i < planeCount; i++) {
        cwriter.saveBytes(i, img);
    }
    cwriter.close();
    assertTrue(cFile.exists());
    OMETiffReader reader = new OMETiffReader();
    reader.setId(companion);
    assertEquals(reader.getSizeX(), WriterUtilities.SIZE_X);
    assertEquals(reader.getSizeY(), WriterUtilities.SIZE_Y);
    assertEquals(reader.getSizeZ(), WriterUtilities.SIZE_Z);
    assertEquals(reader.getSizeC(), WriterUtilities.SIZE_C);
    assertEquals(reader.getSizeT(), WriterUtilities.SIZE_T);
    reader.close();
    outFile.deleteOnExit();
    cFile.deleteOnExit();
    wd.toFile().deleteOnExit();
}
Also used : Path(java.nio.file.Path) OMETiffWriter(loci.formats.out.OMETiffWriter) OMETiffReader(loci.formats.in.OMETiffReader) DynamicMetadataOptions(loci.formats.in.DynamicMetadataOptions) File(java.io.File) Test(org.testng.annotations.Test)

Aggregations

File (java.io.File)1 Path (java.nio.file.Path)1 DynamicMetadataOptions (loci.formats.in.DynamicMetadataOptions)1 OMETiffReader (loci.formats.in.OMETiffReader)1 OMETiffWriter (loci.formats.out.OMETiffWriter)1 Test (org.testng.annotations.Test)1