Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LowRankModelBuilder: PCA Basisvectors and values are not scaled correctly #242

Open
zarquon42b opened this issue Mar 17, 2016 · 8 comments
Assignees

Comments

@zarquon42b
Copy link
Member

In LowRankModelBuilder: PCA Basisvectors and values are not scaled correctly. The call GetOrthonormalPCABasisMatrix does not return an orthonormal matrix.

@zarquon42b
Copy link
Member Author

Hi @marcelluethi,
how does the LowRankModelBuilder work exactly? Will simple norming of basis vectors be enough to solve this issue? Which is the reliable part concerning the variance calculation: the eigenvalues or the eigenvectors. If simply the eigenvectors need to be scaled, then this: 775a614 should take care.

Best
Stefan

@marcelluethi
Copy link
Member

Hi Stefan,

Thanks for investigating this. I just checked the code in the LowRankGPModelBuilder.
At this point
https://github.com/statismo/statismo/blob/master/modules/core/include/LowRankGPModelBuilder.h#L212
the matrix is orthonormal (at least in my test case). Can you check if this is also the case for you?

@zarquon42b
Copy link
Member Author

Hi Marcel,

not in all cases. For large number of coordinates, the nystroem approximation gets worse:
a) basis Matix deviates from orthogonality (a Mathematician probably gets a fit reading this ;) )
b) vector lengths are far off from unit length
I thought that the 3 lines scaling the vectors at least ensure a normed basis

@zarquon42b
Copy link
Member Author

For low number of coordinates, the approximation is excellent. I checked the covariance matrices from statismo against explicitly calculated ones in R using the same kernel.

Here is an example using RvtkStatismo, where the nystroem approx is not too good:

require(RvtkStatismo);require(Morpho);require(Rvcg)
data(humface)
kernel1 <- GaussianKernel(10,1)
hummodel <- statismoModelFromRepresenter(humface,kernel1,ncomp = 100,nystroem = 500)
## get vector norms
colSums(GetOrthonormalPCABasisMatrix(hummodel)^2)

Vector norms:
[1] 0.6548145 0.9067647 0.8971522 0.7161306 0.5347492 ...

Example with only 1000 coordinates

require(RvtkStatismo);require(Morpho);require(Rvcg)
data(humface)
kernel1 <- GaussianKernel(10,1)
hummodel <- statismoModelFromRepresenter(vert2points(humface)[1:1000,],kernel1,ncomp = 100,nystroem = 1000)
## get vector norms
colSums(GetOrthonormalPCABasisMatrix(hummodel)^2)

Vector norms:
[1] 0.9999995 1.0000002 1.0000000 0.999999 ...

@marcelluethi
Copy link
Member

Now I see what you mean. Maybe in this case it would be better to throw an exception, in order to make the user aware that the approximation is bad and he should use more points for the approximation (or assume greater smoothness). If the approximation is so bad, it is unlikely that the resulting model is useful.

I guess in your example you would also get back an orthonormal matrix if you increase the smoothness (i.e. the sigma in the Gaussian kernel).

@zarquon42b
Copy link
Member Author

I think an exception would be too harsh, as things escalate quite quickly :(
There is some improvement fiddling with the scale and sigma (but the trailing vector norms are pretty off getting values > 20).. But for large meshes, you would probably always get an exception.
And on the up-side: For registration, even the "bad" models give good matching results.

@marcelluethi
Copy link
Member

You are right. It still enlarges the space of deformations that can be expressed. It is maybe just not a good approximation to the original kernel.

Anyway, we are currently working on improving the approximation quality. We should soon have a better approximation method, which does not suffer from this problem.

@zarquon42b
Copy link
Member Author

Awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants