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

CV7000: handle case where wells are recorded, but all files were removed #4006

Merged
merged 2 commits into from
Jun 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 16 additions & 0 deletions components/formats-gpl/src/loci/formats/in/CV7000Reader.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ public class CV7000Reader extends FormatReader {
private String startTime, endTime;
private ArrayList<String> extraFiles;

private transient Map<String, Boolean> acquiredWells = new HashMap<String, Boolean>();

// -- Constructor --

/** Constructs a new Yokogawa CV7000 reader. */
Expand Down Expand Up @@ -206,6 +208,7 @@ public void close(boolean fileOnly) throws IOException {
endTime = null;
reversePlaneLookup = null;
extraFiles = null;
acquiredWells.clear();
}
}

Expand Down Expand Up @@ -309,6 +312,10 @@ public int compare(Channel c1, Channel c2) {

for (Plane p : planeData) {
if (p != null) {
if (!isWellAcquired(p.field.row, p.field.column)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, the logic is to populate a more faithful uniqueWells (excluding the missing wells) and then initialize and populate a reversePlaneLookup map only for the existing wells which makes total sense.

My primary concern with the proposed fix is its computational cost and the potential performance impact on large plates. isWellAcquired returns the existence of a particular well from a loop on PlaneData itself. Having this call nested within a PlaneData loop means an increase of complexity which will scale with the number of wells/fields in a plate.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. I wasn't really thinking about performance for the initial fix, was really trying to verify that it worked. 8e1dac2 is one option that should make isWellAcquired inexpensive for repeated checks on the same well.

continue;
}

p.channelIndex = getChannelIndex(p);

int wellIndex = p.field.row * plate.getPlateColumns() + p.field.column;
Expand Down Expand Up @@ -383,6 +390,9 @@ public int compare(Channel c1, Channel c2) {
for (int i=0; i<planeData.size(); i++) {
Plane p = planeData.get(i);
Field f = p.field;
if (!isWellAcquired(f.row, f.column)) {
continue;
}
int wellNumber = f.row * plate.getPlateColumns() + f.column;
int wellIndex = Arrays.binarySearch(wells, wellNumber);
p.series = FormatTools.positionToRaster(seriesLengths,
Expand Down Expand Up @@ -639,13 +649,19 @@ private String readSanitizedXML(String filename) throws IOException {
}

private boolean isWellAcquired(int row, int col) {
String key = row + "-" + col;
if (acquiredWells.containsKey(key)) {
return acquiredWells.get(key);
}
if (planeData != null) {
for (Plane p : planeData) {
if (p != null && p.file != null && p.field.row == row && p.field.column == col) {
acquiredWells.put(key, true);
return true;
}
}
}
acquiredWells.put(key, false);
return false;
}

Expand Down