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

# Visualization
import matplotlib.pyplot as plt

# Ground Truth
nManifoldDim = 1

p_interp = manifolds.pos_real(nManifoldDim)
v_slope = manifolds.pos_real_tVec(nManifoldDim)

p_interp_vec = 2.0

p_interp.SetPoint(p_interp_vec)
v_slope.SetTangentVector(2.0)

## Random Ground Truth Generation
# random_interp = np.random.rand(3)
# random_interp_n = np.divide( random_interp, np.linalg.norm( random_interp ) )

# random_tangent_vector = np.random.rand(3)
# random_scale = np.random.rand(1) * 2
# random_tangent_vector = np.multiply( random_tangent_vector, random_scale )

# p_interp.SetSpherePt( random_interp_n )
# v_slope.SetTangentVector( random_tangent_vector )
Exemple #2
0
est_pt_list = []
est_t_list = []

base_rad_pt_list = []
tangent_rad_tVec_list = []

for p_i in range(len(point_idx_list)):
    pt_idx = point_idx_list[p_i]
    k_cmrep = nDimStartlist[a] + pt_idx

    base_rad_pt_list.append(base.pt[k_cmrep][1])
    tangent_rad_tVec_list.append(tangent.tVector[k_cmrep][1].tVector[0])

base_rad_pt = rsm.FrechetMean(base_rad_pt_list)
tangent_pt = np.average(tangent_rad_tVec_list)
tangent_rad_pt = manifolds.pos_real_tVec(1)
tangent_rad_pt.tVector[0] = tangent_pt

for t in range(nTimePt):
    time_pt = (tN - t0) * t / (nTimePt - 1) + t0

    v_t = manifolds.pos_real_tVec(1)
    v_t.SetTangentVector(np.multiply(tangent_rad_pt.tVector, time_pt).tolist())
    mean = base_rad_pt.ExponentialMap(v_t)

    est_pt_list.append(mean.pt)
    est_t_list.append(time_pt)

########################################
#####        Visualization        ######
########################################
Exemple #3
0
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" )

pos_real_tVec_r = manifolds.pos_real_tVec( 1 )
pos_real_tVec_r.Read( "pos_real_tVec.tvec" )

print( pos_real_tVec_r.tVector )
print( pos_real_tVec_r.nDim )
print( pos_real_tVec_r.Type )

pos_real_pt = manifolds.pos_real( 1 )
pos_real_pt.SetPoint( 4.0 )
pos_real_pt.Write( "pos_real.rpt" )
Exemple #4
0
for n in range( nData ):
	pt_list_a.append( CMRepDataList[ n ].pt[ k_cmrep ][ 1 ].pt )
	t_list_a.append( ageList[ n ] )

est_pt_list = [] 
est_t_list = []

for t in range( nTimePt ):
	time_pt = ( tN - t0 ) * t / ( nTimePt - 1 ) + t0

	base_rad_pt = base.pt[ k_cmrep ][ 1 ]
	tangent_rad_pt = tangent.tVector[ k_cmrep ][ 1 ]


	v_t = manifolds.pos_real_tVec( 1 )
	v_t.SetTangentVector( np.multiply( tangent_rad_pt.tVector, time_pt ).tolist() )
	mean = base_rad_pt.ExponentialMap( v_t )

	est_pt_list.append( mean.pt ) 
	est_t_list.append( time_pt ) 


########################################
#####        Visualization        ######   
########################################
font = {'family' : 'normal',
        'weight' : 'bold',
        'size'   : 12}

plt.rc('font', **font)
# Visualization
import vtk

# Stats Model
import statsmodels.api as sm

# Pandas
import pandas as pd
import matplotlib.pyplot as plt

# Ground Truth
nManifoldDim = 1

p_interp = manifolds.pos_real(nManifoldDim)
v_slope = manifolds.pos_real_tVec(nManifoldDim)

p_interp_vec = 2.0

p_interp.SetPoint(p_interp_vec)
v_slope.SetTangentVector(2.0)

## Random Ground Truth Generation
# random_interp = np.random.rand(3)
# random_interp_n = np.divide( random_interp, np.linalg.norm( random_interp ) )

# random_tangent_vector = np.random.rand(3)
# random_scale = np.random.rand(1) * 2
# random_tangent_vector = np.multiply( random_tangent_vector, random_scale )

# p_interp.SetSpherePt( random_interp_n )