Skip to content

Commit

Permalink
merge master -Dorg -Ssuccess-only: PR 4259 (OIR: parse time step from…
Browse files Browse the repository at this point in the history
… TIMELAPSE axis when possible)
  • Loading branch information
snoopycrimecop committed Dec 25, 2024
2 parents c913bbd + a0b60c9 commit b5a992f
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion components/formats-gpl/src/loci/formats/in/OIRReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import java.util.Objects;
import javax.xml.parsers.ParserConfigurationException;

import loci.common.Constants;
import loci.common.DataTools;
import loci.common.DateTools;
import loci.common.Location;
Expand Down Expand Up @@ -92,6 +93,7 @@ public class OIRReader extends FormatReader {

private transient Double zStart;
private transient Double zStep;
private transient Double tStart;
private transient Double tStep;
private transient HashMap<Integer, Double> timestampAdjustments = new HashMap<Integer, Double>();

Expand Down Expand Up @@ -277,6 +279,7 @@ public void close(boolean fileOnly) throws IOException {
minT = Integer.MAX_VALUE;
zStart = null;
zStep = null;
tStart = null;
tStep = null;
}
}
Expand Down Expand Up @@ -603,6 +606,9 @@ else if (!checkSuffix(id, "oir")) {
for (int i=0; i<getImageCount(); i++) {
int t = getZCTCoords(i)[2];
double deltaT = t * tStep;
if (tStart != null) {
deltaT += tStart;
}
for (Integer frame : timestampAdjustments.keySet()) {
if (t >= frame) {
deltaT += (timestampAdjustments.get(frame) - tStep);
Expand Down Expand Up @@ -1189,7 +1195,11 @@ private void parseImageProperties(Element root) throws FormatException {
Element speed = getFirstChild(getFirstChild(scanner, "lsmimage:param"), "lsmparam:speed");
speed = getFirstChild(speed, "commonparam:speedInformation");
Element seriesInterval = getFirstChild(speed, "commonparam:seriesInterval");
if (seriesInterval != null) {

// prefer setting tStep from the TIMELAPSE axis,
// but fall back to this if needed
if (seriesInterval != null && tStep == null) {
// units are expected to be milliseconds
tStep = DataTools.parseDouble(seriesInterval.getTextContent());
}
}
Expand Down Expand Up @@ -1358,6 +1368,12 @@ private void parseAxis(Element dimensionAxis) {
else if (name.equals("TIMELAPSE")) {
if (m.sizeT <= 1) {
m.sizeT = Integer.parseInt(size.getTextContent());
// units are expected to be seconds, multiply to get milliseconds
tStart = DataTools.parseDouble(start.getTextContent()) * 1000;
double stepValue = DataTools.parseDouble(step.getTextContent());
if (stepValue > Constants.EPSILON) {
tStep = stepValue * 1000;
}
}
}
else if (name.equals("LAMBDA")) {
Expand Down

0 comments on commit b5a992f

Please sign in to comment.