Search in sources :

Example 26 with DependencyException

use of loci.common.services.DependencyException in project bioformats by openmicroscopy.

the class Exporter method run.

// -- Exporter API methods --
/**
 * Executes the plugin.
 */
public void run() {
    String outfile = null;
    Boolean splitZ = null;
    Boolean splitC = null;
    Boolean splitT = null;
    Boolean padded = null;
    Boolean saveRoi = null;
    String compression = null;
    Boolean windowless = Boolean.FALSE;
    if (plugin.arg != null) {
        outfile = Macro.getValue(plugin.arg, "outfile", null);
        String z = Macro.getValue(plugin.arg, "splitZ", null);
        String c = Macro.getValue(plugin.arg, "splitC", null);
        String t = Macro.getValue(plugin.arg, "splitT", null);
        String zeroPad = Macro.getValue(plugin.arg, "padded", null);
        String sr = Macro.getValue(plugin.arg, "saveRoi", null);
        compression = Macro.getValue(plugin.arg, "compression", null);
        String id = Macro.getValue(plugin.arg, "imageid", null);
        splitZ = z == null ? null : Boolean.valueOf(z);
        splitC = c == null ? null : Boolean.valueOf(c);
        splitT = t == null ? null : Boolean.valueOf(t);
        padded = zeroPad == null ? null : Boolean.valueOf(zeroPad);
        saveRoi = sr == null ? null : Boolean.valueOf(sr);
        if (id != null) {
            try {
                int imageID = Integer.parseInt(id);
                ImagePlus plus = WindowManager.getImage(imageID);
                if (plus != null)
                    imp = plus;
            } catch (Exception e) {
            // nothing to do, we use the current imagePlus
            }
        }
        String w = Macro.getValue(plugin.arg, "windowless", null);
        if (w != null) {
            windowless = Boolean.valueOf(w);
        }
        plugin.arg = null;
    }
    if (outfile == null) {
        String options = Macro.getOptions();
        if (options != null) {
            String save = Macro.getValue(options, "save", null);
            if (save != null)
                outfile = save;
        }
    }
    // create a temporary file if window less
    if (windowless && (outfile == null || outfile.length() == 0)) {
        File tmp = null;
        try {
            String name = removeExtension(imp.getTitle());
            String n = name + ".ome.tif";
            tmp = File.createTempFile(name, ".ome.tif");
            File p = tmp.getParentFile();
            File[] list = p.listFiles();
            // make sure we delete a previous tmp file with same name if any
            if (list != null) {
                File toDelete = null;
                for (int i = 0; i < list.length; i++) {
                    if (list[i].getName().equals(n)) {
                        toDelete = list[i];
                        break;
                    }
                }
                if (toDelete != null) {
                    toDelete.delete();
                }
            }
            outfile = new File(p, n).getAbsolutePath();
            if (Recorder.record)
                Recorder.recordPath("outputfile", outfile);
            IJ.log("exporter outputfile " + outfile);
        } catch (Exception e) {
        // fall back to window mode.
        } finally {
            if (tmp != null)
                tmp.delete();
        }
    }
    File f = null;
    if (outfile == null || outfile.length() == 0) {
        // open a dialog prompting for the filename to save
        // NB: Copied and adapted from ij.io.SaveDIalog.jSaveDispatchThread,
        // so that the save dialog has a file filter for choosing output format.
        String dir = null, name = null;
        JFileChooser fc = GUITools.buildFileChooser(new ImageWriter(), false);
        fc.setDialogTitle("Bio-Formats Exporter");
        String defaultDir = OpenDialog.getDefaultDirectory();
        if (defaultDir != null)
            fc.setCurrentDirectory(new File(defaultDir));
        // set OME-TIFF as the default output format
        FileFilter[] ff = fc.getChoosableFileFilters();
        FileFilter defaultFilter = null;
        for (int i = 0; i < ff.length; i++) {
            if (ff[i] instanceof ExtensionFileFilter) {
                ExtensionFileFilter eff = (ExtensionFileFilter) ff[i];
                if (i == 0 || eff.getExtension().equals("ome.tif")) {
                    defaultFilter = eff;
                    break;
                }
            }
        }
        if (defaultFilter != null)
            fc.setFileFilter(defaultFilter);
        int returnVal = fc.showSaveDialog(IJ.getInstance());
        if (returnVal != JFileChooser.APPROVE_OPTION) {
            Macro.abort();
            return;
        }
        f = fc.getSelectedFile();
        dir = fc.getCurrentDirectory().getPath() + File.separator;
        name = fc.getName(f);
        if (f.exists()) {
            int ret = JOptionPane.showConfirmDialog(fc, "The file " + f.getName() + " already exists. \n" + "Would you like to replace it?", "Replace?", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
            if (ret != JOptionPane.OK_OPTION)
                f = null;
        } else {
            // ensure filename matches selected filter
            FileFilter filter = fc.getFileFilter();
            if (filter instanceof ExtensionFileFilter) {
                ExtensionFileFilter eff = (ExtensionFileFilter) filter;
                String[] ext = eff.getExtensions();
                String lName = name.toLowerCase();
                boolean hasExtension = false;
                for (int i = 0; i < ext.length; i++) {
                    if (lName.endsWith("." + ext[i])) {
                        hasExtension = true;
                        break;
                    }
                }
                if (!hasExtension && ext.length > 0) {
                    // append chosen extension
                    name = name + "." + ext[0];
                }
                f = fc.getSelectedFile();
                String filePath = f.getAbsolutePath();
                if (!filePath.endsWith("." + ext[0])) {
                    f = new File(filePath + '.' + ext[0]);
                }
                if (f.exists()) {
                    int ret1 = JOptionPane.showConfirmDialog(fc, "The file " + f.getName() + " already exists. \n" + "Would you like to replace it?", "Replace?", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
                    if (ret1 != JOptionPane.OK_OPTION)
                        f = null;
                }
            }
        }
        if (f == null)
            Macro.abort();
        else {
            // do some ImageJ bookkeeping
            OpenDialog.setDefaultDirectory(dir);
            if (Recorder.record)
                Recorder.recordPath("save", dir + name);
        }
        if (dir == null || name == null)
            return;
        outfile = new File(dir, name).getAbsolutePath();
        if (outfile == null)
            return;
    }
    if (windowless) {
        if (splitZ == null)
            splitZ = Boolean.FALSE;
        if (splitC == null)
            splitC = Boolean.FALSE;
        if (splitT == null)
            splitT = Boolean.FALSE;
        if (padded == null)
            padded = Boolean.FALSE;
    }
    if (splitZ == null || splitC == null || splitT == null) {
        // ask if we want to export multiple files
        GenericDialog multiFile = new GenericDialog("Bio-Formats Exporter - Multiple Files");
        multiFile.addCheckbox("Write_each_Z_section to a separate file", false);
        multiFile.addCheckbox("Write_each_timepoint to a separate file", false);
        multiFile.addCheckbox("Write_each_channel to a separate file", false);
        multiFile.addCheckbox("Use zero padding for filename indexes", false);
        multiFile.showDialog();
        splitZ = multiFile.getNextBoolean();
        splitT = multiFile.getNextBoolean();
        splitC = multiFile.getNextBoolean();
        padded = multiFile.getNextBoolean();
        if (multiFile.wasCanceled())
            return;
    }
    try (IFormatWriter w = new ImageWriter().getWriter(outfile)) {
        int ptype = 0;
        int channels = 1;
        switch(imp.getType()) {
            case ImagePlus.GRAY8:
            case ImagePlus.COLOR_256:
                ptype = FormatTools.UINT8;
                break;
            case ImagePlus.COLOR_RGB:
                channels = 3;
                ptype = FormatTools.UINT8;
                break;
            case ImagePlus.GRAY16:
                ptype = FormatTools.UINT16;
                break;
            case ImagePlus.GRAY32:
                ptype = FormatTools.FLOAT;
                break;
        }
        String title = imp.getTitle();
        w.setWriteSequentially(true);
        FileInfo fi = imp.getOriginalFileInfo();
        String xml = fi == null ? null : fi.description == null ? null : fi.description.indexOf("xml") == -1 ? null : fi.description;
        OMEXMLService service = null;
        IMetadata store = null;
        try {
            ServiceFactory factory = new ServiceFactory();
            service = factory.getInstance(OMEXMLService.class);
            store = service.createOMEXMLMetadata(xml);
        } catch (DependencyException de) {
        } catch (ServiceException se) {
        }
        if (store == null)
            IJ.error("OME-XML Java library not found.");
        OMEXMLMetadataRoot root = (OMEXMLMetadataRoot) store.getRoot();
        if (root.sizeOfROIList() > 0) {
            while (root.sizeOfROIList() > 0) {
                ROI roi = root.getROI(0);
                root.removeROI(roi);
            }
            store.setRoot(root);
        }
        if (xml == null) {
            store.createRoot();
        } else if (store.getImageCount() > 1) {
            // the original dataset had multiple series
            // we need to modify the IMetadata to represent the correct series
            ArrayList<Integer> matchingSeries = new ArrayList<Integer>();
            for (int series = 0; series < store.getImageCount(); series++) {
                String type = store.getPixelsType(series).toString();
                int pixelType = FormatTools.pixelTypeFromString(type);
                if (pixelType == ptype) {
                    String imageName = store.getImageName(series);
                    if (title.indexOf(imageName) >= 0) {
                        matchingSeries.add(series);
                    }
                }
            }
            int series = 0;
            if (matchingSeries.size() > 1) {
                for (int i = 0; i < matchingSeries.size(); i++) {
                    int index = matchingSeries.get(i);
                    String name = store.getImageName(index);
                    boolean valid = true;
                    for (int j = 0; j < matchingSeries.size(); j++) {
                        if (i != j) {
                            String compName = store.getImageName(matchingSeries.get(j));
                            if (compName.indexOf(name) >= 0) {
                                valid = false;
                                break;
                            }
                        }
                    }
                    if (valid) {
                        series = index;
                        break;
                    }
                }
            } else if (matchingSeries.size() == 1)
                series = matchingSeries.get(0);
            ome.xml.model.Image exportImage = root.getImage(series);
            List<ome.xml.model.Image> allImages = root.copyImageList();
            for (ome.xml.model.Image img : allImages) {
                if (!img.equals(exportImage)) {
                    root.removeImage(img);
                }
            }
            store.setRoot(root);
        }
        store.setPixelsSizeX(new PositiveInteger(imp.getWidth()), 0);
        store.setPixelsSizeY(new PositiveInteger(imp.getHeight()), 0);
        store.setPixelsSizeZ(new PositiveInteger(imp.getNSlices()), 0);
        store.setPixelsSizeC(new PositiveInteger(channels * imp.getNChannels()), 0);
        store.setPixelsSizeT(new PositiveInteger(imp.getNFrames()), 0);
        if (store.getImageID(0) == null) {
            store.setImageID(MetadataTools.createLSID("Image", 0), 0);
        }
        if (store.getPixelsID(0) == null) {
            store.setPixelsID(MetadataTools.createLSID("Pixels", 0), 0);
        }
        // reset the pixel type, unless the only change is signedness
        // this prevents problems if the user changed the bit depth of the image
        boolean applyCalibrationFunction = false;
        try {
            int originalType = -1;
            if (store.getPixelsType(0) != null) {
                originalType = FormatTools.pixelTypeFromString(store.getPixelsType(0).toString());
            }
            if (ptype != originalType && (store.getPixelsType(0) == null || !FormatTools.isSigned(originalType) || FormatTools.getBytesPerPixel(originalType) != FormatTools.getBytesPerPixel(ptype))) {
                store.setPixelsType(PixelType.fromString(FormatTools.getPixelTypeString(ptype)), 0);
            } else if (FormatTools.isSigned(originalType)) {
                applyCalibrationFunction = true;
            }
        } catch (EnumerationException e) {
        }
        if (store.getPixelsBinDataCount(0) == 0 || store.getPixelsBinDataBigEndian(0, 0) == null) {
            store.setPixelsBinDataBigEndian(Boolean.FALSE, 0, 0);
        }
        if (store.getPixelsDimensionOrder(0) == null) {
            try {
                store.setPixelsDimensionOrder(DimensionOrder.fromString(ORDER), 0);
            } catch (EnumerationException e) {
            }
        }
        LUT[] luts = new LUT[imp.getNChannels()];
        for (int c = 0; c < imp.getNChannels(); c++) {
            if (c >= store.getChannelCount(0) || store.getChannelID(0, c) == null) {
                String lsid = MetadataTools.createLSID("Channel", 0, c);
                store.setChannelID(lsid, 0, c);
            }
            store.setChannelSamplesPerPixel(new PositiveInteger(channels), 0, 0);
            if (imp instanceof CompositeImage) {
                luts[c] = ((CompositeImage) imp).getChannelLut(c + 1);
            }
        }
        Calibration cal = imp.getCalibration();
        store.setPixelsPhysicalSizeX(FormatTools.getPhysicalSizeX(cal.pixelWidth), 0);
        store.setPixelsPhysicalSizeY(FormatTools.getPhysicalSizeY(cal.pixelHeight), 0);
        store.setPixelsPhysicalSizeZ(FormatTools.getPhysicalSizeZ(cal.pixelDepth), 0);
        store.setPixelsTimeIncrement(new Time(new Double(cal.frameInterval), UNITS.SECOND), 0);
        if (imp.getImageStackSize() != imp.getNChannels() * imp.getNSlices() * imp.getNFrames()) {
            if (!windowless) {
                IJ.showMessageWithCancel("Bio-Formats Exporter Warning", "The number of planes in the stack (" + imp.getImageStackSize() + ") does not match the number of expected planes (" + (imp.getNChannels() * imp.getNSlices() * imp.getNFrames()) + ")." + "\nIf you select 'OK', only " + imp.getImageStackSize() + " planes will be exported. If you wish to export all of the " + "planes,\nselect 'Cancel' and convert the Image5D window " + "to a stack.");
            }
            store.setPixelsSizeZ(new PositiveInteger(imp.getImageStackSize()), 0);
            store.setPixelsSizeC(new PositiveInteger(1), 0);
            store.setPixelsSizeT(new PositiveInteger(1), 0);
        }
        Object info = imp.getProperty("Info");
        if (info != null) {
            String imageInfo = info.toString();
            if (imageInfo != null) {
                String[] lines = imageInfo.split("\n");
                for (String line : lines) {
                    int eq = line.lastIndexOf("=");
                    if (eq > 0) {
                        String key = line.substring(0, eq).trim();
                        String value = line.substring(eq + 1).trim();
                        if (key.endsWith("BitsPerPixel")) {
                            w.setValidBitsPerPixel(Integer.parseInt(value));
                            break;
                        }
                    }
                }
            }
        }
        // NB: Animation rate code copied from ij.plugin.Animator#doOptions().
        final int rate;
        if (cal.fps != 0.0) {
            rate = (int) cal.fps;
        } else if (cal.frameInterval != 0.0 && cal.getTimeUnit().equals("sec")) {
            rate = (int) (1.0 / cal.frameInterval);
        } else {
            // NB: Code from ij.plugin.Animator#animationRate initializer.
            // The value is 7 by default in ImageJ, so must be 7 here as well.
            rate = (int) Prefs.getDouble(Prefs.FPS, 7.0);
        }
        if (rate > 0)
            w.setFramesPerSecond(rate);
        String[] outputFiles = new String[] { outfile };
        int sizeZ = store.getPixelsSizeZ(0).getValue();
        int sizeC = store.getPixelsSizeC(0).getValue();
        int sizeT = store.getPixelsSizeT(0).getValue();
        if (splitZ || splitC || splitT) {
            int nFiles = 1;
            if (splitZ) {
                nFiles *= sizeZ;
            }
            if (splitC) {
                nFiles *= sizeC;
            }
            if (splitT) {
                nFiles *= sizeT;
            }
            outputFiles = new String[nFiles];
            int dot = outfile.indexOf(".", outfile.lastIndexOf(File.separator));
            String base = outfile.substring(0, dot);
            String ext = outfile.substring(dot);
            int nextFile = 0;
            for (int z = 0; z < (splitZ ? sizeZ : 1); z++) {
                for (int c = 0; c < (splitC ? sizeC : 1); c++) {
                    for (int t = 0; t < (splitT ? sizeT : 1); t++) {
                        int index = FormatTools.getIndex(ORDER, sizeZ, sizeC, sizeT, sizeZ * sizeC * sizeT, z, c, t);
                        String pattern = base + (splitZ ? "_Z%z" : "") + (splitC ? "_C%c" : "") + (splitT ? "_T%t" : "") + ext;
                        outputFiles[nextFile++] = FormatTools.getFilename(0, index, store, pattern, padded);
                    }
                }
            }
        }
        if (!w.getFormat().startsWith("OME")) {
            if (splitZ) {
                store.setPixelsSizeZ(new PositiveInteger(1), 0);
            }
            if (splitC) {
                store.setPixelsSizeC(new PositiveInteger(1), 0);
            }
            if (splitT) {
                store.setPixelsSizeT(new PositiveInteger(1), 0);
            }
        }
        // prompt for options
        String[] codecs = w.getCompressionTypes();
        ImageProcessor proc = imp.getImageStack().getProcessor(1);
        Image firstImage = proc.createImage();
        firstImage = AWTImageTools.makeBuffered(firstImage, proc.getColorModel());
        int thisType = AWTImageTools.getPixelType((BufferedImage) firstImage);
        if (proc instanceof ColorProcessor) {
            thisType = FormatTools.UINT8;
        } else if (proc instanceof ShortProcessor) {
            thisType = FormatTools.UINT16;
        }
        boolean notSupportedType = !w.isSupportedType(thisType);
        if (notSupportedType) {
            IJ.error("Pixel type (" + FormatTools.getPixelTypeString(thisType) + ") not supported by this format.");
            return;
        }
        if (codecs != null && codecs.length > 1) {
            boolean selected = false;
            if (compression != null) {
                for (int i = 0; i < codecs.length; i++) {
                    if (codecs[i].equals(compression)) {
                        selected = true;
                        break;
                    }
                }
            }
            if (!selected && !windowless) {
                GenericDialog gd = new GenericDialog("Bio-Formats Exporter Options");
                gd.addChoice("Compression type: ", codecs, codecs[0]);
                if (saveRoi != null) {
                    gd.addCheckbox("Export ROIs", saveRoi.booleanValue());
                } else {
                    gd.addCheckbox("Export ROIs", true);
                }
                gd.showDialog();
                saveRoi = gd.getNextBoolean();
                if (gd.wasCanceled())
                    return;
                compression = gd.getNextChoice();
            }
        }
        boolean in = false;
        if (outputFiles.length > 1) {
            for (int i = 0; i < outputFiles.length; i++) {
                if (new File(outputFiles[i]).exists()) {
                    in = true;
                    break;
                }
            }
        }
        if (in && !windowless) {
            int ret1 = JOptionPane.showConfirmDialog(null, "Some files already exist. \n" + "Would you like to replace them?", "Replace?", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
            if (ret1 != JOptionPane.OK_OPTION) {
                return;
            }
            // Delete the files overwrite does not correctly work
            for (int i = 0; i < outputFiles.length; i++) {
                new File(outputFiles[i]).delete();
            }
        }
        // delete the file.
        if (f != null)
            f.delete();
        if (compression != null) {
            w.setCompression(compression);
        }
        // Save ROI's
        if (saveRoi != null && saveRoi.booleanValue()) {
            ROIHandler.saveROIs(store);
        }
        w.setMetadataRetrieve(store);
        // convert and save slices
        int size = imp.getImageStackSize();
        ImageStack is = imp.getImageStack();
        boolean doStack = w.canDoStacks() && size > 1;
        int start = doStack ? 0 : imp.getCurrentSlice() - 1;
        int end = doStack ? size : start + 1;
        boolean littleEndian = false;
        if (w.getMetadataRetrieve().getPixelsBigEndian(0) != null) {
            littleEndian = !w.getMetadataRetrieve().getPixelsBigEndian(0).booleanValue();
        } else if (w.getMetadataRetrieve().getPixelsBinDataCount(0) == 0) {
            littleEndian = !w.getMetadataRetrieve().getPixelsBinDataBigEndian(0, 0).booleanValue();
        }
        byte[] plane = null;
        w.setInterleaved(false);
        int[] no = new int[outputFiles.length];
        for (int i = start; i < end; i++) {
            if (doStack) {
                BF.status(false, "Saving plane " + (i + 1) + "/" + size);
                BF.progress(false, i, size);
            } else
                BF.status(false, "Saving image");
            proc = is.getProcessor(i + 1);
            if (proc instanceof RecordedImageProcessor) {
                proc = ((RecordedImageProcessor) proc).getChild();
            }
            int x = proc.getWidth();
            int y = proc.getHeight();
            if (proc instanceof ByteProcessor) {
                if (applyCalibrationFunction) {
                    // don't alter 'pixels' directly as that will
                    // affect the open ImagePlus
                    byte[] pixels = (byte[]) proc.getPixels();
                    plane = new byte[pixels.length];
                    float[] calibration = proc.getCalibrationTable();
                    for (int pixel = 0; pixel < pixels.length; pixel++) {
                        plane[pixel] = (byte) calibration[pixels[pixel] & 0xff];
                    }
                } else {
                    plane = (byte[]) proc.getPixels();
                }
            } else if (proc instanceof ShortProcessor) {
                short[] pixels = (short[]) proc.getPixels();
                if (applyCalibrationFunction) {
                    // don't alter 'pixels' directly as that will
                    // affect the open ImagePlus
                    plane = new byte[pixels.length * 2];
                    float[] calibration = proc.getCalibrationTable();
                    for (int pixel = 0; pixel < pixels.length; pixel++) {
                        short v = (short) calibration[pixels[pixel] & 0xffff];
                        DataTools.unpackBytes(v, plane, pixel * 2, 2, littleEndian);
                    }
                } else {
                    plane = DataTools.shortsToBytes(pixels, littleEndian);
                }
            } else if (proc instanceof FloatProcessor) {
                plane = DataTools.floatsToBytes((float[]) proc.getPixels(), littleEndian);
            } else if (proc instanceof ColorProcessor) {
                byte[][] pix = new byte[3][x * y];
                ((ColorProcessor) proc).getRGB(pix[0], pix[1], pix[2]);
                plane = new byte[3 * x * y];
                System.arraycopy(pix[0], 0, plane, 0, x * y);
                System.arraycopy(pix[1], 0, plane, x * y, x * y);
                System.arraycopy(pix[2], 0, plane, 2 * x * y, x * y);
                if (i == start) {
                    sizeC /= 3;
                }
            }
            int fileIndex = 0;
            if (doStack) {
                int[] coords = FormatTools.getZCTCoords(ORDER, sizeZ, sizeC, sizeT, size, i);
                int realZ = sizeZ;
                int realC = sizeC;
                int realT = sizeT;
                if (!splitZ) {
                    coords[0] = 0;
                    realZ = 1;
                }
                if (!splitC) {
                    coords[1] = 0;
                    realC = 1;
                }
                if (!splitT) {
                    coords[2] = 0;
                    realT = 1;
                }
                fileIndex = FormatTools.getIndex(ORDER, realZ, realC, realT, realZ * realC * realT, coords[0], coords[1], coords[2]);
            }
            if (notSupportedType) {
                IJ.error("Pixel type not supported by this format.");
            } else {
                w.changeOutputFile(outputFiles[fileIndex]);
                int currentChannel = FormatTools.getZCTCoords(ORDER, sizeZ, sizeC, sizeT, imp.getStackSize(), i)[1];
                if (luts[currentChannel] != null) {
                    // expand to 16-bit LUT if necessary
                    int bpp = FormatTools.getBytesPerPixel(thisType);
                    if (bpp == 1) {
                        w.setColorModel(luts[currentChannel]);
                    } else if (bpp == 2) {
                        int lutSize = luts[currentChannel].getMapSize();
                        byte[][] lut = new byte[3][lutSize];
                        luts[currentChannel].getReds(lut[0]);
                        luts[currentChannel].getGreens(lut[1]);
                        luts[currentChannel].getBlues(lut[2]);
                        short[][] newLut = new short[3][65536];
                        int bins = newLut[0].length / lut[0].length;
                        for (int c = 0; c < newLut.length; c++) {
                            for (int q = 0; q < newLut[c].length; q++) {
                                int index = q / bins;
                                newLut[c][q] = (short) ((lut[c][index] * lut[0].length) + (q % bins));
                            }
                        }
                        w.setColorModel(new Index16ColorModel(16, newLut[0].length, newLut, littleEndian));
                    }
                } else if (!proc.isDefaultLut()) {
                    w.setColorModel(proc.getColorModel());
                }
                w.saveBytes(no[fileIndex]++, plane);
            }
        }
        w.close();
    } catch (FormatException e) {
        WindowTools.reportException(e);
    } catch (IOException e) {
        WindowTools.reportException(e);
    }
}
Also used : ServiceFactory(loci.common.services.ServiceFactory) ArrayList(java.util.ArrayList) Image(java.awt.Image) BufferedImage(java.awt.image.BufferedImage) CompositeImage(ij.CompositeImage) OMEXMLService(loci.formats.services.OMEXMLService) Index16ColorModel(loci.formats.gui.Index16ColorModel) ImageProcessor(ij.process.ImageProcessor) RecordedImageProcessor(loci.plugins.util.RecordedImageProcessor) IMetadata(loci.formats.meta.IMetadata) FileInfo(ij.io.FileInfo) List(java.util.List) ArrayList(java.util.ArrayList) ImageStack(ij.ImageStack) FloatProcessor(ij.process.FloatProcessor) DependencyException(loci.common.services.DependencyException) ROI(ome.xml.model.ROI) FormatException(loci.formats.FormatException) IFormatWriter(loci.formats.IFormatWriter) JFileChooser(javax.swing.JFileChooser) ServiceException(loci.common.services.ServiceException) OMEXMLMetadataRoot(ome.xml.meta.OMEXMLMetadataRoot) File(java.io.File) ExtensionFileFilter(loci.formats.gui.ExtensionFileFilter) EnumerationException(ome.xml.model.enums.EnumerationException) ByteProcessor(ij.process.ByteProcessor) ImageWriter(loci.formats.ImageWriter) Time(ome.units.quantity.Time) ColorProcessor(ij.process.ColorProcessor) CompositeImage(ij.CompositeImage) GenericDialog(ij.gui.GenericDialog) RecordedImageProcessor(loci.plugins.util.RecordedImageProcessor) ExtensionFileFilter(loci.formats.gui.ExtensionFileFilter) FileFilter(javax.swing.filechooser.FileFilter) PositiveInteger(ome.xml.model.primitives.PositiveInteger) LUT(ij.process.LUT) Calibration(ij.measure.Calibration) IOException(java.io.IOException) ImagePlus(ij.ImagePlus) ServiceException(loci.common.services.ServiceException) DependencyException(loci.common.services.DependencyException) EnumerationException(ome.xml.model.enums.EnumerationException) FormatException(loci.formats.FormatException) IOException(java.io.IOException) ShortProcessor(ij.process.ShortProcessor) PositiveInteger(ome.xml.model.primitives.PositiveInteger)

Example 27 with DependencyException

use of loci.common.services.DependencyException 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 28 with DependencyException

use of loci.common.services.DependencyException in project bioformats by openmicroscopy.

the class FormatTools method convert.

// -- Conversion convenience methods --
/**
 * Convenience method for converting the specified input file to the
 * specified output file.  The ImageReader and ImageWriter classes are used
 * for input and output, respectively.  To use other IFormatReader or
 * IFormatWriter implementation,
 * @see #convert(IFormatReader, IFormatWriter, String).
 *
 * @param input the full path name of the existing input file
 * @param output the full path name of the output file to be created
 * @throws FormatException if there is a general problem reading from or
 * writing to one of the files.
 * @throws IOException if there is an I/O-related error.
 */
public static void convert(String input, String output) throws FormatException, IOException {
    IFormatReader reader = new ImageReader();
    try {
        ServiceFactory factory = new ServiceFactory();
        OMEXMLService service = factory.getInstance(OMEXMLService.class);
        reader.setMetadataStore(service.createOMEXMLMetadata());
    } catch (DependencyException de) {
        throw new MissingLibraryException(OMEXMLServiceImpl.NO_OME_XML_MSG, de);
    } catch (ServiceException se) {
        throw new FormatException(se);
    }
    reader.setId(input);
    IFormatWriter writer = new ImageWriter();
    convert(reader, writer, output);
}
Also used : ServiceException(loci.common.services.ServiceException) ServiceFactory(loci.common.services.ServiceFactory) DependencyException(loci.common.services.DependencyException) OMEXMLService(loci.formats.services.OMEXMLService)

Example 29 with DependencyException

use of loci.common.services.DependencyException in project bioformats by openmicroscopy.

the class MetadataTools method populatePixels.

/**
 * Populates the Pixels element of the given metadata store, using core
 * metadata from the given reader.  If the {@code doPlane} flag is set,
 * then the Plane elements will be populated as well. If the
 * {@code doImageName} flag is set, then the image name will be populated as
 * well.
 *
 * @param store       The metadata store whose Pixels should be populated
 * @param r           The format reader whose core metadata should be used
 * @param doPlane     Specifies whether Plane elements should be populated
 * @param doImageName Specifies whether the Image name should be populated
 */
public static void populatePixels(MetadataStore store, IFormatReader r, boolean doPlane, boolean doImageName) {
    if (store == null || r == null)
        return;
    int oldSeries = r.getSeries();
    for (int i = 0; i < r.getSeriesCount(); i++) {
        r.setSeries(i);
        String imageName = null;
        if (doImageName) {
            Location f = new Location(r.getCurrentFile());
            imageName = f.getName();
            if (r.getSeriesCount() > 1) {
                imageName += " #" + (i + 1);
            }
        }
        String pixelType = FormatTools.getPixelTypeString(r.getPixelType());
        populateMetadata(store, r.getCurrentFile(), i, imageName, r.isLittleEndian(), r.getDimensionOrder(), pixelType, r.getSizeX(), r.getSizeY(), r.getSizeZ(), r.getSizeC(), r.getSizeT(), r.getRGBChannelCount());
        store.setPixelsInterleaved(r.isInterleaved(), i);
        store.setPixelsSignificantBits(new PositiveInteger(r.getBitsPerPixel()), i);
        try {
            OMEXMLService service = new ServiceFactory().getInstance(OMEXMLService.class);
            if (service.isOMEXMLRoot(store.getRoot())) {
                MetadataStore baseStore = r.getMetadataStore();
                if (service.isOMEXMLMetadata(baseStore)) {
                    OMEXMLMetadata omeMeta;
                    try {
                        omeMeta = service.getOMEMetadata(service.asRetrieve(baseStore));
                        if (omeMeta.getTiffDataCount(i) == 0 && omeMeta.getPixelsBinDataCount(i) == 0) {
                            service.addMetadataOnly(omeMeta, i, i == 0);
                        }
                    } catch (ServiceException e) {
                        LOGGER.warn("Failed to add MetadataOnly", e);
                    }
                }
            }
        } catch (DependencyException exc) {
            LOGGER.warn("Failed to add MetadataOnly", exc);
        }
        if (doPlane) {
            for (int q = 0; q < r.getImageCount(); q++) {
                int[] coords = r.getZCTCoords(q);
                store.setPlaneTheZ(new NonNegativeInteger(coords[0]), i, q);
                store.setPlaneTheC(new NonNegativeInteger(coords[1]), i, q);
                store.setPlaneTheT(new NonNegativeInteger(coords[2]), i, q);
            }
        }
    }
    r.setSeries(oldSeries);
}
Also used : MetadataStore(loci.formats.meta.MetadataStore) PositiveInteger(ome.xml.model.primitives.PositiveInteger) ServiceException(loci.common.services.ServiceException) ServiceFactory(loci.common.services.ServiceFactory) OMEXMLMetadata(loci.formats.ome.OMEXMLMetadata) NonNegativeInteger(ome.xml.model.primitives.NonNegativeInteger) DependencyException(loci.common.services.DependencyException) OMEXMLService(loci.formats.services.OMEXMLService) Location(loci.common.Location)

Example 30 with DependencyException

use of loci.common.services.DependencyException in project bioformats by openmicroscopy.

the class CellVoyagerReader method readInfo.

private void readInfo(final Document msDocument, final Document omeDocument) throws FormatException {
    /*
     * Magnification.
     *
     * We need it early, because the file format reports only un-magnified
     * sizes. So if we are to put proper metadata, we need to make the
     * conversion to size measured at the sample level ourselves. I feel
     * like this is fragile and most likely to change in a future version of
     * the file format.
     */
    final Element msRoot = msDocument.getDocumentElement();
    final double objectiveMagnification = Double.parseDouble(getChildText(msRoot, new String[] { "ObjectiveLens", "Magnification" }));
    // final double zoomLensMagnification = Double.parseDouble(
    // getChildText( msRoot, new String[] { "ZoomLens", "Magnification",
    // "Value" } ) );
    // *
    final double magnification = objectiveMagnification;
    // zoomLensMagnification;
    /*
     * Read the ome.xml file. Since it is malformed, we need to parse all
     * nodes, and add an "ID" attribute to those who do not have it.
     */
    final NodeList nodeList = omeDocument.getElementsByTagName("*");
    for (int i = 0; i < nodeList.getLength(); i++) {
        final Node node = nodeList.item(i);
        if (node.getNodeType() == Node.ELEMENT_NODE) {
            final NamedNodeMap atts = node.getAttributes();
            final Node namedItem = atts.getNamedItem("ID");
            if (namedItem == null) {
                final String name = node.getNodeName();
                final String id = name + ":" + i;
                if (!node.getParentNode().getNodeName().equals("LightSource")) {
                    ((Element) node).setAttribute("ID", id);
                }
            }
        }
    }
    /*
     * For single-slice image, the PhysicalSizeZ can be 0, which will make
     * the metadata read fail. Correct that.
     */
    final Element pszEl = getChild(omeDocument.getDocumentElement(), new String[] { "Image", "Pixels" });
    final double physicalSizeZ = Double.parseDouble(pszEl.getAttribute("PhysicalSizeZ"));
    if (physicalSizeZ <= 0) {
        // default to 1 whatever
        pszEl.setAttribute("PhysicalSizeZ", "" + 1);
    }
    /*
     * Now that the XML document is properly formed, we can build a metadata
     * object from it.
     */
    OMEXMLService service = null;
    String xml = null;
    try {
        xml = XMLTools.getXML(omeDocument);
    } catch (final TransformerConfigurationException e2) {
        LOGGER.debug("", e2);
    } catch (final TransformerException e2) {
        LOGGER.debug("", e2);
    }
    try {
        service = new ServiceFactory().getInstance(OMEXMLService.class);
    } catch (final DependencyException e1) {
        LOGGER.debug("", e1);
    }
    OMEXMLMetadata omeMD = null;
    try {
        omeMD = service.createOMEXMLMetadata(xml);
    } catch (final ServiceException e) {
        LOGGER.debug("", e);
    } catch (final NullPointerException npe) {
        LOGGER.debug("", npe);
        throw npe;
    }
    // Correct pixel size for magnification
    omeMD.setPixelsPhysicalSizeX(FormatTools.createLength(omeMD.getPixelsPhysicalSizeX(0).value().doubleValue() / magnification, omeMD.getPixelsPhysicalSizeX(0).unit()), 0);
    omeMD.setPixelsPhysicalSizeY(FormatTools.createLength(omeMD.getPixelsPhysicalSizeY(0).value().doubleValue() / magnification, omeMD.getPixelsPhysicalSizeY(0).unit()), 0);
    // Time interval
    if (Double.valueOf(readFrameInterval(msDocument)) != null) {
        omeMD.setPixelsTimeIncrement(new Time(Double.valueOf(readFrameInterval(msDocument)), UNITS.SECOND), 0);
    }
    /*
     * Channels
     */
    final Element channelsEl = getChild(msRoot, "Channels");
    final List<Element> channelEls = getChildren(channelsEl, "Channel");
    channelInfos = new ArrayList<ChannelInfo>();
    for (final Element channelEl : channelEls) {
        final boolean isEnabled = Boolean.parseBoolean(getChildText(channelEl, "IsEnabled"));
        if (!isEnabled) {
            continue;
        }
        final ChannelInfo ci = readChannel(channelEl);
        channelInfos.add(ci);
    }
    /*
     * Fix missing IDs.
     *
     * Some IDs are missing in the malformed OME.XML file. We must put them
     * back manually. Some are fixed here
     */
    omeMD.setProjectID(MetadataTools.createLSID("Project", 0), 0);
    omeMD.setScreenID(MetadataTools.createLSID("Screen", 0), 0);
    omeMD.setPlateID(MetadataTools.createLSID("Plate", 0), 0);
    omeMD.setInstrumentID(MetadataTools.createLSID("Instrument", 0), 0);
    // Read pixel sizes from OME metadata.
    final double pixelWidth = omeMD.getPixelsPhysicalSizeX(0).value().doubleValue();
    final double pixelHeight = omeMD.getPixelsPhysicalSizeY(0).value().doubleValue();
    /*
     * Read tile size from channel info. This is weird, but it's like that.
     * Since we build a multi-C image, we have to assume that all channels
     * have the same dimension, even if the file format allows for changing
     * the size, binning, etc. from channel to channel. Failure to load
     * datasets that have this exoticity is to be sought here.
     */
    final int tileWidth = channelInfos.get(0).tileWidth;
    final int tileHeight = channelInfos.get(0).tileHeight;
    /*
     * Handle multiple wells.
     *
     * The same kind of remark apply: We assume that a channel setting can
     * be applied to ALL wells. So this file reader will fail for dataset
     * that have one well that has a different dimension that of others.
     */
    /*
     * First remark: there can be two modes to store Areas in the xml file:
     * Either we define different areas for each well, and in that case, the
     * areas are found as a child element of the well element. Either the
     * definition of areas is common to all wells, and in that case they
     * area defined in a separate element.
     */
    final boolean sameAreaPerWell = Boolean.parseBoolean(getChildText(msRoot, "UsesSameAreaParWell"));
    List<AreaInfo> areas = null;
    if (sameAreaPerWell) {
        final Element areasEl = getChild(msRoot, new String[] { "SameAreaUsingWell", "Areas" });
        final List<Element> areaEls = getChildren(areasEl, "Area");
        int areaIndex = 0;
        areas = new ArrayList<AreaInfo>(areaEls.size());
        int fieldIndex = 1;
        for (final Element areaEl : areaEls) {
            final AreaInfo area = readArea(areaEl, fieldIndex, pixelWidth, pixelHeight, tileWidth, tileHeight);
            area.index = areaIndex++;
            areas.add(area);
            // Continue incrementing field index across areas.
            fieldIndex = area.fields.get(area.fields.size() - 1).index + 1;
        }
    }
    final Element wellsEl = getChild(msRoot, "Wells");
    final List<Element> wellEls = getChildren(wellsEl, "Well");
    wells = new ArrayList<WellInfo>();
    for (final Element wellEl : wellEls) {
        final boolean isWellEnabled = Boolean.parseBoolean(getChild(wellEl, "IsEnabled").getTextContent());
        if (isWellEnabled) {
            final WellInfo wi = readWellInfo(wellEl, pixelWidth, pixelHeight, tileWidth, tileHeight);
            if (sameAreaPerWell) {
                wi.areas = areas;
            }
            wells.add(wi);
        }
    }
    /*
     * Z range.
     *
     * In this file format, the Z range appears to be general: it applies to
     * all fields of all wells.
     */
    final int nZSlices = Integer.parseInt(getChildText(msRoot, new String[] { "ZStackConditions", "NumberOfSlices" }));
    /*
     * Time points. They are general as well. Which just makes sense.
     */
    timePoints = readTimePoints(msDocument);
    /*
     * Populate CORE metadata for each area.
     *
     * This reader takes to convention that state that 1 area = 1 series. So
     * if you have 10 wells with 2 areas in each well, and each area is made
     * of 20 fields, you will get 20 series, and each series will be
     * stitched from 20 fields.
     */
    OMEXMLMetadataRoot root = (OMEXMLMetadataRoot) omeMD.getRoot();
    Image firstImage = root.getImage(0);
    core.clear();
    for (final WellInfo well : wells) {
        for (final AreaInfo area : well.areas) {
            final CoreMetadata ms = new CoreMetadata();
            core.add(ms);
            if (core.size() > 1) {
                root.addImage(firstImage);
            }
            ms.sizeX = area.width;
            ms.sizeY = area.height;
            ms.sizeZ = nZSlices;
            ms.sizeC = channelInfos.size();
            ms.sizeT = timePoints.size();
            ms.dimensionOrder = "XYCZT";
            ms.rgb = false;
            ms.imageCount = nZSlices * channelInfos.size() * timePoints.size();
            // Bit depth.
            switch(omeMD.getPixelsType(0)) {
                case UINT8:
                    ms.pixelType = FormatTools.UINT8;
                    ms.bitsPerPixel = 8;
                    break;
                case UINT16:
                    ms.pixelType = FormatTools.UINT16;
                    ms.bitsPerPixel = 16;
                    break;
                case UINT32:
                    ms.pixelType = FormatTools.UINT32;
                    ms.bitsPerPixel = 32;
                    break;
                default:
                    throw new FormatException("Cannot read image with pixel type = " + omeMD.getPixelsType(0));
            }
            // Determined manually on sample data. Check here is the image
            // you get is weird.
            ms.littleEndian = true;
        }
    }
    omeMD.setRoot(root);
    /*
     * Populate the MetadataStore.
     */
    final MetadataStore store = makeFilterMetadata();
    MetadataConverter.convertMetadata(omeMD, store);
    MetadataTools.populatePixels(store, this, true);
    /*
     * Pinhole disk
     */
    final double pinholeSize = Double.parseDouble(getChildText(msRoot, new String[] { "PinholeDisk", "PinholeSize_um" }));
    /*
     * MicroPlate specific stuff
     */
    final Element containerEl = getChild(msRoot, new String[] { "Attachment", "HolderInfoList", "HolderInfo", "MountedSampleContainer" });
    final String type = containerEl.getAttribute("xsi:type");
    boolean plateMetadata = false;
    if (type.equals("WellPlate")) {
        plateMetadata = true;
        final int nrows = Integer.parseInt(getChildText(containerEl, "RowCount"));
        final int ncols = Integer.parseInt(getChildText(containerEl, "ColumnCount"));
        store.setPlateRows(new PositiveInteger(nrows), 0);
        store.setPlateColumns(new PositiveInteger(ncols), 0);
        final String plateAcqID = MetadataTools.createLSID("PlateAcquisition", 0, 0);
        store.setPlateAcquisitionID(plateAcqID, 0, 0);
        final Element dimInfoEl = getChild(msRoot, "DimensionsInfo");
        final int maxNFields = Integer.parseInt(getChild(dimInfoEl, "F").getAttribute("Max"));
        final PositiveInteger fieldCount = FormatTools.getMaxFieldCount(maxNFields);
        if (fieldCount != null) {
            store.setPlateAcquisitionMaximumFieldCount(fieldCount, 0, 0);
        }
        // Plate acquisition time
        final String beginTime = getChildText(msRoot, "BeginTime");
        final String endTime = getChildText(msRoot, "EndTime");
        store.setPlateAcquisitionStartTime(new Timestamp(beginTime), 0, 0);
        store.setPlateAcquisitionEndTime(new Timestamp(endTime), 0, 0);
        store.setPlateName(beginTime, 0);
    } else if (!type.equals("PreparedSlide")) {
        LOGGER.warn("Unexpected acquisition type: {}", type);
    }
    // Wells position on the plate
    int seriesIndex = -1;
    int wellIndex = -1;
    for (final WellInfo well : wells) {
        wellIndex++;
        final int wellNumber = well.number;
        if (plateMetadata) {
            store.setWellID(MetadataTools.createLSID("Well", 0, wellIndex), 0, wellIndex);
            store.setWellRow(new NonNegativeInteger(well.row), 0, wellIndex);
            store.setWellColumn(new NonNegativeInteger(well.col), 0, wellIndex);
        }
        int areaIndex = -1;
        for (final AreaInfo area : well.areas) {
            seriesIndex++;
            areaIndex++;
            String imageID = MetadataTools.createLSID("Image", seriesIndex);
            store.setImageID(imageID, seriesIndex);
            final String imageName = "Well " + wellNumber + " (UID=" + well.UID + ", r=" + well.row + ", c=" + well.col + ") - Area " + areaIndex;
            store.setImageName(imageName, seriesIndex);
            if (plateMetadata) {
                Length posX = new Length(Double.valueOf(well.centerX), UNITS.REFERENCEFRAME);
                Length posY = new Length(Double.valueOf(well.centerY), UNITS.REFERENCEFRAME);
                String wellSample = MetadataTools.createLSID("WellSample", 0, wellIndex, areaIndex);
                store.setWellSampleID(wellSample, 0, wellIndex, areaIndex);
                store.setWellSampleImageRef(imageID, 0, wellIndex, areaIndex);
                store.setWellSampleIndex(new NonNegativeInteger(area.index), 0, wellIndex, areaIndex);
                store.setWellSamplePositionX(posX, 0, wellIndex, areaIndex);
                store.setWellSamplePositionY(posY, 0, wellIndex, areaIndex);
                store.setPlateAcquisitionWellSampleRef(wellSample, 0, 0, seriesIndex);
            }
            store.setImageInstrumentRef(MetadataTools.createLSID("Instrument", 0), seriesIndex);
            for (int i = 0; i < channelInfos.size(); i++) {
                store.setChannelPinholeSize(new Length(pinholeSize, UNITS.MICROMETER), seriesIndex, i);
                store.setChannelName(channelInfos.get(i).name, seriesIndex, i);
                store.setChannelColor(channelInfos.get(i).color, seriesIndex, i);
            }
        }
    }
}
Also used : TransformerConfigurationException(javax.xml.transform.TransformerConfigurationException) ServiceFactory(loci.common.services.ServiceFactory) Element(org.w3c.dom.Element) Node(org.w3c.dom.Node) Time(ome.units.quantity.Time) Image(ome.xml.model.Image) Timestamp(ome.xml.model.primitives.Timestamp) OMEXMLService(loci.formats.services.OMEXMLService) TransformerException(javax.xml.transform.TransformerException) PositiveInteger(ome.xml.model.primitives.PositiveInteger) NamedNodeMap(org.w3c.dom.NamedNodeMap) NonNegativeInteger(ome.xml.model.primitives.NonNegativeInteger) NodeList(org.w3c.dom.NodeList) DependencyException(loci.common.services.DependencyException) CoreMetadata(loci.formats.CoreMetadata) FormatException(loci.formats.FormatException) MetadataStore(loci.formats.meta.MetadataStore) ServiceException(loci.common.services.ServiceException) Length(ome.units.quantity.Length) OMEXMLMetadata(loci.formats.ome.OMEXMLMetadata) OMEXMLMetadataRoot(ome.xml.meta.OMEXMLMetadataRoot)

Aggregations

DependencyException (loci.common.services.DependencyException)51 ServiceFactory (loci.common.services.ServiceFactory)49 FormatException (loci.formats.FormatException)39 ServiceException (loci.common.services.ServiceException)32 OMEXMLService (loci.formats.services.OMEXMLService)32 MissingLibraryException (loci.formats.MissingLibraryException)15 MetadataStore (loci.formats.meta.MetadataStore)14 CoreMetadata (loci.formats.CoreMetadata)13 IMetadata (loci.formats.meta.IMetadata)13 IOException (java.io.IOException)12 Location (loci.common.Location)10 ImageReader (loci.formats.ImageReader)10 Length (ome.units.quantity.Length)10 PositiveInteger (ome.xml.model.primitives.PositiveInteger)9 OMEXMLMetadata (loci.formats.ome.OMEXMLMetadata)8 ArrayList (java.util.ArrayList)7 MetadataRetrieve (loci.formats.meta.MetadataRetrieve)6 EnumerationException (ome.xml.model.enums.EnumerationException)6 File (java.io.File)5 IFormatWriter (loci.formats.IFormatWriter)5