コード例 #1
0
ファイル: test_boot.py プロジェクト: JuergenNeubauer/osmosis
def test_dyad():
    """
    Test the dyadic tensor and coherence based on the dyadic tensor
    """

    eigs1 = [np.eye(3), np.eye(3)]
    dyad = ozb.dyadic_tensor(eigs1, average=True)

    npt.assert_equal(ozb.dyad_coherence(dyad), 1.0)

    # For this collection of eigenvectors: 
    eigs2 = np.array([[[1,0,0],[0,2,0],[0,0,3]],[[1,0,0],[0,2,0],[0,0,3]]])
    dyad_dist = ozb.dyadic_tensor(eigs2, average=False)

    # The dispersion should be null:
    npt.assert_equal(ozb.dyad_dispersion(dyad_dist), 0)
コード例 #2
0
ファイル: test_boot.py プロジェクト: zhangerjun/osmosis
def test_dyad():
    """
    Test the dyadic tensor and coherence based on the dyadic tensor
    """

    eigs1 = [np.eye(3), np.eye(3)]
    dyad = ozb.dyadic_tensor(eigs1, average=True)

    npt.assert_equal(ozb.dyad_coherence(dyad), 1.0)

    # For this collection of eigenvectors:
    eigs2 = np.array([[[1, 0, 0], [0, 2, 0], [0, 0, 3]],
                      [[1, 0, 0], [0, 2, 0], [0, 0, 3]]])
    dyad_dist = ozb.dyadic_tensor(eigs2, average=False)

    # The dispersion should be null:
    npt.assert_equal(ozb.dyad_dispersion(dyad_dist), 0)
コード例 #3
0
ファイル: dti.py プロジェクト: JuergenNeubauer/osmosis
def _dyad_stats(tensor_model_list, mask=None, dyad_stat=boot.dyad_coherence,
                average=True):
    """
    Helper function that does most of the work on calcualting dyad statistics
    """
    if mask is None:
        mask = np.ones(tensor_model_list[0].shape[:3])
        
    # flatten the eigenvectors:
    tensor_model_flat=np.array([this.evecs[np.where(mask)] for this in
    tensor_model_list])
    out_flat = np.empty(tensor_model_flat[0].shape[0])

    # Loop over voxels
    for idx in xrange(tensor_model_flat.shape[1]):
        dyad = boot.dyadic_tensor(tensor_model_flat[:,idx,:,:],
                                  average=average)
        out_flat[idx] = dyad_stat(dyad)

    out = ozu.nans(tensor_model_list[0].shape[:3])
    out[np.where(mask)] = out_flat
    return out        
コード例 #4
0
def _dyad_stats(tensor_model_list,
                mask=None,
                dyad_stat=boot.dyad_coherence,
                average=True):
    """
    Helper function that does most of the work on calcualting dyad statistics
    """
    if mask is None:
        mask = np.ones(tensor_model_list[0].shape[:3])

    # flatten the eigenvectors:
    tensor_model_flat = np.array(
        [this.evecs[np.where(mask)] for this in tensor_model_list])
    out_flat = np.empty(tensor_model_flat[0].shape[0])

    # Loop over voxels
    for idx in xrange(tensor_model_flat.shape[1]):
        dyad = boot.dyadic_tensor(tensor_model_flat[:, idx, :, :],
                                  average=average)
        out_flat[idx] = dyad_stat(dyad)

    out = ozu.nans(tensor_model_list[0].shape[:3])
    out[np.where(mask)] = out_flat
    return out