# Geodesic Regression on Sphere Manifold
# Manifolds
import manifolds
import numpy as np
import StatsModel as sm

import matplotlib.pyplot as plt
# Visualization
import vtk

# Parameters
nDimManifold = 3

# Ground Truth
p_interp = manifolds.sphere(nDimManifold)
v_slope = manifolds.sphere_tVec(nDimManifold)

p_interp.SetPoint([0.0, 0.0, 1.0])
v_slope.SetTangentVector([0, np.pi * 0.25, 0])

# Generating sphere manifolds. distributed over time perturbed by Gaussian random
# Time
t0 = 0
t1 = 2.0

# Generate a random point on the manifold
nData = 500
dim = nDimManifold
sigma = 0.1

pt_list = []
#####################################################

# Generating sphere manifolds. distributed over time perturbed by Gaussian random
# Time
t0 = 0
t1 = 2

# Generate a random point on the manifold
# Parameters
nDimManifold = 3
nData = 200
dim = nDimManifold
sigma = 0.15

# Ground Truth
p_interp = manifolds.sphere(nDimManifold)
v_slope = manifolds.sphere_tVec(nDimManifold)

p_interp.SetPoint([0.0, 0.0, 1.0])
v_slope.SetTangentVector([0, np.pi * 0.25, 0])

# Point List
# Base Function ( Geodesic )
pt_list = []

# Projected sin on the base point function at time t
pt_list_proj_sin = []

# Time List
t_list = []
Example #3
0
    arrow_transform = vtk.vtkTransform()
    arrow_transform.Translate(start_point)
    arrow_transform.Concatenate(tVec_at_b0_mat)
    arrow_transform.Scale(length, length, length)
    arrow_transform.Update()

    transformPD = vtk.vtkTransformPolyDataFilter()
    transformPD.SetInputData(arrowBase.GetOutput())
    transformPD.SetTransform(arrow_transform)
    transformPD.Update()

    return transformPD.GetOutput()


# Base Intercept Point
beta0 = manifolds.sphere(nDimManifold)
beta0.SetPoint([1, 0, 0])

gamma1 = manifolds.sphere_tVec(nDimManifold)
gamma1.SetTangentVector([0.0, -0.3, 0.0])

tVec_to_f_i = manifolds.sphere_tVec(nDimManifold)
tVec_to_f_i.SetTangentVector([0.0, -1.0, 0.0])

f_i = beta0.ExponentialMap(tVec_to_f_i)
# f_i.SetPoint( [ 0, 1, 0 ] )

gamma1_f_i = beta0.ParallelTranslateAtoB(beta0, f_i, gamma1)

pt_sigma = 0.15
            # Set CM-Rep Abstract Point
            cmrep_ij = manifolds.cmrep_abstract(nAtoms)

            # Center
            center_ij = manifolds.euclidean(3)
            # print( "Center Of Mass " )
            center_ij.SetPoint(cenOfMass)

            # Scale
            scale_ij = manifolds.pos_real(1)
            # print( "Scale" )

            scale_ij.SetPoint(length_HX)

            # Abstract Position
            pos_ij = manifolds.sphere(3 * (nAtoms - 1))

            # print( "Abstract Position" )
            # print( np.array( Z_H_flatten ).flatten().shape )
            # print( 3 * ( nAtoms - 1 ) )

            pos_ij.SetPoint(np.array(Z_H_flatten).flatten())

            # Radius
            rad_ij = manifolds.pos_real(nAtoms)
            # print( "Radius" )
            rad_ij.SetPoint(rad_arr)

            # CM-Rep Point
            pt_abs = [center_ij, scale_ij, pos_ij, rad_ij]
            # print( "CMRep Abstract Point" )
Example #5
0
#				 	Data Generation					#
#####################################################
# Generating sphere manifolds. distributed over time perturbed by Gaussian random
# Time
t0 = 0
t1 = 2

# Generate a random point on the manifold
# Parameters
nDimManifold = 3
nData = 200
dim = nDimManifold
sigma = 0.15

# Population Bias
p_bias = manifolds.sphere(nDimManifold)
v_bias = manifolds.sphere_tVec(nDimManifold)

p_bias.SetPoint([0.0, 0.0, 1.0])
v_bias.SetTangentVector([0, np.pi * 0.1, 0])

bias_param_t0 = 0.0
bias_param_t1 = 3.0

nSubj = 10
bias_step = (bias_param_t1 - bias_param_t0) / float(nSubj - 1)

# Subject-wise Ground Truth
subj_t0 = -0.5
subj_t1 = 0.5
Example #6
0
print( eucl_pt_r.Type )

# Sphere
sphere_tVec = manifolds.sphere_tVec( 3 )
sphere_tVec.SetTangentVector( [ 0, 0.8192, 0 ] ) 

sphere_tVec.Write( "sphere_tVec.tvec" )

sphere_tVec_r = manifolds.sphere_tVec( 3 )
sphere_tVec_r.Read( "sphere_tVec.tvec" )

print( sphere_tVec_r.tVector )
print( sphere_tVec_r.nDim )
print( sphere_tVec_r.Type )

sphere_pt = manifolds.sphere( 3 )
sphere_pt.SetPoint( [ 0.0, 1.0, 0.0 ] )
sphere_pt.Write( "sphere.rpt" )

sphere_pt_r = manifolds.sphere( 3 )
sphere_pt_r.Read( "sphere.rpt" )

print( sphere_pt_r.pt )
print( sphere_pt_r.nDim ) 
print( sphere_pt_r.Type )

# Pos Real 
pos_real_tVec = manifolds.pos_real_tVec( 1 )
pos_real_tVec.SetTangentVector( 2 ) 

pos_real_tVec.Write( "pos_real_tVec.tvec" )
Example #7
0
            normal2_arr = []

            for k in range(nAtoms):
                pos = polyData.GetPoint(k)
                pos_cen = np.subtract(pos, cenOfMass)
                polyData_cen.GetPoints().SetPoint(k, pos_cen)

                pos_centered_arr.append(pos_cen)

                spoke1 = polyData.GetPointData().GetArray("Spoke1").GetTuple(k)
                spoke1 = np.divide(spoke1, np.linalg.norm(spoke1))

                spoke2 = polyData.GetPointData().GetArray("Spoke2").GetTuple(k)
                spoke2 = np.divide(spoke2, np.linalg.norm(spoke2))

                normal1_k = manifolds.sphere(3)
                normal2_k = manifolds.sphere(3)

                normal1_k.SetPoint(spoke1)
                normal2_k.SetPoint(spoke2)

                normal1_arr.append(normal1_k)
                normal2_arr.append(normal2_k)

                rad = polyData.GetPointData().GetArray(
                    "Radius Function").GetValue(k)
                rad_arr.append(rad)

            pos_centered_arr_flatten = np.matrix(pos_centered_arr).flatten()
            print(pos_centered_arr_flatten.shape)