コード例 #1
0
def test_reorder_lrt_ltr_var_rpts():
    """ 
    This reordering with variable repeats is not supported. In priciple
    it is possible (TI1_R1, TI2_R1, TI2_R2, TI2_R3) but this seems unlikely
    and is probably more likely an error
    """
    d = np.zeros([5, 5, 5, 8])
    for z in range(8):
        d[..., z] = z
    img = AslImage(name="asldata",
                   image=d,
                   tis=[1, 2],
                   rpts=[1, 3],
                   iaf="tc",
                   order='lrt')
    with pytest.raises(Exception):
        img.reorder("ltr")
コード例 #2
0
def test_reorder_lrt_tlr():
    d = np.zeros([5, 5, 5, 8])
    for z in range(8):
        d[..., z] = z
    img = AslImage(name="asldata", image=d, tis=[1, 2], iaf="tc", order='lrt')
    img = img.reorder("tlr")
    assert img.ntis == 2
    assert img.tis == [1, 2]
    assert not img.have_plds
    assert img.rpts == [2, 2]
    assert img.ntc == 2
    assert img.order == "tlr"
    data = img.nibImage.get_data()
    assert list(data.shape) == [5, 5, 5, 8]
    for znew, zold in enumerate([0, 4, 1, 5, 2, 6, 3, 7]):
        assert np.all(data[..., znew] == zold)
コード例 #3
0
def test_reorder_lrt_rtl():
    d = np.zeros([5, 5, 5, 8])
    for z in range(8):
        d[..., z] = z
    img = AslImage(name="asldata", image=d, tis=[1], iaf="tc", order='lrt')
    img = img.reorder("rtl")
    assert img.ntis == 1
    assert img.tis == [1]
    assert not img.have_plds
    assert img.rpts == [4]
    assert img.ntc == 2
    assert img.order == "rtl"
    data = img.nibImage.get_data()
    assert list(data.shape) == [5, 5, 5, 8]
    for z in range(8):
        if z < 4:
            assert np.all(data[..., z] == z * 2)
        else:
            assert np.all(data[..., z] == (z - 4) * 2 + 1)
コード例 #4
0
def test_reorder_tc_ct():
    d = np.zeros([5, 5, 5, 8])
    for z in range(8):
        d[..., z] = z
    img = AslImage(name="asldata", image=d, tis=[1], iaf="tc", order='lrt')
    img = img.reorder(iaf="ct")
    assert img.ntis == 1
    assert img.tis == [1]
    assert not img.have_plds
    assert img.rpts == [4]
    assert img.ntc == 2
    assert img.order == "lrt"
    assert img.iaf == "ct"
    data = img.nibImage.get_data()
    assert list(data.shape) == [5, 5, 5, 8]
    for z in range(8):
        if z % 2 == 0:
            assert np.all(data[..., z] == z + 1)
        else:
            assert np.all(data[..., z] == z - 1)