[Nipy-devel] Affine orientation ordering - please review and test

Matthew Brett matthew.brett@gmail....
Tue Jan 19 14:04:07 CST 2010


> If this is what you intended it to do, then you can ignore
> I think I have it extended to general dimensions (patch attached).

Thanks  - very much - that's very helpful.

> One test
> was failing for me, namely one based on
> In [16]: io_orientation(np.array([[1,1,0,0],[1,1,0,0],[0,0,1,0],[0,0,0,1]]))
> Out[16]:
> array([[ 1.,  1.],
>        [ 0.,  1.],
>        [ 2.,  1.]])
> It fails because, in the general case, I took R to have the same rank as
> affine.
> In the original code for this case, because you didn't zero out essentially
> 0 eigenvalues in computing R from RS
> your matrix R has rank 3 while affine has rank 2. With R as you wrote it,
> you are getting a
> false sense of what is happening because your matrix R is always full rank
> and can be quite far from "affine". Also,
> if affine is not full rank, than R as originally computed is not
> mathematically unique and possibly numerically instable.
> The little script "perturb_svd.py" illustrates this.

Thanks a lot for thinking about this.   Can I ask about this change:

-    RS = RZS / zooms
+    RS = np.dot(RZS, np.diag(zooms))

is it easy to explain?

By the way - I noticed _ornt_to_affine - this produces the permutation
matrix you described.   Can you think of a good name to differentiate
this from the current orientation_affine?  Like _ornt_to_affine ->
orientation_permutation , orientation_affine ->
applied_orientation_affine ?

> I changed the test so that all the matrices have rank 3, then all tests
> pass.

Thanks - again...


More information about the Nipy-devel mailing list