Skip to content

Commit

Permalink
Fixed issue with WholeSlideImporter opening wrong frame_t file
Browse files Browse the repository at this point in the history
  • Loading branch information
smistad committed Feb 9, 2024
1 parent 8d19677 commit 629a506
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions source/FAST/Importers/WholeSlideImageImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,7 @@ void WholeSlideImageImporter::readVSI(std::string filename) {
std::string etsFilename = "";
for(auto folder : getDirectoryList(directoryName, false, true)) {
if(fileExists(join(directoryName, folder, "frame_t.ets"))) {
if(!etsFilename.empty()) {
// If multiple files: use the one which have correct compression.. (normal lossy JPEG)
if(!etsFilename.empty()) { // Multiple files
auto stream = new std::ifstream(join(directoryName, folder, "frame_t.ets"), std::ifstream::binary | std::ifstream::in);
if(!stream->is_open())
continue;
Expand Down Expand Up @@ -177,8 +176,11 @@ void WholeSlideImageImporter::readVSI(std::string filename) {
READ(ets_header.dimy)
READ(ets_header.dimz)

if(ets_header.compression == 2 || ets_header.compression == 0)
etsFilename = join(directoryName, folder, "frame_t.ets");
if(ets_header.compression == 2 || ets_header.compression == 0) { // Correct compression?
auto newFilename = join(directoryName, folder, "frame_t.ets");
if(fileSize(etsFilename) < fileSize(newFilename)) // If multiple files, select biggest one..
etsFilename = newFilename;
}
stream->close();
delete stream;
} else {
Expand All @@ -187,7 +189,7 @@ void WholeSlideImageImporter::readVSI(std::string filename) {
}
}
if(etsFilename.empty())
throw Exception("Could not find frame_t.ets file under " + directoryName + " while importing " + filename);
throw Exception("Could not find frame_t.ets file with valid compression under " + directoryName + " while importing " + filename);

std::ifstream* stream = new std::ifstream(etsFilename.c_str(), std::ifstream::binary | std::ifstream::in);
if(!stream->is_open())
Expand Down

0 comments on commit 629a506

Please sign in to comment.