diff --git a/components/formats-gpl/src/loci/formats/in/FlexReader.java b/components/formats-gpl/src/loci/formats/in/FlexReader.java index 6a9c78dab21..020e9860380 100644 --- a/components/formats-gpl/src/loci/formats/in/FlexReader.java +++ b/components/formats-gpl/src/loci/formats/in/FlexReader.java @@ -135,6 +135,7 @@ public class FlexReader extends FormatReader { private ArrayList planeExposureTime = new ArrayList(); private ArrayList planeDeltaT = new ArrayList(); + private ArrayList runDirs; private ArrayList flexFiles; private int nFiles = 0; @@ -376,7 +377,7 @@ public void close(boolean fileOnly) throws IOException { reverseFileMapping.clear(); dichroicMap.clear(); filterMap.clear(); - + runDirs = null; } } @@ -390,6 +391,28 @@ protected void initFile(String id) throws FormatException, IOException { measurementFiles = new ArrayList(); acquisitionDates = new HashMap(); + Location currentFile = new Location(id).getAbsoluteFile(); + Location dir = currentFile.getParentFile(); + runDirs = new ArrayList(); + if (!dir.getName().startsWith("Meas_") || !groupPlates()) { + runDirs.add(dir); + } + else { + // look for other acquisitions of the same plate + dir = dir.getParentFile(); + String[] parentDirs = dir.list(true); + Arrays.sort(parentDirs); + for (String d : parentDirs) { + Location f = new Location(dir.getAbsoluteFile(), d); + if (f.isDirectory() && d.startsWith("Meas_")) { + runDirs.add(f); + } + } + } + + runCount = runDirs.size(); + if (runCount == 0) runCount = 1; + if (checkSuffix(id, FLEX_SUFFIX)) { initFlexFile(id); }