def intensities(self, codebook=None) -> IntensityTable: if codebook is None: codebook = self.codebook() intensities = IntensityTable.synthetic_intensities( codebook, self.n_z, self.height, self.width, self.n_spots, self.mean_fluor_per_spot, self.mean_photons_per_fluor) assert intensities.dtype == np.float32 and intensities.max() <= 1 return intensities
def test_synthetic_intensities_generates_correct_number_of_features( loaded_codebook): n_spots = 2 intensities = IntensityTable.synthetic_intensities(loaded_codebook, n_spots=n_spots) assert isinstance(intensities, IntensityTable) # shape should have n_spots and channels and hybridization rounds equal to the codebook's shape assert intensities.shape == (n_spots, *loaded_codebook.shape[1:])
def test_synthetic_intensities_have_correct_number_of_on_features( loaded_codebook): n_spots = 2 intensities = IntensityTable.synthetic_intensities(loaded_codebook, n_spots=n_spots) on_features = np.sum(intensities.values != 0) # this asserts that the number of features "on" in intensities should be equal to the # number of "on" features in the codewords, times the total number of spots in intensities. assert on_features == loaded_codebook.sum( (Indices.CH, Indices.HYB)).values.mean() * n_spots
def intensities(self, codebook=None) -> IntensityTable: if codebook is None: codebook = self.codebook() return IntensityTable.synthetic_intensities( codebook, self.n_z, self.height, self.width, self.n_spots, self.mean_fluor_per_spot, self.mean_photons_per_fluor)
def synthetic_intensity_table(loaded_codebook) -> IntensityTable: return IntensityTable.synthetic_intensities(loaded_codebook, n_spots=2)