Search in sources :

Example 6 with OMEXMLService

use of loci.formats.services.OMEXMLService 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 7 with OMEXMLService

use of loci.formats.services.OMEXMLService in project bioformats by openmicroscopy.

the class DumpOMEXML method dumpOMEXML.

public static void dumpOMEXML(String path) throws FormatException, IOException, DependencyException, ServiceException {
    ServiceFactory serviceFactory = new ServiceFactory();
    OMEXMLService omexmlService = serviceFactory.getInstance(OMEXMLService.class);
    IMetadata meta = omexmlService.createOMEXMLMetadata();
    ImageReader r = new ImageReader();
    r.setMetadataStore(meta);
    r.setOriginalMetadataPopulated(true);
    r.setId(path);
    r.close();
    String xml = omexmlService.getOMEXML(meta);
    System.out.println(xml);
}
Also used : IMetadata(loci.formats.meta.IMetadata) ServiceFactory(loci.common.services.ServiceFactory) ImageReader(loci.formats.ImageReader) OMEXMLService(loci.formats.services.OMEXMLService)

Example 8 with OMEXMLService

use of loci.formats.services.OMEXMLService in project bioformats by openmicroscopy.

the class EditImageName method main.

public static void main(String[] args) throws Exception {
    if (args.length != 1) {
        System.out.println("Usage: java EditImageName file");
        return;
    }
    ImageReader reader = new ImageReader();
    // record metadata to OME-XML format
    ServiceFactory factory = new ServiceFactory();
    OMEXMLService service = factory.getInstance(OMEXMLService.class);
    IMetadata omexmlMeta = service.createOMEXMLMetadata();
    reader.setMetadataStore(omexmlMeta);
    String id = args[0];
    System.out.print("Reading metadata ");
    reader.setId(id);
    System.out.println(" [done]");
    // get image name
    String name = omexmlMeta.getImageName(0);
    System.out.println("Initial Image name = " + name);
    // change image name (reverse it)
    char[] arr = name.toCharArray();
    for (int i = 0; i < arr.length / 2; i++) {
        int i2 = arr.length - i - 1;
        char c = arr[i];
        char c2 = arr[i2];
        arr[i] = c2;
        arr[i2] = c;
    }
    name = new String(arr);
    // save altered name back to OME-XML structure
    omexmlMeta.setImageName(name, 0);
    System.out.println("Updated Image name = " + name);
    // output full OME-XML block
    System.out.println("Full OME-XML dump:");
    String xml = service.getOMEXML(omexmlMeta);
    System.out.println(xml);
}
Also used : IMetadata(loci.formats.meta.IMetadata) ServiceFactory(loci.common.services.ServiceFactory) ImageReader(loci.formats.ImageReader) OMEXMLService(loci.formats.services.OMEXMLService)

Example 9 with OMEXMLService

use of loci.formats.services.OMEXMLService in project bioformats by openmicroscopy.

the class Schema2011_06_Instrument_Upgrade_Test method setUp.

@BeforeClass
public void setUp() throws Exception {
    InputStream source = this.getClass().getResourceAsStream(ref.FILE_LOCATION);
    ServiceFactory sf = new ServiceFactory();
    OMEXMLService service = sf.getInstance(OMEXMLService.class);
    String xml = XMLTools.transformXML(new StreamSource(source), UPDATE_201106);
    ome = (OME) service.createOMEXMLRoot(xml);
}
Also used : ServiceFactory(loci.common.services.ServiceFactory) InputStream(java.io.InputStream) StreamSource(javax.xml.transform.stream.StreamSource) OMEXMLService(loci.formats.services.OMEXMLService) BeforeClass(org.testng.annotations.BeforeClass)

Example 10 with OMEXMLService

use of loci.formats.services.OMEXMLService 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)

Aggregations

OMEXMLService (loci.formats.services.OMEXMLService)59 ServiceFactory (loci.common.services.ServiceFactory)57 IMetadata (loci.formats.meta.IMetadata)35 DependencyException (loci.common.services.DependencyException)28 ServiceException (loci.common.services.ServiceException)26 FormatException (loci.formats.FormatException)23 ImageReader (loci.formats.ImageReader)21 PositiveInteger (ome.xml.model.primitives.PositiveInteger)12 IOException (java.io.IOException)11 MetadataStore (loci.formats.meta.MetadataStore)7 File (java.io.File)6 Location (loci.common.Location)6 ImageWriter (loci.formats.ImageWriter)6 OMEXMLMetadata (loci.formats.ome.OMEXMLMetadata)6 Length (ome.units.quantity.Length)6 BeforeClass (org.testng.annotations.BeforeClass)6 IFormatWriter (loci.formats.IFormatWriter)5 MissingLibraryException (loci.formats.MissingLibraryException)5 OMETiffWriter (loci.formats.out.OMETiffWriter)5 ArrayList (java.util.ArrayList)4