Skip to content

Commit

Permalink
SVS: populate plane position for full-resolution image
Browse files Browse the repository at this point in the history
Fixes ome#3743
  • Loading branch information
melissalinkert committed Aug 11, 2023
1 parent 1b6da10 commit 593c819
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion components/formats-gpl/src/loci/formats/in/SVSReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ public class SVSReader extends BaseTiffReader {
// total number of extra (label and macro) images
private int extraImages = 0;

private transient Double physicalDistanceFromLeftEdge;
private transient Double physicalDistanceFromTopEdge;

// -- Constructor --

/** Constructs a new SVS reader. */
Expand Down Expand Up @@ -481,6 +484,12 @@ else if (t.toLowerCase().indexOf("macro") >= 0) {
int color = Integer.parseInt(value);
displayColor = new Color((color << 8) | 0xff);
break;
case "Left":
physicalDistanceFromLeftEdge = DataTools.parseDouble(value);
break;
case "Top":
physicalDistanceFromTopEdge = DataTools.parseDouble(value);
break;
}
}
}
Expand All @@ -498,7 +507,10 @@ protected void initMetadataStore() throws FormatException {
super.initMetadataStore();

MetadataStore store = makeFilterMetadata();
MetadataTools.populatePixels(store, this, getImageCount() > 1);
boolean populatePlaneData = getImageCount() > 1 ||
physicalDistanceFromTopEdge != null ||
physicalDistanceFromLeftEdge != null;
MetadataTools.populatePixels(store, this, populatePlaneData);

String instrument = MetadataTools.createLSID("Instrument", 0);
String objective = MetadataTools.createLSID("Objective", 0, 0);
Expand All @@ -513,6 +525,21 @@ protected void initMetadataStore() throws FormatException {
store.setImageInstrumentRef(instrument, i);
store.setObjectiveSettingsID(objective, i);

if (i == 0) {
if (physicalDistanceFromTopEdge != null) {
Length yPos = FormatTools.getStagePosition(physicalDistanceFromTopEdge, UNITS.MM);
for (int p=0; p<getImageCount(); p++) {
store.setPlanePositionY(yPos, i, p);
}
}
if (physicalDistanceFromLeftEdge != null) {
Length xPos = FormatTools.getStagePosition(physicalDistanceFromLeftEdge, UNITS.MM);
for (int p=0; p<getImageCount(); p++) {
store.setPlanePositionX(xPos, i, p);
}
}
}

if (hasFlattenedResolutions() || i > extraImages) {
store.setImageName("Series " + (i + 1), i);
}
Expand Down

0 comments on commit 593c819

Please sign in to comment.