@Test public void testSplitSubspaces() { final long tSize = 3; final long cSize = 3; final long wSize = 3; final long expectedSubspaces = tSize * cSize * wSize; final long depth = 2; final long height = 10; final long width = 15; final Img<ByteType> img = ArrayImgs.bytes(width, height, depth, wSize, cSize, tSize); final ImgPlus<ByteType> imgPlus = new ImgPlus<>(img, "", X_AXIS, Y_AXIS, Z_AXIS, W_AXIS, C_AXIS, T_AXIS); final List<Subspace<ByteType>> subspaces = HyperstackUtils.split3DSubspaces( imgPlus).collect(Collectors.toList()); assertEquals("Wrong number of subspaces", expectedSubspaces, subspaces .size()); subspaces.stream().map(s -> s.interval).forEach(v -> { assertEquals("Subspace has wrong number of dimensions", 3, v .numDimensions()); assertEquals("Incorrect max X", width - 1, v.max(0)); assertEquals("Incorrect min X", 0, v.min(0)); assertEquals("Incorrect max Y", height - 1, v.max(1)); assertEquals("Incorrect min Y", 0, v.min(1)); assertEquals("Incorrect max Z", depth - 1, v.max(2)); assertEquals("Incorrect min Z", 0, v.min(2)); }); }
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);  }