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);
}
}
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();
}
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);
}
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;
}
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();
}
Aggregations