def __init__(self, boundary_radius=None, map_manager=None): ''' Create a mask (map object) with values of 1 except at the map boundaries This will not be a soft mask. To make it a soft mask, follow this with soft_mask(soft_mask_radius = soft_mask_radius) Parameters are: boundary_radius: radius for masking map_manager: source of information for n_real and crystal_symmetryi . origin (0, 0, 0) ''' assert boundary_radius is not None assert (map_manager is not None) n_real = map_manager.map_data().all() self._crystal_symmetry = map_manager.crystal_symmetry() from cctbx.maptbx.segment_and_split_map import get_zero_boundary_map self._mask = get_zero_boundary_map( map_data=map_manager.map_data(), crystal_symmetry=self._crystal_symmetry, radius=boundary_radius) # Set up map_manager with this mask self._map_manager = map_manager.customized_copy(map_data=self._mask) self._map_manager.set_is_mask(True) # Initialize soft mask self._is_soft_mask = False self._is_soft_mask_around_edges = False
def soft_mask_around_edges(self, resolution = None, soft_mask_radius = None, ): ''' Create a new soft mask around the edges of box Parameters: resolution: Resolution to be used in smoothing soft_mask_radius: Distance over which the edge mask affects the map ''' # Checks: assert resolution is not None if soft_mask_radius is None: soft_mask_radius = resolution assert not self.is_soft_mask_around_edges() # do not do it twice from cctbx.maptbx.segment_and_split_map import get_zero_boundary_map, \ smooth_mask_data zero_boundary_map = get_zero_boundary_map( map_data = self._map_manager.map_data(), crystal_symmetry = self.box_crystal_symmetry, radius = soft_mask_radius) original_mask_data = zero_boundary_map.deep_copy() self._mask= smooth_mask_data(mask_data = zero_boundary_map, crystal_symmetry = self.box_crystal_symmetry, rad_smooth = soft_mask_radius) self._is_soft_mask_around_edges = True