@@ -576,7 +576,7 @@ public <T extends RealType<T> & NativeType<T>, M extends N5DatasetMetadata, N ex
576
576
Arrays .fill (relativeFactors , 1 );
577
577
578
578
if (s > 0 ) {
579
- relativeFactors = getRelativeDownsampleFactors (currentMetadata , currentChannelImg . numDimensions () , s , currentAbsoluteDownsampling );
579
+ relativeFactors = getRelativeDownsampleFactors (currentMetadata , currentChannelImg , s , currentAbsoluteDownsampling );
580
580
581
581
// update absolute downsampling factors
582
582
for (int i = 0 ; i < nd ; i ++)
@@ -615,7 +615,7 @@ public <T extends RealType<T> & NativeType<T>, M extends N5DatasetMetadata, N ex
615
615
anyScalesWritten = true ;
616
616
617
617
// chunkSize variable is updated by the write method
618
- if (lastScale (chunkSize , currentChannelImg ))
618
+ if (lastScale (chunkSize , currentChannelImg , currentMetadata ))
619
619
break ;
620
620
}
621
621
@@ -725,13 +725,15 @@ protected <N extends SpatialMetadataGroup<?>> N finalizeMultiscaleMetadata(final
725
725
return multiscaleMetadata ;
726
726
}
727
727
728
- protected boolean lastScale (final int [] chunkSize , final Interval imageDimensions ) {
728
+ protected <M extends N5Metadata > boolean lastScale (final int [] chunkSize , final Interval imageDimensions , final M metadata ) {
729
+
730
+ final Axis [] axes = getAxes (metadata , imageDimensions .numDimensions ());
729
731
730
732
for (int i = 0 ; i < imageDimensions .numDimensions (); i ++) {
731
- if (imageDimensions .dimension (i ) <= chunkSize [i ])
732
- return true ;
733
+ if (axes [ i ]. getType (). equals ( Axis . SPACE ) && imageDimensions .dimension (i ) > chunkSize [i ])
734
+ return false ;
733
735
}
734
- return false ;
736
+ return true ;
735
737
}
736
738
737
739
protected <M extends N5DatasetMetadata > void fillResolution (final M baseMetadata , final double [] resolution ) {
@@ -866,17 +868,18 @@ protected <M extends N5Metadata> long[] getDownsampleFactors(final M metadata, f
866
868
return factors ;
867
869
}
868
870
869
- protected <M extends N5Metadata > long [] getRelativeDownsampleFactors (final M metadata , final int nd , final int scale ,
871
+ protected <M extends N5Metadata > long [] getRelativeDownsampleFactors (final M metadata , final Interval img , final int scale ,
870
872
final long [] downsampleFactors ) {
871
873
874
+ int nd = img .numDimensions ();
872
875
final Axis [] axes = getAxes (metadata , nd );
873
876
874
877
// under what condisions is nd != axes.length
875
878
final long [] factors = new long [axes .length ];
876
879
for (int i = 0 ; i < nd ; i ++) {
877
880
878
881
// only downsample spatial dimensions
879
- if (axes [i ].getType ().equals (Axis .SPACE ))
882
+ if (axes [i ].getType ().equals (Axis .SPACE ) && img . dimension ( i ) > 1 )
880
883
factors [i ] = 2 ;
881
884
else
882
885
factors [i ] = 1 ;
0 commit comments