Skip to content

Commit d52ee9b

Browse files
Parse .vsi timestamps similar to Z positions
1 parent 9303ee8 commit d52ee9b

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

components/formats-gpl/src/loci/formats/in/CellSensReader.java

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -912,6 +912,7 @@ else if (zCount > 0) {
912912
if (pyramid != null) {
913913
int nextPlane = 0;
914914
int effectiveSizeC = core.get(i).rgb ? 1 : core.get(i).sizeC;
915+
int[] tzc = new int[] {core.get(i).sizeT, core.get(i).sizeZ, core.get(i).sizeC};
915916
for (int c=0; c<effectiveSizeC; c++) {
916917
store.setDetectorSettingsID(
917918
MetadataTools.createLSID("Detector", 0, nextPyramid - 1), ii, c);
@@ -971,6 +972,24 @@ else if (pyramid.zStart != null && pyramid.zIncrement != null) {
971972
UNITS.MICROMETER), ii, nextPlane);
972973
}
973974
store.setPixelsPhysicalSizeZ(FormatTools.getPhysicalSizeZ(pyramid.zIncrement), ii);
975+
976+
// calculate index into timestamp list using TZC order
977+
// that matches the plane iteration order here, and seems to work
978+
// on the limited data we have that is fully 5D
979+
// this approach may need to be re-evaluated for new data though
980+
int reorderedPlane = FormatTools.positionToRaster(tzc, new int[] {t, z, c});
981+
if (reorderedPlane < pyramid.tValues.size()) {
982+
store.setPlaneDeltaT(
983+
FormatTools.createTime(pyramid.tValues.get(reorderedPlane),
984+
UNITS.MILLISECOND), ii, nextPlane);
985+
}
986+
else if (pyramid.tStart != null && pyramid.tIncrement != null) {
987+
store.setPlaneDeltaT(
988+
FormatTools.createTime(pyramid.tStart + (t * pyramid.tIncrement),
989+
UNITS.MILLISECOND), ii, nextPlane);
990+
}
991+
store.setPixelsTimeIncrement(
992+
FormatTools.createTime(pyramid.tIncrement, UNITS.MILLISECOND), ii);
974993
}
975994
}
976995
}
@@ -1960,6 +1979,15 @@ else if (tagPrefix.equals("Z increment")) {
19601979
else if (tagPrefix.equals("Z value")) {
19611980
pyramid.zValues.add(DataTools.parseDouble(value));
19621981
}
1982+
else if (tagPrefix.equals("Timelapse start")) {
1983+
pyramid.tStart = DataTools.parseDouble(value);
1984+
}
1985+
else if (tagPrefix.equals("Timelapse increment")) {
1986+
pyramid.tIncrement = DataTools.parseDouble(value);
1987+
}
1988+
else if (tagPrefix.equals("Timestamp ")) {
1989+
pyramid.tValues.add(DataTools.parseDouble(value));
1990+
}
19631991
}
19641992
}
19651993
catch (NumberFormatException e) {
@@ -2082,6 +2110,8 @@ private String getVolumeName(int tag) {
20822110
return "Channel Wavelength ";
20832111
case WORKING_DISTANCE:
20842112
return "Objective Working Distance ";
2113+
case TIME_VALUE:
2114+
return "Timestamp ";
20852115
}
20862116
LOGGER.debug("Unhandled volume {}", tag);
20872117
return "";
@@ -2668,6 +2698,11 @@ class Pyramid {
26682698
public transient Double zStart;
26692699
public transient Double zIncrement;
26702700
public transient ArrayList<Double> zValues = new ArrayList<Double>();
2701+
2702+
public transient Double tStart;
2703+
public transient Double tIncrement;
2704+
public transient ArrayList<Double> tValues = new ArrayList<Double>();
2705+
26712706
public boolean HasAssociatedEtsFile = false;
26722707
}
26732708

0 commit comments

Comments
 (0)