Skip to content

Commit

Permalink
Merge pull request #3925 from melissalinkert/vsi-blob-files-develop
Browse files Browse the repository at this point in the history
Olympus .vsi: only read pixels from frame_*.ets files
  • Loading branch information
dgault authored Jan 27, 2023
2 parents d3be809 + c46deeb commit 3493350
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
18 changes: 16 additions & 2 deletions components/formats-gpl/src/loci/formats/in/CellSensReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,8 @@ public class CellSensReader extends FormatReader {
// -- Fields --

private String[] usedFiles;
// non-pixels files that are included in the directory (e.g. "blobs")
private ArrayList<String> extraFiles = new ArrayList<String>();
private HashMap<Integer, String> fileMap = new HashMap<Integer, String>();

private TiffParser parser;
Expand Down Expand Up @@ -451,7 +453,15 @@ public String[] getSeriesUsedFiles(boolean noPixels) {
FormatTools.assertId(currentId, true, 1);

// all files contain pixels
return noPixels ? null : usedFiles;
if (noPixels) {
return extraFiles.toArray(new String[extraFiles.size()]);
}
String[] allFiles = new String[extraFiles.size() + usedFiles.length];
System.arraycopy(usedFiles, 0, allFiles, 0, usedFiles.length);
for (int i=0; i<extraFiles.size(); i++) {
allFiles[usedFiles.length + i] = extraFiles.get(i);
}
return allFiles;
}

/* @see loci.formats.IFormatReader#getOptimalTileWidth() */
Expand Down Expand Up @@ -591,6 +601,7 @@ public void close(boolean fileOnly) throws IOException {
parser = null;
ifds = null;
usedFiles = null;
extraFiles.clear();
fileMap.clear();
tileOffsets.clear();
jpeg = false;
Expand Down Expand Up @@ -673,9 +684,12 @@ protected void initFile(String id) throws FormatException, IOException {
if (pixelsFiles != null) {
Arrays.sort(pixelsFiles);
for (String pixelsFile : pixelsFiles) {
if (checkSuffix(pixelsFile, "ets")) {
if (checkSuffix(pixelsFile, "ets") && pixelsFile.startsWith("frame_")) {
files.add(new Location(stackDir, pixelsFile).getAbsolutePath());
}
else {
extraFiles.add(new Location(stackDir, pixelsFile).getAbsolutePath());
}
}
}
}
Expand Down
20 changes: 18 additions & 2 deletions components/test-suite/src/loci/tests/testng/FormatReaderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2010,7 +2010,15 @@ else if (success) {
{
continue;
}


// .vsi datasets can only be detected with .vsi and frame*.ets
if (reader.getFormat().equals("CellSens VSI") &&
((!base[i].toLowerCase().endsWith(".vsi") && !base[i].toLowerCase().endsWith(".ets")) ||
(base[i].toLowerCase().endsWith(".ets") && !base[i].toLowerCase().startsWith("frame"))))
{
continue;
}

// XLef datasets not detected from xlif/lof file
if (reader.getFormat().equals("Extended leica file") &&
(base[i].toLowerCase().endsWith("xlif") || base[i].toLowerCase().endsWith("lof")
Expand Down Expand Up @@ -2801,7 +2809,15 @@ else if (!result && r instanceof OlympusTileReader &&
{
continue;
}


// .vsi data can only be detected from .vsi and frame*.ets
if (!result && r instanceof CellSensReader &&
((!used[i].endsWith(".vsi") && !used[i].endsWith(".ets")) ||
(used[i].endsWith(".ets") && !used[i].startsWith("frame"))))
{
continue;
}

// XLEF data can only be detected from xlef file
if (!result && readers[j] instanceof XLEFReader &&
(used[i].endsWith(".xlif") || used[i].endsWith(".xlcf") ||
Expand Down

0 comments on commit 3493350

Please sign in to comment.