test_preprocessing.py 文件源码

python
阅读 34 收藏 0 点赞 0 评论 0

项目:brainiak 作者: brainiak 项目源码 文件源码
def test_prepare_fcma_data():
    images = io.load_images_from_dir(data_dir, suffix=suffix)
    mask = io.load_boolean_mask(mask_file)
    conditions = io.load_labels(epoch_file)
    raw_data, _, labels = prepare_fcma_data(images, conditions, mask)
    expected_raw_data = np.load(expected_dir / 'expected_raw_data.npy')
    assert len(raw_data) == len(expected_raw_data), \
        'numbers of epochs do not match in test_prepare_fcma_data'
    for idx in range(len(raw_data)):
        assert np.allclose(raw_data[idx], expected_raw_data[idx]), \
            'raw data do not match in test_prepare_fcma_data'
    assert np.array_equal(labels, expected_labels), \
        'the labels do not match in test_prepare_fcma_data'
    from brainiak.fcma.preprocessing import RandomType
    images = io.load_images_from_dir(data_dir, suffix=suffix)
    random_raw_data, _, _ = prepare_fcma_data(images, conditions, mask,
                                              random=RandomType.REPRODUCIBLE)
    assert len(random_raw_data) == len(expected_raw_data), \
        'numbers of epochs do not match in test_prepare_fcma_data'
    images = io.load_images_from_dir(data_dir, suffix=suffix)
    random_raw_data, _, _ = prepare_fcma_data(images, conditions, mask,
                                              random=RandomType.UNREPRODUCIBLE)
    assert len(random_raw_data) == len(expected_raw_data), \
        'numbers of epochs do not match in test_prepare_fcma_data'
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号