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

ScanR: populate exposure times even if field positions are missing #4280

Open
wants to merge 1 commit 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
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