Search in sources :

Example 21 with IFormatReader

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

the class WrapperTest method createWrappers.

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

Example 22 with IFormatReader

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

the class PrintLensNA method main.

public static void main(String[] args) throws DependencyException, FormatException, IOException, ServiceException {
    // parse command line arguments
    if (args.length < 1) {
        System.err.println("Usage: java PrintLensNA imageFile");
        System.exit(1);
    }
    String id = args[0];
    // configure reader
    IFormatReader reader = new ImageReader();
    ServiceFactory factory = new ServiceFactory();
    OMEXMLService service = factory.getInstance(OMEXMLService.class);
    IMetadata meta = service.createOMEXMLMetadata();
    reader.setMetadataStore(meta);
    System.out.println("Initializing file: " + id);
    // parse metadata
    reader.setId(id);
    // output metadata values
    int instrumentCount = meta.getInstrumentCount();
    System.out.println("There are " + instrumentCount + " instrument(s) associated with this file");
    for (int i = 0; i < instrumentCount; i++) {
        int objectiveCount = meta.getObjectiveCount(i);
        System.out.println();
        System.out.println("Instrument #" + i + " [" + meta.getInstrumentID(i) + "]: " + objectiveCount + " objective(s) found");
        for (int o = 0; o < objectiveCount; o++) {
            Double lensNA = meta.getObjectiveLensNA(i, o);
            System.out.println("\tObjective #" + o + " [" + meta.getObjectiveID(i, o) + "]: LensNA=" + lensNA);
        }
    }
}
Also used : IFormatReader(loci.formats.IFormatReader) IMetadata(loci.formats.meta.IMetadata) ServiceFactory(loci.common.services.ServiceFactory) ImageReader(loci.formats.ImageReader) OMEXMLService(loci.formats.services.OMEXMLService)

Example 23 with IFormatReader

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

the class PrintTimestamps method main.

public static void main(String[] args) throws Exception {
    // parse command line arguments
    if (args.length < 1) {
        System.err.println("Usage: java PrintTimestamps imageFile [seriesNo]");
        System.exit(1);
    }
    String id = args[0];
    int series = args.length > 1 ? Integer.parseInt(args[1]) : 0;
    // enable debugging
    // FormatReader.debug = true;
    // create OME-XML metadata store of the latest schema version
    ServiceFactory factory = new ServiceFactory();
    OMEXMLService service = factory.getInstance(OMEXMLService.class);
    IMetadata meta = service.createOMEXMLMetadata();
    // or if you want a specific schema version, you can use:
    // IMetadata meta = service.createOMEXMLMetadata(null, "2009-02");
    // meta.createRoot();
    // create format reader
    IFormatReader reader = new ImageReader();
    reader.setMetadataStore(meta);
    // initialize file
    System.out.println("Initializing " + id);
    reader.setId(id);
    int seriesCount = reader.getSeriesCount();
    if (series < seriesCount)
        reader.setSeries(series);
    series = reader.getSeries();
    System.out.println("\tImage series = " + series + " of " + seriesCount);
    printDimensions(reader);
    printGlobalTiming(meta, series);
    printTimingPerTimepoint(meta, series);
    printTimingPerPlane(meta, series);
}
Also used : IMetadata(loci.formats.meta.IMetadata) IFormatReader(loci.formats.IFormatReader) ServiceFactory(loci.common.services.ServiceFactory) ImageReader(loci.formats.ImageReader) OMEXMLService(loci.formats.services.OMEXMLService)

Example 24 with IFormatReader

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

the class CropDialog method harvestResults.

@Override
protected boolean harvestResults(GenericDialog gd) {
    final int seriesCount = process.getSeriesCount();
    final IFormatReader r = process.getReader();
    for (int s = 0; s < seriesCount; s++) {
        if (!options.isSeriesOn(s))
            continue;
        r.setSeries(s);
        Region region = new Region();
        region.x = (int) gd.getNextNumber();
        region.y = (int) gd.getNextNumber();
        region.width = (int) gd.getNextNumber();
        region.height = (int) gd.getNextNumber();
        if (region.x < 0)
            region.x = 0;
        if (region.y < 0)
            region.y = 0;
        if (region.x >= r.getSizeX())
            region.x = r.getSizeX() - region.width - 1;
        if (region.y >= r.getSizeY())
            region.y = r.getSizeY() - region.height - 1;
        if (region.width < 1)
            region.width = 1;
        if (region.height < 1)
            region.height = 1;
        if (region.width + region.x > r.getSizeX()) {
            region.width = r.getSizeX() - region.x;
        }
        if (region.height + region.y > r.getSizeY()) {
            region.height = r.getSizeY() - region.y;
        }
        options.setCropRegion(s, region);
    }
    return true;
}
Also used : IFormatReader(loci.formats.IFormatReader) Region(loci.common.Region)

Example 25 with IFormatReader

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

the class ImagePlusReader method readImage.

private ImagePlus readImage(int s, boolean thumbnail) throws FormatException, IOException {
    final ImporterOptions options = process.getOptions();
    final int zCount = process.getZCount(s);
    final int cCount = process.getCCount(s);
    final int tCount = process.getTCount(s);
    final List<LUT> luts = new ArrayList<LUT>();
    // create image stack
    final ImageStack stack;
    if (options.isVirtual())
        stack = createVirtualStack(process, s, luts);
    else
        stack = readPlanes(process, s, luts, thumbnail);
    notifyListeners(new StatusEvent(1, 1, "Creating image"));
    // create title
    final String seriesName = process.getOMEMetadata().getImageName(s);
    final String file = process.getCurrentFile();
    final IFormatReader reader = process.getReader();
    final String title = constructImageTitle(reader, file, seriesName, options.isGroupFiles());
    // create image
    final ImagePlus imp;
    if (stack.isVirtual()) {
        VirtualImagePlus vip = new VirtualImagePlus(title, stack);
        vip.setReader(reader);
        imp = vip;
        saveLUTs(imp, luts);
    } else
        imp = createImage(title, stack, luts);
    // if concatenating images only store metadata on first series
    if (!options.isConcatenate() || s == 0) {
        final String metadata = process.getOriginalMetadata().toString();
        imp.setProperty("Info", metadata);
    }
    imp.setProperty(PROP_SERIES, s);
    // retrieve the spatial calibration information, if available
    final FileInfo fi = createFileInfo();
    new Calibrator(process).applyCalibration(imp);
    imp.setFileInfo(fi);
    imp.setDimensions(cCount, zCount, tCount);
    // open as a hyperstack, as appropriate
    final boolean hyper = !options.isViewStandard();
    imp.setOpenAsHyperStack(hyper);
    return imp;
}
Also used : IFormatReader(loci.formats.IFormatReader) ImageStack(ij.ImageStack) VirtualImagePlus(loci.plugins.util.VirtualImagePlus) ArrayList(java.util.ArrayList) LUT(ij.process.LUT) VirtualImagePlus(loci.plugins.util.VirtualImagePlus) ImagePlus(ij.ImagePlus) FileInfo(ij.io.FileInfo) StatusEvent(loci.common.StatusEvent)

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