From c2daf2e6c1c41dc1a7a8f9c4e8ccd37b26672aca Mon Sep 17 00:00:00 2001 From: Malte Hoffmann Date: Sat, 21 Sep 2024 08:25:55 -0400 Subject: [PATCH] Compute resolution from affine to fix voxel-size bug. --- surfa/image/framed.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/surfa/image/framed.py b/surfa/image/framed.py index 4862b59..7345f76 100644 --- a/surfa/image/framed.py +++ b/surfa/image/framed.py @@ -474,9 +474,6 @@ def reorient(self, orientation, copy=True): world_axes_trg = get_world_axes(trg_matrix[:self.basedim, :self.basedim]) world_axes_src = get_world_axes(src_matrix[:self.basedim, :self.basedim]) - voxsize = np.asarray(self.geom.voxsize) - voxsize = voxsize[world_axes_src][world_axes_trg] - # initialize new data = self.data.copy() affine = self.geom.vox2world.matrix.copy() @@ -497,6 +494,9 @@ def reorient(self, orientation, copy=True): affine[:, i] = - affine[:, i] affine[:3, 3] = affine[:3, 3] - affine[:3, i] * (data.shape[i] - 1) + # derive new voxel size + voxsize = np.sqrt(np.sum(affine[:self.basedim, :self.basedim] ** 2, axis=0)) + # update geometry target_geom = ImageGeometry( shape=data.shape[:3],