Skip to content

Commit

Permalink
Add typeFlags for vigra axistags
Browse files Browse the repository at this point in the history
  • Loading branch information
k-dominik committed Mar 21, 2024
1 parent fa91ac4 commit 3aee23e
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions src/main/java/org/ilastik/ilastik4ij/util/ImgUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -328,11 +328,31 @@ public static List<AxisType> parseAxes(String json) {
public static String axesToJSON(List<AxisType> axes)
{
JSONArray jsonAxesArray = new JSONArray();
for (AxisType axis : axes)
List<AxisType> axes_for_serialization = new ArrayList<>(axes);
Collections.reverse(axes_for_serialization);
for (AxisType axis : axes_for_serialization)
{
JSONObject jsonAxis = new JSONObject();
jsonAxis.put("key", axis.getLabel());
jsonAxesArray.put( jsonAxis );
axis.isSpatial();
String label = axis.getLabel().toLowerCase();
int vigraType;
String vigraKey;
if (axis.isSpatial()){
vigraType = 2;
vigraKey = label;
} else if (label.equals("time")) {
vigraType = 8;
vigraKey = "t";
} else if (label.equals("channel")) {
vigraType = 1;
vigraKey = "c";
} else {
throw new IllegalArgumentException(
String.format("Unknown axis type found with label %s.", label));
}
jsonAxis.put("key", vigraKey);
jsonAxis.put("typeFlags", vigraType);
jsonAxesArray.put(jsonAxis);
}

JSONObject root = new JSONObject();
Expand Down

0 comments on commit 3aee23e

Please sign in to comment.