Skip to content

Commit

Permalink
OIR: parse time step from TIMELAPSE axis when possible
Browse files Browse the repository at this point in the history
  • Loading branch information
melissalinkert committed Dec 10, 2024
1 parent 862723a commit 68b8e17
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions components/formats-gpl/src/loci/formats/in/OIRReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,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 +278,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 +605,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,8 +1194,12 @@ 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) {
tStep = DataTools.parseDouble(seriesInterval.getTextContent());

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

0 comments on commit 68b8e17

Please sign in to comment.