def test_compute_cell_mask_between_nucleus_centroids(self): image_set = ImageSet(self.repo, path_list=['mrna/actn2/immature/']) nuc_dist, nucs_dist, cell_masks, nucs_pos = image_set.compute_cell_mask_between_nucleus_centroids() self.assertEqual(np.sum([754, 483, 526]), np.sum(nuc_dist)) self.assertEqual(len([754]) + len([483, 526]), len(nucs_dist[0]) + len(nucs_dist[1])) for nuc_pos in nucs_pos: if len(nuc_pos) == 1: self.assertEqual(nuc_pos[0],[110, 864]) else: self.assertEqual(nuc_pos[0], [154, 637]) self.assertEqual(nuc_pos[1], [637, 1163])
secondary_fp = pathlib.Path(dataset_root_fp, constants.dataset_config['SECONDARY_FILE_NAME']) analysis_repo = H5RepositoryWithCheckpoint(repo_path=primary_fp, secondary_repo_path=secondary_fp) z_line_spacing = constants.analysis_config['Z_LINE_SPACING'] band_n = constants.analysis_config['STRIPE_NUM'] molecule_type = ['/mrna'] genes = ['actn2-mature', 'gapdh-mature', 'actn2-immature'] # figure 8C degree of clustering for muscle data for g in genes: [gene, timepoint] = g.split("-") image_set = ImageSet(analysis_repo, [f"{'mrna'}/{gene}/{timepoint}/"]) nuc_dist, nucs_dist, cell_masks, nucs_pos = image_set.compute_cell_mask_between_nucleus_centroids( ) # compute histogram mod hx, hy, _ = plt.hist(nuc_dist) bin_max = np.where(hx == hx.max())[0] hist_mod = hy[bin_max] if len(hist_mod) > 1: hist_mod = np.mean(hist_mod) # compute density by stripe and build spline wave graph image_counter = 0 for im in image_set.get_images(): nucleus_mask = im.get_nucleus_mask() nucleus_centroids = im.get_multiple_nucleus_centroid() spots = im.get_spots() z_lines = im.get_z_lines_masks()