Created
January 24, 2013 14:46
-
-
Save satra/4622498 to your computer and use it in GitHub Desktop.
fix mri_convert produced gradients
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
img = nib.load(imgfile) | |
bvecs = np.genfromtxt(bvecs) | |
def get_trackvis_mat(aff): | |
"""based on input from ruopeng @ tracvkis | |
""" | |
for i in range(10): | |
#aff = aff.dot(np.linalg.inv(np.eye(3) + 3*aff.T.dot(aff)).dot(3*np.eye(3) + aff.T.dot(aff))) | |
aff = 0.5 * (aff + np.linalg.inv(aff.T)) | |
return np.dot(aff, np.array([[1,0,0],[0,-1,0],[0,0,1]])) | |
if rotate: | |
mat = get_trackvis_mat(img.get_affine().copy()[:3, :3]) | |
bvecs = mat.dot(bvecs.T).T |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment