Esempio n. 1
0
    def filter(self,
               stack: ImageStack,
               in_place: bool = True) -> Optional[ImageStack]:
        """Perform filtering of an image stack

        Parameters
        ----------
        stack : ImageStack
            Stack to be filtered.
        in_place : bool
            if True, process ImageStack in-place, otherwise return a new stack

        Returns
        -------
        Optional[ImageStack] :
            if in-place is False, return the results of filter as a new stack

        """
        high_pass: Callable = partial(self.high_pass, sigma=self.sigma)
        result = stack.apply(high_pass,
                             is_volume=self.is_volume,
                             verbose=self.verbose,
                             in_place=in_place)
        if not in_place:
            return result
        return None
    def filter(self,
               stack: ImageStack,
               in_place: bool = True) -> Optional[ImageStack]:
        """Perform filtering of an image stack

        Parameters
        ----------
        stack : ImageStack
            Stack to be filtered.
        in_place : bool
            if True, process ImageStack in-place, otherwise return a new stack

        Returns
        -------
        Optional[ImageStack] :
            if in-place is False, return the results of filter as a new stack

        """
        func: Callable = partial(self.richardson_lucy_deconv,
                                 num_iter=self.num_iter,
                                 psf=self.psf,
                                 clip=self.clip)
        result = stack.apply(func, in_place=in_place, verbose=self.verbose)
        if not in_place:
            return result
        return None
Esempio n. 3
0
    def filter(self,
               stack: ImageStack,
               in_place: bool = True) -> Optional[ImageStack]:
        """Perform filtering of an image stack

        Parameters
        ----------
        stack : ImageStack
            Stack to be filtered.
        in_place : bool
            if True, process ImageStack in-place, otherwise return a new stack

        Returns
        -------
        Optional[ImageStack] :
            if in-place is False, return the results of filter as a new stack

        """
        clip = partial(self.clip, p_min=self.p_min, p_max=self.p_max)
        result = stack.apply(clip,
                             is_volume=self.is_volume,
                             verbose=self.verbose,
                             in_place=in_place)
        if not in_place:
            return result
        return None
    def find(self, stack: ImageStack):
        """
        Find spots.

        Parameters
        ----------
        stack : ImageStack
            Stack where we find the spots in.
        """
        spot_attributes: List[SpotAttributes] = stack.apply(
            self.find_attributes,
            in_place=False,
            is_volume=self.is_volume,
            verbose=self.verbose)

        # TODO ambrosejcarr: do we need to find spots in the aux_dict too?

        # TODO ambrosejcarr: this is where development stopped; spot_attributes is correct, but translating
        # spot_attributes into an encoder_table is tricky without first implementing the new codebook. Do that first.
        # create an encoded table
        # encoded_spots = self.encode(spot_attributes.data)

        return spot_attributes
Esempio n. 5
0
    def filter(self, stack: ImageStack, in_place: bool=True) -> Optional[ImageStack]:
        """Perform filtering of an image stack

        Parameters
        ----------
        stack : ImageStack
            Stack to be filtered.
        in_place : bool
            if True, process ImageStack in-place, otherwise return a new stack

        Returns
        -------
        Optional[ImageStack] :
            if in-place is False, return the results of filter as a new stack

        """
        bandpass_ = partial(
            self.bandpass, lshort=self.lshort, llong=self.llong, threshold=self.threshold, truncate=self.truncate
        )
        result = stack.apply(bandpass_, verbose=self.verbose, in_place=in_place)
        if not in_place:
            return result
        return None
Esempio n. 6
0
    def filter(self,
               stack: ImageStack,
               in_place: bool = True) -> Optional[ImageStack]:
        """Perform filtering of an image stack

        Parameters
        ----------
        stack : ImageStack
            Stack to be filtered.
        in_place : bool
            if True, process ImageStack in-place, otherwise return a new stack

        Returns
        -------
        Optional[ImageStack] :
            if in-place is False, return the results of filter as a new stack

        """
        from scipy.ndimage.filters import maximum_filter, minimum_filter
        from skimage.morphology import disk

        def white_tophat(image):
            if image.dtype.kind != "u":
                raise TypeError(
                    "images should be stored in an unsigned integer array")
            structuring_element = disk(self.disk_size)
            min_filtered = minimum_filter(image, footprint=structuring_element)
            max_filtered = maximum_filter(min_filtered,
                                          footprint=structuring_element)
            filtered_image = image - np.minimum(image, max_filtered)
            return filtered_image

        result = stack.apply(white_tophat)
        if not in_place:
            return result
        return None