def test_xsvs(): images = [] for i in range(5): int_array = np.tril((i + 2) * np.ones(10)) int_array[int_array == 0] = (i + 1) images.append(int_array) images_sets = [ np.asarray(images), ] roi_data = np.array(([4, 2, 2, 2], [0, 5, 4, 4]), dtype=np.int64) label_array = roi.rectangles(roi_data, shape=images[0].shape) prob_k_all, std = xsvs.xsvs(images_sets, label_array, timebin_num=2, number_of_img=5, max_cts=6) assert_array_almost_equal(prob_k_all[0, 0], np.array([0., 0., 0.2, 0.2, 0.4])) assert_array_almost_equal(prob_k_all[0, 1], np.array([0., 0.2, 0.2, 0.2, 0.4])) imgs = [] for i in range(6): int_array = np.tril((i + 2) * np.ones(10)) int_array[int_array == 0] = (i + 1) imgs.append(int_array) # testing for bad images bad_list = [5] # convert each bad image to np.nan array images1 = mask.bad_to_nan_gen(imgs, bad_list) new_prob_k, new_std = xsvs.xsvs((images1, ), label_array, timebin_num=2, number_of_img=5, max_cts=6) assert_array_almost_equal(new_prob_k[0, 0], np.array([0., 0., 0.2, 0.2, 0.4])) assert_array_almost_equal(new_prob_k[0, 1], np.array([0., 0.2, 0.2, 0.2, 0.4]))
def test_xsvs(): images = [] for i in range(5): int_array = np.tril((i + 2) * np.ones(10)) int_array[int_array == 0] = (i + 1) images.append(int_array) images_sets = [np.asarray(images), ] roi_data = np.array(([4, 2, 2, 2], [0, 5, 4, 4]), dtype=np.int64) label_array = roi.rectangles(roi_data, shape=images[0].shape) prob_k_all, std = xsvs.xsvs(images_sets, label_array, timebin_num=2, number_of_img=5, max_cts=6) assert_array_almost_equal(prob_k_all[0, 0], np.array([0., 0., 0.2, 0.2, 0.4])) assert_array_almost_equal(prob_k_all[0, 1], np.array([0., 0.2, 0.2, 0.2, 0.4])) imgs = [] for i in range(6): int_array = np.tril((i + 2) * np.ones(10)) int_array[int_array == 0] = (i + 1) imgs.append(int_array) # testing for bad images bad_list = [5] # convert each bad image to np.nan array images1 = mask.bad_to_nan_gen(imgs, bad_list) new_prob_k, new_std = xsvs.xsvs((images1, ), label_array, timebin_num=2, number_of_img=5, max_cts=6) assert_array_almost_equal(new_prob_k[0, 0], np.array([0., 0., 0.2, 0.2, 0.4])) assert_array_almost_equal(new_prob_k[0, 1], np.array([0., 0.2, 0.2, 0.2, 0.4]))
def test_xsvs(): images = [] for i in range(5): int_array = np.tril((i + 2) * np.ones(10)) int_array[int_array == 0] = (i + 1) images.append(int_array) images_sets = [np.asarray(images), ] roi_data = np.array(([4, 2, 2, 2], [0, 5, 4, 4]), dtype=np.int64) label_array = roi.rectangles(roi_data, shape=images[0].shape) prob_k_all, std = xsvs.xsvs(images_sets, label_array, timebin_num=2, number_of_img=5, max_cts=None) assert_array_almost_equal(prob_k_all[0, 0], np.array([0., 0., 0.2, 0.2, 0.4])) assert_array_almost_equal(prob_k_all[0, 1], np.array([0., 0.2, 0.2, 0.2, 0.4]))