Changeset 4019


Ignore:
Timestamp:
05/07/08 15:41:08 (12 years ago)
Author:
curtis
Message:

Some cleanup to file stitcher. Still has problems.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/loci/formats/FileStitcher.java

    r4018 r4019  
    3434/** 
    3535 * Logic to stitch together files with similar names. 
    36  * Assumes that all files have the same dimensions. 
     36 * Assumes that all files have the same characteristics (e.g., dimensions). 
    3737 * 
    3838 * <dl><dt><b>Source code:</b></dt> 
     
    7777 
    7878  /** Reader used for each file. */ 
    79   private IFormatReader[][] readers; 
     79  private DimensionSwapper[][] readers; 
    8080 
    8181  /** Blank buffered image, for use when image counts vary between files. */ 
     
    664664          for (int j=0; j<files[i].length; j++) { 
    665665            try { 
    666               readers[i][j].setId(files[i][j]); 
     666              initReader(i, j); 
    667667            } 
    668668            catch (FormatException exc) { 
     
    830830  // -- Internal FormatReader API methods -- 
    831831 
    832   /** Initializes the given file. */ 
     832  /** Initializes the given file or file pattern. */ 
    833833  protected void initFile(String id) throws FormatException, IOException { 
    834834    if (FormatHandler.debug) { 
     
    843843    reader.setId(fp.getFiles()[0]); 
    844844    if (reader.fileGroupOption(fp.getFiles()[0]) == FormatTools.MUST_GROUP) { 
     845      // reader subclass is handling file grouping 
    845846      noStitch = true; 
    846847      return; 
    847848    } 
    848  
    849     // if this is a multi-series dataset, we need some special logic 
    850849 
    851850    AxisGuesser guesser = new AxisGuesser(fp, reader.getDimensionOrder(), 
     
    853852      reader.isOrderCertain()); 
    854853 
     854    // use the dimension order recommended by the axis guesser 
     855    reader.swapDimensions(guesser.getAdjustedOrder()); 
     856 
     857    // if this is a multi-series dataset, we need some special logic 
    855858    int seriesCount = reader.getSeriesCount(); 
    856859    seriesInFile = true; 
     
    864867 
    865868      for (int i=0; i<axes.length; i++) { 
    866         if (axes[i] == AxisGuesser.S_AXIS) { 
    867           sBlock.add(blockPrefixes[i]); 
    868         } 
     869        if (axes[i] == AxisGuesser.S_AXIS) sBlock.add(blockPrefixes[i]); 
    869870      } 
    870871 
     
    897898        files[i] = (String[]) fileVector.get(i); 
    898899      } 
    899     } 
    900  
    901     // check if multiple Z or multiple T axes were found 
    902  
    903     if (!reader.isOrderCertain() && ((guesser.getAxisCountZ() > 0 && 
    904       reader.getSizeZ() > 1) || (guesser.getAxisCountT() > 0 && 
    905       reader.getSizeT() > 1))) 
    906     { 
    907       String order = reader.getDimensionOrder(); 
    908       order = order.replaceAll("Z", "p"); 
    909       order = order.replaceAll("T", "Z"); 
    910       order = order.replaceAll("p", "T"); 
    911       reader.swapDimensions(order); 
    912900    } 
    913901 
     
    948936 
    949937    // construct list of readers for all files 
    950     readers = new IFormatReader[files.length][]; 
     938    readers = new DimensionSwapper[files.length][]; 
    951939    for (int i=0; i<readers.length; i++) { 
    952       readers[i] = new IFormatReader[files[i].length]; 
     940      readers[i] = new DimensionSwapper[files[i].length]; 
    953941    } 
    954942 
     
    967955            } 
    968956          } 
    969           readers[i][j] = (IFormatReader) r; 
     957          readers[i][j] = (DimensionSwapper) r; 
    970958        } 
    971959        catch (InstantiationException exc) { LogTools.trace(exc); } 
     
    10151003      // the reader for this file uses its own stitching logic that is probably 
    10161004      // smarter than FileStitcher 
    1017       readers = new IFormatReader[1][1]; 
     1005      readers = new DimensionSwapper[1][1]; 
    10181006      readers[0][0] = reader; 
    10191007      String f = files[0][0]; 
     
    11031091 
    11041092    try { 
    1105       readers[sno][0].setId(files[sno][0]); 
    1106       readers[sno][0].setSeries(seriesInFile ? getSeries() : 0); 
     1093      initReader(sno, 0); 
    11071094    } 
    11081095    catch (IOException e) { 
     
    12271214 
    12281215    // configure the reader, in case we haven't done this one yet 
    1229     readers[sno][fno].setId(files[sno][fno]); 
    1230     readers[sno][fno].setSeries(reader.getSeries()); 
     1216    initReader(sno, fno); 
    12311217 
    12321218    int ino; 
     
    12351221      posT[0] < readers[sno][fno].getSizeT()) 
    12361222    { 
    1237       if (readers[sno][fno].isRGB()) { 
    1238         posC[0] /= lenC[sno][0]; 
    1239       } 
     1223      if (readers[sno][fno].isRGB()) posC[0] /= lenC[sno][0]; 
    12401224      ino = FormatTools.getIndex(readers[sno][fno], posZ[0], posC[0], posT[0]); 
    12411225    } 
     
    12641248  } 
    12651249 
    1266   private FilePattern getPattern(String[] f, String dir, String block) 
     1250  protected void initReader(int sno, int fno) 
     1251    throws FormatException, IOException 
    12671252  { 
     1253    readers[sno][fno].setId(files[sno][fno]); 
     1254    readers[sno][fno].setSeries(seriesInFile ? getSeries() : 0); 
     1255    readers[sno][fno].swapDimensions(reader.getDimensionOrder()); 
     1256  } 
     1257 
     1258  private FilePattern getPattern(String[] f, String dir, String block) { 
    12681259    Vector v = new Vector(); 
    12691260    for (int i=0; i<f.length; i++) { 
Note: See TracChangeset for help on using the changeset viewer.