Search in sources :

Example 1 with MetadataOptions

use of loci.formats.in.MetadataOptions 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 2 with MetadataOptions

use of loci.formats.in.MetadataOptions 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 3 with MetadataOptions

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

the class ImageReaderTest method testOptionsExplicit.

@Test
public void testOptionsExplicit() throws Exception {
    DynamicMetadataOptions opt = new DynamicMetadataOptions();
    opt.set(KEY, VALUE);
    ImageReader reader = new ImageReader();
    reader.setMetadataOptions(opt);
    reader.setId("test.fake");
    MetadataOptions rOpt = reader.getReader().getMetadataOptions();
    assertTrue(rOpt instanceof DynamicMetadataOptions);
    String v = ((DynamicMetadataOptions) rOpt).get(KEY);
    assertNotNull(v);
    assertEquals(v, VALUE);
    reader.close();
}
Also used : MetadataOptions(loci.formats.in.MetadataOptions) DynamicMetadataOptions(loci.formats.in.DynamicMetadataOptions) DynamicMetadataOptions(loci.formats.in.DynamicMetadataOptions) ImageReader(loci.formats.ImageReader) Test(org.testng.annotations.Test)

Aggregations

DynamicMetadataOptions (loci.formats.in.DynamicMetadataOptions)3 MetadataOptions (loci.formats.in.MetadataOptions)3 ImageReader (loci.formats.ImageReader)2 ClassList (loci.formats.ClassList)1 IFormatReader (loci.formats.IFormatReader)1 ND2Reader (loci.formats.in.ND2Reader)1 NativeND2Reader (loci.formats.in.NativeND2Reader)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 Test (org.testng.annotations.Test)1