Skip to content

Commit

Permalink
Fix issue if 'labels' part of filename
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikl committed Dec 5, 2024
1 parent f0e4caf commit 1fe4861
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/loci/formats/in/ZarrReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -1119,19 +1119,25 @@ private Number getDouble(Map<String, Object> 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<String> usedFiles = new ArrayList<String>();
reloadOptionsFile(zarrRootPath);

boolean skipPixels = noPixels || !listPixels() || !systemEnvListPixels();
boolean includeLabels = includeLabels();
try (Stream<Path> 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")) ||
(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());
});
.forEach(path -> {
if (
(!skipPixels && includeLabels) ||
(!skipPixels && !includeLabels && (path.toString().toLowerCase().lastIndexOf("labels")<rootPathLength) ||
(skipPixels && includeLabels && (path.endsWith(".zgroup") || path.endsWith(".zattrs") || path.endsWith(".xml"))) ||
(skipPixels && !includeLabels && (path.toString().toLowerCase().lastIndexOf("labels")<rootPathLength) &&(path.endsWith(".zgroup") || path.endsWith(".zattrs") || path.endsWith(".xml")))))
{
usedFiles.add(path.toFile().getAbsolutePath());
}
}
);
} catch (IOException e) {
e.printStackTrace();
}
Expand Down

0 comments on commit 1fe4861

Please sign in to comment.