|
@ -14,9 +14,10 @@ class Monocycle1Tests(unittest.TestCase): |
|
|
def tearDown(self): |
|
|
def tearDown(self): |
|
|
self.nd2.close() |
|
|
self.nd2.close() |
|
|
|
|
|
|
|
|
|
|
|
def test_channels(self): |
|
|
|
|
|
self.assertListEqual(self.nd2.channels, ['Cy3Narrow', 'TxRed-modified', 'FITC', 'DAPI']) |
|
|
|
|
|
|
|
|
def test_select(self): |
|
|
def test_select(self): |
|
|
# If we take the first 20 GFP images, they should be identical to the first 20 items iterated from select() |
|
|
|
|
|
# if we set our criteria to just "GFP" |
|
|
|
|
|
manual_images = [] |
|
|
manual_images = [] |
|
|
for _, image in zip(range(20), self.nd2): |
|
|
for _, image in zip(range(20), self.nd2): |
|
|
if image is not None and image.channel == 'FITC': |
|
|
if image is not None and image.channel == 'FITC': |
|
@ -39,7 +40,9 @@ class Monocycle1Tests(unittest.TestCase): |
|
|
def test_select_order_all(self): |
|
|
def test_select_order_all(self): |
|
|
# If we select every possible image using select(), we should just get every image in order |
|
|
# If we select every possible image using select(), we should just get every image in order |
|
|
n = 0 |
|
|
n = 0 |
|
|
for image in self.nd2.select(channels=['Cy3Narrow', 'DAPI', 'FITC', 'TxRed-modified'], z_levels=list(range(35)), fields_of_view=list(range(5))): |
|
|
|
|
|
|
|
|
for image in self.nd2.select(channels=['Cy3Narrow', 'DAPI', 'FITC', 'TxRed-modified'], |
|
|
|
|
|
z_levels=list(range(35)), |
|
|
|
|
|
fields_of_view=list(range(5))): |
|
|
while True: |
|
|
while True: |
|
|
indexed_image = self.nd2[n] |
|
|
indexed_image = self.nd2[n] |
|
|
if indexed_image is not None: |
|
|
if indexed_image is not None: |
|
@ -48,14 +51,17 @@ class Monocycle1Tests(unittest.TestCase): |
|
|
self.assertTrue(np.array_equal(image, indexed_image)) |
|
|
self.assertTrue(np.array_equal(image, indexed_image)) |
|
|
n += 1 |
|
|
n += 1 |
|
|
if n > 100: |
|
|
if n > 100: |
|
|
# Quit after the first hundred images just to save time. If there's a problem, we'll have seen it by now. |
|
|
|
|
|
|
|
|
# Quit after the first hundred images just to save time. |
|
|
|
|
|
# If there's a problem, we'll have seen it by now. |
|
|
break |
|
|
break |
|
|
|
|
|
|
|
|
def test_select_order_subset(self): |
|
|
def test_select_order_subset(self): |
|
|
# Test that images are always yielded in increasing order. This guarantees that no matter what subset of images |
|
|
# Test that images are always yielded in increasing order. This guarantees that no matter what subset of images |
|
|
# we're filtering, we still get them in the chronological order they were acquired |
|
|
# we're filtering, we still get them in the chronological order they were acquired |
|
|
n = -1 |
|
|
n = -1 |
|
|
for image in self.nd2.select(channels='FITC', z_levels=[0, 1], fields_of_view=[1, 2, 4]): |
|
|
|
|
|
|
|
|
for image in self.nd2.select(channels='FITC', |
|
|
|
|
|
z_levels=[0, 1], |
|
|
|
|
|
fields_of_view=[1, 2, 4]): |
|
|
self.assertGreater(image.index, n) |
|
|
self.assertGreater(image.index, n) |
|
|
self.assertEqual(image.channel, 'FITC') |
|
|
self.assertEqual(image.channel, 'FITC') |
|
|
self.assertIn(image.field_of_view, (1, 2, 4)) |
|
|
self.assertIn(image.field_of_view, (1, 2, 4)) |
|
@ -73,8 +79,6 @@ class Monocycle2Tests(unittest.TestCase): |
|
|
self.nd2.close() |
|
|
self.nd2.close() |
|
|
|
|
|
|
|
|
def test_select(self): |
|
|
def test_select(self): |
|
|
# If we take the first 20 HHQ 500 LP 1 images, they should be identical to the first 20 items iterated from select() |
|
|
|
|
|
# if we set our criteria to just "HHQ 500 LP 1" |
|
|
|
|
|
manual_images = [] |
|
|
manual_images = [] |
|
|
for _, image in zip(range(20), self.nd2): |
|
|
for _, image in zip(range(20), self.nd2): |
|
|
if image is not None and image.channel == 'HHQ 500 LP 1': |
|
|
if image is not None and image.channel == 'HHQ 500 LP 1': |
|
@ -97,7 +101,9 @@ class Monocycle2Tests(unittest.TestCase): |
|
|
def test_select_order_all(self): |
|
|
def test_select_order_all(self): |
|
|
# If we select every possible image using select(), we should just get every image in order |
|
|
# If we select every possible image using select(), we should just get every image in order |
|
|
n = 0 |
|
|
n = 0 |
|
|
for image in self.nd2.select(channels=['HHQ 500 LP 1', 'HHQ 500 LP 2'], z_levels=[0], fields_of_view=list(range(100))): |
|
|
|
|
|
|
|
|
for image in self.nd2.select(channels=['HHQ 500 LP 1', 'HHQ 500 LP 2'], |
|
|
|
|
|
z_levels=[0], |
|
|
|
|
|
fields_of_view=list(range(100))): |
|
|
while True: |
|
|
while True: |
|
|
indexed_image = self.nd2[n] |
|
|
indexed_image = self.nd2[n] |
|
|
if indexed_image is not None: |
|
|
if indexed_image is not None: |
|
@ -106,14 +112,17 @@ class Monocycle2Tests(unittest.TestCase): |
|
|
self.assertTrue(np.array_equal(image, indexed_image)) |
|
|
self.assertTrue(np.array_equal(image, indexed_image)) |
|
|
n += 1 |
|
|
n += 1 |
|
|
if n > 100: |
|
|
if n > 100: |
|
|
# Quit after the first hundred images just to save time. If there's a problem, we'll have seen it by now. |
|
|
|
|
|
|
|
|
# Quit after the first hundred images just to save time. |
|
|
|
|
|
# If there's a problem, we'll have seen it by now. |
|
|
break |
|
|
break |
|
|
|
|
|
|
|
|
def test_select_order_subset(self): |
|
|
def test_select_order_subset(self): |
|
|
# Test that images are always yielded in increasing order. This guarantees that no matter what subset of images |
|
|
# Test that images are always yielded in increasing order. This guarantees that no matter what subset of images |
|
|
# we're filtering, we still get them in the chronological order they were acquired |
|
|
# we're filtering, we still get them in the chronological order they were acquired |
|
|
n = -1 |
|
|
n = -1 |
|
|
for image in self.nd2.select(channels='HHQ 500 LP 2', z_levels=[0], fields_of_view=[1, 2, 4]): |
|
|
|
|
|
|
|
|
for image in self.nd2.select(channels='HHQ 500 LP 2', |
|
|
|
|
|
z_levels=[0], |
|
|
|
|
|
fields_of_view=[1, 2, 4]): |
|
|
self.assertGreater(image.index, n) |
|
|
self.assertGreater(image.index, n) |
|
|
self.assertEqual(image.channel, 'HHQ 500 LP 2') |
|
|
self.assertEqual(image.channel, 'HHQ 500 LP 2') |
|
|
self.assertIn(image.field_of_view, (1, 2, 4)) |
|
|
self.assertIn(image.field_of_view, (1, 2, 4)) |
|
|