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

cleanup

parent f9a04f7d
No related branches found
No related tags found
No related merge requests found
...@@ -75,7 +75,7 @@ class TestRoiSetMonoProducts(BaseTestRoiSetMonoProducts, unittest.TestCase): ...@@ -75,7 +75,7 @@ class TestRoiSetMonoProducts(BaseTestRoiSetMonoProducts, unittest.TestCase):
ar = roiset.get_df().iloc[1]['area'] ar = roiset.get_df().iloc[1]['area']
self.assertGreaterEqual(sh[0] * sh[1], ar) self.assertGreaterEqual(sh[0] * sh[1], ar)
def test_zmask_works_on_non_zstacks(self, **kwargs): def test_roiset_from_non_zstacks(self, **kwargs):
acc_zstack_slice = InMemoryDataAccessor(self.stack_ch_pa.data[:, :, :, 0]) acc_zstack_slice = InMemoryDataAccessor(self.stack_ch_pa.data[:, :, :, 0])
self.assertEqual(acc_zstack_slice.nz, 1) self.assertEqual(acc_zstack_slice.nz, 1)
id_map = get_label_ids(self.seg_mask) id_map = get_label_ids(self.seg_mask)
...@@ -86,23 +86,14 @@ class TestRoiSetMonoProducts(BaseTestRoiSetMonoProducts, unittest.TestCase): ...@@ -86,23 +86,14 @@ class TestRoiSetMonoProducts(BaseTestRoiSetMonoProducts, unittest.TestCase):
zmask_acc = InMemoryDataAccessor(zmask) zmask_acc = InMemoryDataAccessor(zmask)
self.assertTrue(zmask_acc.is_mask()) self.assertTrue(zmask_acc.is_mask())
def test_zmask_makes_correct_contours(self): def test_slices_are_valid(self):
return self._make_roi_set(mask_type='contours')
def test_zmask_makes_correct_boxes_with_filters(self):
return self._make_roi_set()
def test_zmask_makes_correct_expanded_boxes(self):
return self._make_roi_set()
def test_zmask_slices_are_valid(self):
roiset = self._make_roi_set() roiset = self._make_roi_set()
for s in roiset.get_slices(): for s in roiset.get_slices():
ebb = roiset.acc_raw.data[s] ebb = roiset.acc_raw.data[s]
self.assertEqual(len(ebb.shape), 4) self.assertEqual(len(ebb.shape), 4)
self.assertTrue(np.all([si >= 1 for si in ebb.shape])) self.assertTrue(np.all([si >= 1 for si in ebb.shape]))
def test_zmask_rel_slices_are_valid(self): def test_rel_slices_are_valid(self):
roiset = self._make_roi_set() roiset = self._make_roi_set()
for roi in roiset: for roi in roiset:
ebb = roiset.acc_raw.data[roi.slice] ebb = roiset.acc_raw.data[roi.slice]
...@@ -112,7 +103,7 @@ class TestRoiSetMonoProducts(BaseTestRoiSetMonoProducts, unittest.TestCase): ...@@ -112,7 +103,7 @@ class TestRoiSetMonoProducts(BaseTestRoiSetMonoProducts, unittest.TestCase):
self.assertEqual(len(rbb.shape), 4) self.assertEqual(len(rbb.shape), 4)
self.assertTrue(np.all([si >= 1 for si in rbb.shape])) self.assertTrue(np.all([si >= 1 for si in rbb.shape]))
def test_make_2d_patches_from_zmask(self): def test_make_2d_patches(self):
roiset = self._make_roi_set() roiset = self._make_roi_set()
files = export_patches_from_zstack( files = export_patches_from_zstack(
output_path / '2d_patches', output_path / '2d_patches',
...@@ -121,7 +112,7 @@ class TestRoiSetMonoProducts(BaseTestRoiSetMonoProducts, unittest.TestCase): ...@@ -121,7 +112,7 @@ class TestRoiSetMonoProducts(BaseTestRoiSetMonoProducts, unittest.TestCase):
) )
self.assertGreaterEqual(len(files), 1) self.assertGreaterEqual(len(files), 1)
def test_make_3d_patches_from_zmask(self): def test_make_3d_patches(self):
roiset = self._make_roi_set() roiset = self._make_roi_set()
files = export_patches_from_zstack( files = export_patches_from_zstack(
output_path / '3d_patches', output_path / '3d_patches',
...@@ -160,7 +151,7 @@ class TestRoiSetMonoProducts(BaseTestRoiSetMonoProducts, unittest.TestCase): ...@@ -160,7 +151,7 @@ class TestRoiSetMonoProducts(BaseTestRoiSetMonoProducts, unittest.TestCase):
InMemoryDataAccessor(img) InMemoryDataAccessor(img)
) )
def test_make_binary_masks_from_zmask(self): def test_make_binary_masks(self):
roiset = self._make_roi_set() roiset = self._make_roi_set()
files = roiset.export_patch_masks(output_path / '2d_mask_patches', ) files = roiset.export_patch_masks(output_path / '2d_mask_patches', )
self.assertGreaterEqual(len(files), 1) self.assertGreaterEqual(len(files), 1)
...@@ -303,9 +294,11 @@ class TestRoiSetMultichannelProducts(BaseTestRoiSetMonoProducts, unittest.TestCa ...@@ -303,9 +294,11 @@ class TestRoiSetMultichannelProducts(BaseTestRoiSetMonoProducts, unittest.TestCa
self.assertEqual(result.chroma, 5) self.assertEqual(result.chroma, 5)
def test_multichannel_annotated_zstack(self): def test_multichannel_annotated_zstack(self):
self.roiset.export_annotated_zstack( file = self.roiset.export_annotated_zstack(
output_path / 'multichannel' / 'annotated_zstack', output_path / 'multichannel' / 'annotated_zstack',
'test_multichannel_annotated_zstack', 'test_multichannel_annotated_zstack',
) )
result = generate_file_accessor(Path(file['location']) / file['filename'])
self.assertEqual(result.chroma, self.stack.chroma)
self.assertEqual(result.nz, self.stack.nz)
from uuid import uuid4 from uuid import uuid4
from math import floor
import numpy as np import numpy as np
import pandas as pd import pandas as pd
from pathlib import Path
from skimage.measure import find_contours, label, regionprops_table from skimage.measure import label, regionprops_table
from sklearn.preprocessing import PolynomialFeatures from sklearn.preprocessing import PolynomialFeatures
from sklearn.linear_model import LinearRegression from sklearn.linear_model import LinearRegression
from model_server.base.accessors import GenericImageDataAccessor, InMemoryDataAccessor, write_accessor_data_to_file from model_server.base.accessors import GenericImageDataAccessor, InMemoryDataAccessor, write_accessor_data_to_file
from model_server.base.models import InstanceSegmentationModel from model_server.base.models import InstanceSegmentationModel
from model_server.base.process import pad, rescale, resample_to_8bit
from model_server.extensions.chaeo.annotators import draw_boxes_on_3d_image from model_server.extensions.chaeo.annotators import draw_boxes_on_3d_image
from model_server.extensions.chaeo.products import export_patches_from_zstack from model_server.extensions.chaeo.products import export_patches_from_zstack
......
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