Search in sources :

Example 16 with ImageReader

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

the class ImageInfo method printOMEXML.

public void printOMEXML() throws MissingLibraryException, ServiceException {
    LOGGER.info("");
    MetadataStore ms = reader.getMetadataStore();
    if (baseReader instanceof ImageReader) {
        baseReader = ((ImageReader) baseReader).getReader();
    }
    OMEXMLService service;
    try {
        ServiceFactory factory = new ServiceFactory();
        service = factory.getInstance(OMEXMLService.class);
    } catch (DependencyException de) {
        throw new MissingLibraryException(OMEXMLServiceImpl.NO_OME_XML_MSG, de);
    }
    String version = service.getOMEXMLVersion(ms);
    if (version == null)
        LOGGER.info("Generating OME-XML");
    else {
        LOGGER.info("Generating OME-XML (schema version {})", version);
    }
    if (ms instanceof MetadataRetrieve) {
        if (omexmlOnly) {
            DebugTools.setRootLevel("INFO");
        }
        String xml = service.getOMEXML((MetadataRetrieve) ms);
        LOGGER.info("{}", XMLTools.indentXML(xml, xmlSpaces, true));
        if (omexmlOnly) {
            DebugTools.setRootLevel("OFF");
        }
    } else {
        LOGGER.info("The metadata could not be converted to OME-XML.");
        if (omexmlVersion == null) {
            LOGGER.info("The OME-XML Java library is probably not available.");
        } else {
            LOGGER.info("{} is probably not a legal schema version.", omexmlVersion);
        }
    }
}
Also used : MetadataStore(loci.formats.meta.MetadataStore) ServiceFactory(loci.common.services.ServiceFactory) MissingLibraryException(loci.formats.MissingLibraryException) ImageReader(loci.formats.ImageReader) BufferedImageReader(loci.formats.gui.BufferedImageReader) DependencyException(loci.common.services.DependencyException) MetadataRetrieve(loci.formats.meta.MetadataRetrieve) OMEXMLService(loci.formats.services.OMEXMLService)

Example 17 with ImageReader

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

the class PrintDomains method main.

public static void main(String[] args) {
    // get a list of all available readers
    IFormatReader[] readers = new ImageReader().getReaders();
    final TreeMultimap<String, String> domains = TreeMultimap.create();
    for (IFormatReader reader : readers) {
        try {
            String[] readerDomains = reader.getPossibleDomains("");
            for (String domain : readerDomains) {
                domains.put(domain, reader.getFormat());
            }
        } catch (FormatException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    for (final Map.Entry<String, Collection<String>> domain : domains.asMap().entrySet()) {
        System.out.println(domain.getKey() + ":");
        for (final String readerFormat : domain.getValue()) {
            System.out.println("  " + readerFormat);
        }
    }
}
Also used : IFormatReader(loci.formats.IFormatReader) Collection(java.util.Collection) IOException(java.io.IOException) ImageReader(loci.formats.ImageReader) Map(java.util.Map) FormatException(loci.formats.FormatException)

Example 18 with ImageReader

use of loci.formats.ImageReader 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 19 with ImageReader

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

the class FormatReaderTest method setupReader.

// -- Helper methods --
/**
 * Sets up the current IFormatReader.
 */
private void setupReader() {
    // Remove external SlideBook6Reader class for testing purposes
    ImageReader ir = new ImageReader();
    reader = new BufferedImageReader(new FileStitcher(new Memoizer(ir, Memoizer.DEFAULT_MINIMUM_ELAPSED, new File(""))));
    reader.setMetadataOptions(new DefaultMetadataOptions(MetadataLevel.NO_OVERLAYS));
    reader.setNormalized(true);
    reader.setOriginalMetadataPopulated(false);
    reader.setMetadataFiltered(true);
    MetadataStore store = null;
    try {
        store = omexmlService.createOMEXMLMetadata();
    } catch (ServiceException e) {
        LOGGER.warn("Could not parse OME-XML", e);
    }
    reader.setMetadataStore(store);
}
Also used : MetadataStore(loci.formats.meta.MetadataStore) FileStitcher(loci.formats.FileStitcher) ServiceException(loci.common.services.ServiceException) Memoizer(loci.formats.Memoizer) BufferedImageReader(loci.formats.gui.BufferedImageReader) ImageReader(loci.formats.ImageReader) BufferedImageReader(loci.formats.gui.BufferedImageReader) File(java.io.File)

Example 20 with ImageReader

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

the class OpenBytesPerformanceTest method setId.

@Test
public void setId() throws Exception {
    reader = new ImageReader();
    reader = new ChannelFiller(reader);
    reader = new ChannelSeparator(reader);
    reader = new MinMaxCalculator(reader);
    if (memMap && reader.isSingleFile(id)) {
        TestTools.mapFile(id);
    }
    StopWatch stopWatch = new Slf4JStopWatch();
    reader.setId(id);
    stopWatch.stop(String.format("%s.setId.%s", ((ReaderWrapper) reader).unwrap().getClass().getName(), filename));
    seriesCount = reader.getSeriesCount();
}
Also used : Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) MinMaxCalculator(loci.formats.MinMaxCalculator) ChannelFiller(loci.formats.ChannelFiller) ImageReader(loci.formats.ImageReader) ChannelSeparator(loci.formats.ChannelSeparator) ReaderWrapper(loci.formats.ReaderWrapper) Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) StopWatch(org.perf4j.StopWatch) Test(org.testng.annotations.Test)

Aggregations

ImageReader (loci.formats.ImageReader)71 ServiceFactory (loci.common.services.ServiceFactory)23 OMEXMLService (loci.formats.services.OMEXMLService)23 FormatException (loci.formats.FormatException)20 IFormatReader (loci.formats.IFormatReader)20 IMetadata (loci.formats.meta.IMetadata)19 Test (org.testng.annotations.Test)15 IOException (java.io.IOException)11 ChannelFiller (loci.formats.ChannelFiller)11 DependencyException (loci.common.services.DependencyException)10 ServiceException (loci.common.services.ServiceException)10 ChannelSeparator (loci.formats.ChannelSeparator)10 MinMaxCalculator (loci.formats.MinMaxCalculator)10 BufferedImageReader (loci.formats.gui.BufferedImageReader)8 ImageWriter (loci.formats.ImageWriter)7 File (java.io.File)6 FileStitcher (loci.formats.FileStitcher)6 OMETiffWriter (loci.formats.out.OMETiffWriter)6 Location (loci.common.Location)5 DimensionSwapper (loci.formats.DimensionSwapper)5