Changeset 6724


Ignore:
Timestamp:
07/22/10 19:16:02 (9 years ago)
Author:
melissa
Message:

Fixed a bunch of type detection problems. See #273.

Location:
trunk/components/bio-formats/src/loci/formats/in
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/components/bio-formats/src/loci/formats/in/DeltavisionReader.java

    r6692 r6724  
    9999  /** Constructs a new Deltavision reader. */ 
    100100  public DeltavisionReader() { 
    101     super("Deltavision", new String[] {"dv", "r3d", "r3d_d3d", "dv.log"}); 
     101    super("Deltavision", 
     102      new String[] {"dv", "r3d", "r3d_d3d", "dv.log", "r3d.log"}); 
    102103    suffixSufficient = false; 
    103104    suffixNecessary = false; 
     
    115116  /* @see loci.formats.IFormatReader#isThisType(String, boolean) */ 
    116117  public boolean isThisType(String name, boolean open) { 
    117     if (checkSuffix(name, "dv.log") || name.endsWith("_log.txt")) return true; 
     118    if (checkSuffix(name, "dv.log") || checkSuffix(name, "r3d.log") || 
     119      name.endsWith("_log.txt")) 
     120    { 
     121      return true; 
     122    } 
    118123    if (checkSuffix(name, "pnl")) return false; 
    119124    return super.isThisType(name, open); 
     
    172177  protected void initFile(String id) throws FormatException, IOException { 
    173178    if (!checkSuffix(id, "dv")) { 
    174       if (checkSuffix(id, "dv.log")) { 
     179      if (checkSuffix(id, "dv.log") || checkSuffix(id, "r3d.log")) { 
    175180        id = id.substring(0, id.lastIndexOf(".")); 
    176181      } 
  • trunk/components/bio-formats/src/loci/formats/in/JEOLReader.java

    r6230 r6724  
    5252  /** Constructs a new JEOL reader. */ 
    5353  public JEOLReader() { 
    54     super("JEOL", new String[] {"dat", "img"}); 
     54    super("JEOL", new String[] {"dat", "img", "par"}); 
    5555    domains = new String[] {FormatTools.SEM_DOMAIN}; 
    5656    suffixSufficient = false; 
     
    6161  /* @see loci.formats.IFormatReader#isThisType(String) */ 
    6262  public boolean isThisType(String name, boolean open) { 
     63    if (checkSuffix(name, "par")) return true; 
    6364    if (checkSuffix(name, "dat")) { 
    6465      try { 
     
    116117  /* @see loci.formats.FormatReader#initFile(String) */ 
    117118  protected void initFile(String id) throws FormatException, IOException { 
     119    if (checkSuffix(id, "par")) { 
     120      String base = new Location(id).getAbsoluteFile().getAbsolutePath(); 
     121      base = base.substring(0, base.lastIndexOf(".")); 
     122      id = base + ".IMG"; 
     123      if (!new Location(id).exists()) { 
     124        id = base + ".DAT"; 
     125      } 
     126      if (!new Location(id).exists()) { 
     127        throw new FormatException("Could not find image file."); 
     128      } 
     129    } 
     130 
    118131    super.initFile(id); 
    119132    in = new RandomAccessInputStream(id); 
  • trunk/components/bio-formats/src/loci/formats/in/PerkinElmerReader.java

    r6655 r6724  
    135135      prefix = prefix.substring(0, prefix.lastIndexOf(".")); 
    136136    } 
    137     if (prefix.indexOf("_") != -1) { 
     137    if (prefix.indexOf("_") != -1 && binFile) { 
    138138      prefix = prefix.substring(0, prefix.lastIndexOf("_")); 
    139139    } 
  • trunk/components/bio-formats/src/loci/formats/in/TillVisionReader.java

    r6655 r6724  
    6969 
    7070  private String[] pixelsFiles; 
    71   private RandomAccessInputStream[] pixelsStream; 
     71  private RandomAccessInputStream pixelsStream; 
    7272  private Hashtable<Integer, Double> exposureTimes; 
    7373  private boolean embeddedImages; 
     
    8282  /** Constructs a new TillVision reader. */ 
    8383  public TillVisionReader() { 
    84     super("TillVision", "vws"); 
     84    super("TillVision", new String[] {"vws", "pst"}); 
    8585    domains = new String[] {FormatTools.LM_DOMAIN}; 
    8686  } 
     
    101101      readPlane(in, x, y, w, h, buf); 
    102102    } 
    103     else if ((no + 1) * plane <= pixelsStream[series].length()) { 
    104       pixelsStream[series].seek(no * plane); 
    105       readPlane(pixelsStream[series], x, y, w, h, buf); 
     103    else { 
     104      pixelsStream = new RandomAccessInputStream(pixelsFiles[series]); 
     105      if ((no + 1) * plane <= pixelsStream.length()) { 
     106        pixelsStream.seek(no * plane); 
     107        readPlane(pixelsStream, x, y, w, h, buf); 
     108      } 
     109      pixelsStream.close(); 
    106110    } 
    107111 
     
    113117    super.close(fileOnly); 
    114118    if (!fileOnly) { 
    115       if (pixelsStream != null) { 
    116         for (RandomAccessInputStream stream : pixelsStream) { 
    117           if (stream != null) stream.close(); 
    118         } 
    119       } 
     119      if (pixelsStream != null) pixelsStream.close(); 
    120120      pixelsStream = null; 
    121121      pixelsFiles = null; 
     
    157157  /* @see loci.formats.FormatReader#initFile(String) */ 
    158158  protected void initFile(String id) throws FormatException, IOException { 
     159    // make sure that we have the .vws file 
     160 
     161    if (!checkSuffix(id, "vws")) { 
     162      Location pst = new Location(id).getAbsoluteFile(); 
     163      String name = pst.getParentFile().getName(); 
     164      Location parent = pst.getParentFile().getParentFile(); 
     165      Location vwsFile = new Location(parent, name.replaceAll(".pst", ".vws")); 
     166      if (vwsFile.exists()) { 
     167        id = vwsFile.getAbsolutePath(); 
     168      } 
     169      else throw new FormatException("Could not find .vws file."); 
     170    } 
     171 
    159172    super.initFile(id); 
    160173 
     
    194207          if (!type.equals("CImage")) { 
    195208            embeddedImages = false; 
     209            s.close(); 
    196210            continue; 
    197211          } 
     
    213227          core[0].pixelType = convertPixelType(s.readInt()); 
    214228          embeddedOffset = s.getFilePointer() + 28; 
     229          in.close(); 
    215230          in = poi.getDocumentStream(name); 
    216231          nImages++; 
     232          s.close(); 
    217233          break; 
    218234        } 
     
    289305          nImages++; 
    290306        } 
     307        s.close(); 
    291308      } 
    292309    } 
     
    334351    Arrays.sort(pixelsFile); 
    335352 
    336     pixelsStream = new RandomAccessInputStream[getSeriesCount()]; 
    337353    pixelsFiles = new String[getSeriesCount()]; 
    338354 
     
    364380 
    365381        file = f.getAbsolutePath(); 
    366         pixelsStream[i] = new RandomAccessInputStream(file); 
    367382        pixelsFiles[i] = file; 
    368383 
     
    372387        String inf = file.substring(0, dot) + ".inf"; 
    373388 
    374         IniList data = parser.parseINI(new BufferedReader(new FileReader(inf))); 
     389        BufferedReader reader = new BufferedReader(new FileReader(inf)); 
     390        IniList data = parser.parseINI(reader); 
     391        reader.close(); 
    375392        IniTable infoTable = data.getTable("Info"); 
    376393 
Note: See TracChangeset for help on using the changeset viewer.