Example #1
0
#Step 1: set up storeage vectors for rest and contraction information, and
#        perform 2D alignment.

cShape = np.shape(cRest)

#Rest state
rR = [0] * cShape[0]
rS = [0] * cShape[0]
rT = [0] * cShape[0]
rPoints = [0] * cShape[0]
rMeanShape = cRest[0]  #start with the mean as the first shape

print 'aligning shapes at rest'
for i in range(cShape[0]):
    rPoints[i], rR[i], rS[i], rT[i] = IT.procrustesAlignment2D(
        rMeanShape, cRest[i])

#Contracted state
cR = [0] * cShape[0]
cS = [0] * cShape[0]
cT = [0] * cShape[0]
cPoints = [0] * cShape[0]
cMeanShape = cRest[0]

print 'apply the alignment of rest to contractoin'
for i in range(cShape[0]):
    cPoints[i] = IT.apply2DTransformation(list(cCont[i]), rT[i], rR[i], rS[i])
#	cPoints[i],cR[i],cS[i],cT[i]=IT.procrustesAlignment2D(cMeanShape,cCont[i])

#plot the aligned shapes
f2, ax2 = plt.subplots(1, 1)
		ax3[0,0].plot(cRest[i][:,0],cRest[i][:,1]*-1,'rx')
		ax3[0,0].plot(cCont[i][:,0],cCont[i][:,1]*-1,'ok')
		#ax3_1.set_xlim(100,300)
		#ax3_1.set_ylim(-350,-150)
		ax3[0,0].axis('equal')

	#Now align all the rest starts
	cShape=np.shape(cRest)
	rR=[0]*cShape[0]
	rS=[0]*cShape[0]
	rT=[0]*cShape[0]
	rPoints=[0]*cShape[0]
	rMeanShape=cRest[0] #start with the mean as the first shape
	print 'aligning shapes at rest'
	for i in range(cShape[0]):
		rPoints[i],rR[i],rS[i],rT[i]=IT.procrustesAlignment2D(rMeanShape,cRest[i])

	#Contracted state
	cR=[0]*cShape[0]
	cS=[0]*cShape[0]
	cT=[0]*cShape[0]
	cPoints=[0]*cShape[0]
	cMeanShape=cRest[0] 

	print 'apply the alignment of rest to contractoin'
	for i in range(cShape[0]):
		cPoints[i]=IT.apply2DTransformation(list(cCont[i]),rT[i],rR[i],rS[i])

	for i in range(cShape[0]):
		ax3[0,1].plot(rPoints[i][:,0],rPoints[i][:,1]*-1,'or')
		ax3[0,1].plot(cPoints[i][:,0],cPoints[i][:,1]*-1,'xb')