Changeset 6868


Ignore:
Timestamp:
09/01/10 16:51:01 (9 years ago)
Author:
melissa
Message:

Merged trunk r6867 into junit-test-suite.

Location:
branches/junit-test-suite
Files:
22 edited
3 copied

Legend:

Unmodified
Added
Removed
  • branches/junit-test-suite

  • branches/junit-test-suite/ant/java.xml

    r6686 r6868  
    2121 
    2222  <target name="compile" depends="copy-source" description="compile classes"> 
    23     <javac debug="true" deprecation="${component.deprecation}" 
     23    <javac debug="true" includeantruntime="false" 
     24      deprecation="${component.deprecation}" 
    2425      source="${component.java-version}" 
    2526      target="${component.java-version}" 
     
    3334  <target name="compile-tests" depends="compile, copy-test-source" 
    3435    description="compile test classes" if="doTests"> 
    35     <javac debug="true" deprecation="${component.deprecation}" 
     36    <javac debug="true" includeantruntime="false" 
     37      deprecation="${component.deprecation}" 
    3638      source="${component.java-version}" 
    3739      target="${component.java-version}" 
     
    150152      <fileset dir="${utils.dir}" includes="*.class"/> 
    151153    </delete> 
    152     <javac debug="true" deprecation="true" source="1.5" target="1.5" 
     154    <javac debug="true" includeantruntime="false" 
     155      deprecation="true" source="1.5" target="1.5" 
    153156      srcdir="${utils.dir}" includes="*.java" 
    154157      classpath="${artifact.dir}/${component.jar}"> 
  • branches/junit-test-suite/ant/toplevel.xml

    r6686 r6868  
    151151      <fileset dir="${toplevel-utils.dir}" includes="*.class"/> 
    152152    </delete> 
    153     <javac debug="true" deprecation="true" source="1.5" target="1.5" 
     153    <javac debug="true" includeantruntime="false" 
     154      deprecation="true" source="1.5" target="1.5" 
    154155      srcdir="${toplevel-utils.dir}" includes="*.java"> 
    155156      <classpath> 
  • branches/junit-test-suite/components/bio-formats/src/loci/formats/AxisGuesser.java

    r6026 r6868  
    314314      new Location(System.getProperty("user.dir")).listFiles()[0] : 
    315315      new Location(args[0]); 
    316     LOGGER.debug("File = {}", file.getAbsoluteFile()); 
     316    LOGGER.info("File = {}", file.getAbsoluteFile()); 
    317317    String pat = FilePattern.findPattern(file); 
    318     if (pat == null) LOGGER.debug("No pattern found."); 
     318    if (pat == null) LOGGER.info("No pattern found."); 
    319319    else { 
    320       LOGGER.debug("Pattern = {}", pat); 
     320      LOGGER.info("Pattern = {}", pat); 
    321321      FilePattern fp = new FilePattern(pat); 
    322322      if (fp.isValid()) { 
    323         LOGGER.debug("Pattern is valid."); 
     323        LOGGER.info("Pattern is valid."); 
    324324        String id = fp.getFiles()[0]; 
    325325        if (!new Location(id).exists()) { 
    326           LOGGER.debug("File '{}' does not exist.", id); 
     326          LOGGER.info("File '{}' does not exist.", id); 
    327327        } 
    328328        else { 
    329329          // read dimensional information from first file 
    330           LOGGER.debug("Reading first file "); 
     330          LOGGER.info("Reading first file "); 
    331331          ImageReader reader = new ImageReader(); 
    332332          reader.setId(id); 
     
    337337          boolean certain = reader.isOrderCertain(); 
    338338          reader.close(); 
    339           LOGGER.debug("[done]"); 
    340           LOGGER.debug("\tdimOrder = {} ({})", 
     339          LOGGER.info("[done]"); 
     340          LOGGER.info("\tdimOrder = {} ({})", 
    341341            dimOrder, certain ? "certain" : "uncertain"); 
    342           LOGGER.debug("\tsizeZ = {}", sizeZ); 
    343           LOGGER.debug("\tsizeT = {}", sizeT); 
    344           LOGGER.debug("\tsizeC = {}", sizeC); 
     342          LOGGER.info("\tsizeZ = {}", sizeZ); 
     343          LOGGER.info("\tsizeT = {}", sizeT); 
     344          LOGGER.info("\tsizeC = {}", sizeC); 
    345345 
    346346          // guess axes 
     
    354354          String newOrder = ag.getAdjustedOrder(); 
    355355          boolean isCertain = ag.isCertain(); 
    356           LOGGER.debug("Axis types:"); 
     356          LOGGER.info("Axis types:"); 
    357357          for (int i=0; i<blocks.length; i++) { 
    358358            String axis; 
     
    370370                axis = "?"; 
    371371            } 
    372             LOGGER.debug("\t{}\t{} (prefix = {})", 
     372            LOGGER.info("\t{}\t{} (prefix = {})", 
    373373              new Object[] {blocks[i], axis, prefixes[i]}); 
    374374          } 
    375375          if (!dimOrder.equals(newOrder)) { 
    376             LOGGER.debug("Adjusted dimension order = {} ({})", 
     376            LOGGER.info("Adjusted dimension order = {} ({})", 
    377377              newOrder, isCertain ? "certain" : "uncertain"); 
    378378          } 
    379379        } 
    380380      } 
    381       else LOGGER.debug("Pattern is invalid: {}", fp.getErrorMessage()); 
     381      else LOGGER.info("Pattern is invalid: {}", fp.getErrorMessage()); 
    382382    } 
    383383  } 
  • branches/junit-test-suite/components/bio-formats/src/loci/formats/FilePattern.java

    r6263 r6868  
    588588      // test file pattern detection based on the given file on disk 
    589589      Location file = new Location(args[0]); 
    590       LOGGER.debug("File = {}", file.getAbsoluteFile()); 
     590      LOGGER.info("File = {}", file.getAbsoluteFile()); 
    591591      pat = findPattern(file); 
    592592    } 
     
    609609      pat = findPattern(nameList[1], null, nameList); 
    610610    } 
    611     if (pat == null) LOGGER.debug("No pattern found."); 
     611    if (pat == null) LOGGER.info("No pattern found."); 
    612612    else { 
    613       LOGGER.debug("Pattern = {}", pat); 
     613      LOGGER.info("Pattern = {}", pat); 
    614614      FilePattern fp = new FilePattern(pat); 
    615615      if (fp.isValid()) { 
    616         LOGGER.debug("Pattern is valid."); 
    617         LOGGER.debug("Files:"); 
     616        LOGGER.info("Pattern is valid."); 
     617        LOGGER.info("Files:"); 
    618618        String[] ids = fp.getFiles(); 
    619619        for (int i=0; i<ids.length; i++) { 
    620           LOGGER.debug("  #{}: {}", i, ids[i]); 
    621         } 
    622       } 
    623       else LOGGER.debug("Pattern is invalid: {}", fp.getErrorMessage()); 
     620          LOGGER.info("  #{}: {}", i, ids[i]); 
     621        } 
     622      } 
     623      else LOGGER.info("Pattern is invalid: {}", fp.getErrorMessage()); 
    624624    } 
    625625  } 
  • branches/junit-test-suite/components/bio-formats/src/loci/formats/in/AVIReader.java

    r6754 r6868  
    6868  private Vector<Long> lengths; 
    6969 
     70  private String listString; 
    7071  private String type = "error"; 
    7172  private String fcc = "error"; 
     
    210211    super.close(fileOnly); 
    211212    if (!fileOnly) { 
     213      listString = null; 
    212214      offsets = null; 
    213215      lengths = null; 
     
    239241    lastImageNo = -1; 
    240242 
    241     String listString; 
    242  
     243    while (in.getFilePointer() < in.length() - 8) { 
     244      readChunk(); 
     245    } 
     246    LOGGER.info("Populating metadata"); 
     247 
     248    core[0].imageCount = offsets.size(); 
     249    core[0].sizeZ = 1; 
     250    core[0].sizeT = getImageCount(); 
     251    core[0].littleEndian = true; 
     252    core[0].interleaved = bmpBitsPerPixel != 16; 
     253 
     254    if (bmpBitsPerPixel == 32) { 
     255      core[0].sizeC = 4; 
     256      core[0].rgb = true; 
     257    } 
     258    else if (bytesPerPlane == 0 || bmpBitsPerPixel == 24) { 
     259      core[0].rgb = bmpBitsPerPixel > 8 || (bmpCompression != 0 && lut == null); 
     260      core[0].sizeC = isRGB() ? 3 : 1; 
     261    } 
     262    else { 
     263      core[0].sizeC = bytesPerPlane / 
     264        (getSizeX() * getSizeY() * (bmpBitsPerPixel / 8)); 
     265      core[0].rgb = getSizeC() > 1; 
     266    } 
     267    core[0].dimensionOrder = isRGB() ? "XYCTZ" : "XYTCZ"; 
     268    core[0].falseColor = false; 
     269    core[0].metadataComplete = true; 
     270    core[0].indexed = lut != null && !isRGB(); 
     271 
     272    if (bmpBitsPerPixel <= 8) { 
     273      core[0].pixelType = FormatTools.UINT8; 
     274      core[0].bitsPerPixel = bmpBitsPerPixel; 
     275    } 
     276    else if (bmpBitsPerPixel == 16) core[0].pixelType = FormatTools.UINT16; 
     277    else if (bmpBitsPerPixel == 24 || bmpBitsPerPixel == 32) { 
     278      core[0].pixelType = FormatTools.UINT8; 
     279    } 
     280    else { 
     281      throw new FormatException( 
     282          "Unknown matching for pixel bit width of: " + bmpBitsPerPixel); 
     283    } 
     284 
     285    if (bmpCompression != 0) core[0].pixelType = FormatTools.UINT8; 
     286 
     287    MetadataStore store = makeFilterMetadata(); 
     288    MetadataTools.populatePixels(store, this); 
     289    MetadataTools.setDefaultCreationDate(store, id, 0); 
     290  } 
     291 
     292  // -- Helper methods -- 
     293 
     294  private byte[] uncompress(int no, byte[] buf) 
     295    throws FormatException, IOException 
     296  { 
     297    CodecOptions options = new CodecOptions(); 
     298    options.width = getSizeX(); 
     299    options.height = getSizeY(); 
     300    options.previousImage = (lastImageNo == no - 1) ? lastImage : null; 
     301    options.bitsPerSample = bmpBitsPerPixel; 
     302 
     303    if (bmpCompression == MSRLE) { 
     304      byte[] b = new byte[(int) lengths.get(no).longValue()]; 
     305      in.read(b); 
     306      MSRLECodec codec = new MSRLECodec(); 
     307      buf = codec.decompress(b, options); 
     308      lastImage = buf; 
     309      lastImageNo = no; 
     310    } 
     311    else if (bmpCompression == MS_VIDEO) { 
     312      MSVideoCodec codec = new MSVideoCodec(); 
     313      buf = codec.decompress(in, options); 
     314      lastImage = buf; 
     315      lastImageNo = no; 
     316    } 
     317    /* 
     318    else if (bmpCompression == CINEPAK) { 
     319      Object[] options = new Object[2]; 
     320      options[0] = new Integer(bmpBitsPerPixel); 
     321      options[1] = lastImage; 
     322 
     323      CinepakCodec codec = new CinepakCodec(); 
     324      buf = codec.decompress(b, options); 
     325      lastImage = buf; 
     326      if (no == core[0].imageCount - 1) lastImage = null; 
     327      return buf; 
     328    } 
     329    */ 
     330    else { 
     331      throw new FormatException("Unsupported compression : " + bmpCompression); 
     332    } 
     333    return buf; 
     334  } 
     335 
     336  private void readChunkHeader() throws IOException { 
     337    readTypeAndSize(); 
     338    fcc = in.readString(4); 
     339  } 
     340 
     341  private void readTypeAndSize() throws IOException { 
     342    type = in.readString(4); 
     343    size = in.readInt(); 
     344  } 
     345 
     346  private void readChunk() throws FormatException, IOException { 
    243347    readChunkHeader(); 
    244348 
    245349    if (type.equals("RIFF")) { 
    246       if (!fcc.equals("AVI ")) { 
     350      if (!fcc.startsWith("AVI")) { 
    247351        throw new FormatException("Sorry, AVI RIFF format not found."); 
    248352      } 
    249353    } 
    250     else throw new FormatException("Not an AVI file"); 
     354    else if (in.getFilePointer() == 12) { 
     355      throw new FormatException("Not an AVI file"); 
     356    } 
     357    else return; 
    251358 
    252359    pos = in.getFilePointer(); 
     
    441548 
    442549              spos = in.getFilePointer(); 
    443               readTypeAndSize(); 
    444               if (type.startsWith("ix")) { 
    445                 in.skipBytes(size); 
     550              boolean end = false; 
     551              while (!end) { 
    446552                readTypeAndSize(); 
     553                String oldType = type; 
     554                if (type.startsWith("ix")) { 
     555                  in.skipBytes(size); 
     556                  readTypeAndSize(); 
     557                } 
     558 
     559                String check = type.substring(2); 
     560                boolean foundPixels = false; 
     561                while (check.equals("db") || check.equals("dc") || 
     562                  check.equals("wb")) 
     563                { 
     564                  foundPixels = true; 
     565                  if (check.startsWith("d")) { 
     566                    if (size > 0 || bmpCompression != 0) { 
     567                      offsets.add(new Long(in.getFilePointer())); 
     568                      lengths.add(new Long(size)); 
     569                      in.skipBytes(size); 
     570                    } 
     571                  } 
     572 
     573                  spos = in.getFilePointer(); 
     574                  if (spos + 8 >= in.length()) return; 
     575 
     576                  readTypeAndSize(); 
     577                  if (type.equals("JUNK")) { 
     578                    in.skipBytes(size); 
     579                    spos = in.getFilePointer(); 
     580                    readTypeAndSize(); 
     581                  } 
     582                  check = type.substring(2); 
     583                } 
     584                in.seek(spos); 
     585                if (!oldType.startsWith("ix") && !foundPixels) { 
     586                  end = true; 
     587                } 
    447588              } 
    448  
    449               String check = type.substring(2); 
    450               while (check.equals("db") || check.equals("dc") || 
    451                 check.equals("wb")) 
    452               { 
    453                 if (check.startsWith("d")) { 
    454                   if (size > 0 || bmpCompression != 0) { 
    455                     offsets.add(new Long(in.getFilePointer())); 
    456                     lengths.add(new Long(size)); 
    457                     in.skipBytes(size); 
    458                   } 
    459                 } 
    460  
    461                 spos = in.getFilePointer(); 
    462  
    463                 readTypeAndSize(); 
    464                 if (type.equals("JUNK")) { 
    465                   in.skipBytes(size); 
    466                   spos = in.getFilePointer(); 
    467                   readTypeAndSize(); 
    468                 } 
    469                 check = type.substring(2); 
    470               } 
    471               in.seek(spos); 
    472589            } 
    473590          } 
     
    481598        // skipping unknown block 
    482599        readTypeAndSize(); 
    483         if (in.getFilePointer() + 8 < in.length()) { 
     600        if (in.getFilePointer() + 8 < in.length() && !type.equals("idx1")) { 
    484601          readTypeAndSize(); 
    485602        } 
    486         else break; 
     603        else if (!type.equals("idx1")) break; 
    487604        if (in.getFilePointer() + size + 4 <= in.length()) { 
    488605          in.skipBytes(size); 
    489606        } 
     607        if (type.equals("idx1")) break; 
    490608      } 
    491609      pos = in.getFilePointer(); 
    492610    } 
    493     LOGGER.info("Populating metadata"); 
    494  
    495     core[0].imageCount = offsets.size(); 
    496     core[0].sizeZ = 1; 
    497     core[0].sizeT = getImageCount(); 
    498     core[0].littleEndian = true; 
    499     core[0].interleaved = bmpBitsPerPixel != 16; 
    500  
    501     if (bmpBitsPerPixel == 32) { 
    502       core[0].sizeC = 4; 
    503       core[0].rgb = true; 
    504     } 
    505     else if (bytesPerPlane == 0 || bmpBitsPerPixel == 24) { 
    506       core[0].rgb = bmpBitsPerPixel > 8 || (bmpCompression != 0 && lut == null); 
    507       core[0].sizeC = isRGB() ? 3 : 1; 
    508     } 
    509     else { 
    510       core[0].sizeC = bytesPerPlane / 
    511         (getSizeX() * getSizeY() * (bmpBitsPerPixel / 8)); 
    512       core[0].rgb = getSizeC() > 1; 
    513     } 
    514     core[0].dimensionOrder = isRGB() ? "XYCTZ" : "XYTCZ"; 
    515     core[0].falseColor = false; 
    516     core[0].metadataComplete = true; 
    517     core[0].indexed = lut != null && !isRGB(); 
    518  
    519     if (bmpBitsPerPixel <= 8) { 
    520       core[0].pixelType = FormatTools.UINT8; 
    521       core[0].bitsPerPixel = bmpBitsPerPixel; 
    522     } 
    523     else if (bmpBitsPerPixel == 16) core[0].pixelType = FormatTools.UINT16; 
    524     else if (bmpBitsPerPixel == 24 || bmpBitsPerPixel == 32) { 
    525       core[0].pixelType = FormatTools.UINT8; 
    526     } 
    527     else { 
    528       throw new FormatException( 
    529           "Unknown matching for pixel bit width of: " + bmpBitsPerPixel); 
    530     } 
    531  
    532     if (bmpCompression != 0) core[0].pixelType = FormatTools.UINT8; 
    533  
    534     MetadataStore store = makeFilterMetadata(); 
    535     MetadataTools.populatePixels(store, this); 
    536     MetadataTools.setDefaultCreationDate(store, id, 0); 
    537   } 
    538  
    539   // -- Helper methods -- 
    540  
    541   private byte[] uncompress(int no, byte[] buf) 
    542     throws FormatException, IOException 
    543   { 
    544     CodecOptions options = new CodecOptions(); 
    545     options.width = getSizeX(); 
    546     options.height = getSizeY(); 
    547     options.previousImage = (lastImageNo == no - 1) ? lastImage : null; 
    548     options.bitsPerSample = bmpBitsPerPixel; 
    549  
    550     if (bmpCompression == MSRLE) { 
    551       byte[] b = new byte[(int) lengths.get(no).longValue()]; 
    552       in.read(b); 
    553       MSRLECodec codec = new MSRLECodec(); 
    554       buf = codec.decompress(b, options); 
    555       lastImage = buf; 
    556       lastImageNo = no; 
    557     } 
    558     else if (bmpCompression == MS_VIDEO) { 
    559       MSVideoCodec codec = new MSVideoCodec(); 
    560       buf = codec.decompress(in, options); 
    561       lastImage = buf; 
    562       lastImageNo = no; 
    563     } 
    564     /* 
    565     else if (bmpCompression == CINEPAK) { 
    566       Object[] options = new Object[2]; 
    567       options[0] = new Integer(bmpBitsPerPixel); 
    568       options[1] = lastImage; 
    569  
    570       CinepakCodec codec = new CinepakCodec(); 
    571       buf = codec.decompress(b, options); 
    572       lastImage = buf; 
    573       if (no == core[0].imageCount - 1) lastImage = null; 
    574       return buf; 
    575     } 
    576     */ 
    577     else { 
    578       throw new FormatException("Unsupported compression : " + bmpCompression); 
    579     } 
    580     return buf; 
    581   } 
    582  
    583   private void readChunkHeader() throws IOException { 
    584     readTypeAndSize(); 
    585     fcc = in.readString(4); 
    586   } 
    587  
    588   private void readTypeAndSize() throws IOException { 
    589     type = in.readString(4); 
    590     size = in.readInt(); 
    591611  } 
    592612 
  • branches/junit-test-suite/components/bio-formats/src/loci/formats/in/BaseTiffReader.java

    r6791 r6868  
    420420      // set the X and Y pixel dimensions 
    421421 
    422       int resolutionUnit = firstIFD.getIFDIntValue(IFD.RESOLUTION_UNIT); 
    423       TiffRational xResolution = firstIFD.getIFDRationalValue(IFD.X_RESOLUTION); 
    424       TiffRational yResolution = firstIFD.getIFDRationalValue(IFD.Y_RESOLUTION); 
    425       double pixX = xResolution == null ? 0 : 1 / xResolution.doubleValue(); 
    426       double pixY = yResolution == null ? 0 : 1 / yResolution.doubleValue(); 
    427  
    428       switch (resolutionUnit) { 
    429         case 2: 
    430           // resolution is expressed in pixels per inch 
    431           pixX *= 25400; 
    432           pixY *= 25400; 
    433           break; 
    434         case 3: 
    435           // resolution is expressed in pixels per centimeter 
    436           pixX *= 10000; 
    437           pixY *= 10000; 
    438           break; 
    439       } 
     422      double pixX = firstIFD.getXResolution(); 
     423      double pixY = firstIFD.getYResolution(); 
    440424 
    441425      store.setPixelsPhysicalSizeX(pixX, 0); 
  • branches/junit-test-suite/components/bio-formats/src/loci/formats/in/FV1000Reader.java

    r6805 r6868  
    565565    core[0].dimensionOrder = "XY"; 
    566566 
     567    Hashtable<String, String> values = new Hashtable<String, String>(); 
     568    Vector<String> baseKeys = new Vector<String>(); 
     569 
    567570    for (int i=0, ii=0; ii<getImageCount(); i++, ii++) { 
    568571      String file = filenames.get(new Integer(i)); 
     
    639642          String[] keys = table.keySet().toArray(new String[table.size()]); 
    640643          for (String key : keys) { 
    641             addGlobalMeta("Image " + ii + " : " + key, table.get(key)); 
    642           } 
     644            values.put("Image " + ii + " : " + key, table.get(key)); 
     645            if (!baseKeys.contains(key)) baseKeys.add(key); 
     646          } 
     647        } 
     648      } 
     649    } 
     650 
     651    for (String key : baseKeys) { 
     652      if (key.equals("DataName") || key.indexOf("FileName") >= 0) break; 
     653      boolean equal = true; 
     654      String first = values.get("Image 0 : " + key); 
     655      for (int i=1; i<getImageCount(); i++) { 
     656        if (!first.equals(values.get("Image " + i + " : " + key))) { 
     657          equal = false; 
     658          break; 
     659        } 
     660      } 
     661      if (equal) { 
     662        addGlobalMeta(key, first); 
     663      } 
     664      else { 
     665        for (int i=0; i<getImageCount(); i++) { 
     666          String k = "Image " + i + " : " + key; 
     667          addGlobalMeta(k, values.get(k)); 
    643668        } 
    644669      } 
  • branches/junit-test-suite/components/bio-formats/src/loci/formats/in/NativeND2Reader.java

    r6823 r6868  
    813813 
    814814    // populate Dimensions data 
    815     for (int i=0; i<getSeriesCount(); i++) { 
    816       store.setPixelsPhysicalSizeX(handler.getPixelSizeX(), i); 
    817       store.setPixelsPhysicalSizeY(handler.getPixelSizeY(), i); 
    818       store.setPixelsPhysicalSizeZ(handler.getPixelSizeZ(), i); 
     815    if (handler != null) { 
     816      for (int i=0; i<getSeriesCount(); i++) { 
     817        store.setPixelsPhysicalSizeX(handler.getPixelSizeX(), i); 
     818        store.setPixelsPhysicalSizeY(handler.getPixelSizeY(), i); 
     819        store.setPixelsPhysicalSizeZ(handler.getPixelSizeZ(), i); 
     820      } 
    819821    } 
    820822 
    821823    // populate PlaneTiming and StagePosition data 
    822     ArrayList<Double> exposureTime = handler.getExposureTimes(); 
     824    ArrayList<Double> exposureTime = null; 
     825    if (handler != null) handler.getExposureTimes(); 
    823826    for (int i=0; i<getSeriesCount(); i++) { 
    824827      if (tsT.size() > 0) { 
     
    832835 
    833836          int index = i * getSizeC() + coords[1]; 
    834           if (index < exposureTime.size()) { 
     837          if (exposureTime != null && index < exposureTime.size()) { 
    835838            store.setPlaneExposureTime(exposureTime.get(index), i, n); 
    836839          } 
     
    838841      } 
    839842 
    840       if (posX == null) posX = handler.getXPositions(); 
    841       if (posY == null) posY = handler.getYPositions(); 
    842       if (posZ == null) posZ = handler.getZPositions(); 
    843  
     843      if (handler != null) { 
     844        if (posX == null) posX = handler.getXPositions(); 
     845        if (posY == null) posY = handler.getYPositions(); 
     846        if (posZ == null) posZ = handler.getZPositions(); 
     847      } 
     848 
     849      String pos = "for position #" + (i + 1); 
    844850      for (int n=0; n<getImageCount(); n++) { 
    845851        int index = i * getImageCount() + n; 
    846         if (index >= posX.size()) index = i; 
    847         if (index < posX.size()) { 
    848           store.setPlanePositionX(posX.get(index), i, n); 
    849           addSeriesMeta("X position " + (i + 1), posX.get(index)); 
    850           addGlobalMeta("X position for position #" + (i + 1), posX.get(index)); 
    851         } 
    852         if (index < posY.size()) { 
    853           store.setPlanePositionY(posY.get(index), i, n); 
    854           addSeriesMeta("Y position " + (i + 1), posY.get(index)); 
    855           addGlobalMeta("Y position for position #" + (i + 1), posY.get(index)); 
    856         } 
    857         if (index < posZ.size()) { 
    858           store.setPlanePositionZ(posZ.get(index), i, n); 
    859           String key = 
    860             "Z position for position #" + (i + 1) + ", plane #" + (n + 1); 
    861           addSeriesMeta(key, posZ.get(index)); 
    862           addGlobalMeta(key, posZ.get(index)); 
    863         } 
    864  
    865       } 
     852        if (posX != null) { 
     853          if (index >= posX.size()) index = i; 
     854          if (index < posX.size()) { 
     855            String key = "X position "; 
     856            store.setPlanePositionX(posX.get(index), i, n); 
     857            addSeriesMeta(key + (i + 1), posX.get(index)); 
     858            addGlobalMeta(key + pos, posX.get(index)); 
     859          } 
     860        } 
     861        if (posY != null) { 
     862          if (index < posY.size()) { 
     863            String key = "Y position "; 
     864            store.setPlanePositionY(posY.get(index), i, n); 
     865            addSeriesMeta(key + (i + 1), posY.get(index)); 
     866            addGlobalMeta(key + pos, posY.get(index)); 
     867          } 
     868        } 
     869        if (posZ != null) { 
     870          if (index < posZ.size()) { 
     871            store.setPlanePositionZ(posZ.get(index), i, n); 
     872            String key = "Z position " + pos + ", plane #" + (n + 1); 
     873            addSeriesMeta(key, posZ.get(index)); 
     874            addGlobalMeta(key, posZ.get(index)); 
     875          } 
     876        } 
     877      } 
     878    } 
     879 
     880    if (handler == null) { 
     881      setSeries(0); 
     882      return; 
    866883    } 
    867884 
  • branches/junit-test-suite/components/bio-formats/src/loci/formats/in/OMEXMLReader.java

    r6836 r6868  
    5151 
    5252import org.xml.sax.Attributes; 
     53import org.xml.sax.Locator; 
    5354import org.xml.sax.helpers.DefaultHandler; 
    5455 
     
    8788 
    8889  // compression value and offset for each BinData element 
     90  private Vector<BinData> binData; 
    8991  private Vector<Long> binDataOffsets; 
    90   private Vector<Long> binDataLengths; 
    9192  private Vector<String> compression; 
    9293 
     
    136137 
    137138    long offset = binDataOffsets.get(index).longValue(); 
    138     long length = binDataLengths.get(index).longValue(); 
    139139    String compress = compression.get(index); 
    140140 
    141     in.seek(offset - 64); 
    142  
    143     // offset is approximate, we will need to skip a few bytes 
    144     boolean foundBinData = false; 
    145     byte[] check = new byte[8192]; 
    146     int overlap = 14; 
    147     int n = in.read(check, 0, overlap); 
    148  
    149     while (!foundBinData) { 
    150       int r = in.read(check, overlap, check.length - overlap); 
    151       if (r <= 0) throw new IOException("Cannot read from input stream"); 
    152       n += r; 
    153       String checkString = new String(check); 
    154       int pos = 0; 
    155       while (checkString.indexOf("BinData", pos) != -1 && 
    156         pos < checkString.length() && pos >= 0) 
    157       { 
    158         int idx = checkString.indexOf("BinData", pos) + 7; 
    159         pos = idx + 1; 
    160         boolean foundBeginning = false; 
    161         int openBracket = idx; 
    162         while (!foundBeginning && openBracket >= 1) { 
    163           openBracket--; 
    164           foundBeginning = checkString.charAt(openBracket) == '<'; 
    165         } 
    166         if (checkString.charAt(openBracket + 1) == '/') continue; 
    167         foundBinData = true; 
    168         in.seek(in.getFilePointer() - n + idx); 
    169         while (true) { 
    170           r = in.read(); 
    171           if (r <= 0) { 
    172             throw new IOException("EOF looking for terminating > character"); 
    173           } 
    174           if (r == '>') break; 
    175         } 
    176         if (foundBinData) break; 
    177       } 
    178       if (!foundBinData) { 
    179         System.arraycopy(check, check.length - overlap, check, 0, overlap); 
    180         n = overlap; 
    181       } 
    182     } 
    183  
    184     if (length < 0 && index + 1 < binDataOffsets.size()) { 
    185       length = binDataOffsets.get(index + 1).longValue() - offset; 
    186     } 
    187     else if (length < 0) { 
    188       length = in.length() - offset; 
    189     } 
     141    in.seek(offset); 
    190142 
    191143    int depth = FormatTools.getBytesPerPixel(getPixelType()); 
     
    243195      compression = null; 
    244196      binDataOffsets = null; 
    245       binDataLengths = null; 
     197      binData = null; 
    246198      omexml = null; 
    247199      hasSPW = false; 
     
    258210    in = new RandomAccessInputStream(id); 
    259211 
     212    binData = new Vector<BinData>(); 
    260213    binDataOffsets = new Vector<Long>(); 
    261     binDataLengths = new Vector<Long>(); 
    262214    compression = new Vector<String>(); 
    263215 
     
    270222    catch (IOException e) { 
    271223      throw new FormatException("Malformed OME-XML", e); 
     224    } 
     225 
     226    int lineNumber = 1; 
     227    for (BinData bin : binData) { 
     228      int line = bin.getRow(); 
     229      int col = bin.getColumn(); 
     230 
     231      while (lineNumber < line) { 
     232        in.readLine(); 
     233        lineNumber++; 
     234      } 
     235      binDataOffsets.add(in.getFilePointer() + col - 1); 
    272236    } 
    273237 
     
    349313  class OMEXMLHandler extends DefaultHandler { 
    350314    private StringBuffer xmlBuffer; 
    351     private long nextBinDataOffset; 
    352315    private String currentQName; 
    353     private boolean hadCharData; 
    354     private int binDataChars; 
     316    private Locator locator; 
    355317 
    356318    public OMEXMLHandler() { 
    357319      xmlBuffer = new StringBuffer(); 
    358       nextBinDataOffset = 0; 
    359320    } 
    360321 
    361322    public void characters(char[] ch, int start, int length) { 
    362       if (currentQName.indexOf("BinData") != -1) { 
    363         binDataChars += length; 
     323      if (currentQName.indexOf("BinData") < 0) { 
     324        xmlBuffer.append(new String(ch, start, length)); 
    364325      } 
    365       else xmlBuffer.append(new String(ch, start, length)); 
    366       nextBinDataOffset += length; 
    367       hadCharData = true; 
    368326    } 
    369327 
     
    372330      xmlBuffer.append(qName); 
    373331      xmlBuffer.append(">"); 
    374       if (qName.indexOf("BinData") >= 0) { 
    375         binDataOffsets.add(new Long(nextBinDataOffset - binDataChars)); 
    376       } 
    377  
    378       nextBinDataOffset += 2; 
    379       if (!qName.equals(currentQName) || hadCharData) { 
    380         nextBinDataOffset += qName.length(); 
    381       } 
    382     } 
    383  
    384     public void ignorableWhitespace(char[] ch, int start, int length) { 
    385       nextBinDataOffset += length; 
    386332    } 
    387333 
     
    389335      Attributes attributes) 
    390336    { 
    391       hadCharData = false; 
    392337      currentQName = qName; 
    393338 
     
    417362      } 
    418363      else { 
    419         String length = attributes.getValue("Length"); 
    420         if (length == null) { 
    421           binDataLengths.add(new Long(-1)); 
    422         } 
    423         else binDataLengths.add(new Long(length)); 
     364        binData.add( 
     365          new BinData(locator.getLineNumber(), locator.getColumnNumber())); 
    424366        String compress = attributes.getValue("Compression"); 
    425367        compression.add(compress == null ? "" : compress); 
    426         binDataChars = 0; 
    427368 
    428369        xmlBuffer.append("<"); 
     
    440381        xmlBuffer.append(">"); 
    441382      } 
    442  
    443       nextBinDataOffset += 2 + qName.length() + 4*attributes.getLength(); 
    444       for (int i=0; i<attributes.getLength(); i++) { 
    445         nextBinDataOffset += attributes.getQName(i).length(); 
    446         nextBinDataOffset += attributes.getValue(i).length(); 
    447       } 
    448383    } 
    449384 
     
    452387    } 
    453388 
     389    public void setDocumentLocator(Locator locator) { 
     390      this.locator = locator; 
     391    } 
     392  } 
     393 
     394  class BinData { 
     395    private int row; 
     396    private int column; 
     397 
     398    public BinData(int row, int column) { 
     399      this.row = row; 
     400      this.column = column; 
     401    } 
     402 
     403    public int getRow() { return row; } 
     404    public int getColumn() { return column; } 
    454405  } 
    455406 
  • branches/junit-test-suite/components/bio-formats/src/loci/formats/in/PCIReader.java

    r6801 r6868  
    101101    if (tp.isValidHeader()) { 
    102102      IFD ifd = tp.getFirstIFD(); 
    103       tp.getSamples(ifd, buf); 
     103      tp.getSamples(ifd, buf, x, y, w, h); 
    104104    } 
    105105    else { 
  • branches/junit-test-suite/components/bio-formats/src/loci/formats/out/OMEXMLWriter.java

    r6508 r6868  
    6969    super("OME-XML", "ome"); 
    7070    compressionTypes = 
    71       new String[] {"Uncompressed", "zlib", "J2K", "JPEG"}; 
     71      new String[] {"Uncompressed", "zlib"}; 
    7272    compression = compressionTypes[0]; 
    7373  } 
  • branches/junit-test-suite/components/bio-formats/src/loci/formats/services

  • branches/junit-test-suite/components/bio-formats/src/loci/formats/services/OMEXMLServiceImpl.java

    r6622 r6868  
    361361    int annotationIndex = 0; 
    362362    try { 
    363       annotationIndex = omexmlMeta.getListAnnotationCount(); 
     363      annotationIndex = omexmlMeta.getCommentAnnotationCount(); 
    364364    } 
    365365    catch (NullPointerException e) { } 
    366     String listID = MetadataTools.createLSID("Annotation", annotationIndex * 3); 
    367     omexmlMeta.setListAnnotationID(listID, annotationIndex); 
    368     omexmlMeta.setListAnnotationNamespace( 
    369       StructuredAnnotations.NAMESPACE, annotationIndex); 
    370  
    371     int keyIndex = annotationIndex * 2; 
    372     int valueIndex = annotationIndex * 2 + 1; 
    373     String keyID = 
    374       MetadataTools.createLSID("Annotation", annotationIndex * 3 + 1); 
    375     String valueID = 
    376       MetadataTools.createLSID("Annotation", annotationIndex * 3 + 2); 
    377     omexmlMeta.setCommentAnnotationID(keyID, keyIndex); 
    378     omexmlMeta.setCommentAnnotationID(valueID, valueIndex); 
    379     omexmlMeta.setCommentAnnotationValue(key, keyIndex); 
    380     omexmlMeta.setCommentAnnotationValue(value, valueIndex); 
    381     omexmlMeta.setCommentAnnotationNamespace( 
    382       StructuredAnnotations.NAMESPACE, keyIndex); 
    383     omexmlMeta.setCommentAnnotationNamespace( 
    384       StructuredAnnotations.NAMESPACE, valueIndex); 
    385     omexmlMeta.setListAnnotationAnnotationRef(keyID, annotationIndex, 0); 
    386     omexmlMeta.setListAnnotationAnnotationRef(valueID, annotationIndex, 1); 
     366 
     367    String id = MetadataTools.createLSID("Annotation", annotationIndex); 
     368    omexmlMeta.setCommentAnnotationID(id, annotationIndex); 
     369    omexmlMeta.setCommentAnnotationDescription(key, annotationIndex); 
     370    omexmlMeta.setCommentAnnotationValue(value, annotationIndex); 
    387371  } 
    388372 
  • branches/junit-test-suite/components/bio-formats/src/loci/formats/tiff/IFD.java

    r6823 r6868  
    815815  } 
    816816 
     817  /** 
     818   * Retrieve the X resolution (TIFF tag XResolution) from this IFD. 
     819   * The resolution will be normalized to microns per pixel. 
     820   * 
     821   * @return the X resolution, in microns per pixel 
     822   * @throws FormatException if there is a problem parsing the IFD metadata. 
     823   */ 
     824  public double getXResolution() throws FormatException { 
     825    TiffRational xResolution = getIFDRationalValue(X_RESOLUTION); 
     826    double x = xResolution == null ? 0 : 1 / xResolution.doubleValue(); 
     827 
     828    int resolutionUnit = getIFDIntValue(RESOLUTION_UNIT); 
     829    int multiplier = resolutionUnit == 2 ? 25400 : 10000; 
     830    return x * multiplier; 
     831  } 
     832 
     833  /** 
     834   * Retrieve the Y resolution (TIFF tag YResolution) from this IFD. 
     835   * The resolution will be normalized to microns per pixel. 
     836   * 
     837   * @return the Y resolution, in microns per pixel 
     838   * @throws FormatException if there is a problem parsing the IFD metadata. 
     839   */ 
     840  public double getYResolution() throws FormatException { 
     841    TiffRational yResolution = getIFDRationalValue(Y_RESOLUTION); 
     842    double y = yResolution == null ? 0 : 1 / yResolution.doubleValue(); 
     843 
     844    int resolutionUnit = getIFDIntValue(RESOLUTION_UNIT); 
     845    int multiplier = resolutionUnit == 2 ? 25400 : 10000; 
     846    return y * multiplier; 
     847  } 
     848 
    817849  // -- IFD population methods -- 
    818850 
  • branches/junit-test-suite/components/bio-formats/test/loci/formats/utests/SPWModelMock.java

    r6841 r6868  
    100100 * <a href="https://skyking.microscopy.wisc.edu/svn/java/trunk/components/bio-formats/test/ome/xml/utests/SPWModelMock.java">SVN</a></dd></dl> 
    101101 */ 
    102 public class SPWModelMock { 
     102public class SPWModelMock implements ModelMock { 
    103103 
    104104  private OME ome; 
     
    208208 
    209209  public static final NamingConvention WELL_COL = NamingConvention.NUMBER; 
    210    
     210 
    211211  public static final String PLANE = 
    212212    "ZrXEfwslJ9N1nDrbtxxWh4fRHo4w8nZ2N0I74Lgj9oIKN9qrPbBK24z+w+9zYzRQ" + 
     
    237237  /** XML namespace. */ 
    238238  public static final String XML_NS = 
    239     "http://www.openmicroscopy.org/Schemas/OME/2010-04"; 
     239    "http://www.openmicroscopy.org/Schemas/OME/2010-06"; 
    240240 
    241241  /** XSI namespace. */ 
     
    245245  /** XML schema location. */ 
    246246  public static final String SCHEMA_LOCATION = 
    247     "http://www.openmicroscopy.org/Schemas/OME/2010-04/ome.xsd"; 
     247    "http://www.openmicroscopy.org/Schemas/OME/2010-06/ome.xsd"; 
    248248 
    249249  public SPWModelMock(boolean makeLightSources) { 
  • branches/junit-test-suite/components/bio-formats/test/loci/formats/utests/SPWModelReaderTest.java

    r6841 r6868  
    8585  } 
    8686 
    87   private void writeMockToFile(SPWModelMock mock, File file) throws Exception { 
     87  /** 
     88   * Writes a model mock to a file as XML. 
     89   * @param mock Mock to build a DOM tree of and serialize to XML. 
     90   * @param file File to write serialized XML to. 
     91   * @throws Exception If there is an error writing the XML to the file. 
     92   */ 
     93  public static void writeMockToFile(ModelMock mock, File file) 
     94  throws Exception { 
    8895    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); 
    8996    DocumentBuilder parser = factory.newDocumentBuilder(); 
     
    135142  } 
    136143 
    137   private boolean canReadEveryPlane(IFormatReader reader) throws Exception { 
     144  /** 
     145   * Checks to see if every plane of an initialized reader can be read. 
     146   * @param reader Reader to read all planes from. 
     147   * @return <code>true</code> if all planes can be read, <code>false</code> 
     148   * otherwise. 
     149   * @throws Exception If there is an error reading data. 
     150   */ 
     151  public static boolean canReadEveryPlane(IFormatReader reader) 
     152  throws Exception { 
    138153    int sizeX = reader.getSizeX(); 
    139154    int sizeY = reader.getSizeY(); 
     
    160175          throw new RuntimeException(e); 
    161176        } 
     177        System.err.println(String.format("%d/%d", i, j)); 
    162178      } 
    163179    } 
     
    181197   * @return the number of bytes per pixel. 
    182198   */ 
    183   private int getBytesPerPixel(int type) { 
     199  public static int getBytesPerPixel(int type) { 
    184200    switch(type) { 
    185201    case 0: 
  • branches/junit-test-suite/components/bio-formats/test/loci/formats/utests/testng.xml

    r6839 r6868  
    7474      </classes> 
    7575    </test> 
    76     <test name="SPWModel"> 
     76    <test name="ModelMockReader"> 
    7777      <groups/> 
    7878      <classes> 
    7979        <class name="loci.formats.utests.SPWModelReaderTest"/> 
     80        <class name="loci.formats.utests.BaseModelReaderTest"/> 
    8081      </classes> 
    8182    </test> 
  • branches/junit-test-suite/components/bio-formats/utils/bfopen.m

    r6752 r6868  
    77arrays of (matrix, label) pairs, with each matrix representing a single 
    88image plane, and each inner list of matrices representing an image 
    9 series. See the bottom of this file below for examples of usage. 
     9series. See below for examples of usage. 
    1010 
    1111Portions of this code were adapted from: 
    1212http://www.mathworks.com/support/solutions/data/1-2WPAYR.html?solution=1-2WPAYR 
    1313 
    14 This method is ~1.5x-2.5x slower than Bio-Formats's command line showinf 
    15 tool (MATLAB R14 vs. java 1.6.0_20), due to overhead from copying arrays. 
     14This method is ~1.5x-2.5x slower than Bio-Formats's command line 
     15showinf tool (MATLAB 7.0.4.365 R14 SP2 vs. java 1.6.0_20), 
     16due to overhead from copying arrays. 
    1617 
    1718Thanks to all who offered suggestions and improvements: 
     
    2324    * Arnon Lieber 
    2425 
    25 Internet Explorer sometimes erroneously renames the Bio-Formats library 
    26 to loci_tools.zip. If this happens, rename it back to loci_tools.jar. 
     26NB: Internet Explorer sometimes erroneously renames the Bio-Formats library 
     27    to loci_tools.zip. If this happens, rename it back to loci_tools.jar. 
     28 
     29Here are some examples of accessing data using the bfopen function: 
     30 
     31    % read the data using Bio-Formats 
     32    data = bfopen('C:/data/experiment.lif'); 
     33 
     34    % unwrap some specific image planes from the result 
     35    numSeries = size(data, 1); 
     36    series1 = data{1, 1}; 
     37    series2 = data{2, 1}; 
     38    series3 = data{3, 1}; 
     39    metadataList = data{1, 2}; 
     40    % ...etc. 
     41    series1_numPlanes = size(series1, 1); 
     42    series1_plane1 = series1{1, 1}; 
     43    series1_label1 = series1{1, 2}; 
     44    series1_plane2 = series1{2, 1}; 
     45    series1_label2 = series1{2, 2}; 
     46    series1_plane3 = series1{3, 1}; 
     47    series1_label3 = series1{3, 2}; 
     48    % ...etc. 
     49 
     50    % plot the 1st series's 1st image plane in a new figure 
     51    series1_colorMaps = data{1, 3}; 
     52    figure('Name', series1_label1); 
     53    if isempty(series1_colorMaps{1}) 
     54        colormap(gray); 
     55    else 
     56        colormap(series1_colorMaps{1}); 
     57    end 
     58    imagesc(series1_plane1); 
     59 
     60    % Or if you have the image processing toolbox, you could use: 
     61    % imshow(series1_plane1, []); 
     62 
     63    % Or animate as a movie (assumes 8-bit unsigned data) 
     64    v = linspace(0, 1, 256)'; 
     65    cmap = [v v v]; 
     66    for p = 1:series1_numPlanes 
     67        M(p) = im2frame(uint8(series1{p, 1}), cmap); 
     68    end 
     69    movie(M); 
     70 
     71    % Query some metadata fields (keys are format-dependent) 
     72    subject = metadataList.get('Subject'); 
     73    title = metadataList.get('Title'); 
    2774%} 
    2875 
     76% -- Configuration - customize this section to your liking -- 
     77 
     78% Toggle the autoloadBioFormats flag to control automatic loading 
     79% of the Bio-Formats library using the javaaddpath command. 
     80% 
     81% For static loading, you can add the library to MATLAB's class path: 
     82%     1. Type "edit classpath.txt" at the MATLAB prompt. 
     83%     2. Go to the end of the file, and add the path to your JAR file 
     84%        (e.g., C:/Program Files/MATLAB/work/loci_tools.jar). 
     85%     3. Save the file and restart MATLAB. 
     86% 
     87% There are advantages to using the static approach over javaaddpath: 
     88%     1. If you use bfopen within a loop, it saves on overhead 
     89%        to avoid calling the javaaddpath command repeatedly. 
     90%     2. Calling 'javaaddpath' may erase certain global parameters. 
     91autoloadBioFormats = 1; 
     92 
     93% Toggle the stitchFiles flag to control grouping of similarly 
     94% named files into a single dataset based on file numbering. 
     95stitchFiles = 0; 
     96 
     97% To work with compressed Evotec Flex, fill in your LuraWave license code. 
     98%lurawaveLicense = 'xxxxxx-xxxxxxx'; 
     99 
     100% -- Main function - no need to edit anything past this point -- 
     101 
    29102% load the Bio-Formats library into the MATLAB environment 
    30 javaaddpath(fullfile(fileparts(mfilename('fullpath')),'loci_tools.jar')); 
    31 %{ 
    32 Alternately, you can add the library to MATLAB's static class path: 
    33     1. Type "edit classpath.txt" at the MATLAB prompt. 
    34     2. Go to the end of the file, and add the path to your JAR file 
    35        (e.g., C:/Program Files/MATLAB/work/loci_tools.jar). 
    36     3. Save the file and restart MATLAB. 
    37  
    38 There are advantages to using the static approach over javaaddpath: 
    39     1. If you use bfopen within a loop, it saves on overhead 
    40        to avoid calling the javaaddpath command repeatedly. 
    41     2. Calling 'javaaddpath' may erase certain global parameters. 
    42 %} 
    43  
    44 % to work with Evotec Flex, fill in your LuraWave license code 
    45 %javaaddpath(fullfile(fileparts(mfilename('fullpath')),'lwf_jsdk2.6.jar')); 
    46 %java.lang.System.setProperty('lurawave.license', 'xxxxxx-xxxxxxx'); 
     103if autoloadBioFormats 
     104    path = fullfile(fileparts(mfilename('fullpath')), 'loci_tools.jar'); 
     105    javaaddpath(path); 
     106end 
     107 
     108% set LuraWave license code, if available 
     109if exist('lurawaveLicense') 
     110    path = fullfile(fileparts(mfilename('fullpath')), 'lwf_jsdk2.6.jar'); 
     111    javaaddpath(path); 
     112    java.lang.System.setProperty('lurawave.license', lurawaveLicense); 
     113end 
     114 
     115% check MATLAB version, since typecast function requires MATLAB 7.1+ 
     116canTypecast = versionCheck(version, 7, 1); 
     117 
     118% check Bio-Formats version, since makeDataArray2D function requires trunk 
     119bioFormatsVersion = char(loci.formats.FormatTools.VERSION); 
     120isBioFormatsTrunk = versionCheck(bioFormatsVersion, 5, 0); 
    47121 
    48122r = loci.formats.ChannelFiller(); 
    49123r = loci.formats.ChannelSeparator(r); 
    50  
    51 % uncomment the following line to enable grouping of similarly 
    52 % named files into a single dataset based on file numbering 
    53 %r = loci.formats.FileStitcher(r); 
     124if stitchFiles 
     125    r = loci.formats.FileStitcher(r); 
     126end 
    54127 
    55128tic 
     
    65138    bpp = loci.formats.FormatTools.getBytesPerPixel(pixelType); 
    66139    fp = loci.formats.FormatTools.isFloatingPoint(pixelType); 
     140    sgn = loci.formats.FormatTools.isSigned(pixelType); 
     141    bppMax = power(2, bpp * 8); 
    67142    little = r.isLittleEndian(); 
    68143    numImages = r.getImageCount(); 
     
    70145    colorMaps = cell(numImages); 
    71146    for i = 1:numImages 
     147        if mod(i, 72) == 1 
     148            fprintf('\n    '); 
     149        end 
    72150        fprintf('.'); 
    73151        plane = r.openBytes(i - 1); 
     
    79157            colorMaps{s, i} = r.get16BitLookupTable()'; 
    80158        end 
    81         rowCount = size(colorMaps{s, i}, 1); 
    82         colCount = size(colorMaps{s, i}, 2); 
    83         newMap = zeros(rowCount, colCount); 
    84         for (row = 1:rowCount) 
    85             for (col = 1:colCount) 
    86                 newMap(row, col) = colorMaps{s, i}(row, col); 
    87                 pow = power(2, bpp * 8); 
    88                 if newMap(row, col) < 0 
    89                     newMap(row, col) = newMap(row, col) + pow; 
     159        if ~isempty(colorMaps{s, i}) 
     160            newMap = colorMaps{s, i}; 
     161            m = newMap(row, col) < 0; 
     162            newMap(m) = newMap(m) + bppMax; 
     163            colorMaps{s, i} = newMap / (bppMax - 1); 
     164        end 
     165 
     166        % convert byte array to MATLAB image 
     167        if isBioFormatsTrunk && (sgn || ~canTypecast) 
     168            % can get the data directly to a matrix 
     169            arr = loci.common.DataTools.makeDataArray2D(plane, ... 
     170                bpp, fp, little, height); 
     171        else 
     172            % get the data as a vector, either because makeDataArray2D 
     173            % is not available, or we need a vector for typecast 
     174            arr = loci.common.DataTools.makeDataArray(plane, ... 
     175                bpp, fp, little); 
     176        end 
     177 
     178        % Java does not have explicitly unsigned data types; 
     179        % hence, we must inform MATLAB when the data is unsigned 
     180        if ~sgn 
     181            if canTypecast 
     182                % TYPECAST requires at least MATLAB 7.1 
     183                % NB: arr will always be a vector here 
     184                switch class(arr) 
     185                    case 'int8' 
     186                        arr = typecast(arr, 'uint8'); 
     187                    case 'int16' 
     188                        arr = typecast(arr, 'uint16'); 
     189                    case 'int32' 
     190                        arr = typecast(arr, 'uint32'); 
     191                    case 'int64' 
     192                        arr = typecast(arr, 'uint64'); 
    90193                end 
    91                 newMap(row, col) = newMap(row, col) / (pow - 1); 
    92             end 
    93         end 
    94         colorMaps{s, i} = newMap; 
    95  
    96         % convert byte array to MATLAB image 
    97         arr = loci.common.DataTools.makeDataArray2D(plane, ... 
    98             bpp, fp, little, height); 
    99         % if using Bio-Formats 4.2 stable rather than trunk, 
    100         % use the following commands instead of the above line 
    101         %pix = loci.common.DataTools.makeDataArray(plane, bpp, fp, little); 
    102         %shape = [width height]; 
    103         %arr = reshape(pix, shape)'; 
     194            else 
     195                % adjust apparent negative values to actual positive ones 
     196                % NB: arr might be either a vector or a matrix here 
     197                mask = arr < 0; 
     198                adjusted = arr(mask) + bppMax / 2; 
     199                switch class(arr) 
     200                    case 'int8' 
     201                        arr = uint8(arr); 
     202                        adjusted = uint8(adjusted); 
     203                    case 'int16' 
     204                        arr = uint16(arr); 
     205                        adjusted = uint16(adjusted); 
     206                    case 'int32' 
     207                        arr = uint32(arr); 
     208                        adjusted = uint32(adjusted); 
     209                    case 'int64' 
     210                        arr = uint64(arr); 
     211                        adjusted = uint64(adjusted); 
     212                end 
     213                adjusted = adjusted + bppMax / 2; 
     214                arr(mask) = adjusted; 
     215            end 
     216        end 
     217 
     218        if isvector(arr) 
     219            % convert results from vector to matrix 
     220            shape = [width height]; 
     221            arr = reshape(arr, shape)'; 
     222        end 
    104223 
    105224        % build an informative title for our figure 
     
    156275toc 
    157276 
    158 %{ 
    159 Here are some examples of accessing data using the bfopen function: 
    160  
    161 % read the data using Bio-Formats 
    162 data = bfopen('C:/data/experiment.lif'); 
    163  
    164 % unwrap some specific image planes from the result 
    165 numSeries = size(data, 1); 
    166 series1 = data{1, 1}; 
    167 series2 = data{2, 1}; 
    168 series3 = data{3, 1}; 
    169 metadataList = data{1, 2}; 
    170 % ...etc. 
    171 series1_numPlanes = size(series1, 1); 
    172 series1_plane1 = series1{1, 1}; 
    173 series1_label1 = series1{1, 2}; 
    174 series1_plane2 = series1{2, 1}; 
    175 series1_label2 = series1{2, 2}; 
    176 series1_plane3 = series1{3, 1}; 
    177 series1_label3 = series1{3, 2}; 
    178 % ...etc. 
    179  
    180 % plot the 1st series's 1st image plane in a new figure 
    181 series1_colorMaps = data{1, 3}; 
    182 figure('Name', series1_label1); 
    183 if isempty(series1_colorMaps{1}) 
    184     colormap(gray); 
    185 else 
    186     colormap(series1_colorMaps{1}); 
    187 end 
    188 imagesc(series1_plane1); 
    189  
    190 % Or if you have the image processing toolbox, you could use: 
    191 % imshow(series1_plane1, []); 
    192  
    193 % Or animate as a movie (assumes 8-bit unsigned data) 
    194 v = linspace(0, 1, 256)'; 
    195 cmap = [v v v]; 
    196 for p = 1:series1_numPlanes 
    197     M(p) = im2frame(uint8(series1{p, 1}), cmap); 
    198 end 
    199 movie(M); 
    200  
    201 % Query some metadata fields (keys are format-dependent) 
    202 subject = metadataList.get('Subject'); 
    203 title = metadataList.get('Title'); 
    204 %} 
     277% -- Helper functions -- 
     278 
     279function [result] = versionCheck(v, maj, min) 
     280 
     281tokens = regexp(v, '[^\d]*(\d+)[^\d]+(\d+).*', 'tokens'); 
     282majToken = tokens{1}(1); 
     283minToken = tokens{1}(2); 
     284major = str2num(majToken{1}); 
     285minor = str2num(minToken{1}); 
     286result = major > maj || (major == maj && minor >= min); 
  • branches/junit-test-suite/components/common/src/loci/common/xml/XMLTools.java

  • branches/junit-test-suite/components/common/test/loci/common/utests/LocationTest.java

    r6128 r6868  
    7474      new Location(invalidPath), 
    7575      new Location(System.getProperty("java.io.tmpdir")), 
    76       new Location("http://www.kernel.org/pub/linux/"), 
    7776      new Location("http://loci.wisc.edu/software/bio-formats"), 
    7877      new Location("http://openmicroscopy.org/software/bio-formats"), 
     
    8180 
    8281    exists = new boolean[] { 
    83       true, false, true, true, true, false, true 
     82      true, false, true, true, false, true 
    8483    }; 
    8584 
    8685    isDirectory = new boolean[] { 
    87       false, false, true, true, false, false, false 
     86      false, false, true, false, false, false 
    8887    }; 
    8988 
    9089    isHidden = new boolean[] { 
    91       false, false, false, false, false, false, true 
     90      false, false, false, false, false, true 
    9291    }; 
    9392 
    9493    mode = new String[] { 
    95       "rw", "", "rw", "r", "r", "", "rw" 
     94      "rw", "", "rw", "r", "", "rw" 
    9695    }; 
    9796 
  • branches/junit-test-suite/components/loci-plugins/src/loci/plugins/in/importer-options.txt

    r6659 r6868  
    168168#  <br><br>When viewing as a virtual stack with this option enabled,      \ 
    169169#  Bio-Formats will attempt to record the operations you perform. When    \ 
    170 #  you switch to a new image plane, Bio-Formats will \"play back\" those  \ 
     170#  you switch to a new image plane, Bio-Formats will "play back" those    \ 
    171171#  same operations, so that the image plane undergoes the same processing \ 
    172172#  you performed previously. In this way, the image stack should behave   \ 
     
    181181[showMetadata] 
    182182type = boolean 
    183 label = Display_metadata in results window 
    184 info = <b>Display metadata in results window</b> - \ 
     183label = Display_metadata 
     184info = <b>Display metadata</b> - \ 
    185185  Reads metadata that may be contained within the file format and      \ 
    186186  displays it. You can save it as a text file or copy it from the File \ 
    187   and Edit menus specific to the ImageJ Results window. Readability    \ 
    188   depends upon the manner in which metadata is formatted in the data   \ 
    189   source. 
     187  and Edit menus specific to the "Original Metadata" window.           \ 
     188  Readability depends upon the manner in which metadata is formatted   \ 
     189  in the data source. 
    190190default = false 
    191191 
Note: See TracChangeset for help on using the changeset viewer.