Skip to content

Commit

Permalink
fix: multichannel export (enable test)
Browse files Browse the repository at this point in the history
* for n5v and ngff metadata
  • Loading branch information
bogovicj committed Dec 4, 2024
1 parent fd63d65 commit 51d49c9
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -643,16 +643,15 @@ protected <M extends N5DatasetMetadata> 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;
Expand All @@ -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() {
Expand Down Expand Up @@ -770,9 +783,14 @@ protected <N extends SpatialMetadataGroup<?>> N finalizeMultiscaleMetadata(final

protected <M extends N5Metadata> 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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" })
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 51d49c9

Please sign in to comment.