Skip to content

Commit 041905f

Browse files
authored
Merge pull request #41 from mu40/voxsize-from-affine
Compute resolution from affine to fix voxel-size bug.
2 parents c80a3de + c2daf2e commit 041905f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

surfa/image/framed.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -474,9 +474,6 @@ def reorient(self, orientation, copy=True):
474474
world_axes_trg = get_world_axes(trg_matrix[:self.basedim, :self.basedim])
475475
world_axes_src = get_world_axes(src_matrix[:self.basedim, :self.basedim])
476476

477-
voxsize = np.asarray(self.geom.voxsize)
478-
voxsize = voxsize[world_axes_src][world_axes_trg]
479-
480477
# initialize new
481478
data = self.data.copy()
482479
affine = self.geom.vox2world.matrix.copy()
@@ -497,6 +494,9 @@ def reorient(self, orientation, copy=True):
497494
affine[:, i] = - affine[:, i]
498495
affine[:3, 3] = affine[:3, 3] - affine[:3, i] * (data.shape[i] - 1)
499496

497+
# derive new voxel size
498+
voxsize = np.sqrt(np.sum(affine[:self.basedim, :self.basedim] ** 2, axis=0))
499+
500500
# update geometry
501501
target_geom = ImageGeometry(
502502
shape=data.shape[:3],

0 commit comments

Comments
 (0)