@@ -474,6 +474,19 @@ def reorient(self, orientation, copy=True):
474
474
world_axes_trg = get_world_axes (trg_matrix [:self .basedim , :self .basedim ])
475
475
world_axes_src = get_world_axes (src_matrix [:self .basedim , :self .basedim ])
476
476
477
+ voxsize = np .asarray (self .geom .voxsize )
478
+ voxsize_swapped = np .ones (self .basedim )
479
+ for i in range (self .basedim ):
480
+ c1 = trg_orientation [i ]
481
+ for j in range (self .basedim ):
482
+ c2 = src_orientation [j ]
483
+ if ((c1 in 'RL' and c2 in 'RL' ) or
484
+ (c1 in 'AP' and c2 in 'AP' ) or
485
+ (c1 in 'SI' and c2 in 'SI' )):
486
+ voxsize_swapped [i ] = voxsize [j ]
487
+ break
488
+ voxsize = voxsize_swapped
489
+
477
490
# initialize new
478
491
data = self .data .copy ()
479
492
affine = self .geom .vox2world .matrix .copy ()
@@ -494,9 +507,6 @@ def reorient(self, orientation, copy=True):
494
507
affine [:, i ] = - affine [:, i ]
495
508
affine [:3 , 3 ] = affine [:3 , 3 ] - affine [:3 , i ] * (data .shape [i ] - 1 )
496
509
497
- # derive new voxel size
498
- voxsize = np .sqrt (np .sum (affine [:self .basedim , :self .basedim ] ** 2 , axis = 0 ))
499
-
500
510
# update geometry
501
511
target_geom = ImageGeometry (
502
512
shape = data .shape [:3 ],
0 commit comments