Search in sources :

Example 1 with IFormatReader

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

the class CropDialog method constructDialog.

@Override
protected GenericDialog constructDialog() {
    final int seriesCount = process.getSeriesCount();
    final IFormatReader r = process.getReader();
    // construct dialog
    final GenericDialog gd = new GenericDialog("Bio-Formats Crop Options");
    for (int s = 0; s < seriesCount; s++) {
        if (!options.isSeriesOn(s))
            continue;
        r.setSeries(s);
        Region region = process.getCropRegion(s);
        gd.addMessage(process.getSeriesLabel(s).replaceAll("_", " "));
        gd.addNumericField("X_Coordinate_" + (s + 1), region.x, 0);
        gd.addNumericField("Y_Coordinate_" + (s + 1), region.y, 0);
        gd.addNumericField("Width_" + (s + 1), region.width, 0);
        gd.addNumericField("Height_" + (s + 1), region.height, 0);
    }
    WindowTools.addScrollBars(gd);
    return gd;
}
Also used : IFormatReader(loci.formats.IFormatReader) GenericDialog(ij.gui.GenericDialog) Region(loci.common.Region)

Example 2 with IFormatReader

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

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

the class MakeDatasetStructureTable method printTable.

/**
 * Write the table to the file specified using setOutputFile(String[])
 */
public void printTable() {
    ImageReader baseReader = new ImageReader();
    IFormatReader[] allReaders = baseReader.getReaders();
    Comparator<IFormatReader> comparator = new Comparator<IFormatReader>() {

        @Override
        public int compare(IFormatReader r1, IFormatReader r2) {
            String s1 = r1.getFormat();
            String s2 = r2.getFormat();
            return s1.compareTo(s2);
        }
    };
    Arrays.sort(allReaders, comparator);
    printHeader();
    for (IFormatReader reader : allReaders) {
        try {
            printFormatEntry(reader);
        } catch (IllegalStateException e) {
        }
    }
    printFooter();
}
Also used : IFormatReader(loci.formats.IFormatReader) ImageReader(loci.formats.ImageReader) Comparator(java.util.Comparator)

Example 4 with IFormatReader

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

the class HitachiReader method initFile.

// -- Internal FormatReader API methods --
/* @see loci.formats.FormatReader#initFile(String) */
@Override
protected void initFile(String id) throws FormatException, IOException {
    if (!checkSuffix(id, "txt")) {
        String base = id;
        if (base.indexOf('.') >= 0) {
            base = base.substring(0, base.lastIndexOf("."));
        }
        id = base + ".txt";
        initFile(id);
        return;
    }
    super.initFile(id);
    String data = DataTools.readFile(id);
    IniParser parser = new IniParser();
    parser.setBackslashContinuesLine(false);
    IniList ini = parser.parseINI(new BufferedReader(new StringReader(data)));
    IniTable image = ini.getTable("SemImageFile");
    if (image == null) {
        throw new FormatException("Could not find 'SemImageFile' table.");
    }
    for (String key : image.keySet()) {
        addGlobalMeta(key, image.get(key));
    }
    String imageName = image.get("SampleName");
    String pixelsFile = image.get("ImageName");
    String date = image.get("Date");
    String time = image.get("Time");
    Location parent = new Location(id).getAbsoluteFile().getParentFile();
    pixelsFile = new Location(parent, pixelsFile).getAbsolutePath();
    ClassList<IFormatReader> classes = ImageReader.getDefaultReaderClasses();
    Class<? extends IFormatReader>[] classArray = classes.getClasses();
    ClassList<IFormatReader> newClasses = new ClassList<IFormatReader>(IFormatReader.class);
    for (Class<? extends IFormatReader> c : classArray) {
        if (!c.equals(HitachiReader.class)) {
            newClasses.addClass(c);
        }
    }
    helperReader = new ImageReader(newClasses);
    helperReader.setId(pixelsFile);
    core = new ArrayList<CoreMetadata>(helperReader.getCoreMetadataList());
    MetadataStore store = makeFilterMetadata();
    MetadataTools.populatePixels(store, this, getMetadataOptions().getMetadataLevel() != MetadataLevel.MINIMUM);
    store.setImageName(imageName, 0);
    date = DateTools.formatDate(date + " " + time, DATE_FORMAT);
    if (date != null) {
        store.setImageAcquisitionDate(new Timestamp(date), 0);
    }
    populateOMEMetadata(image, store);
}
Also used : IniParser(loci.common.IniParser) IFormatReader(loci.formats.IFormatReader) IniList(loci.common.IniList) ClassList(loci.formats.ClassList) CoreMetadata(loci.formats.CoreMetadata) Timestamp(ome.xml.model.primitives.Timestamp) FormatException(loci.formats.FormatException) MetadataStore(loci.formats.meta.MetadataStore) IniTable(loci.common.IniTable) BufferedReader(java.io.BufferedReader) StringReader(java.io.StringReader) ImageReader(loci.formats.ImageReader) Location(loci.common.Location)

Example 5 with IFormatReader

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

the class GetPhysicalMetadata method main.

public static void main(String[] args) throws Exception {
    // parse command line arguments
    if (args.length < 1) {
        System.err.println("Usage: java GetMetadata imageFile [seriesNo]");
        System.exit(1);
    }
    String id = args[0];
    int series = args.length > 1 ? Integer.parseInt(args[1]) : 0;
    // create OME-XML metadata store
    ServiceFactory factory = new ServiceFactory();
    OMEXMLService service = factory.getInstance(OMEXMLService.class);
    IMetadata meta = service.createOMEXMLMetadata();
    // 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);
    printPixelDimensions(reader);
    printPhysicalDimensions(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)

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