Skip to content

Commit 4c7509d

Browse files
ScanR: populate exposure times even if field positions are missing
Fixes #4231.
1 parent 1d58269 commit 4c7509d

File tree

1 file changed

+27
-19
lines changed

1 file changed

+27
-19
lines changed

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

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -611,8 +611,13 @@ else if (row1 > row2) {
611611
ms.bitsPerPixel = 12;
612612
}
613613

614+
// only populate Plane.The* if at least one kind of additional
615+
// plane metadata is available
616+
boolean populatePlanes = deltaT != null || exposures.size() >= getSizeC() ||
617+
fieldPositionX != null || fieldPositionY != null;
618+
614619
MetadataStore store = makeFilterMetadata();
615-
MetadataTools.populatePixels(store, this);
620+
MetadataTools.populatePixels(store, this, populatePlanes);
616621

617622
store.setPlateID(MetadataTools.createLSID("Plate", 0), 0);
618623
store.setPlateColumns(new PositiveInteger(wellColumns), 0);
@@ -688,32 +693,35 @@ else if (row1 > row2) {
688693
store.setPixelsPhysicalSizeY(y, i);
689694
}
690695

696+
697+
int field = i % nFields;
698+
int well = i / nFields;
691699
if (fieldPositionX != null && fieldPositionY != null) {
692-
int field = i % nFields;
693-
int well = i / nFields;
694700
final Length posX = fieldPositionX[field];
695701
final Length posY = fieldPositionY[field];
696-
702+
697703
store.setWellSamplePositionX(posX, 0, well, field);
698704
store.setWellSamplePositionY(posY, 0, well, field);
699-
for (int c=0; c<getSizeC(); c++) {
700-
int image = getIndex(0, c, 0);
701-
store.setPlaneTheZ(new NonNegativeInteger(0), i, image);
702-
store.setPlaneTheC(new NonNegativeInteger(c), i, image);
703-
store.setPlaneTheT(new NonNegativeInteger(0), i, image);
705+
}
706+
707+
for (int image=0; image<getImageCount(); image++) {
708+
if (fieldPositionX != null) {
704709
store.setPlanePositionX(fieldPositionX[field], i, image);
710+
}
711+
if (fieldPositionY != null) {
705712
store.setPlanePositionY(fieldPositionY[field], i, image);
713+
}
706714

707-
// exposure time is stored in milliseconds
708-
// convert to seconds before populating MetadataStore
709-
Double time = exposures.get(c);
710-
if (time != null) {
711-
time /= 1000;
712-
store.setPlaneExposureTime(new Time(time, UNITS.SECOND), i, image);
713-
}
714-
if (deltaT != null) {
715-
store.setPlaneDeltaT(new Time(deltaT, UNITS.SECOND), i, image);
716-
}
715+
// exposure time is stored in milliseconds
716+
// convert to seconds before populating MetadataStore
717+
int[] coords = getZCTCoords(image);
718+
Double time = exposures.get(coords[1]);
719+
if (time != null) {
720+
time /= 1000;
721+
store.setPlaneExposureTime(new Time(time, UNITS.SECOND), i, image);
722+
}
723+
if (deltaT != null) {
724+
store.setPlaneDeltaT(new Time(deltaT, UNITS.SECOND), i, image);
717725
}
718726
}
719727
}

0 commit comments

Comments
 (0)