diff --git a/newimage.cc b/newimage.cc
index 115c67637a967ed2d59dc97151c566f0ded14b22..388f9c81ebe4cce6b91f4edb521b862f1a9037e2 100644
--- a/newimage.cc
+++ b/newimage.cc
@@ -2349,10 +2349,10 @@ namespace NEWIMAGE {
     //   hence sampling mats
 
     Matrix nmat;
-    nmat = this->sform_mat() * this->sampling_mat().i() * this->swapmat(dim1,dim2,dim3) 
+    nmat = this->sform_mat() * this->sampling_mat().i() * this->swapmat(dim1,dim2,dim3).i() 
       * this->sampling_mat();
     swapvol.set_sform(this->sform_code(), nmat);
-    nmat = this->qform_mat() * this->sampling_mat().i() * this->swapmat(dim1,dim2,dim3) 
+    nmat = this->qform_mat() * this->sampling_mat().i() * this->swapmat(dim1,dim2,dim3).i() 
       * this->sampling_mat();
     swapvol.set_qform(this->qform_code(), nmat);