Skip to content

Commit

Permalink
ScanR: populate exposure times even if field positions are missing
Browse files Browse the repository at this point in the history
Fixes ome#4231.
  • Loading branch information
melissalinkert committed Feb 24, 2025
1 parent 1d58269 commit 4c7509d
Showing 1 changed file with 27 additions and 19 deletions.
46 changes: 27 additions & 19 deletions components/formats-gpl/src/loci/formats/in/ScanrReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -611,8 +611,13 @@ else if (row1 > row2) {
ms.bitsPerPixel = 12;
}

// only populate Plane.The* if at least one kind of additional
// plane metadata is available
boolean populatePlanes = deltaT != null || exposures.size() >= getSizeC() ||
fieldPositionX != null || fieldPositionY != null;

MetadataStore store = makeFilterMetadata();
MetadataTools.populatePixels(store, this);
MetadataTools.populatePixels(store, this, populatePlanes);

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


int field = i % nFields;
int well = i / nFields;
if (fieldPositionX != null && fieldPositionY != null) {
int field = i % nFields;
int well = i / nFields;
final Length posX = fieldPositionX[field];
final Length posY = fieldPositionY[field];

store.setWellSamplePositionX(posX, 0, well, field);
store.setWellSamplePositionY(posY, 0, well, field);
for (int c=0; c<getSizeC(); c++) {
int image = getIndex(0, c, 0);
store.setPlaneTheZ(new NonNegativeInteger(0), i, image);
store.setPlaneTheC(new NonNegativeInteger(c), i, image);
store.setPlaneTheT(new NonNegativeInteger(0), i, image);
}

for (int image=0; image<getImageCount(); image++) {
if (fieldPositionX != null) {
store.setPlanePositionX(fieldPositionX[field], i, image);
}
if (fieldPositionY != null) {
store.setPlanePositionY(fieldPositionY[field], i, image);
}

// exposure time is stored in milliseconds
// convert to seconds before populating MetadataStore
Double time = exposures.get(c);
if (time != null) {
time /= 1000;
store.setPlaneExposureTime(new Time(time, UNITS.SECOND), i, image);
}
if (deltaT != null) {
store.setPlaneDeltaT(new Time(deltaT, UNITS.SECOND), i, image);
}
// exposure time is stored in milliseconds
// convert to seconds before populating MetadataStore
int[] coords = getZCTCoords(image);
Double time = exposures.get(coords[1]);
if (time != null) {
time /= 1000;
store.setPlaneExposureTime(new Time(time, UNITS.SECOND), i, image);
}
if (deltaT != null) {
store.setPlaneDeltaT(new Time(deltaT, UNITS.SECOND), i, image);
}
}
}
Expand Down

0 comments on commit 4c7509d

Please sign in to comment.