Skip to content

Commit

Permalink
Update LeicaHandler plane handling for backwards compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
melissalinkert committed Nov 19, 2024
1 parent 676dfe6 commit 10b48d2
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 5 deletions.
41 changes: 37 additions & 4 deletions components/formats-gpl/src/loci/formats/in/LeicaHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ public class LeicaHandler extends BaseHandler {
private MetadataLevel level;
private int laserCount = 0;

private boolean setPlaneMetadataInStore = true;
private Map<String, Time> exposureTimes = new HashMap<String, Time>();
private Map<String, Time> deltaT = new HashMap<String, Time>();

Expand All @@ -139,6 +140,11 @@ public LeicaHandler(MetadataStore store, MetadataLevel level) {
this.level = level;
}

public LeicaHandler(MetadataStore store, MetadataLevel level, boolean planesInStore) {
this(store, level);
setPlaneMetadataInStore = planesInStore;
}

// -- LeicaHandler API methods --

public List<CoreMetadata> getCoreMetadataList() { return core; }
Expand Down Expand Up @@ -556,7 +562,13 @@ else if (id.indexOf("WFC") == 1) {
try {
Double exposureTime = DataTools.parseDouble(value);
if (exposureTime != null) {
exposureTimes.put(numDatasets + "-" + c, new Time(exposureTime, UNITS.SECOND));
Time expTime = new Time(exposureTime, UNITS.SECOND);
if (setPlaneMetadataInStore) {
store.setPlaneExposureTime(expTime, numDatasets, c);
}
else {
exposureTimes.put(numDatasets + "-" + c, expTime);
}
}
}
catch (IndexOutOfBoundsException e) { }
Expand Down Expand Up @@ -885,14 +897,28 @@ else if (qName.equals("TimeStamp") && numDatasets >= 0) {
store.setImageAcquisitionDate(new Timestamp(date), numDatasets);
}
firstStamp = ms;
deltaT.put(numDatasets + "-" + count, new Time(0.0, UNITS.SECOND));

Time stamp = new Time(0.0, UNITS.SECOND);
if (setPlaneMetadataInStore) {
store.setPlaneDeltaT(stamp, numDatasets, count);
}
else {
deltaT.put(numDatasets + "-" + count, stamp);
}
}
else if (level != MetadataLevel.MINIMUM) {
CoreMetadata coreMeta = core.get(numDatasets);
int nImages = coreMeta.sizeZ * coreMeta.sizeT * coreMeta.sizeC;
if (count < nImages) {
ms -= firstStamp;
deltaT.put(numDatasets + "-" + count, new Time(ms / 1000.0, UNITS.SECOND));

Time stamp = new Time(ms / 1000.00, UNITS.SECOND);
if (setPlaneMetadataInStore) {
store.setPlaneDeltaT(stamp, numDatasets, count);
}
else {
deltaT.put(numDatasets + "-" + count, stamp);
}
}
}

Expand All @@ -904,7 +930,14 @@ else if (qName.equals("RelTimeStamp") && level != MetadataLevel.MINIMUM) {
if (count < nImages) {
Double time = DataTools.parseDouble(attributes.getValue("Time"));
if (time != null) {
deltaT.put(numDatasets + "-" + count, new Time(time, UNITS.SECOND));
Time stamp = new Time(time, UNITS.SECOND);
if (setPlaneMetadataInStore) {
store.setPlaneDeltaT(stamp, numDatasets, count);
}
else {
deltaT.put(numDatasets + "-" + count, stamp);
}

count++;
}
}
Expand Down
2 changes: 1 addition & 1 deletion components/formats-gpl/src/loci/formats/in/TCSReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ else if (getSizeT() == 1) {
xml = XMLTools.sanitizeXML(PREFIX + xml + SUFFIX);

LeicaHandler handler =
new LeicaHandler(store, getMetadataOptions().getMetadataLevel());
new LeicaHandler(store, getMetadataOptions().getMetadataLevel(), false);
XMLTools.parseXML(xml, handler);
exposureTime = handler.getExposureTimes();
deltaT = handler.getDeltaT();
Expand Down

0 comments on commit 10b48d2

Please sign in to comment.