diff --git a/src/loci/formats/in/ZarrReader.java b/src/loci/formats/in/ZarrReader.java index b4dcb00..6c2e4f6 100644 --- a/src/loci/formats/in/ZarrReader.java +++ b/src/loci/formats/in/ZarrReader.java @@ -1127,6 +1127,7 @@ private Double getDouble(Map src, String key) { public String[] getUsedFiles(boolean noPixels) { FormatTools.assertId(currentId, true, 1); String zarrRootPath = currentId.substring(0, currentId.indexOf(".zarr") + 5); + int rootPathLength = zarrRootPath.length(); ArrayList usedFiles = new ArrayList(); reloadOptionsFile(zarrRootPath); @@ -1134,11 +1135,11 @@ public String[] getUsedFiles(boolean noPixels) { boolean includeLabels = includeLabels(); try (Stream paths = Files.walk(Paths.get(zarrRootPath), FileVisitOption.FOLLOW_LINKS)) { paths.filter(Files::isRegularFile) - .forEach(path -> {if ((!skipPixels && includeLabels) || - (!skipPixels && !includeLabels && !path.toString().toLowerCase().contains("labels")) || + .forEach(path -> { if ((!skipPixels && includeLabels) || + (!skipPixels && !includeLabels && !(path.toString().toLowerCase().indexOf("labels")>=rootPathLength)) || (skipPixels && includeLabels && (path.endsWith(".zgroup") || path.endsWith(".zattrs") || path.endsWith(".xml"))) || - (skipPixels && !includeLabels && !path.toString().toLowerCase().contains("labels") &&(path.endsWith(".zgroup") || path.endsWith(".zattrs") || path.endsWith(".xml")))) - usedFiles.add(path.toFile().getAbsolutePath()); + (skipPixels && !includeLabels && !(path.toString().toLowerCase().indexOf("labels")>=rootPathLength) &&(path.endsWith(".zgroup") || path.endsWith(".zattrs") || path.endsWith(".xml")))) + usedFiles.add(path.toFile().getAbsolutePath()); }); } catch (IOException e) { e.printStackTrace();