def test_whole_pixel_shifts(self): self.check_skip() L = 21 dims = (L, L + 2) # avoid square images in tests pos = [7, 13] expected = np.array([pos]) image = np.ones(dims, dtype='uint8') draw_feature(image, pos, 3.75) guess = np.array([[6, 13]]) actual = refine_com(image, image, 6, guess,characterize=False, engine=self.engine)[:, :2][:, ::-1] assert_allclose(actual, expected, atol=0.1) guess = np.array([[7, 12]]) actual = refine_com(image, image, 6, guess, characterize=False, engine=self.engine)[:, :2][:, ::-1] assert_allclose(actual, expected, atol=0.1) guess = np.array([[7, 14]]) actual = refine_com(image, image, 6, guess, characterize=False, engine=self.engine)[:, :2][:, ::-1] assert_allclose(actual, expected, atol=0.1) guess = np.array([[6, 12]]) actual = refine_com(image, image, 6, guess, characterize=False, engine=self.engine)[:, :2][:, ::-1] assert_allclose(actual, expected, atol=0.1)
def refine_com(self, pos_diff=None, signal_dev=None, size_dev=None, noise=None, **kwargs): """ Parameters ---------- noise : integer noise level pos_diff : pixels deviation of p0 from true feature location signal_dev : deviation of feature signal with respect to p0 size_dev : deviation of feature size with respect to p0 """ if pos_diff is None: pos_diff = self.pos_diff if signal_dev is None: signal_dev = self.signal_dev if size_dev is None: size_dev = self.size_dev if noise is None: noise = self.noise # generate image with array of features and deviating signal and size image, expected = self.get_image(noise, signal_dev, size_dev) expected_pos, expected_signal, expected_size = expected p0_pos = self.gen_p0_coords(expected_pos, pos_diff) actual = refine_com(image, image, self.radius, p0_pos, **kwargs) actual = self.from_tp_ndarray(actual) return self.compute_deviations(actual, expected)
def refine_com(self, pos_diff=None, signal_dev=None, size_dev=None, noise=None, **kwargs): """ Parameters ---------- noise : integer noise level pos_diff : pixels deviation of p0 from true feature location signal_dev : deviation of feature signal with respect to p0 size_dev : deviation of feature size with respect to p0 """ if pos_diff is None: pos_diff = self.pos_diff if signal_dev is None: signal_dev = self.signal_dev if size_dev is None: size_dev = self.size_dev if noise is None: noise = self.noise # generate image with array of features and deviating signal and size image, expected = self.get_image(noise, signal_dev, size_dev) expected_pos, expected_signal, expected_size = expected p0_pos = self.gen_p0_coords(expected_pos, pos_diff) actual = refine_com(image, image, self.radius, p0_pos, **kwargs) actual = self.from_dataframe(actual) return self.compute_deviations(actual, expected)
def refine_cluster_com(self, cluster_size, hard_radius, pos_diff=None, signal_dev=None, size_dev=None, noise=None, angle=None, **kwargs): """ Parameters ---------- noise : integer noise level pos_diff : pixels deviation of p0 from true feature location signal_dev : deviation of feature signal with respect to p0 size_dev : deviation of feature size with respect to p0 """ if pos_diff is None: pos_diff = self.pos_diff if signal_dev is None: signal_dev = self.signal_dev if size_dev is None: size_dev = self.size_dev if noise is None: noise = self.noise # generate image with array of features and deviating signal and size image, expected, clusters = self.get_image_clusters( cluster_size, hard_radius, noise, signal_dev, size_dev, angle) expected_pos, expected_signal, expected_size = expected expected_center, expected_angle = clusters p0_pos = self.gen_p0_coords(expected_pos, pos_diff) actual = refine_com(image, image, self.radius, p0_pos, **kwargs) actual = self.from_dataframe(actual) actual_pos, actual_signal, actual_size, pos_err = actual deviations = self.get_deviations(actual_pos, expected_pos, cluster_size, expected_center, expected_angle) return self.compute_deviations_cluster(actual, expected, deviations)
def refine_cluster_com(self, cluster_size, hard_radius, pos_diff=None, signal_dev=None, size_dev=None, noise=None, angle=None, **kwargs): """ Parameters ---------- noise : integer noise level pos_diff : pixels deviation of p0 from true feature location signal_dev : deviation of feature signal with respect to p0 size_dev : deviation of feature size with respect to p0 """ if pos_diff is None: pos_diff = self.pos_diff if signal_dev is None: signal_dev = self.signal_dev if size_dev is None: size_dev = self.size_dev if noise is None: noise = self.noise # generate image with array of features and deviating signal and size image, expected, clusters = self.get_image_clusters(cluster_size, hard_radius, noise, signal_dev, size_dev, angle) expected_pos, expected_signal, expected_size = expected expected_center, expected_angle = clusters p0_pos = self.gen_p0_coords(expected_pos, pos_diff) actual = refine_com(image, image, self.radius, p0_pos, **kwargs) actual = self.from_tp_ndarray(actual) actual_pos, actual_signal, actual_size, pos_err = actual deviations = self.get_deviations(actual_pos, expected_pos, cluster_size, expected_center, expected_angle) return self.compute_deviations_cluster(actual, expected, deviations)