Changeset 1802


Ignore:
Timestamp:
11/16/06 15:41:25 (13 years ago)
Author:
curtis
Message:

Implement swapDimensions for FileStitcher; implement initial API for swapping
stitched dimensional blocks: FileStitcher.setAxisTypes(String, int[]).

Location:
trunk/loci/formats
Files:
2 edited

Legend:

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

    r1783 r1802  
    240240   */ 
    241241  public int[] getAxisTypes() { return axes; } 
     242 
     243  /** 
     244   * Sets the axis type for each dimensional block. 
     245   * @param axes An array containing values from the enumeration: 
     246   *   <ul> 
     247   *     <li>Z_AXIS: focal planes</li> 
     248   *     <li>T_AXIS: time points</li> 
     249   *     <li>C_AXIS: channels</li> 
     250   *   </ul> 
     251   */ 
     252  public void setAxisTypes(int[] axes) { this.axes = axes; } 
    242253 
    243254  /** Gets the number of Z axes in the pattern. */ 
  • trunk/loci/formats/FileStitcher.java

    r1788 r1802  
    3333 
    3434/** 
    35  * Logic to stitch together files with similar names. Only stitches the first 
    36  * series for each file, and assumes that all files have the same dimensions. 
     35 * Logic to stitch together files with similar names. Stitches based on the 
     36 * first series for each file, and assumes that all files have the same 
     37 * dimensions. 
    3738 */ 
    3839public class FileStitcher implements IFormatReader { 
     
    7071  private int imagesPerFile; 
    7172 
     73  /** Total number of image planes. */ 
     74  private int totalImages; 
     75 
     76  /** Dimension order. */ 
     77  private String order; 
     78 
    7279  /** Dimensional axis lengths per file. */ 
    7380  private int sizeZ, sizeC, sizeT; 
    7481 
    75   /** Total number of image planes. */ 
    76   private int totalImages; 
    77  
    7882  /** Total dimensional axis lengths. */ 
    7983  private int totalSizeZ, totalSizeC, totalSizeT; 
    80  
    81   /** Dimension order. */ 
    82   private String order; 
    8384 
    8485  /** Component lengths for each axis type. */ 
     
    111112    reader = r; 
    112113    this.patternIds = patternIds; 
     114  } 
     115 
     116  // -- FileStitcher API methods -- 
     117 
     118  /** 
     119   * Gets the axis type for each dimensional block. 
     120   * @return An array containing values from the enumeration: 
     121   *   <ul> 
     122   *     <li>AxisGuesser.Z_AXIS: focal planes</li> 
     123   *     <li>AxisGuesser.T_AXIS: time points</li> 
     124   *     <li>AxisGuesser.C_AXIS: channels</li> 
     125   *   </ul> 
     126   */ 
     127  public int[] getAxisTypes(String id) 
     128    throws FormatException, IOException 
     129  { 
     130    if (!id.equals(currentId)) initFile(id); 
     131    return ag.getAxisTypes(); 
     132  } 
     133 
     134  /** 
     135   * Sets the axis type for each dimensional block. 
     136   * @param axes An array containing values from the enumeration: 
     137   *   <ul> 
     138   *     <li>AxisGuesser.Z_AXIS: focal planes</li> 
     139   *     <li>AxisGuesser.T_AXIS: time points</li> 
     140   *     <li>AxisGuesser.C_AXIS: channels</li> 
     141   *   </ul> 
     142   */ 
     143  public void setAxisTypes(String id, int[] axes) 
     144    throws FormatException, IOException 
     145  { 
     146    if (!id.equals(currentId)) initFile(id); 
     147    ag.setAxisTypes(axes); 
     148    computeAxisLengths(); 
     149  } 
     150 
     151  /** Gets the file pattern object used to build the list of files. */ 
     152  public FilePattern getFilePattern(String id) 
     153    throws FormatException, IOException 
     154  { 
     155    if (!id.equals(currentId)) initFile(id); 
     156    return fp; 
     157  } 
     158 
     159  /** 
     160   * Gets the axis guesser object used to guess 
     161   * which dimensional axes are which. 
     162   */ 
     163  public AxisGuesser getAxisGuesser(String id) 
     164    throws FormatException, IOException 
     165  { 
     166    if (!id.equals(currentId)) initFile(id); 
     167    return ag; 
    113168  } 
    114169 
     
    336391    throws FormatException, IOException 
    337392  { 
    338     throw new FormatException("Unimplemented"); 
     393    if (!id.equals(currentId)) initFile(id); 
     394    this.order = order; 
     395    String f0 = files[0]; 
     396    reader.swapDimensions(f0, order); 
     397    sizeZ = reader.getSizeZ(f0); 
     398    sizeC = reader.getSizeC(f0); 
     399    sizeT = reader.getSizeT(f0); 
     400    computeAxisLengths(); 
    339401  } 
    340402 
     
    532594    height = reader.getSizeY(f0); 
    533595    imagesPerFile = reader.getImageCount(f0); 
     596    totalImages = files.length * imagesPerFile; 
     597    order = reader.getDimensionOrder(f0); 
    534598    sizeZ = reader.getSizeZ(f0); 
    535599    sizeC = reader.getSizeC(f0); 
    536600    sizeT = reader.getSizeT(f0); 
    537     int pixelType = reader.getPixelType(f0); 
    538     boolean little = reader.isLittleEndian(f0); 
    539     order = reader.getDimensionOrder(f0); 
    540601    boolean certain = reader.isOrderCertain(f0); 
    541602 
     
    545606    // order may need to be adjusted 
    546607    order = ag.getAdjustedOrder(); 
    547     reader.swapDimensions(f0, order); 
    548     sizeZ = reader.getSizeZ(f0); 
    549     sizeC = reader.getSizeC(f0); 
    550     sizeT = reader.getSizeT(f0); 
    551  
    552     // compute total axis lengths 
     608    swapDimensions(id, order); 
     609  } 
     610 
     611  /** Computes axis length arrays, and total axis lengths. */ 
     612  protected void computeAxisLengths() throws FormatException, IOException { 
    553613    int[] count = fp.getCount(); 
    554614    int[] axes = ag.getAxisTypes(); 
     
    556616    int numC = ag.getAxisCountC(); 
    557617    int numT = ag.getAxisCountT(); 
    558     totalImages = files.length * imagesPerFile; 
    559618    totalSizeZ = sizeZ; 
    560619    totalSizeC = sizeC; 
     
    588647 
    589648    // populate metadata store 
     649    String f0 = files[0]; 
     650    int pixelType = reader.getPixelType(f0); 
     651    boolean little = reader.isLittleEndian(f0); 
    590652    MetadataStore s = reader.getMetadataStore(f0); 
    591653    s.setPixels(new Integer(width), new Integer(height), 
     
    593655      new Integer(totalSizeT), new Integer(pixelType), 
    594656      new Boolean(!little), order, null); 
    595     setMetadataStore(s); 
    596657  } 
    597658 
Note: See TracChangeset for help on using the changeset viewer.