def check_voxel(mask_index, ref_voxel, datarange): """ Check if the voxel centrosymmetric to ref_voxel belongs also to the datarange. :param mask_index: tuple of three integers, indices of the masked voxel :param ref_voxel: tuple of three integers, indices of the origin of reciprocal space :param datarange: tuple of six integers (z_start, z_stop, y_start, y_stop, x_tart, x_stop) representing the range of valid indices :return: tuple (boolean, mask_index, sym_index) where boolean is True if the centrosymmetric voxel belongs to the datarange and sym_index is a tuple of three integers representing it's indices. """ # calculate the position of the centrosymmetric voxel sym_z, sym_y, sym_x = (2 * ref_voxel[0] - mask_index[0], 2 * ref_voxel[1] - mask_index[1], 2 * ref_voxel[2] - mask_index[2]) # check if this voxel is masked. Copy its intensity if not. if util.in_range(point=(sym_z, sym_y, sym_x), extent=datarange): return True, mask_index, (sym_z, sym_y, sym_x) return False, None, None
def test_inrange_larger_edge_z(self): self.assertTrue(util.in_range(point=(99, 0, 20), extent=self.extent))
def test_inrange_not_in_range_high_x(self): self.assertFalse(util.in_range(point=(0, 0, 120), extent=self.extent))
def test_inrange_not_in_range_low_x(self): self.assertFalse(util.in_range(point=(0, 0, 9), extent=self.extent))
def test_inrange_not_in_range_low_y(self): self.assertFalse(util.in_range(point=(0, -21, 20), extent=self.extent))
def test_inrange_not_in_range_low_z(self): self.assertFalse(util.in_range(point=(-11, 0, 20), extent=self.extent))
def test_inrange_in_range(self): self.assertTrue(util.in_range(point=(0, 0, 20), extent=self.extent))
def test_inrange_larger_edge_x(self): self.assertTrue(util.in_range(point=(0, 0, 119), extent=self.extent))
def test_inrange_lower_edge_y(self): self.assertTrue(util.in_range(point=(0, -20, 20), extent=self.extent))