- All Implemented Interfaces:
- com.google.gson.JsonDeserializer<ZarrTransposeCodecInfo.ZarrTransposeOrder>, com.google.gson.JsonSerializer<ZarrTransposeCodecInfo.ZarrTransposeOrder>
- Enclosing class:
- ZarrTransposeCodecInfo
public static class ZarrTransposeCodecInfo.ZarrTransposeOrderAdapter
extends Object
implements com.google.gson.JsonDeserializer<ZarrTransposeCodecInfo.ZarrTransposeOrder>, com.google.gson.JsonSerializer<ZarrTransposeCodecInfo.ZarrTransposeOrder>
Note:
The implementation layer can not directly consume the permutation stored in 'order'
due to changes of indexing (C- vs F-) order.
Zarr specifies that a block with size [z, y, x] will be flattened such that the x-dimension
varies fastest and the z-dimension varies slowest. Because it uses F-order, N5 reverses the
order of these dimensions: the same block in N5 will have size [x, y, z].
If a TranposeCodec is present, conjugating the permutation with a reversal permutation:
reverse * order * reverse
gives the proper behavior.
Example
(C-order)
Suppose order = [1, 2, 0], and labeling the dimensions [z, y, x]
The resulting transposed array will have size [x, z, y].
As a result, the y (x) dimension will vary fastest (slowest).
(F-order)
The F-order axis relabeling of this is [x, y, z] with x (z) varying fastest (slowest)
The permutation we need to apply has to result in [y, z, x] because
we need the y (x) dimensions to vary fastest (slowest) as above
i.e. the permutation is [2, 0, 1]
input: [x, y, z]
"reverse" / "c-to-f-order"
[z, y, x]
apply the given permutation ([1, 2, 0] in this example)
[x, z, y]
"un-reverse" / "f-to-c-order"
[y, z, x]
gives the result tha t we need.