def afb3D_A(x, af, d):
    lpf=af[:, 0]
    hpf=af[:, 1]
    # permute dimensions of x so that dimension d is first.
    p=[(i+d)%3 for i in xrange(3)]
    x=x.transpose(p)
    # filter along dimension 0
    (N1, N2, N3)=x.shape
    L=af.shape[0]//2
    x=cshift3D(x, -L, 0);
    n1Half=N1//2
    lo=np.zeros((L+n1Half, N2, N3));
    hi=np.zeros((L+n1Half, N2, N3));
    for k in xrange(N3):
        lo[:, :, k]=firdn(x[:, :, k], lpf);
    lo[:L]=lo[:L]+lo[n1Half:n1Half+L, :, :];
    lo=lo[:n1Half, :, :];
    
    for k in xrange(N3):
        hi[:, :, k]=firdn(x[:, :, k], hpf);
    hi[:L]=hi[:L]+hi[n1Half:n1Half+L, :, :];
    hi=hi[:n1Half, :, :];
    #permute dimensions of x (inverse permutation)
    q=permutationInverse(p)
    lo=lo.transpose(q)
    hi=hi.transpose(q)
    return lo, hi
dataset/ETHPy150Open neuropoly/spinalcordtoolbox/dev/denoise/aonlm/wavelet/afb3D.py/afb3D_A/original