Changeset 6953


Ignore:
Timestamp:
09/16/10 15:34:15 (9 years ago)
Author:
melissa
Message:

Allow MIAS text files to be passed to MIASReader.setId. Closes #562.

File:
1 edited

Legend:

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

    r6881 r6953  
    101101  /** Constructs a new MIAS reader. */ 
    102102  public MIASReader() { 
    103     super("MIAS", new String[] {"tif", "tiff"}); 
     103    super("MIAS", new String[] {"tif", "tiff", "txt"}); 
    104104    suffixSufficient = false; 
    105105    domains = new String[] {FormatTools.HCS_DOMAIN}; 
     
    120120    Location baseFile = new Location(filename).getAbsoluteFile(); 
    121121    Location wellDir = baseFile.getParentFile(); 
     122    String wellName = wellDir.getName(); 
     123 
     124    if (checkSuffix(filename, "txt")) { 
     125      String name = baseFile.getName(); 
     126      return wellName.equals("results") || wellName.equals("Batchresults") || 
     127        name.equals("Nugenesistemplate.txt") || name.startsWith("mode"); 
     128    } 
     129 
    122130    Location experiment = null; 
    123131    try { 
     
    128136    if (experiment == null) return false; 
    129137 
    130     String wellName = wellDir.getName(); 
    131138    boolean validName = 
    132139      wellName.startsWith("Well") || wellName.equals("results") || 
     
    233240    Vector<String> files = new Vector<String>(); 
    234241 
    235     if (!noPixels) { 
     242    if (!noPixels && tiffs != null) { 
    236243      String[] f = new String[tiffs[getSeries()].length]; 
    237244      System.arraycopy(tiffs[getSeries()], 0, f, 0, f.length); 
     
    286293  protected void initFile(String id) throws FormatException, IOException { 
    287294    super.initFile(id); 
     295 
     296    if (checkSuffix(id, "txt")) { 
     297      // first need to find a relevant TIFF file 
     298 
     299      Location base = new Location(id).getAbsoluteFile(); 
     300      Location plate = null; 
     301      if (base.getParentFile().getName().equals("Batchresults")) { 
     302        Location experiment = base.getParentFile().getParentFile(); 
     303        String[] plates = experiment.list(true); 
     304        Arrays.sort(plates); 
     305        plate = new Location(experiment, plates[0]); 
     306      } 
     307      else { 
     308        plate = base.getParentFile(); 
     309        if (plate.getName().equals("results")) plate = plate.getParentFile(); 
     310      } 
     311 
     312      String[] list = plate.list(true); 
     313      for (String f : list) { 
     314        if (f.startsWith("Well")) { 
     315          Location well = new Location(plate, f); 
     316          String[] wellList = well.list(true); 
     317          for (String file : wellList) { 
     318            String path = new Location(well, file).getAbsolutePath(); 
     319            if (isThisType(path) && 
     320              checkSuffix(path, new String[] {"tif", "tiff"})) 
     321            { 
     322              initFile(path); 
     323              return; 
     324            } 
     325          } 
     326        } 
     327      } 
     328 
     329      throw new FormatException("Could not locate an appropriate TIFF file."); 
     330    } 
    288331 
    289332    if (!isGroupFiles()) { 
Note: See TracChangeset for help on using the changeset viewer.