Changeset 1399


Ignore:
Timestamp:
08/31/06 13:53:39 (14 years ago)
Author:
curtis
Message:

Update testRead to print basic information about all series within the file(s).

File:
1 edited

Legend:

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

    r1386 r1399  
    138138    throws FormatException, IOException 
    139139  { 
    140     return ImageTools.scale(openImage(id, no),  
    141       getThumbSizeX(id), getThumbSizeY(id));       
     140    return ImageTools.scale(openImage(id, no), 
     141      getThumbSizeX(id), getThumbSizeY(id)); 
    142142  } 
    143143 
     
    443443   */ 
    444444  public Object getMetadataStoreRoot(String id) 
    445     throws FormatException, IOException { 
     445    throws FormatException, IOException 
     446  { 
    446447    if (!id.equals(currentId)) initFile(id); 
    447448    return getMetadataStore(id).getRoot(); 
     
    525526    if (merge) reader = new ChannelMerger(reader); 
    526527 
     528    // read basic metadata 
     529    System.out.println(); 
     530    System.out.println("Reading core metadata"); 
     531    System.out.println(stitch ? 
     532      ("File pattern = " + FilePattern.findPattern(new File(id))) : 
     533      ("Filename = " + id)); 
     534    int seriesCount = reader.getSeriesCount(id); 
     535    System.out.println("Series count = " + seriesCount); 
     536    for (int j=0; j<seriesCount; j++) { 
     537      reader.setSeries(id, j); 
     538 
     539      // read basic metadata for series #i 
     540      int imageCount = reader.getImageCount(id); 
     541      boolean rgb = reader.isRGB(id); 
     542      int sizeX = reader.getSizeX(id); 
     543      int sizeY = reader.getSizeY(id); 
     544      int sizeZ = reader.getSizeZ(id); 
     545      int sizeC = reader.getSizeC(id); 
     546      int sizeT = reader.getSizeT(id); 
     547      boolean little = reader.isLittleEndian(id); 
     548      String dimOrder = reader.getDimensionOrder(id); 
     549 
     550      // output basic metadata for series #i 
     551      System.out.println("Series #" + j + ":"); 
     552      System.out.println("\tImage count = " + imageCount); 
     553      System.out.print("\tRGB = " + rgb); 
     554      if (rgb && separate) System.out.print(" (separated)"); 
     555      else if (!rgb && !separate) System.out.print(" (merged)"); 
     556      System.out.println(); 
     557      System.out.println("\tWidth = " + sizeX); 
     558      System.out.println("\tHeight = " + sizeY); 
     559      System.out.println("\tSizeZ = " + sizeZ); 
     560      System.out.println("\tSizeC = " + sizeC); 
     561      System.out.println("\tSizeT = " + sizeT); 
     562      if (imageCount != sizeZ * sizeC * sizeT / 
     563        ((rgb && !separate) ? sizeC : 1)) 
     564      { 
     565        System.out.println("\t************ Warning: ZCT mismatch ************"); 
     566      } 
     567      System.out.println("\tEndianness = " + 
     568        (little ? "intel (little)" : "motorola (big)")); 
     569      System.out.println("\tDimension order = " + dimOrder); 
     570      System.out.println("\t-----"); 
     571      int[] indices; 
     572      if (imageCount > 6) { 
     573        int q = imageCount / 2; 
     574        indices = new int[] {0, q - 2, q - 1, q, q + 1, q + 2, imageCount - 1}; 
     575      } 
     576      else if (imageCount > 2) { 
     577        indices = new int[] {0, imageCount / 2, imageCount - 1}; 
     578      } 
     579      else if (imageCount > 1) indices = new int[] {0, 1}; 
     580      else indices = new int[] {0}; 
     581      int[][] zct = new int[indices.length][]; 
     582      int[] indices2 = new int[indices.length]; 
     583      for (int i=0; i<indices.length; i++) { 
     584        zct[i] = reader.getZCTCoords(id, indices[i]); 
     585        indices2[i] = reader.getIndex(id, zct[i][0], zct[i][1], zct[i][2]); 
     586        System.out.print("\tPlane #" + indices[i] + " <=> Z " + zct[i][0] + 
     587          ", C " + zct[i][1] + ", T " + zct[i][2]); 
     588        if (indices[i] != indices2[i]) { 
     589          System.out.println(" [mismatch: " + indices2[i] + "]"); 
     590        } 
     591        else System.out.println(); 
     592      } 
     593    } 
     594    reader.setSeries(id, series); 
     595    String s = seriesCount > 1 ? (" series #" + series) : ""; 
     596 
    527597    // read pixels 
    528598    if (pixels) { 
    529       System.out.print("Reading " + (stitch ? 
    530         FilePattern.findPattern(new File(id)) : id) + " pixel data "); 
     599      System.out.println(); 
     600      System.out.print("Reading" + s + " pixel data "); 
    531601      long s1 = System.currentTimeMillis(); 
    532602      reader.setSeparated(separate); 
    533       reader.setSeries(id, series); 
    534603      int num = reader.getImageCount(id); 
    535604      if (end == 0 || end > num) end = num; 
     
    562631    } 
    563632 
    564     // read metadata 
     633    // read format-specific metadata table 
    565634    System.out.println(); 
    566     System.out.print("Reading " + id + " metadata "); 
    567     int imageCount = reader.getImageCount(id); 
    568     boolean rgb = reader.isRGB(id); 
    569     int sizeX = reader.getSizeX(id); 
    570     int sizeY = reader.getSizeY(id); 
    571     int sizeZ = reader.getSizeZ(id); 
    572     int sizeC = reader.getSizeC(id); 
    573     int sizeT = reader.getSizeT(id); 
    574     boolean little = reader.isLittleEndian(id); 
    575     String dimOrder = reader.getDimensionOrder(id); 
     635    System.out.println("Reading" + s + " metadata"); 
    576636    Hashtable meta = reader.getMetadata(id); 
    577     System.out.println("[done]"); 
    578  
    579     // output basic metadata 
    580     System.out.println("-----"); 
    581     System.out.println("Image count = " + imageCount); 
    582     System.out.print("RGB = " + rgb); 
    583     if (rgb && separate) System.out.print(" (separated)"); 
    584     else if (!rgb && !separate) System.out.print(" (merged)"); 
    585     System.out.println(); 
    586     System.out.println("Width = " + sizeX); 
    587     System.out.println("Height = " + sizeY); 
    588     System.out.println("SizeZ = " + sizeZ); 
    589     System.out.println("SizeC = " + sizeC); 
    590     System.out.println("SizeT = " + sizeT); 
    591     if (imageCount != sizeZ * sizeC * sizeT / 
    592       ((rgb && !separate) ? sizeC : 1)) 
    593     { 
    594       System.out.println("************ Warning: ZCT mismatch ************"); 
    595     } 
    596     System.out.println("Endianness = " + 
    597       (little ? "intel (little)" : "motorola (big)")); 
    598     System.out.println("Dimension order = " + dimOrder); 
    599     System.out.println("-----"); 
    600     int[] indices; 
    601     if (imageCount > 6) { 
    602       int q = imageCount / 2; 
    603       indices = new int[] {0, q - 2, q - 1, q, q + 1, q + 2, imageCount - 1}; 
    604     } 
    605     else if (imageCount > 2) { 
    606       indices = new int[] {0, imageCount / 2, imageCount - 1}; 
    607     } 
    608     else if (imageCount > 1) indices = new int[] {0, 1}; 
    609     else indices = new int[] {0}; 
    610     int[][] zct = new int[indices.length][]; 
    611     int[] indices2 = new int[indices.length]; 
    612     for (int i=0; i<indices.length; i++) { 
    613       zct[i] = reader.getZCTCoords(id, indices[i]); 
    614       indices2[i] = reader.getIndex(id, zct[i][0], zct[i][1], zct[i][2]); 
    615       System.out.print("Plane #" + indices[i] + " <=> Z " + zct[i][0] + 
    616         ", C " + zct[i][1] + ", T " + zct[i][2]); 
    617       if (indices[i] != indices2[i]) { 
    618         System.out.println(" [mismatch: " + indices2[i] + "]"); 
    619       } 
    620       else System.out.println(); 
    621     } 
    622     System.out.println("-----"); 
    623  
    624     // output metadata table 
    625637    String[] keys = (String[]) meta.keySet().toArray(new String[0]); 
    626638    Arrays.sort(keys); 
     
    629641      System.out.println(reader.getMetadataValue(id, keys[i])); 
    630642    } 
    631     System.out.println(); 
    632643 
    633644    // output OME-XML 
    634645    if (omexml) { 
     646      System.out.println(); 
     647      System.out.println("Generating OME-XML"); 
    635648      MetadataStore ms = reader.getMetadataStore(id); 
    636649      try { 
    637650        Method m = ms.getClass().getMethod("dumpXML", (Class[]) null); 
    638         System.out.println("OME-XML:"); 
    639651        System.out.println(m.invoke(ms, (Object[]) null)); 
    640652        System.out.println(); 
     
    653665  /** Creates JFileChooser file filters for this file format. */ 
    654666  protected void createFilters() { 
    655     filters = new FileFilter[] { new FormatFileFilter(this) }; 
     667    filters = new FileFilter[] {new FormatFileFilter(this)}; 
    656668  } 
    657669 
Note: See TracChangeset for help on using the changeset viewer.