class Modeller(object): def __init__(self, beam, detector, min_count=5, nsigma=6, sigma=0.5, kernel_size=9, niter=10): from dials.algorithms.background.gmodel import PixelFilter self.beam = beam self.detector = detector self.min_count = min_count self.nsigma = nsigma self.sigma = sigma self.kernel_size = kernel_size self.niter = niter width, height = detector[0].get_image_size() self._filter = PixelFilter(height, width) self.detector_mask = None def add_image(self, frame, image, mask, reflections): height, width = image.all() _,_,_,_,z0,z1 = reflections['bbox'].parts() selection = (z0 <= frame) & (z1 > frame) subset = reflections.select(selection) sbox_mask = subset['shoebox'].apply_background_mask(frame, 1, (height, width)) if self.detector_mask is None: self.detector_mask = mask mask = mask & sbox_mask self._filter.add(image, mask) def compute(self): from dials.algorithms.background.gmodel import FillGaps from dials.algorithms.image.fill_holes import simple_fill result = self._filter.compute(self.min_count, self.nsigma) data = result.data() mask = result.mask() data = simple_fill(data, mask) fill = FillGaps(self.beam, self.detector[0]) mask = mask.as_1d().as_int() mask = mask - (~self.detector_mask).as_1d().as_int() mask.reshape(data.accessor()) fill(data, mask, self.sigma, self.kernel_size, self.niter) return data
def __init__(self, beam, detector, min_count=5, nsigma=6, sigma=0.5, kernel_size=9, niter=10): from dials.algorithms.background.gmodel import PixelFilter self.beam = beam self.detector = detector self.min_count = min_count self.nsigma = nsigma self.sigma = sigma self.kernel_size = kernel_size self.niter = niter width, height = detector[0].get_image_size() self._filter = PixelFilter(height, width) self.detector_mask = None
class Modeller: def __init__(self, beam, detector, min_count=5, nsigma=6, sigma=0.5, kernel_size=9, niter=10): from dials.algorithms.background.gmodel import PixelFilter self.beam = beam self.detector = detector self.min_count = min_count self.nsigma = nsigma self.sigma = sigma self.kernel_size = kernel_size self.niter = niter width, height = detector[0].get_image_size() self._filter = PixelFilter(height, width) self.detector_mask = None def add_image(self, frame, image, mask, reflections): height, width = image.all() _, _, _, _, z0, z1 = reflections["bbox"].parts() selection = (z0 <= frame) & (z1 > frame) subset = reflections.select(selection) sbox_mask = subset["shoebox"].apply_background_mask( frame, 1, (height, width)) if self.detector_mask is None: self.detector_mask = mask mask = mask & sbox_mask self._filter.add(image, mask) def compute(self): from dials.algorithms.background.gmodel import FillGaps from dials.algorithms.image.fill_holes import simple_fill result = self._filter.compute(self.min_count, self.nsigma) data = result.data() mask = result.mask() data = simple_fill(data, mask) fill = FillGaps(self.beam, self.detector[0]) mask = mask.as_1d().as_int() mask = mask - (~self.detector_mask).as_1d().as_int() mask.reshape(data.accessor()) fill(data, mask, self.sigma, self.kernel_size, self.niter) return data