Search in sources :

Example 1 with DynamicMetadataOptions

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

the class DynamicMetadataOptionsTest method testMetadataLevel.

// -- MetadataOptions tests --
@Test
public void testMetadataLevel() {
    assertEquals(opt.getMetadataLevel(), DynamicMetadataOptions.METADATA_LEVEL_DEFAULT);
    for (MetadataLevel level : MetadataLevel.values()) {
        opt.setMetadataLevel(level);
        assertEquals(opt.getMetadataLevel(), level);
        assertEquals((new DynamicMetadataOptions(level)).getMetadataLevel(), level);
    }
}
Also used : DynamicMetadataOptions(loci.formats.in.DynamicMetadataOptions) MetadataLevel(loci.formats.in.MetadataLevel) Test(org.testng.annotations.Test)

Example 2 with DynamicMetadataOptions

use of loci.formats.in.DynamicMetadataOptions 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)

Example 3 with DynamicMetadataOptions

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

the class FileStitcherTest method checkKV.

public static void checkKV(IFormatReader r, String k, String expv) {
    MetadataOptions rOpt = r.getMetadataOptions();
    assertTrue(rOpt instanceof DynamicMetadataOptions);
    String v = ((DynamicMetadataOptions) rOpt).get(k);
    assertNotNull(v);
    assertEquals(v, expv);
}
Also used : MetadataOptions(loci.formats.in.MetadataOptions) DynamicMetadataOptions(loci.formats.in.DynamicMetadataOptions) DynamicMetadataOptions(loci.formats.in.DynamicMetadataOptions)

Example 4 with DynamicMetadataOptions

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

the class LociPrefs method makeImageReader.

// -- Utility methods --
/**
 * Creates an image reader according to the current configuration settings,
 * including which format readers are currently enabled, as well as
 * format-specific configuration settings.
 */
public static ImageReader makeImageReader() {
    ClassList<IFormatReader> defaultClasses = ImageReader.getDefaultReaderClasses();
    Class<? extends IFormatReader>[] c = defaultClasses.getClasses();
    // include only enabled classes
    ClassList<IFormatReader> enabledClasses = new ClassList<IFormatReader>(IFormatReader.class);
    for (int i = 0; i < c.length; i++) {
        boolean on = LociPrefs.isReaderEnabled(c[i]);
        if (on)
            enabledClasses.addClass(c[i]);
    }
    ImageReader reader = new ImageReader(enabledClasses);
    MetadataOptions options = reader.getMetadataOptions();
    if (options instanceof DynamicMetadataOptions) {
        ((DynamicMetadataOptions) options).setBoolean(ZeissCZIReader.ALLOW_AUTOSTITCHING_KEY, allowCZIAutostitch());
        ((DynamicMetadataOptions) options).setBoolean(ZeissCZIReader.INCLUDE_ATTACHMENTS_KEY, includeCZIAttachments());
        ((DynamicMetadataOptions) options).setBoolean(NativeND2Reader.USE_CHUNKMAP_KEY, useND2Chunkmap());
        ((DynamicMetadataOptions) options).setBoolean(LIFReader.OLD_PHYSICAL_SIZE_KEY, isLeicaLIFPhysicalSizeBackwardsCompatible());
        ((DynamicMetadataOptions) options).setBoolean(CellSensReader.FAIL_ON_MISSING_KEY, isCellsensFailOnMissing());
        reader.setMetadataOptions(options);
    }
    // toggle reader-specific options
    boolean nd2Nikon = LociPrefs.isND2Nikon();
    boolean pictQTJava = LociPrefs.isPictQTJava();
    boolean qtQTJava = LociPrefs.isQTQTJava();
    boolean sdtIntensity = LociPrefs.isSDTIntensity();
    boolean tiffImageIO = LociPrefs.isTiffImageIO();
    IFormatReader[] r = reader.getReaders();
    for (int i = 0; i < r.length; i++) {
        if (r[i] instanceof ND2Reader) {
            ND2Reader nd2 = (ND2Reader) r[i];
            nd2.setLegacy(nd2Nikon);
        } else if (r[i] instanceof PictReader) {
            PictReader pict = (PictReader) r[i];
            pict.setLegacy(pictQTJava);
        } else if (r[i] instanceof QTReader) {
            QTReader qt = (QTReader) r[i];
            qt.setLegacy(qtQTJava);
        } else if (r[i] instanceof SDTReader) {
            SDTReader sdt = (SDTReader) r[i];
            sdt.setIntensity(sdtIntensity);
        } else if (r[i] instanceof TiffDelegateReader) {
            TiffDelegateReader tiff = (TiffDelegateReader) r[i];
            tiff.setLegacy(tiffImageIO);
        }
    }
    return reader;
}
Also used : IFormatReader(loci.formats.IFormatReader) TiffDelegateReader(loci.formats.in.TiffDelegateReader) MetadataOptions(loci.formats.in.MetadataOptions) DynamicMetadataOptions(loci.formats.in.DynamicMetadataOptions) ClassList(loci.formats.ClassList) QTReader(loci.formats.in.QTReader) SDTReader(loci.formats.in.SDTReader) NativeND2Reader(loci.formats.in.NativeND2Reader) ND2Reader(loci.formats.in.ND2Reader) DynamicMetadataOptions(loci.formats.in.DynamicMetadataOptions) PictReader(loci.formats.in.PictReader) ImageReader(loci.formats.ImageReader)

Example 5 with DynamicMetadataOptions

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

the class FileStitcherTest method testOptionsExplicit.

@Test
public void testOptionsExplicit() throws IOException, FormatException {
    DynamicMetadataOptions opt = new DynamicMetadataOptions();
    opt.set(KEY, VALUE);
    FileStitcher fs = new FileStitcher();
    fs.setMetadataOptions(opt);
    fs.setId("test_z<0-2>.fake");
    checkKV(fs.getUnderlyingReaders(), KEY, VALUE);
    DynamicMetadataOptions newOpt = new DynamicMetadataOptions();
    String newValue = VALUE + "_";
    newOpt.set(KEY, newValue);
    fs.setMetadataOptions(newOpt);
    checkKV(fs.getUnderlyingReaders(), KEY, newValue);
    fs.close();
}
Also used : FileStitcher(loci.formats.FileStitcher) DynamicMetadataOptions(loci.formats.in.DynamicMetadataOptions) Test(org.testng.annotations.Test)

Aggregations

DynamicMetadataOptions (loci.formats.in.DynamicMetadataOptions)6 Test (org.testng.annotations.Test)4 MetadataOptions (loci.formats.in.MetadataOptions)3 ImageReader (loci.formats.ImageReader)2 File (java.io.File)1 Path (java.nio.file.Path)1 ClassList (loci.formats.ClassList)1 FileStitcher (loci.formats.FileStitcher)1 IFormatReader (loci.formats.IFormatReader)1 MetadataLevel (loci.formats.in.MetadataLevel)1 ND2Reader (loci.formats.in.ND2Reader)1 NativeND2Reader (loci.formats.in.NativeND2Reader)1 OMETiffReader (loci.formats.in.OMETiffReader)1 PictReader (loci.formats.in.PictReader)1 QTReader (loci.formats.in.QTReader)1 SDTReader (loci.formats.in.SDTReader)1 TiffDelegateReader (loci.formats.in.TiffDelegateReader)1 OMETiffWriter (loci.formats.out.OMETiffWriter)1