Changeset 6726


Ignore:
Timestamp:
07/23/10 13:34:17 (9 years ago)
Author:
melissa
Message:

A few more type checking fixes. 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/InCellReader.java

    r6655 r6726  
    6161  private static final String[] PIXELS_SUFFIXES = 
    6262    new String[] {"tif", "tiff", "im"}; 
     63  private static final String[] METADATA_SUFFIXES = 
     64    new String[] {"xdce", "xml", "xlog"}; 
    6365 
    6466  // -- Fields -- 
     
    9496  /** Constructs a new InCell 1000 reader. */ 
    9597  public InCellReader() { 
    96     super("InCell 1000", new String[] {"xdce", "xml"}); 
     98    super("InCell 1000", 
     99      new String[] {"xdce", "xml", "tiff", "tif", "xlog", "im"}); 
    97100    suffixSufficient = false; 
    98101    domains = new String[] {FormatTools.HCS_DOMAIN}; 
     
    101104 
    102105  // -- IFormatReader API methods -- 
     106 
     107  /* @see loci.formats.IFormatReader#isThisType(String, boolean) */ 
     108  public boolean isThisType(String name, boolean open) { 
     109    if (checkSuffix(name, PIXELS_SUFFIXES) || checkSuffix(name, "xlog")) { 
     110      Location file = new Location(name).getAbsoluteFile().getParentFile(); 
     111      String[] list = file.list(true); 
     112      for (String f : list) { 
     113        if (checkSuffix(f, new String[] {"xdce", "xml"})) { 
     114          return isThisType(new Location(file, f).getAbsolutePath(), open); 
     115        } 
     116      } 
     117    } 
     118    return super.isThisType(name, open); 
     119  } 
    103120 
    104121  /* @see loci.formats.IFormatReader#isSingleFile(String) */ 
     
    176193        for (Image plane : timepoints) { 
    177194          if (plane != null && plane.filename != null) { 
    178             files.add(plane.filename); 
    179             files.add(plane.thumbnailFile); 
     195            if (new Location(plane.filename).exists()) { 
     196              files.add(plane.filename); 
     197            } 
     198            if (new Location(plane.thumbnailFile).exists()) { 
     199              files.add(plane.thumbnailFile); 
     200            } 
    180201          } 
    181202        } 
     
    219240  /* @see loci.formats.FormatReader#initFile(String) */ 
    220241  protected void initFile(String id) throws FormatException, IOException { 
     242    // make sure that we have the .xdce (or .xml) file 
     243    if (checkSuffix(id, PIXELS_SUFFIXES) || checkSuffix(id, "xlog")) { 
     244      Location parent = new Location(id).getAbsoluteFile().getParentFile(); 
     245      String[] list = parent.list(true); 
     246      for (String f : list) { 
     247        if (checkSuffix(f, new String[] {"xdce", "xml"})) { 
     248          String path = new Location(parent, f).getAbsolutePath(); 
     249          if (isThisType(path)) { 
     250            id = path; 
     251            break; 
     252          } 
     253        } 
     254      } 
     255    } 
     256 
    221257    super.initFile(id); 
    222258    in = new RandomAccessInputStream(id); 
     
    237273    String[] files = directory.list(true); 
    238274    for (String file : files) { 
    239       if (!checkSuffix(file, PIXELS_SUFFIXES)) { 
     275      if (checkSuffix(file, METADATA_SUFFIXES)) { 
    240276        metadataFiles.add(new Location(directory, file).getAbsolutePath()); 
    241277      } 
  • trunk/components/bio-formats/src/loci/formats/in/LeicaReader.java

    r6655 r6726  
    169169  /** Constructs a new Leica reader. */ 
    170170  public LeicaReader() { 
    171     super("Leica", new String[] {"lei", "tif", "tiff"}); 
     171    super("Leica", new String[] {"lei", "tif", "tiff", "raw"}); 
    172172    domains = new String[] {FormatTools.LM_DOMAIN}; 
    173173    hasCompanionFiles = true; 
     
    184184  public boolean isThisType(String name, boolean open) { 
    185185    if (checkSuffix(name, LEI_SUFFIX)) return true; 
    186     if (!checkSuffix(name, TiffReader.TIFF_SUFFIXES)) return false; 
     186    if (!checkSuffix(name, TiffReader.TIFF_SUFFIXES) && 
     187      !checkSuffix(name, "raw")) 
     188    { 
     189      return false; 
     190    } 
    187191 
    188192    if (!open) return false; // not allowed to touch the file system 
     
    290294    if (leiFilename != null) v.add(leiFilename); 
    291295    if (!noPixels && files != null) { 
    292       v.addAll(files[getSeries()]); 
     296      for (Object file : files[getSeries()]) { 
     297        if (file != null && new Location((String) file).exists()) { 
     298          v.add((String) file); 
     299        } 
     300      } 
    293301    } 
    294302    return v.toArray(new String[v.size()]); 
     
    721729        } 
    722730      } 
     731    } 
     732    else if (checkSuffix(baseFile, "raw") && isGroupFiles()) { 
     733      // check for that there is an .lei file in the same directory 
     734      String prefix = baseFile; 
     735      if (prefix.indexOf(".") != -1) { 
     736        prefix = prefix.substring(0, prefix.lastIndexOf(".")); 
     737      } 
     738      Location lei = new Location(prefix + ".lei"); 
     739      if (!lei.exists()) { 
     740        lei = new Location(prefix + ".LEI"); 
     741        while (!lei.exists() && prefix.indexOf("_") != -1) { 
     742          prefix = prefix.substring(0, prefix.lastIndexOf("_")); 
     743          lei = new Location(prefix + ".lei"); 
     744          if (!lei.exists()) lei = new Location(prefix + ".LEI"); 
     745        } 
     746      } 
     747      if (lei.exists()) return lei.getAbsolutePath(); 
    723748    } 
    724749    return null; 
  • trunk/components/bio-formats/src/loci/formats/in/MetamorphReader.java

    r6711 r6726  
    139139    TiffParser tp = new TiffParser(stream); 
    140140    IFD ifd = tp.getFirstIFD(); 
    141     if (ifd == null || !ifd.containsKey(METAMORPH_ID)) return false; 
     141    if (ifd == null) return false; 
     142    if (ifd.containsKey(METAMORPH_ID)) return true; 
    142143    String software = ifd.getIFDTextValue(IFD.SOFTWARE); 
    143144    return software != null && software.trim().startsWith("Meta"); 
     
    156157    String[] files = l.getParentFile().list(); 
    157158 
    158     for (int i=0; i<files.length; i++) { 
    159       if (checkSuffix(files[i], ND_SUFFIX) && 
    160        id.startsWith(files[i].substring(0, files[i].lastIndexOf(".")))) 
     159    for (String file : files) { 
     160      if (checkSuffix(file, ND_SUFFIX) && 
     161       l.getName().startsWith(file.substring(0, file.lastIndexOf(".")))) 
    161162      { 
    162163        return FormatTools.MUST_GROUP; 
     
    175176    Vector<String> v = new Vector<String>(); 
    176177    if (ndFilename != null) v.add(ndFilename); 
    177     if (!noPixels) v.addAll(Arrays.asList(stks[getSeries()])); 
     178    if (!noPixels) { 
     179      for (String stk : stks[getSeries()]) { 
     180        if (new Location(stk).exists()) { 
     181          v.add(stk); 
     182        } 
     183      } 
     184    } 
    178185    return v.toArray(new String[v.size()]); 
    179186  } 
     
    276283      // an STK file was passed to initFile 
    277284      // let's check the parent directory for an .nd file 
    278       Location parent = new Location(id).getAbsoluteFile().getParentFile(); 
     285      Location stk = new Location(id).getAbsoluteFile(); 
     286      Location parent = stk.getParentFile(); 
    279287      String[] list = parent.list(true); 
    280288      for (String f : list) { 
    281289        if (checkSuffix(f, ND_SUFFIX)) { 
    282290          String prefix = f.substring(0, f.lastIndexOf(".")); 
    283           if (currentId.startsWith(prefix)) { 
     291          if (stk.getName().startsWith(prefix)) { 
    284292            ndfile = new Location(parent, f).getAbsoluteFile(); 
    285293            break; 
  • trunk/components/bio-formats/src/loci/formats/in/ScanrReader.java

    r6720 r6726  
    6262  private static final String EXPERIMENT_FILE = "experiment_descriptor.dat"; 
    6363  private static final String ACQUISITION_FILE = "AcquisitionLog.dat"; 
     64  private static final String[] METADATA_SUFFIXES = new String[] {"dat", "xml"}; 
    6465 
    6566  // -- Fields -- 
     
    246247    for (String file : list) { 
    247248      Location f = new Location(dir, file); 
    248       if (!f.isDirectory()) { 
     249      if (!f.isDirectory() && checkSuffix(file, METADATA_SUFFIXES)) { 
    249250        metadataFiles.add(f.getAbsolutePath()); 
    250251      } 
Note: See TracChangeset for help on using the changeset viewer.