コード例 #1
0
def compute_stability(gene, bootstrap=500, force2D=True):
    total_mads = []
    imageset = ImageSet(analysis_repo, ["mrna/" + gene + "/"], force2D=force2D)
    spots_peripheral_distances = imageset.compute_spots_peripheral_distance()
    peripheral_profiles = np.zeros((len(spots_peripheral_distances), 10))
    for j in range(len(spots_peripheral_distances)):
        for i in range(0, 10):
            peripheral_profiles[j, i] = float(
                len(
                    np.where((spots_peripheral_distances[j] >= (
                        (i * 10) + 1)) & (spots_peripheral_distances[j] <=
                                          (i + 1) * 10))[0]) /
                float(len(spots_peripheral_distances[j])))
    logger.info(
        "Compute mean_absolute_deviation for randomly selected images in {} dataset",
        gene)
    for j in tqdm.tqdm(range(bootstrap), desc="Simulation"):
        mads = []
        for i in range(1, len(imageset.images) - 1):
            arr = peripheral_profiles[np.random.choice(
                peripheral_profiles.shape[0], i, replace=True)]
            rand_idx = randint(0, peripheral_profiles.shape[0] - 1)
            mean_arr = np.mean(arr, axis=0)
            arr_diff = mean_arr - peripheral_profiles[rand_idx, :]
            mse = helpers.mean_absolute_deviation(arr_diff)
            mads.append(mse)
        total_mads.append(mads)
    return total_mads
コード例 #2
0
ファイル: test_imageSet.py プロジェクト: cbib/dypfish
 def test_compute_spots_peripheral_distance(self):
     image_set = ImageSet(self.repo, path_list=['mrna/arhgdia/2h/'])
     result = image_set.compute_spots_peripheral_distance()
     total_sum=0
     for res in result:
         total_sum += np.sum(res)
     self.assertEqual(total_sum, 20030.0)