Changeset 6786


Ignore:
Timestamp:
08/11/10 15:48:24 (9 years ago)
Author:
melissa
Message:

More OME-XML validation fixes, see #520.

Location:
trunk/components
Files:
11 edited

Legend:

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

    r6784 r6786  
    299299              int fieldIndex = fieldRow * fieldMap[fieldRow].length + fieldCol; 
    300300 
    301               String wellSampleID = 
    302                 MetadataTools.createLSID("WellSample", 0, wellIndex, fieldIndex); 
     301              String wellSampleID = MetadataTools.createLSID("WellSample", 
     302                0, wellIndex, fieldIndex); 
    303303              store.setWellSampleID(wellSampleID, 0, wellIndex, fieldIndex); 
    304304              String imageID = MetadataTools.createLSID("Image", nextImage); 
    305305              store.setWellSampleImageRef(imageID, 0, wellIndex, fieldIndex); 
    306               store.setWellSampleIndex( 
    307                 new NonNegativeInteger(fieldIndex), 0, wellIndex, fieldIndex); 
     306              store.setWellSampleIndex(new NonNegativeInteger( 
     307                wellIndex * fieldCount + fieldIndex), 0, wellIndex, fieldIndex); 
    308308 
    309309              String well = (char) (row + 'A') + String.format("%02d", col + 1); 
     
    370370    int row = getWellRow(seriesIndex); 
    371371    int col = getWellColumn(seriesIndex); 
     372    int well = row * wellFiles[0].length + col; 
    372373    String logFile = logFiles[row][col]; 
    373374    LOGGER.debug("Parsing log file for well {}{}", (char) (row + 'A'), col + 1); 
     
    395396      else if (key.equals("Scan Origin")) { 
    396397        String[] axes = value.split(","); 
    397         for (int field=0; field<fieldCount; field++) { 
    398           store.setWellSamplePositionX(new Double(axes[0]), 0, wellIndex, field); 
    399           store.setWellSamplePositionY(new Double(axes[1]), 0, wellIndex, field); 
     398        for (int fieldRow=0; fieldRow<fieldMap.length; fieldRow++) { 
     399          for (int fieldCol=0; fieldCol<fieldMap[fieldRow].length; fieldCol++) { 
     400            if (fieldMap[fieldRow][fieldCol] && wellFiles[row][col] != null) { 
     401              int field = fieldRow * fieldMap[fieldRow].length + fieldCol; 
     402              store.setWellSamplePositionX(new Double(axes[0]), 0, well, field); 
     403              store.setWellSamplePositionY(new Double(axes[1]), 0, well, field); 
     404            } 
     405          } 
    400406        } 
    401407      } 
     
    407413          Double ySize = new Double(value.substring(s + 1, end).trim()); 
    408414          for (int field=0; field<fieldCount; field++) { 
    409             store.setPixelsPhysicalSizeX(xSize / getSizeX(), seriesIndex + field); 
    410             store.setPixelsPhysicalSizeY(ySize / getSizeY(), seriesIndex + field); 
     415            int index = seriesIndex + field; 
     416            store.setPixelsPhysicalSizeX(xSize / getSizeX(), index); 
     417            store.setPixelsPhysicalSizeY(ySize / getSizeY(), index); 
    411418          } 
    412419        } 
  • trunk/components/bio-formats/src/loci/formats/in/FV1000Reader.java

    r6741 r6786  
    10541054          } 
    10551055 
     1056          String shapeID = MetadataTools.createLSID("Shape", nextROI, shape); 
     1057 
    10561058          if (shapeType == POINT) { 
     1059            store.setPointID(shapeID, nextROI, shape); 
    10571060            store.setPointTheZ(new NonNegativeInteger(zIndex), nextROI, shape); 
    10581061            store.setPointTheT(new NonNegativeInteger(tIndex), nextROI, shape); 
     
    10731076                double realY = y + row * height; 
    10741077 
     1078                shapeID = MetadataTools.createLSID("Shape", nextROI, shape); 
     1079                store.setRectangleID(shapeID, nextROI, shape); 
    10751080                store.setRectangleX(realX, nextROI, shape); 
    10761081                store.setRectangleY(realY, nextROI, shape); 
     
    10981103          } 
    10991104          else if (shapeType == LINE) { 
     1105            store.setLineID(shapeID, nextROI, shape); 
    11001106            store.setLineX1(new Double(x), nextROI, shape); 
    11011107            store.setLineY1(new Double(y), nextROI, shape); 
     
    11181124            double rx = width / 2; 
    11191125            double ry = shapeType == CIRCLE ? rx : height / 2; 
     1126            store.setEllipseID(shapeID, nextROI, shape); 
    11201127            store.setEllipseX(x + rx, nextROI, shape); 
    11211128            store.setEllipseY(y + ry, nextROI, shape); 
     
    11431150              if (point < xc.length - 1) points.append(" "); 
    11441151            } 
     1152            store.setPolylineID(shapeID, nextROI, shape); 
    11451153            store.setPolylinePoints(points.toString(), nextROI, shape); 
    11461154            store.setPolylineTransform("rotate(" + angle + ")", nextROI, shape); 
     
    14451453  { 
    14461454    RandomAccessInputStream stream = getFile(filename); 
    1447     stream.skipBytes(2); 
    1448     String data = stream.readString((int) stream.length() - 2); 
     1455    String data = stream.readString((int) stream.length()); 
     1456    if (!data.startsWith("[")) data = data.substring(2, data.length()); 
    14491457    data = DataTools.stripString(data); 
    14501458    BufferedReader reader = new BufferedReader(new StringReader(data)); 
  • trunk/components/bio-formats/src/loci/formats/in/LeicaReader.java

    r6726 r6786  
    164164  private boolean[][] cutOutPopulated; 
    165165  private boolean[][] filterRefPopulated; 
     166 
     167  private Double detectorOffset, detectorVoltage; 
    166168 
    167169  // -- Constructor -- 
     
    11621164          try { 
    11631165            if (tokens[2].equals("VideoOffset")) { 
    1164               store.setDetectorOffset(new Double(data), series, nextDetector); 
     1166              detectorOffset = new Double(data); 
    11651167            } 
    11661168            else if (tokens[2].equals("HighVoltage")) { 
    1167               store.setDetectorVoltage(new Double(data), series, nextDetector); 
     1169              detectorVoltage = new Double(data); 
    11681170              nextDetector++; 
    11691171            } 
    11701172            else if (tokens[2].equals("State")) { 
    1171               store.setDetectorType( 
    1172                 getDetectorType("PMT"), series, nextDetector); 
    11731173              // link Detector to Image, if the detector was actually used 
    11741174              if (data.equals("Active")) { 
     1175                store.setDetectorOffset(detectorOffset, series, nextDetector); 
     1176                store.setDetectorVoltage(detectorVoltage, series, nextDetector); 
     1177                store.setDetectorType( 
     1178                  getDetectorType("PMT"), series, nextDetector); 
    11751179                String index = tokens[1].substring(tokens[1].indexOf(" ") + 1); 
    11761180                int channelIndex = -1; 
  • trunk/components/bio-formats/src/loci/formats/in/MicromanagerReader.java

    r6655 r6786  
    411411    MetadataTools.populatePixels(store, this, true); 
    412412    if (time != null) { 
    413       long stamp = DateTools.getTime(time, DATE_FORMAT); 
    414       String date = DateTools.convertDate(stamp, DateTools.UNIX); 
     413      String date = DateTools.formatDate(time, DATE_FORMAT); 
    415414      store.setImageAcquiredDate(date, 0); 
    416415    } 
     
    440439      } 
    441440 
    442       if (detectorID == null) { 
    443         detectorID = MetadataTools.createLSID("Detector", 0, 0); 
    444       } 
    445       else { 
    446         detectorID = detectorID.substring(detectorID.lastIndexOf(":") + 1); 
    447         detectorID = "Detector:" + detectorID.trim(); 
    448       } 
     441      String serialNumber = detectorID; 
     442      detectorID = MetadataTools.createLSID("Detector", 0, 0); 
    449443 
    450444      for (int i=0; i<channels.length; i++) { 
     
    460454      if (detectorModel != null) { 
    461455        store.setDetectorModel(detectorModel, 0, 0); 
     456      } 
     457 
     458      if (serialNumber != null) { 
     459        store.setDetectorSerialNumber(serialNumber, 0, 0); 
    462460      } 
    463461 
  • trunk/components/bio-formats/src/loci/formats/in/NikonReader.java

    r6495 r6786  
    3232import loci.formats.FormatTools; 
    3333import loci.formats.ImageTools; 
     34import loci.formats.MetadataTools; 
    3435import loci.formats.codec.BitBuffer; 
    3536import loci.formats.codec.NikonCodec; 
    3637import loci.formats.codec.NikonCodecOptions; 
     38import loci.formats.meta.MetadataStore; 
    3739import loci.formats.tiff.IFD; 
    3840import loci.formats.tiff.IFDList; 
     
    419421      core[0].interleaved = true; 
    420422    } 
     423 
     424    MetadataStore store = makeFilterMetadata(); 
     425    MetadataTools.populatePixels(store, this); 
    421426  } 
    422427 
  • trunk/components/bio-formats/src/loci/formats/in/NikonTiffReader.java

    r6655 r6786  
    227227      store.setObjectiveID(objectiveID, 0, 0); 
    228228      store.setImageObjectiveSettingsID(objectiveID, 0); 
    229       store.setObjectiveNominalMagnification( 
     229      if (magnification > 0) { 
     230        store.setObjectiveNominalMagnification( 
    230231          new PositiveInteger(magnification), 0, 0); 
     232      } 
    231233 
    232234      if (correction == null) correction = "Other"; 
     
    247249 
    248250      for (int i=0; i<gain.size(); i++) { 
     251        store.setDetectorID(MetadataTools.createLSID("Detector", 0, i), 0, i); 
    249252        store.setDetectorGain(gain.get(i), 0, i); 
    250253        store.setDetectorType(getDetectorType("Other"), 0, i); 
  • trunk/components/bio-formats/src/loci/formats/in/ScanrReader.java

    r6726 r6786  
    426426    MetadataTools.populatePixels(store, this); 
    427427 
     428    store.setPlateID(MetadataTools.createLSID("Plate", 0), 0); 
     429 
    428430    int nFields = fieldRows * fieldColumns; 
    429431 
     
    437439      int wellCol = well % wellColumns; 
    438440 
     441      store.setWellID(MetadataTools.createLSID("Well", 0, well), 0, well); 
    439442      store.setWellColumn(new NonNegativeInteger(wellCol), 0, well); 
    440443      store.setWellRow(new NonNegativeInteger(wellRow), 0, well); 
    441444 
     445      String wellSample = 
     446        MetadataTools.createLSID("WellSample", 0, well, field); 
     447      store.setWellSampleID(wellSample, 0, well, field); 
    442448      store.setWellSampleIndex(new NonNegativeInteger(i), 0, well, field); 
    443449      String imageID = MetadataTools.createLSID("Image", i); 
  • trunk/components/bio-formats/src/loci/formats/in/TillVisionReader.java

    r6768 r6786  
    227227          core[0].pixelType = convertPixelType(s.readInt()); 
    228228          embeddedOffset = s.getFilePointer() + 28; 
    229           in.close(); 
     229          if (in != null) in.close(); 
    230230          in = poi.getDocumentStream(name); 
    231231          nImages++; 
     
    329329 
    330330      for (String f : files) { 
    331         if (checkSuffix(f, "pst") && f.startsWith(name)) { 
     331        if (checkSuffix(f, "pst")) { 
    332332          Location pst = new Location(directory, f); 
    333           if (pst.isDirectory()) { 
     333          if (pst.isDirectory() && f.startsWith(name)) { 
    334334            String[] subfiles = pst.list(true); 
    335335            for (String q : subfiles) { 
  • trunk/components/bio-formats/src/loci/formats/in/ZeissLSMReader.java

    r6765 r6786  
    414414    MetadataTools.populatePixels(store, this, true); 
    415415    for (int series=0; series<ifdsList.size(); series++) { 
     416      setSeries(series); 
    416417      store.setImageName(imageNames.get(series), series); 
    417418      store.setPixelsBinDataBigEndian(!isLittleEndian(), series, 0); 
     
    11351136      in.skipBytes(34); 
    11361137 
     1138      String roiID = MetadataTools.createLSID("ROI", i); 
     1139      String shapeID = MetadataTools.createLSID("Shape", i, 0); 
     1140 
    11371141      switch (type) { 
    11381142        case TEXT: 
     
    11431147          store.setTextFontSize(new NonNegativeInteger(fontHeight), i, 0); 
    11441148          store.setTextStrokeWidth(lineWidth, i, 0); 
     1149          store.setROIID(roiID, i); 
     1150          store.setTextID(shapeID, i, 0); 
    11451151          break; 
    11461152        case LINE: 
     
    11571163          store.setLineFontSize(new NonNegativeInteger(fontHeight), i, 0); 
    11581164          store.setLineStrokeWidth(lineWidth, i, 0); 
     1165          store.setROIID(roiID, i); 
     1166          store.setLineID(shapeID, i, 0); 
    11591167          break; 
    11601168        case SCALE_BAR: 
     
    11821190          store.setRectangleFontSize(new NonNegativeInteger(fontHeight), i, 0); 
    11831191          store.setRectangleStrokeWidth(lineWidth, i, 0); 
     1192          store.setROIID(roiID, i); 
     1193          store.setRectangleID(shapeID, i, 0); 
    11841194 
    11851195          break; 
     
    12381248          store.setEllipseFontSize(new NonNegativeInteger(fontHeight), i, 0); 
    12391249          store.setEllipseStrokeWidth(lineWidth, i, 0); 
     1250          store.setROIID(roiID, i); 
     1251          store.setEllipseID(shapeID, i, 0); 
    12401252 
    12411253          break; 
     
    12561268          store.setEllipseFontSize(new NonNegativeInteger(fontHeight), i, 0); 
    12571269          store.setEllipseStrokeWidth(lineWidth, i, 0); 
     1270          store.setROIID(roiID, i); 
     1271          store.setEllipseID(shapeID, i, 0); 
    12581272 
    12591273          break; 
     
    12911305          store.setEllipseFontSize(new NonNegativeInteger(fontHeight), i, 0); 
    12921306          store.setEllipseStrokeWidth(lineWidth, i, 0); 
     1307          store.setROIID(roiID, i); 
     1308          store.setEllipseID(shapeID, i, 0); 
    12931309 
    12941310          break; 
     
    13131329          store.setPolylineFontSize(new NonNegativeInteger(fontHeight), i, 0); 
    13141330          store.setPolylineStrokeWidth(lineWidth, i, 0); 
     1331          store.setROIID(roiID, i); 
     1332          store.setPolylineID(shapeID, i, 0); 
    13151333 
    13161334          break; 
     
    13381356          store.setPolylineFontSize(new NonNegativeInteger(fontHeight), i, 0); 
    13391357          store.setPolylineStrokeWidth(lineWidth, i, 0); 
     1358          store.setROIID(roiID, i); 
     1359          store.setPolylineID(shapeID, i, 0); 
    13401360 
    13411361          break; 
     
    13631383          store.setPolylineFontSize(new NonNegativeInteger(fontHeight), i, 0); 
    13641384          store.setPolylineStrokeWidth(lineWidth, i, 0); 
     1385          store.setROIID(roiID, i); 
     1386          store.setPolylineID(shapeID, i, 0); 
    13651387 
    13661388          break; 
  • trunk/components/bio-formats/src/loci/formats/meta/MetadataConverter.java

    r6653 r6786  
    7777    for (int datasetIndex=0; datasetIndex<datasetCount; datasetIndex++) { 
    7878    try { 
     79      String datasetIDValue = src.getDatasetID(datasetIndex); 
     80      if (datasetIDValue != null) dest.setDatasetID(datasetIDValue, datasetIndex); 
     81    } catch (NullPointerException e) { } 
     82    try { 
    7983      for (int annotationRefIndex=0; annotationRefIndex<src.getDatasetAnnotationRefCount(datasetIndex); annotationRefIndex++) 
    8084      { 
     
    9498      String datasetGroupRefValue = src.getDatasetGroupRef(datasetIndex); 
    9599      if (datasetGroupRefValue != null) dest.setDatasetGroupRef(datasetGroupRefValue, datasetIndex); 
    96     } catch (NullPointerException e) { } 
    97     try { 
    98       String datasetIDValue = src.getDatasetID(datasetIndex); 
    99       if (datasetIDValue != null) dest.setDatasetID(datasetIDValue, datasetIndex); 
    100100    } catch (NullPointerException e) { } 
    101101    try { 
     
    14301430    for (int projectIndex=0; projectIndex<projectCount; projectIndex++) { 
    14311431    try { 
     1432      String projectIDValue = src.getProjectID(projectIndex); 
     1433      if (projectIDValue != null) dest.setProjectID(projectIDValue, projectIndex); 
     1434    } catch (NullPointerException e) { } 
     1435    try { 
    14321436      int annotationRefCount = src.getProjectAnnotationRefCount(projectIndex); 
    14331437      for (int annotationRefIndex=0; annotationRefIndex<annotationRefCount; annotationRefIndex++) 
     
    14481452      String projectGroupRefValue = src.getProjectGroupRef(projectIndex); 
    14491453      if (projectGroupRefValue != null) dest.setProjectGroupRef(projectGroupRefValue, projectIndex); 
    1450     } catch (NullPointerException e) { } 
    1451     try { 
    1452       String projectIDValue = src.getProjectID(projectIndex); 
    1453       if (projectIDValue != null) dest.setProjectID(projectIDValue, projectIndex); 
    14541454    } catch (NullPointerException e) { } 
    14551455    try { 
  • trunk/components/test-suite/src/loci/tests/testng/FormatReaderTest.java

    r6768 r6786  
    5555import loci.formats.in.BioRadReader; 
    5656import loci.formats.in.NRRDReader; 
     57import loci.formats.in.OMETiffReader; 
    5758import loci.formats.in.TiffReader; 
    5859import loci.formats.meta.MetadataRetrieve; 
     
    387388          msg = "SizeT"; 
    388389        } 
    389         if (reader.isLittleEndian() == 
    390           retrieve.getPixelsBinDataBigEndian(i, 0).booleanValue()) 
    391         { 
    392           msg = "BigEndian"; 
     390 
     391        // NB: OME-TIFF files do not have a BinData element under Pixels 
     392        IFormatReader r = reader.unwrap(); 
     393        if (r instanceof FileStitcher) r = ((FileStitcher) r).getReader(); 
     394        if (r instanceof ReaderWrapper) r = ((ReaderWrapper) r).unwrap(); 
     395        if (!(r instanceof OMETiffReader)) { 
     396          if (reader.isLittleEndian() == 
     397            retrieve.getPixelsBinDataBigEndian(i, 0).booleanValue()) 
     398          { 
     399            msg = "BigEndian"; 
     400          } 
    393401        } 
    394402        if (!reader.getDimensionOrder().equals( 
Note: See TracChangeset for help on using the changeset viewer.