Search in sources :

Example 6 with IFormatReader

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

the class CellWorxReader method getReader.

private IFormatReader getReader(String file, boolean omexml) throws FormatException, IOException {
    IFormatReader pnl = new DeltavisionReader();
    if (checkSuffix(file, "tif")) {
        pnl = new MetamorphReader();
    }
    if (omexml) {
        IMetadata metadata;
        try {
            metadata = service.createOMEXMLMetadata();
        } catch (ServiceException exc) {
            throw new FormatException("Could not create OME-XML store.", exc);
        }
        pnl.setMetadataStore(metadata);
    }
    pnl.setId(file);
    return pnl;
}
Also used : IFormatReader(loci.formats.IFormatReader) IMetadata(loci.formats.meta.IMetadata) ServiceException(loci.common.services.ServiceException) FormatException(loci.formats.FormatException)

Example 7 with IFormatReader

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

the class FileStitcherTest method testOptionsImplicit.

@Test(dataProvider = "levels")
public void testOptionsImplicit(MetadataLevel level) throws IOException, FormatException {
    FileStitcher fs = new FileStitcher();
    fs.getMetadataOptions().setMetadataLevel(level);
    fs.setId("test_z<0-2>.fake");
    for (IFormatReader r : fs.getUnderlyingReaders()) {
        assertEquals(r.getMetadataOptions().getMetadataLevel(), level);
    }
    fs.close();
}
Also used : IFormatReader(loci.formats.IFormatReader) FileStitcher(loci.formats.FileStitcher) Test(org.testng.annotations.Test)

Example 8 with IFormatReader

use of loci.formats.IFormatReader 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 9 with IFormatReader

use of loci.formats.IFormatReader 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 10 with IFormatReader

use of loci.formats.IFormatReader 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);
}
Also used : IFormatReader(loci.formats.IFormatReader) SkipException(org.testng.SkipException) IOException(java.io.IOException) ImageReader(loci.formats.ImageReader) BufferedImageReader(loci.formats.gui.BufferedImageReader) ReaderWrapper(loci.formats.ReaderWrapper) FormatException(loci.formats.FormatException) Test(org.testng.annotations.Test)

Aggregations

IFormatReader (loci.formats.IFormatReader)38 ImageReader (loci.formats.ImageReader)20 FormatException (loci.formats.FormatException)15 IOException (java.io.IOException)10 FileStitcher (loci.formats.FileStitcher)10 Test (org.testng.annotations.Test)8 Location (loci.common.Location)6 ChannelSeparator (loci.formats.ChannelSeparator)6 ServiceException (loci.common.services.ServiceException)5 ServiceFactory (loci.common.services.ServiceFactory)5 ReaderWrapper (loci.formats.ReaderWrapper)5 IMetadata (loci.formats.meta.IMetadata)5 RandomAccessInputStream (loci.common.RandomAccessInputStream)4 ChannelFiller (loci.formats.ChannelFiller)4 CoreMetadata (loci.formats.CoreMetadata)4 DimensionSwapper (loci.formats.DimensionSwapper)4 MinMaxCalculator (loci.formats.MinMaxCalculator)4 BufferedImageReader (loci.formats.gui.BufferedImageReader)4 OMEXMLService (loci.formats.services.OMEXMLService)4 DependencyException (loci.common.services.DependencyException)3