Search in sources :

Example 1 with Memoizer

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

the class MemoizerTest method testConstructorReaderTimeElapsed.

@Test
public void testConstructorReaderTimeElapsed() throws Exception {
    Memoizer memoizer = new Memoizer(reader, 0);
    checkMemoFile(memoizer.getMemoFile(id));
    checkMemo(memoizer, id);
}
Also used : Memoizer(loci.formats.Memoizer) Test(org.testng.annotations.Test)

Example 2 with Memoizer

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

the class MemoizerTest method testDefaultConstructor.

public void testDefaultConstructor() throws Exception {
    Memoizer memoizer = new Memoizer();
    checkMemoFile(memoizer.getMemoFile(id));
}
Also used : Memoizer(loci.formats.Memoizer)

Example 3 with Memoizer

use of loci.formats.Memoizer 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 4 with Memoizer

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

the class ImageInfo method configureReaderPreInit.

public void configureReaderPreInit() throws FormatException, IOException {
    if (omexml) {
        reader.setOriginalMetadataPopulated(originalMetadata);
        try {
            ServiceFactory factory = new ServiceFactory();
            OMEXMLService service = factory.getInstance(OMEXMLService.class);
            reader.setMetadataStore(service.createOMEXMLMetadata(null, omexmlVersion));
        } catch (DependencyException de) {
            throw new MissingLibraryException(OMEXMLServiceImpl.NO_OME_XML_MSG, de);
        } catch (ServiceException se) {
            throw new FormatException(se);
        }
    }
    // check file format
    if (reader instanceof ImageReader) {
        // determine format
        ImageReader ir = (ImageReader) reader;
        if (new Location(id).exists()) {
            LOGGER.info("Checking file format [{}]", ir.getFormat(id));
        }
    } else {
        // verify format
        LOGGER.info("Checking {} format [{}]", reader.getFormat(), reader.isThisType(id) ? "yes" : "no");
    }
    LOGGER.info("Initializing reader");
    if (stitch) {
        reader = new FileStitcher(reader, true);
        Location f = new Location(id);
        String pat = null;
        if (!f.exists()) {
            ((FileStitcher) reader).setUsingPatternIds(true);
            pat = id;
        } else {
            pat = FilePattern.findPattern(f);
        }
        if (pat != null)
            id = pat;
    }
    if (expand)
        reader = new ChannelFiller(reader);
    if (separate)
        reader = new ChannelSeparator(reader);
    if (merge)
        reader = new ChannelMerger(reader);
    if (cache) {
        if (cachedir != null) {
            reader = new Memoizer(reader, 0, new File(cachedir));
        } else {
            reader = new Memoizer(reader, 0);
        }
    }
    minMaxCalc = null;
    if (minmax || autoscale)
        reader = minMaxCalc = new MinMaxCalculator(reader);
    dimSwapper = null;
    if (swapOrder != null || shuffleOrder != null) {
        reader = dimSwapper = new DimensionSwapper(reader);
    }
    reader = biReader = new BufferedImageReader(reader);
    reader.close();
    reader.setNormalized(normalize);
    reader.setMetadataFiltered(filter);
    reader.setGroupFiles(group);
    options.setMetadataLevel(doMeta ? MetadataLevel.ALL : MetadataLevel.MINIMUM);
    options.setValidate(validate);
    reader.setMetadataOptions(options);
    reader.setFlattenedResolutions(flat);
}
Also used : ServiceFactory(loci.common.services.ServiceFactory) Memoizer(loci.formats.Memoizer) ChannelMerger(loci.formats.ChannelMerger) ChannelFiller(loci.formats.ChannelFiller) BufferedImageReader(loci.formats.gui.BufferedImageReader) DependencyException(loci.common.services.DependencyException) OMEXMLService(loci.formats.services.OMEXMLService) FormatException(loci.formats.FormatException) ChannelSeparator(loci.formats.ChannelSeparator) ServiceException(loci.common.services.ServiceException) FileStitcher(loci.formats.FileStitcher) MinMaxCalculator(loci.formats.MinMaxCalculator) MissingLibraryException(loci.formats.MissingLibraryException) DimensionSwapper(loci.formats.DimensionSwapper) ImageReader(loci.formats.ImageReader) BufferedImageReader(loci.formats.gui.BufferedImageReader) File(java.io.File) Location(loci.common.Location)

Example 5 with Memoizer

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

the class MemoizerTest method testWrappedReader.

@Test
public void testWrappedReader() throws Exception {
    Memoizer memoizer = new Memoizer(reader, 0);
    File memoFile = memoizer.getMemoFile(id);
    assertFalse(memoFile.exists());
    reader.setId(id);
    assertFalse(memoFile.exists());
    reader.close();
    checkMemo(memoizer, id);
}
Also used : Memoizer(loci.formats.Memoizer) File(java.io.File) Test(org.testng.annotations.Test)

Aggregations

Memoizer (loci.formats.Memoizer)15 Test (org.testng.annotations.Test)11 File (java.io.File)8 FileStitcher (loci.formats.FileStitcher)3 ImageReader (loci.formats.ImageReader)3 IOException (java.io.IOException)2 Location (loci.common.Location)2 ServiceException (loci.common.services.ServiceException)2 ChannelFiller (loci.formats.ChannelFiller)2 ChannelMerger (loci.formats.ChannelMerger)2 ChannelSeparator (loci.formats.ChannelSeparator)2 DimensionSwapper (loci.formats.DimensionSwapper)2 FormatException (loci.formats.FormatException)2 MinMaxCalculator (loci.formats.MinMaxCalculator)2 BufferedImageReader (loci.formats.gui.BufferedImageReader)2 RandomAccessInputStream (loci.common.RandomAccessInputStream)1 DependencyException (loci.common.services.DependencyException)1 ServiceFactory (loci.common.services.ServiceFactory)1 IFormatReader (loci.formats.IFormatReader)1 MissingLibraryException (loci.formats.MissingLibraryException)1