def compute(self, roi: Tuple[DataRoi, ConnectedComponentsExtractor]) -> Array5D: """Outputs a Array5D where shape.x is the highest label extracted from the provided DataRoi. Channels are the stacked channels of the features in self.feature_names""" feature_map = self.get_timewise_feature_map(roi) timewise_features = [ Array5D.from_stack(list(frame_features.values()), stack_along="c") for frame_features in feature_map.values() ] return Array5D.from_stack(timewise_features, stack_along="t")
def test_from_stack(): stack = [ Array5D(numpy.asarray([[0, 1, 2], [3, 4, 5], [6, 7, 8]]), axiskeys="yx"), Array5D(numpy.asarray([[7, 2, 2], [3, 1, 5], [2, 7, 3]]), axiskeys="yx"), Array5D(numpy.asarray([[4, 2, 1], [3, 4, 0], [2, 4, 1]]), axiskeys="yx"), ] z_stacked = Array5D.from_stack(stack, stack_along="z") for i in range(len(stack)): assert (z_stacked.cut(Slice5D(z=i)).raw("yx") == stack[i].raw("yx")).all() y_stacked = Array5D.from_stack(stack, stack_along="y") for i in range(len(stack)): stack_slc = Slice5D(y=slice(3 * i, 3 * (i + 1))) assert (y_stacked.cut(stack_slc).raw("yx") == stack[i].raw("yx")).all()