Search in sources :

Example 1 with DimensionSwapper

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

the class ImportProcess method initializeStack.

/**
 * Performed following ImportStep.STACK notification.
 */
private void initializeStack() throws FormatException, IOException {
    IFormatReader r = baseReader;
    if (options.isGroupFiles()) {
        r = fileStitcher = new FileStitcher(baseReader);
        // overwrite base filename with file pattern
        String id = options.getId();
        fileStitcher.setId(id);
        fileStitcher.setUsingPatternIds(true);
        fileStitcher.setCanChangePattern(false);
    }
    r.setId(options.getId());
    if (options.isGroupFiles()) {
        options.setId(fileStitcher.getFilePattern().getPattern());
    }
    final byte[][] lut8 = r.get8BitLookupTable();
    final int sizeC = r.getSizeC();
    r = channelFiller = new ChannelFiller(r);
    if (channelFiller.isFilled()) {
        BF.warn(options.isQuiet(), getIdName() + ": index values will be lost");
    }
    r = channelSeparator = new ChannelSeparator(r);
    r = dimensionSwapper = new DimensionSwapper(r);
    if (options.isAutoscale() || FormatTools.isFloatingPoint(r)) {
        r = minMaxCalculator = new MinMaxCalculator(r);
    }
    if (options.doStitchTiles()) {
        r = tileStitcher = new TileStitcher(r);
    }
    r = virtualReader = new VirtualReader(r);
    reader = new ImageProcessorReader(r);
    if (options != null && !options.showROIs()) {
        baseReader.getMetadataOptions().setMetadataLevel(MetadataLevel.NO_OVERLAYS);
    }
    setId();
    computeSeriesLabels(reader);
}
Also used : IFormatReader(loci.formats.IFormatReader) FileStitcher(loci.formats.FileStitcher) ImageProcessorReader(loci.plugins.util.ImageProcessorReader) MinMaxCalculator(loci.formats.MinMaxCalculator) DimensionSwapper(loci.formats.DimensionSwapper) TileStitcher(loci.formats.TileStitcher) ChannelFiller(loci.formats.ChannelFiller) VirtualReader(loci.plugins.util.VirtualReader) ChannelSeparator(loci.formats.ChannelSeparator)

Example 2 with DimensionSwapper

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

the class DimensionSwapperTest method createDimSwapper.

@DataProvider(name = "swapper")
public Object[][] createDimSwapper() {
    Location.mapId(TEST_FILE, TEST_FILE);
    DimensionSwapper swapper = new DimensionSwapper();
    try {
        swapper.setId(TEST_FILE);
    } catch (FormatException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    swapper.setOutputOrder(OUTPUT_ORDER);
    return new Object[][] { { swapper } };
}
Also used : DimensionSwapper(loci.formats.DimensionSwapper) IOException(java.io.IOException) FormatException(loci.formats.FormatException) DataProvider(org.testng.annotations.DataProvider)

Example 3 with DimensionSwapper

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

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

the class ReaderEqualityTest method createEqualWrappers.

@DataProvider(name = "equalWrappers")
public Object[][] createEqualWrappers() {
    Location.mapId(TEST_FILE_A, TEST_FILE_A);
    Location.mapId(TEST_FILE_B, TEST_FILE_B);
    Object[][] wrappers = new Object[][] { { new ImageReader(), new ImageReader() }, { new ImageReader(), new ImageReader() }, { new MinMaxCalculator(new ChannelSeparator(new ChannelFiller())), new MinMaxCalculator(new ChannelSeparator(new ChannelFiller())) }, { new DimensionSwapper(new ChannelMerger()), new DimensionSwapper(new ChannelMerger()) } };
    for (int i = 1; i < wrappers.length; i++) {
        IFormatReader readerA = (IFormatReader) wrappers[i][0];
        IFormatReader readerB = (IFormatReader) wrappers[i][1];
        try {
            readerA.setId(TEST_FILE_A);
            readerB.setId(TEST_FILE_B);
        } catch (FormatException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    return wrappers;
}
Also used : IFormatReader(loci.formats.IFormatReader) MinMaxCalculator(loci.formats.MinMaxCalculator) ChannelMerger(loci.formats.ChannelMerger) DimensionSwapper(loci.formats.DimensionSwapper) ChannelFiller(loci.formats.ChannelFiller) IOException(java.io.IOException) ImageReader(loci.formats.ImageReader) ChannelSeparator(loci.formats.ChannelSeparator) FormatException(loci.formats.FormatException) DataProvider(org.testng.annotations.DataProvider)

Example 5 with DimensionSwapper

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

the class ReaderEqualityTest method createUnequalWrappers.

@DataProvider(name = "unequalWrappers")
public Object[][] createUnequalWrappers() {
    Object[][] wrappers = new Object[][] { { new ImageReader(), new ImageReader() }, { new ImageReader(), new ImageReader() }, { new MinMaxCalculator(new ChannelSeparator(new ChannelFiller())), new MinMaxCalculator(new ChannelSeparator()) }, { new DimensionSwapper(new ChannelMerger()), new DimensionSwapper(new ChannelMerger()) } };
    for (int i = 0; i < wrappers.length; i++) {
        IFormatReader readerA = (IFormatReader) wrappers[i][0];
        IFormatReader readerB = (IFormatReader) wrappers[i][1];
        try {
            if (i != 1) {
                readerA.setId(TEST_FILE_A);
            } else {
                readerA.setId(TEST_FILE_B);
            }
            if (i > 1) {
                readerB.setId(TEST_FILE_B);
            } else if (i == 1) {
                readerB.setId(TEST_FILE_A);
            }
        } catch (FormatException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    return wrappers;
}
Also used : IFormatReader(loci.formats.IFormatReader) MinMaxCalculator(loci.formats.MinMaxCalculator) ChannelMerger(loci.formats.ChannelMerger) DimensionSwapper(loci.formats.DimensionSwapper) ChannelFiller(loci.formats.ChannelFiller) IOException(java.io.IOException) ImageReader(loci.formats.ImageReader) ChannelSeparator(loci.formats.ChannelSeparator) FormatException(loci.formats.FormatException) DataProvider(org.testng.annotations.DataProvider)

Aggregations

DimensionSwapper (loci.formats.DimensionSwapper)7 ChannelFiller (loci.formats.ChannelFiller)6 ChannelSeparator (loci.formats.ChannelSeparator)5 FormatException (loci.formats.FormatException)5 ImageReader (loci.formats.ImageReader)5 MinMaxCalculator (loci.formats.MinMaxCalculator)5 IOException (java.io.IOException)4 ChannelMerger (loci.formats.ChannelMerger)4 IFormatReader (loci.formats.IFormatReader)4 DataProvider (org.testng.annotations.DataProvider)4 FileStitcher (loci.formats.FileStitcher)3 Memoizer (loci.formats.Memoizer)2 ImageProcessorReader (loci.plugins.util.ImageProcessorReader)2 CompositeImage (ij.CompositeImage)1 ImagePlus (ij.ImagePlus)1 LUT (ij.process.LUT)1 File (java.io.File)1 Location (loci.common.Location)1 DependencyException (loci.common.services.DependencyException)1 ServiceException (loci.common.services.ServiceException)1