Search in sources :

Example 11 with DependencyException

use of loci.common.services.DependencyException in project bioformats by openmicroscopy.

the class PrintROIs method main.

public static void main(String[] args) throws Exception {
    ImageReader reader = new ImageReader();
    IMetadata omexml;
    try {
        ServiceFactory factory = new ServiceFactory();
        OMEXMLService service = factory.getInstance(OMEXMLService.class);
        omexml = service.createOMEXMLMetadata();
    } catch (DependencyException exc) {
        throw new FormatException("Could not create OME-XML store.", exc);
    } catch (ServiceException exc) {
        throw new FormatException("Could not create OME-XML store.", exc);
    }
    reader.setMetadataStore(omexml);
    reader.setId(args[0]);
    printAllROIs(omexml);
    System.out.println();
    for (int series = 0; series < reader.getSeriesCount(); series++) {
        printSeriesROIs(omexml, series);
    }
    reader.close();
}
Also used : IMetadata(loci.formats.meta.IMetadata) ServiceException(loci.common.services.ServiceException) ServiceFactory(loci.common.services.ServiceFactory) ImageReader(loci.formats.ImageReader) DependencyException(loci.common.services.DependencyException) OMEXMLService(loci.formats.services.OMEXMLService) FormatException(loci.formats.FormatException) Point(ome.xml.model.Point)

Example 12 with DependencyException

use of loci.common.services.DependencyException in project bioformats by openmicroscopy.

the class FV1000Reader method initPOIService.

private void initPOIService() throws FormatException, IOException {
    try {
        ServiceFactory factory = new ServiceFactory();
        poi = factory.getInstance(POIService.class);
    } catch (DependencyException de) {
        throw new FormatException("POI library not found", de);
    }
    poi.initialize(Location.getMappedId(getCurrentFile()));
}
Also used : ServiceFactory(loci.common.services.ServiceFactory) POIService(loci.formats.services.POIService) DependencyException(loci.common.services.DependencyException) FormatException(loci.formats.FormatException)

Example 13 with DependencyException

use of loci.common.services.DependencyException in project bioformats by openmicroscopy.

the class CellH5Reader method initializeJHDFService.

// -- Helper methods --
private void initializeJHDFService(String id) throws IOException, MissingLibraryException {
    try {
        ServiceFactory factory = new ServiceFactory();
        jhdf = factory.getInstance(JHDFService.class);
        jhdf.setFile(id);
    } catch (DependencyException e) {
        throw new MissingLibraryException(JHDFServiceImpl.NO_JHDF_MSG, e);
    }
}
Also used : ServiceFactory(loci.common.services.ServiceFactory) MissingLibraryException(loci.formats.MissingLibraryException) JHDFService(loci.formats.services.JHDFService) DependencyException(loci.common.services.DependencyException)

Example 14 with DependencyException

use of loci.common.services.DependencyException in project bioformats by openmicroscopy.

the class WriterUtilities method createMetadata.

public static IMetadata createMetadata(String pixelType, int rgbChannels, int seriesCount, boolean littleEndian, int sizeT) throws Exception {
    IMetadata metadata;
    try {
        ServiceFactory factory = new ServiceFactory();
        OMEXMLService service = factory.getInstance(OMEXMLService.class);
        metadata = service.createOMEXMLMetadata();
    } catch (DependencyException exc) {
        throw new FormatException("Could not create OME-XML store.", exc);
    } catch (ServiceException exc) {
        throw new FormatException("Could not create OME-XML store.", exc);
    }
    for (int i = 0; i < seriesCount; i++) {
        MetadataTools.populateMetadata(metadata, i, "image #" + i, littleEndian, "XYCZT", pixelType, 160, 160, 1, rgbChannels, sizeT, rgbChannels);
    }
    return metadata;
}
Also used : IMetadata(loci.formats.meta.IMetadata) ServiceException(loci.common.services.ServiceException) ServiceFactory(loci.common.services.ServiceFactory) DependencyException(loci.common.services.DependencyException) OMEXMLService(loci.formats.services.OMEXMLService) FormatException(loci.formats.FormatException)

Example 15 with DependencyException

use of loci.common.services.DependencyException in project bioformats by openmicroscopy.

the class LosslessJPEG2000Test method setUp.

@BeforeMethod
public void setUp() throws Exception {
    File temp8 = File.createTempFile("test", ".jp2");
    File temp16 = File.createTempFile("test", ".jp2");
    temp8.deleteOnExit();
    temp16.deleteOnExit();
    Location.mapId(FILE_8, temp8.getAbsolutePath());
    Location.mapId(FILE_16, temp16.getAbsolutePath());
    IMetadata metadata8;
    try {
        ServiceFactory factory = new ServiceFactory();
        OMEXMLService service = factory.getInstance(OMEXMLService.class);
        metadata8 = service.createOMEXMLMetadata();
    } catch (DependencyException exc) {
        throw new FormatException("Could not create OME-XML store.", exc);
    } catch (ServiceException exc) {
        throw new FormatException("Could not create OME-XML store.", exc);
    }
    MetadataTools.populateMetadata(metadata8, 0, "foo", false, "XYCZT", "uint8", 1, 1, 1, 1, 1, 1);
    IFormatWriter writer8 = new JPEG2000Writer();
    writer8.setMetadataRetrieve(metadata8);
    writer8.setId(FILE_8);
    writer8.saveBytes(0, PIXELS_8);
    writer8.close();
    IMetadata metadata16;
    try {
        ServiceFactory factory = new ServiceFactory();
        OMEXMLService service = factory.getInstance(OMEXMLService.class);
        metadata16 = service.createOMEXMLMetadata();
    } catch (DependencyException exc) {
        throw new FormatException("Could not create OME-XML store.", exc);
    } catch (ServiceException exc) {
        throw new FormatException("Could not create OME-XML store.", exc);
    }
    MetadataTools.populateMetadata(metadata16, 0, "foo", false, "XYCZT", "uint16", 1, 1, 1, 1, 1, 1);
    IFormatWriter writer16 = new JPEG2000Writer();
    writer16.setMetadataRetrieve(metadata16);
    writer16.setId(FILE_16);
    writer16.saveBytes(0, PIXELS_16);
    writer16.close();
}
Also used : IFormatWriter(loci.formats.IFormatWriter) JPEG2000Writer(loci.formats.out.JPEG2000Writer) IMetadata(loci.formats.meta.IMetadata) ServiceException(loci.common.services.ServiceException) ServiceFactory(loci.common.services.ServiceFactory) DependencyException(loci.common.services.DependencyException) File(java.io.File) OMEXMLService(loci.formats.services.OMEXMLService) FormatException(loci.formats.FormatException) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

DependencyException (loci.common.services.DependencyException)51 ServiceFactory (loci.common.services.ServiceFactory)49 FormatException (loci.formats.FormatException)39 ServiceException (loci.common.services.ServiceException)32 OMEXMLService (loci.formats.services.OMEXMLService)32 MissingLibraryException (loci.formats.MissingLibraryException)15 MetadataStore (loci.formats.meta.MetadataStore)14 CoreMetadata (loci.formats.CoreMetadata)13 IMetadata (loci.formats.meta.IMetadata)13 IOException (java.io.IOException)12 Location (loci.common.Location)10 ImageReader (loci.formats.ImageReader)10 Length (ome.units.quantity.Length)10 PositiveInteger (ome.xml.model.primitives.PositiveInteger)9 OMEXMLMetadata (loci.formats.ome.OMEXMLMetadata)8 ArrayList (java.util.ArrayList)7 MetadataRetrieve (loci.formats.meta.MetadataRetrieve)6 EnumerationException (ome.xml.model.enums.EnumerationException)6 File (java.io.File)5 IFormatWriter (loci.formats.IFormatWriter)5