// // ScanrReader.java // /* OME Bio-Formats package for reading and converting biological file formats. Copyright (C) 2005-@year@ UW-Madison LOCI and Glencoe Software, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package loci.formats.in; import java.io.IOException; import java.util.Vector; import loci.common.DataTools; import loci.common.Location; import loci.common.RandomAccessInputStream; import loci.common.XMLTools; import loci.formats.CoreMetadata; import loci.formats.FormatException; import loci.formats.FormatReader; import loci.formats.FormatTools; import loci.formats.MetadataTools; import loci.formats.meta.FilterMetadata; import loci.formats.meta.MetadataStore; import loci.formats.tiff.IFD; import loci.formats.tiff.TiffParser; import org.xml.sax.Attributes; import org.xml.sax.helpers.DefaultHandler; /** * ScanrReader is the file format reader for Olympus ScanR datasets. * *
Source code:
*
Trac, * SVN
* * @author Melissa Linkert melissa at glencoesoftware.com */ public class ScanrReader extends FormatReader { // -- Constants -- private static final String XML_FILE = "experiment_descriptor.xml"; private static final String EXPERIMENT_FILE = "experiment_descriptor.dat"; private static final String ACQUISITION_FILE = "AcquisitionLog.dat"; // -- Fields -- private Vector metadataFiles = new Vector(); private int wellRows, wellColumns; private int fieldRows, fieldColumns; private Vector channelNames = new Vector(); private String plateName; private String[] tiffs; private MinimalTiffReader reader; // -- Constructor -- /** Constructs a new ScanR reader. */ public ScanrReader() { super("Olympus ScanR", new String[] {"dat", "xml", "tif"}); domains = new String[] {FormatTools.HCS_DOMAIN}; suffixSufficient = false; } // -- IFormatReader API methods -- /* @see loci.formats.IFormatReader#isThisType(String, boolean) */ public boolean isThisType(String name, boolean open) { String localName = new Location(name).getName(); if (localName.equals(XML_FILE) || localName.equals(EXPERIMENT_FILE) || localName.equals(ACQUISITION_FILE)) { return true; } return super.isThisType(name, open); } /* @see loci.formats.IFormatReader#isThisType(RandomAccessInputStream) */ public boolean isThisType(RandomAccessInputStream stream) throws IOException { TiffParser p = new TiffParser(stream); IFD ifd = p.getFirstIFD(); if (ifd == null) return false; Object s = ifd.getIFDValue(IFD.SOFTWARE); if (s == null) return false; String software = s instanceof String[] ? ((String[]) s)[0] : s.toString(); return software.trim().equals("National Instruments IMAQ"); } /* @see loci.formats.IFormatReader#getSeriesUsedFiles(boolean) */ public String[] getSeriesUsedFiles(boolean noPixels) { FormatTools.assertId(currentId, true, 1); Vector files = new Vector(); for (String file : metadataFiles) { if (file != null) files.add(file); } if (!noPixels && tiffs != null) { int offset = getSeries() * getImageCount(); for (int i=0; i