From 252cd24cbae0a35e3cde305d9367c3563fcc6d50 Mon Sep 17 00:00:00 2001 From: Paul McCarthy <pauld.mccarthy@gmail.com> Date: Fri, 13 Jan 2017 13:53:15 +0000 Subject: [PATCH] Dangerous change - scaleOffsetXform and transform.transform were returning/assuming transposed affines (column-major). This is because that's what OpenGL uses. --- fsl/data/atlases.py | 6 +++--- fsl/data/featanalysis.py | 2 +- fsl/utils/transform.py | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/fsl/data/atlases.py b/fsl/data/atlases.py index daa62700e..36b0d48f9 100644 --- a/fsl/data/atlases.py +++ b/fsl/data/atlases.py @@ -495,7 +495,7 @@ class AtlasDescription(object): # Load the appropriate transformation matrix # and transform all those voxel coordinates # into world coordinates - coords = transform.transform(coords, self.xforms[0].T) + coords = transform.transform(coords, self.xforms[0]) # Update the coordinates # in our label objects @@ -594,7 +594,7 @@ class LabelAtlas(Atlas): location, or ``None`` if the location is out of bounds. """ - voxelLoc = transform.transform([worldLoc], self.worldToVoxMat.T)[0] + voxelLoc = transform.transform([worldLoc], self.worldToVoxMat)[0] voxelLoc = [int(v) for v in voxelLoc.round()] if voxelLoc[0] < 0 or \ @@ -642,7 +642,7 @@ class ProbabilisticAtlas(Atlas): location. Returns an empty list if the given location is out of bounds. """ - voxelLoc = transform.transform([worldLoc], self.worldToVoxMat.T)[0] + voxelLoc = transform.transform([worldLoc], self.worldToVoxMat)[0] voxelLoc = [int(v) for v in voxelLoc.round()] if voxelLoc[0] < 0 or \ diff --git a/fsl/data/featanalysis.py b/fsl/data/featanalysis.py index 1860a5e8d..5d527863d 100644 --- a/fsl/data/featanalysis.py +++ b/fsl/data/featanalysis.py @@ -355,7 +355,7 @@ def loadClusterResults(featdir, settings, contrast): # later on. coordXform = fslimage.Image( getDataFile(featdir), - loadData=False).worldToVoxMat.T + loadData=False).worldToVoxMat if not op.exists(clusterFile): return None diff --git a/fsl/utils/transform.py b/fsl/utils/transform.py index ed90bf35e..df82ddc55 100644 --- a/fsl/utils/transform.py +++ b/fsl/utils/transform.py @@ -73,9 +73,9 @@ def scaleOffsetXform(scales, offsets): xform[1, 1] = scales[1] xform[2, 2] = scales[2] - xform[3, 0] = offsets[0] - xform[3, 1] = offsets[1] - xform[3, 2] = offsets[2] + xform[0, 3] = offsets[0] + xform[1, 3] = offsets[1] + xform[2, 3] = offsets[2] return xform @@ -337,8 +337,8 @@ def transform(p, xform, axes=None): scalings. """ - p = _fillPoints(p, axes) - t = np.dot(xform[:3, :3].T, p.T).T + xform[3, :3] + p = _fillPoints(p, axes) + t = np.dot(xform[:3, :3], p.T).T + xform[:3, 3] if axes is not None: t = t[:, axes] -- GitLab