diff --git a/fsl/data/image.py b/fsl/data/image.py index 5570be15f42db82e17e473964dc85bf694a2e768..189117fe339e38ff1045c3042b810b8e2c08c600 100644 --- a/fsl/data/image.py +++ b/fsl/data/image.py @@ -376,6 +376,9 @@ class Nifti(notifier.Notifier, meta.Meta): [ x, 0, 0]) voxToScaledVoxMat = transform.concat(flip, voxToScaledVoxMat) + affines['fsl', 'fsl'] = np.eye(4) + affines['voxel', 'voxel'] = np.eye(4) + affines['world', 'world'] = np.eye(4) affines['voxel', 'world'] = voxToWorldMat affines['world', 'voxel'] = transform.invert(voxToWorldMat) affines['voxel', 'fsl'] = voxToScaledVoxMat diff --git a/fsl/utils/transform/flirt.py b/fsl/utils/transform/flirt.py index c669eb9c4c9a993ab1ad5fce573af6d39c440eae..56b193e078b6e174725e46b0808a52c7e7f7b06c 100644 --- a/fsl/utils/transform/flirt.py +++ b/fsl/utils/transform/flirt.py @@ -17,9 +17,21 @@ matrices. The following functions are available: """ +import numpy as np + from .affine import concat +def readFlirt(fname): + """Reads a FLIRT matrix from a file. """ + return np.loadtxt(fname) + + +def writeFlirt(xform, fname): + """Writes the given FLIRT matrix to a file. """ + np.savetxt(fname, xform, fmt='%1.15g') + + def fromFlirt(xform, src, ref, from_='voxel', to='world'): """Convert a FLIRT affine matrix into another affine.