Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OIR: parse time step from TIMELAPSE axis when possible #4259

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading