@Test public void testMultipleAxesOfType() { final Img<ByteType> img = ArrayImgs.bytes(2, 2, 2, 2); final Iterator<long[]> expectedSubscripts = Stream.generate( () -> new long[] { 1, 2 }).limit(4).iterator(); final Iterator<String> expectedStrings = Stream.of("Time: 1, Time(2): 1", "Time: 2, Time(2): 1", "Time: 1, Time(2): 2", "Time: 2, Time(2): 2") .iterator(); final ImgPlus<ByteType> imgPlus = new ImgPlus<>(img, "", X_AXIS, Y_AXIS, T_AXIS, T_AXIS); final List<AxisType> types = Arrays.asList(Axes.X, Axes.Y); final Stream<Subspace<ByteType>> subspaces = splitSubspaces(imgPlus, types); subspaces.forEach(subspace -> { assertTrue(subspace.getAxisTypes().allMatch(t -> t == Axes.TIME)); assertArrayEquals( "The subscripts of the multiple axes of the same type are incorrect", expectedSubscripts.next(), subspace.getSubScripts().toArray()); assertEquals("The string describing the subspace position is incorrect", expectedStrings.next(), subspace.toString()); }); }
public static <T extends RealType<T> & NativeType<T>> Stream<Subspace<T>> splitSubspaces(final ImgPlus<T> hyperStack, final Collection<AxisType> subspaceTypes) { final Builder<Subspace<T>> builder = Stream.builder(); final int[] splitIndices = findSplitAxisIndices(hyperStack, subspaceTypes); final long[] typeSubscripts = mapTypeSubscripts(hyperStack, splitIndices); final int numSplits = splitIndices.length; final HyperAxisMeta[] subspaceMeta = new HyperAxisMeta[numSplits]; final List<ValuePair<IntType, LongType>> split = new ArrayList<>(); splitDims(hyperStack, splitIndices, numSplits - 1, subspaceMeta, split, typeSubscripts, builder); return builder.build(); }
HyperstackUtils { public static <T extends RealType<T> & NativeType<T>> Stream<Subspace<T>> splitSubspaces(final ImgPlus<T> hyperStack, final Collection<AxisType> subspaceTypes) { final Builder<Subspace<T>> builder = Stream.builder(); final int[] splitIndices = findSplitAxisIndices(hyperStack, subspaceTypes); final long[] typeSubscripts = mapTypeSubscripts(hyperStack, splitIndices); final int numSplits = splitIndices.length; final HyperAxisMeta[] subspaceMeta = new HyperAxisMeta[numSplits]; final List<ValuePair<IntType, LongType>> split = new ArrayList<>(); splitDims(hyperStack, splitIndices, numSplits - 1, subspaceMeta, split, typeSubscripts, builder); return builder.build(); } }
HyperstackUtils { public static <T extends RealType<T> & NativeType<T>> Stream<Subspace<T>> splitSubspaces(final ImgPlus<T> hyperStack, final Collection<AxisType> subspaceTypes) { final Builder<Subspace<T>> builder = Stream.builder(); final int[] splitIndices = findSplitAxisIndices(hyperStack, subspaceTypes); final long[] typeSubscripts = mapTypeSubscripts(hyperStack, splitIndices); final int numSplits = splitIndices.length; final HyperAxisMeta[] subspaceMeta = new HyperAxisMeta[numSplits]; final List<ValuePair<IntType, LongType>> split = new ArrayList<>(); splitDims(hyperStack, splitIndices, numSplits - 1, subspaceMeta, split, typeSubscripts, builder); return builder.build(); } private  HyperstackUtils(); }
HyperstackUtils { public static <T extends RealType<T> & NativeType<T>> Stream<Subspace<T>> splitSubspaces(final ImgPlus<T> hyperStack, final Collection<AxisType> subspaceTypes) { final Builder<Subspace<T>> builder = Stream.builder(); final int[] splitIndices = findSplitAxisIndices(hyperStack, subspaceTypes); final long[] typeSubscripts = mapTypeSubscripts(hyperStack, splitIndices); final int numSplits = splitIndices.length; final HyperAxisMeta[] subspaceMeta = new HyperAxisMeta[numSplits]; final List<ValuePair<IntType, LongType>> split = new ArrayList<>(); splitDims(hyperStack, splitIndices, numSplits - 1, subspaceMeta, split, typeSubscripts, builder); return builder.build(); } private  HyperstackUtils(); static Stream<Subspace<T>> split3DSubspaces(final ImgPlus<T> hyperStack); static Stream<Subspace<T>> splitSubspaces(final ImgPlus<T> hyperStack,
			final Collection<AxisType> subspaceTypes); }
HyperstackUtils { public static <T extends RealType<T> & NativeType<T>> Stream<Subspace<T>> splitSubspaces(final ImgPlus<T> hyperStack, final Collection<AxisType> subspaceTypes) { final Builder<Subspace<T>> builder = Stream.builder(); final int[] splitIndices = findSplitAxisIndices(hyperStack, subspaceTypes); final long[] typeSubscripts = mapTypeSubscripts(hyperStack, splitIndices); final int numSplits = splitIndices.length; final HyperAxisMeta[] subspaceMeta = new HyperAxisMeta[numSplits]; final List<ValuePair<IntType, LongType>> split = new ArrayList<>(); splitDims(hyperStack, splitIndices, numSplits - 1, subspaceMeta, split, typeSubscripts, builder); return builder.build(); } private  HyperstackUtils(); static Stream<Subspace<T>> split3DSubspaces(final ImgPlus<T> hyperStack); static Stream<Subspace<T>> splitSubspaces(final ImgPlus<T> hyperStack,
			final Collection<AxisType> subspaceTypes);  }