use of loci.formats.FormatException in project bioformats by openmicroscopy.
the class LociFunctions method openImagePlus.
public void openImagePlus(String path) {
ImagePlus[] imps = null;
try {
ImporterOptions options = new ImporterOptions();
options.setId(path);
options.setSeriesOn(series, true);
imps = BF.openImagePlus(options);
for (ImagePlus imp : imps) imp.show();
} catch (IOException exc) {
IJ.handleException(exc);
} catch (FormatException exc) {
IJ.handleException(exc);
}
}
use of loci.formats.FormatException in project bioformats by openmicroscopy.
the class LociFunctions method openThumbImagePlus.
public void openThumbImagePlus(String path) {
ImagePlus[] imps = null;
try {
ImporterOptions options = new ImporterOptions();
options.setId(path);
options.setSeriesOn(series, true);
imps = BF.openThumbImagePlus(options);
for (ImagePlus imp : imps) imp.show();
} catch (IOException exc) {
IJ.handleException(exc);
} catch (FormatException exc) {
IJ.handleException(exc);
}
}
use of loci.formats.FormatException 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.FormatException in project bioformats by openmicroscopy.
the class FormatReaderTest method testConsistentReader.
@Test(groups = { "all", "fast", "automated" })
public void testConsistentReader() {
if (config == null)
throw new SkipException("No config tree");
String testName = "testConsistentReader";
if (!initFile())
result(testName, false, "initFile");
String format = config.getReader();
IFormatReader r = reader;
if (r instanceof ImageReader) {
r = ((ImageReader) r).getReader();
} else if (r instanceof ReaderWrapper) {
try {
r = ((ReaderWrapper) r).unwrap();
} catch (FormatException e) {
} catch (IOException e) {
}
}
String realFormat = TestTools.shortClassName(r);
result(testName, realFormat.equals(format), realFormat);
}
use of loci.formats.FormatException in project bioformats by openmicroscopy.
the class FileConvert method initialize.
/**
* Set up the file reader and writer, ensuring that the input file is
* associated with the reader and the output file is associated with the
* writer.
*
* @return true if the reader and writer were successfully set up, or false
* if an error occurred
*/
private boolean initialize() {
Exception exception = null;
try {
// construct the object that stores OME-XML metadata
ServiceFactory factory = new ServiceFactory();
OMEXMLService service = factory.getInstance(OMEXMLService.class);
IMetadata omexml = service.createOMEXMLMetadata();
// set up the reader and associate it with the input file
reader = new ImageReader();
reader.setMetadataStore(omexml);
reader.setId(inputFile);
// set up the writer and associate it with the output file
writer = new ImageWriter();
writer.setMetadataRetrieve(omexml);
writer.setInterleaved(reader.isInterleaved());
writer.setId(outputFile);
} catch (FormatException e) {
exception = e;
} catch (IOException e) {
exception = e;
} catch (DependencyException e) {
exception = e;
} catch (ServiceException e) {
exception = e;
}
if (exception != null) {
System.err.println("Failed to initialize files.");
exception.printStackTrace();
}
return exception == null;
}
Aggregations