Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.nio.ByteOrder;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayDeque;
import java.util.Deque;
Expand Down Expand Up @@ -149,14 +150,7 @@ public NDTiffStorage(String dir) throws IOException {
tiled_ = true; //Backwards compat
}

try {
String path = dir + (dir.endsWith(File.separator) ? "" : File.separator)
+ "display_settings.txt";
byte[] data = Files.readAllBytes(Paths.get(path));
displaySettings_ = new JSONObject(new String(data, StandardCharsets.UTF_8));
} catch (Exception e) {
System.err.println("Couldn't read displaysettings");
}
displaySettings_ = readDisplaySettings(dir);

imageAxes_.addAll(fullResStorage_.imageKeys().stream()
.map(s -> IndexEntryData.deserializeAxes(s))
Expand Down Expand Up @@ -246,13 +240,7 @@ public Thread newThread(Runnable r) {
tiled_ = true;
}

try {
String path = dir + "display_settings.txt";
byte[] data = Files.readAllBytes(Paths.get(path));
displaySettings_ = new JSONObject(new String(data, StandardCharsets.UTF_8));
} catch (Exception e) {
// display settings optional
}
displaySettings_ = readDisplaySettings(dir);

imageAxes_.addAll(fullResStorage_.imageKeys().stream()
.map(s -> IndexEntryData.deserializeAxes(s))
Expand Down Expand Up @@ -399,6 +387,31 @@ public void setDisplaySettings(JSONObject displaySettings) {
}
}

/**
* Reads display settings from disk. Recent versions of Micro-Manager write
* DisplaySettings.json (a Property Map); older versions wrote display_settings.txt.
* Both are tried, preferring the newer name, since the file is optional and only
* gets written if the dataset was ever shown live in Micro-Manager's viewer.
*/
private JSONObject readDisplaySettings(String dir) {
dir += (dir.endsWith(File.separator) ? "" : File.separator);
for (String filename : new String[] {"DisplaySettings.json", "display_settings.txt"}) {
Path path = Paths.get(dir + filename);
if (!Files.exists(path)) {
continue;
}
try {
byte[] data = Files.readAllBytes(path);
return new JSONObject(new String(data, StandardCharsets.UTF_8));
} catch (Exception e) {
if (debugLogger_ != null) {
debugLogger_.accept("Couldn't parse " + filename + ": " + e.getMessage());
}
}
}
return null;
}

public String getUniqueAcqName() {
return uniqueAcqName_ + ""; //make new instance
}
Expand Down