Example #1
0
    def __init__(self, filter_size: int, xextent: tuple, yextent: tuple, img_shape: tuple):
        """

        Args:
            filter_size (int): size of the mean filter
            xextent (tuple): extent in x
            yextent (tuple): extent in y
            img_shape (tuple): image shape
        """
        super().__init__()

        from decode.neuralfitter.utils import padding_calc as padcalc
        """Sanity checks"""
        if filter_size % 2 == 0:
            raise ValueError("ROI size must be odd.")

        self.filter_size = [filter_size, filter_size]
        self.img_shape = img_shape

        pad_x = padcalc.pad_same_calc(self.img_shape[0], self.filter_size[0], 1, 1)
        pad_y = padcalc.pad_same_calc(self.img_shape[1], self.filter_size[1], 1, 1)

        self.padding = torch.nn.ReplicationPad2d((pad_x, pad_x, pad_y, pad_y))  # to get the same output dim

        self.kernel = torch.ones((1, 1, filter_size, filter_size)) / (filter_size * filter_size)
        self.delta_psf = psf_kernel.DeltaPSF(xextent, yextent, img_shape)
        self.bin_x = self.delta_psf._bin_x
        self.bin_y = self.delta_psf._bin_y
            def __init__(self, xextent, yextent, img_shape):
                super().__init__(ix_low=0, ix_high=0)
                self.xextent = xextent
                self.yextent = yextent
                self.img_shape = img_shape

                self.delta = psf_kernel.DeltaPSF(xextent=self.xextent,
                                                 yextent=self.yextent,
                                                 img_shape=self.img_shape)
Example #3
0
    def __init__(self,
                 *,
                 xextent: tuple,
                 yextent: tuple,
                 img_shape: tuple,
                 roi_size: int,
                 weight_mode='const',
                 weight_power: float = None,
                 forward_safety: bool = True,
                 ix_low: Union[int, None] = None,
                 ix_high: Union[int, None] = None,
                 squeeze_batch_dim: bool = False):
        """

        Args:
            xextent (tuple): extent in x
            yextent (tuple): extent in y
            img_shape: image shape
            roi_size (int): roi size of the target
            weight_mode (str): constant or phot
            weight_power (float): power factor of the weight
            forward_safety: check sanity of forward arguments
        """
        super().__init__(ix_low=ix_low,
                         ix_high=ix_high,
                         squeeze_batch_dim=squeeze_batch_dim)

        self.roi_size = roi_size
        self.target_equivalent = target_generator.UnifiedEmbeddingTarget(
            xextent=xextent,
            yextent=yextent,
            img_shape=img_shape,
            roi_size=roi_size,
            ix_low=ix_low,
            ix_high=ix_high)
        self.weight_psf = psf_kernel.DeltaPSF(xextent, yextent, img_shape)

        self.weight_mode = weight_mode
        self.weight_power = weight_power if weight_power is not None else 1.0
        self._forward_safety = forward_safety

        self.check_sanity()
Example #4
0
 def delta_05px(self):
     return psf_kernel.DeltaPSF(xextent=(-0.5, 31.5),
                                yextent=(-0.5, 31.5),
                                img_shape=(64, 64))
Example #5
0
 def delta_1px(self):
     return psf_kernel.DeltaPSF(xextent=(-0.5, 31.5),
                                yextent=(-0.5, 31.5),
                                img_shape=(32, 32))