Beispiel #1
0
def test_compute_multi_gray_matter_mask():
    pytest.raises(TypeError, compute_multi_gray_matter_mask, [])

    # Check error raised if images with different shapes are given as input
    imgs = [
        Nifti1Image(np.ones((9, 9, 9)), np.eye(4)),
        Nifti1Image(np.ones((9, 9, 8)), np.eye(4))
    ]
    pytest.raises(ValueError, compute_multi_gray_matter_mask, imgs)

    # Check results are the same if affine is the same
    rng = np.random.RandomState(42)
    imgs1 = [
        Nifti1Image(rng.standard_normal(size=(9, 9, 9)), np.eye(4)),
        Nifti1Image(rng.standard_normal(size=(9, 9, 9)), np.eye(4))
    ]
    mask1 = compute_multi_gray_matter_mask(imgs1)

    imgs2 = [
        Nifti1Image(rng.standard_normal(size=(9, 9, 9)), np.eye(4)),
        Nifti1Image(rng.standard_normal(size=(9, 9, 9)), np.eye(4))
    ]
    mask2 = compute_multi_gray_matter_mask(imgs2)

    assert_array_equal(get_data(mask1), get_data(mask2))
Beispiel #2
0
def test_deprecation_warning_compute_multi_gray_matter_mask():
    imgs = [Nifti1Image(np.ones((9, 9, 9)), np.eye(4)),
            Nifti1Image(np.ones((9, 9, 9)), np.eye(4))]
    if distutils.version.LooseVersion(sklearn.__version__) < '0.22':
        with pytest.deprecated_call():
            masking.compute_multi_gray_matter_mask(imgs)
    else:
        with pytest.warns(FutureWarning,
                          match="renamed to 'compute_multi_brain_mask'"):
            masking.compute_multi_gray_matter_mask(imgs)
Beispiel #3
0
def test_compute_multi_gray_matter_mask():
    assert_raises(TypeError, compute_multi_gray_matter_mask, [])

    # Check error raised if images with different shapes are given as input
    imgs = [Nifti1Image(np.ones((9, 9, 9)), np.eye(4)),
            Nifti1Image(np.ones((9, 9, 8)), np.eye(4))]
    assert_raises(ValueError, compute_multi_gray_matter_mask, imgs)

    # Check results are the same if affine is the same
    imgs1 = [Nifti1Image(np.random.randn(9, 9, 9), np.eye(4)),
            Nifti1Image(np.random.randn(9, 9, 9), np.eye(4))]
    mask1 = compute_multi_gray_matter_mask(imgs1)

    imgs2 = [Nifti1Image(np.random.randn(9, 9, 9), np.eye(4)),
             Nifti1Image(np.random.randn(9, 9, 9), np.eye(4))]
    mask2 = compute_multi_gray_matter_mask(imgs2)

    assert_array_equal(mask1.get_data(), mask2.get_data())
Beispiel #4
0
def test_compute_multi_gray_matter_mask():
    assert_raises(TypeError, compute_multi_gray_matter_mask, [])

    # Check error raised if images with different shapes are given as input
    imgs = [
        Nifti1Image(np.ones((9, 9, 9)), np.eye(4)),
        Nifti1Image(np.ones((9, 9, 8)), np.eye(4))
    ]
    assert_raises(ValueError, compute_multi_gray_matter_mask, imgs)

    # Check results are the same if affine is the same
    imgs1 = [
        Nifti1Image(np.random.randn(9, 9, 9), np.eye(4)),
        Nifti1Image(np.random.randn(9, 9, 9), np.eye(4))
    ]
    mask1 = compute_multi_gray_matter_mask(imgs1)

    imgs2 = [
        Nifti1Image(np.random.randn(9, 9, 9), np.eye(4)),
        Nifti1Image(np.random.randn(9, 9, 9), np.eye(4))
    ]
    mask2 = compute_multi_gray_matter_mask(imgs2)

    assert_array_equal(mask1.get_data(), mask2.get_data())