Skip to content
Snippets Groups Projects
Commit 2491ddf1 authored by Christopher Randolph Rhodes's avatar Christopher Randolph Rhodes
Browse files

Can make patch stack from itself

parent 6a98fe2f
No related branches found
No related tags found
No related merge requests found
......@@ -12,9 +12,13 @@ class MonoPatchStack(InMemoryDataAccessor):
:param data: either np.ndarray of dimensions YXn, or a list of np.ndarrays of size YX
"""
if isinstance(data, np.ndarray): # interpret as YXZ
assert data.ndim == 3
self._data = np.expand_dims(data, 2)
if isinstance(data, np.ndarray):
if data.ndim == 3: # interpret as YXZ
self._data = np.expand_dims(data, 2)
elif data.ndim == 4: # interpret as a copy another patch stack
self._data = data
else:
raise InvalidDataForPatchStackError()
elif isinstance(data, list): # list of YX patches
if len(data) == 0:
self._data = np.ndarray([0, 0, 0, 0], dtype='uin9')
......
......@@ -28,6 +28,14 @@ class TestCziImageFileAccess(unittest.TestCase):
self.assertEqual(acc.count, n)
self.assertEqual(acc.hw, (h, w))
self.assertEqual(acc.make_tczyx().shape, (n, 1, 1, h, w))
return acc
def test_make_patch_stack_clone(self):
w = 256
h = 512
n = 4
acc = MonoPatchStack([np.random.rand(h, w) for _ in range(0, n)])
self.assertEqual(MonoPatchStack(acc.data).shape, acc.shape)
def test_make_patch_stack_from_file(self):
h = monozstackmask['h']
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment