Source code for allensdk.internal.mouse_connectivity.projection_thumbnail.image_sheet

import functools
import copy as cp
import logging

import numpy as np


[docs]class ImageSheet(object):
[docs] def append(self, new_cell): if not hasattr(self, 'images'): self.images = [new_cell] else: self.images.append(new_cell)
[docs] def apply(self, fn, *args, **kwargs): fn = functools.partial(fn, *args, **kwargs) self.images = map(fn, self.images)
[docs] def copy(self): new_sheet = ImageSheet() new_sheet.images = cp.deepcopy(self.images) return new_sheet
[docs] def get_output(self, axis): output = np.concatenate(self.images, axis=axis) logging.info('concatenated sheet has size: {0}'.format(output.shape)) return output
[docs] @staticmethod def build_from_image(image, n, axis): images = np.split(image, n, axis) sheet = ImageSheet() sheet.images = images return sheet