Beispiel #1
0
 def detect_foci(self, showplot=False):
     '''
     Clusters that are big enough can be considered foci and could be assigned
     as transcription sites in later steps.
     Key params:
     radius : int
     The maximum distance between two samples for one to be considered as
     in the neighborhood of the other. Radius expressed in nanometer.
     nb_min_spots : int
     The number of spots in a neighborhood for a point to be considered as
     a core point (from which a cluster is expanded). This includes the
     point itself.
     '''
     self.spots_and_foci, self.foci = detection.detect_foci(
         self.spots_post_decomposition, self.voxel_size_z,
         self.voxel_size_yx, self.foci_radius, self.nb_in_foci)
     if showplot:
         plot.plot_detection(
             self.rna_mip,
             [self.spots_post_decomposition, self.foci[:, :3]],
             path_output=f'{self.plotdir}/{self.fov_name}foci',
             ext='png',
             shape=["circle", "polygon"],
             radius=[self.radius_yx, self.radius_yx * 2],
             color=["red", "blue"],
             linewidth=[1, 2],
             fill=[False, True],
             framesize=(10, 8),
             contrast=True,
             show=self.show)
    def detect_spots(self):
        # sigma
        sigma_z, sigma_xy, sigma_xy = detection.get_sigma(self.voxel_size_z,
                                                          self.voxel_size_xy,
                                                          self.psf_z, self.psf_xy)

        sigma = (sigma_z, sigma_xy, sigma_xy)

        # LoG filter
        rna_log = stack.log_filter(self.rna, sigma)

        # local maximum detection
        mask = detection.local_maximum_detection(rna_log, min_distance=sigma)

        # thresholding
        threshold = detection.automated_threshold_setting(rna_log, mask)
        spots, _ = detection.spots_thresholding(rna_log, mask, threshold)

        #note radius
        (radius_z, radius_xy, radius_xy) = detection.get_radius(self.voxel_size_z,
                                                                self.voxel_size_xy,
                                                                self.psf_z, self.psf_xy)
        self.sigma_z = sigma_z
        self.sigma_xy = sigma_xy
        self.radius_z = radius_z
        self.radius_xy = radius_xy
        self.threshold = threshold
        self.spots = spots
        plot.plot_detection(self.rna_mip, self.spots, radius=self.radius_xy,
                            framesize=(10, 8), contrast=True, show=False,
                            path_output=f'{self.plotdir}/{self.fov_name}spots',
                            ext='png')
Beispiel #3
0
    def decompose_clusters(self, showplot=False):
        #Cluster detection: try to decompose clusters of spots into individual foci.
        # alpha impacts the number of spots per cluster
        # beta impacts the number of detected clusters
        self.spots_post_decomposition, self.clusters, self.reference_spot = \
        detection.decompose_cluster(self.rna, self.spots, self.voxel_size_z,
                                    self.voxel_size_yx, self.psf_z, self.psf_yx,
                                    alpha=0.7, beta=1)

        plot.plot_reference_spot(
            self.reference_spot,
            path_output=f'{self.plotdir}/{self.fov_name}refspot',
            ext='png',
            contrast=True,
            show=self.show)
        if showplot:
            plot.plot_detection(
                self.rna_mip,
                self.spots_post_decomposition,
                radius=self.radius_yx,
                framesize=(10, 8),
                contrast=True,
                show=self.show,
                path_output=f'{self.plotdir}/{self.fov_name}clusters',
                ext='png')
    def detect_foci(self):
        #Clusters that are big enough can be considered foci
        self.spots_post_clustering, self.foci = detection.detect_foci(
                                                self.spots_post_decomposition,
                                                self.voxel_size_z, self.voxel_size_xy,
                                                self.cluster_radius, self.nb_in_cluster)

        plot.plot_detection(self.rna_mip, [self.spots_post_decomposition, self.foci[:, :3]],
                            path_output = f'{self.plotdir}/{self.fov_name}foci',
                            ext='png', shape=["circle", "polygon"],
                            radius=[self.radius_xy, self.radius_xy*2],
                            color=["red", "blue"], linewidth=[1, 2],
                            fill=[False, True], framesize=(10, 8), contrast=True,
                            show=False)
Beispiel #5
0
    def detect_spots(self, showplot=False):
        # sigma
        sigma_z, sigma_yx, sigma_yx = detection.get_sigma(
            self.voxel_size_z, self.voxel_size_yx, self.psf_z, self.psf_yx)

        sigma = (sigma_z, sigma_yx, sigma_yx)

        # LoG filter
        rna_log = stack.log_filter(self.rna, sigma)

        # local maximum detection
        mask = detection.local_maximum_detection(rna_log, min_distance=sigma)

        if self.manual_threshold is not None:
            spots, _ = detection.spots_thresholding(rna_log, mask,
                                                    self.manual_threshold)
            self.threshold = self.manual_threshold
            self.threshold_type = 'manual'

        else:
            # thresholding
            threshold = detection.automated_threshold_setting(rna_log, mask)
            spots, _ = detection.spots_thresholding(rna_log, mask, threshold)
            self.threshold = threshold
            self.threshold_type = 'auto'

        #note radius
        (radius_z, radius_yx,
         radius_yx) = detection.get_radius(self.voxel_size_z,
                                           self.voxel_size_yx, self.psf_z,
                                           self.psf_yx)
        self.sigma_z = sigma_z
        self.sigma_yx = sigma_yx
        self.radius_z = radius_z
        self.radius_yx = radius_yx
        self.rna_log = rna_log
        self.mask = mask
        self.spots = spots
        if showplot:
            plot.plot_detection(
                self.rna_mip,
                self.spots,
                radius=self.radius_yx,
                framesize=(10, 8),
                contrast=True,
                show=self.show,
                path_output=f'{self.plotdir}/{self.fov_name}spots',
                ext='png')