]> Creatis software - clitk.git/commitdiff
Manage a list of transform for image sequences
authorSimon Rit <simon.rit@creatis.insa-lyon.fr>
Fri, 10 Aug 2012 14:46:15 +0000 (16:46 +0200)
committerSimon Rit <simon.rit@creatis.insa-lyon.fr>
Fri, 10 Aug 2012 14:46:15 +0000 (16:46 +0200)
12 files changed:
common/vvImage.cxx
common/vvImage.h
common/vvImage.txx
common/vvImageReader.cxx
common/vvImageReader.h
common/vvImageReader.txx
common/vvImageWriter.txx
vv/vvMainWindow.cxx
vv/vvSlicer.cxx
vv/vvSlicerManager.cxx
vv/vvSlicerManager.h
vv/vvToolRigidReg.cxx

index 0bddb262cb7a4f8ce70d204d8be1750e3ae35f0c..31c6ef0fecd8234ecde506d542a8884b2293e84b 100644 (file)
@@ -32,7 +32,7 @@
 #include <cassert>
 
 //--------------------------------------------------------------------
-vvImage::vvImage():mTransform(vtkSmartPointer<vtkTransform>::New())
+vvImage::vvImage()
 {
   Init();
 }
@@ -251,7 +251,7 @@ bool vvImage::IsScalarTypeInteger(int t)
 //--------------------------------------------------------------------
 
 //--------------------------------------------------------------------
-vtkSmartPointer<vtkTransform> vvImage::GetTransform()
+const std::vector< vtkSmartPointer<vtkTransform> >& vvImage::GetTransform()
 {
   return this->mTransform;
 }
index ec01a1ffbe40d67f0f8b6a095f8cd56a80edacef..a120457f6f9f5a5f375f22cd426f5262cf05af9e 100644 (file)
@@ -56,7 +56,7 @@ public :
   bool IsTimeSequence() const;
   bool IsScalarTypeInteger();
   bool IsScalarTypeInteger(int t);
-  vtkSmartPointer<vtkTransform> GetTransform();
+  const std::vector< vtkSmartPointer<vtkTransform> >& GetTransform();
   void SetTimeSpacing(double s) { mTimeSpacing = s; }
   void SetTimeOrigin(double o) { mTimeOrigin = o; }
   bool HaveSameSizeAndSpacingThan(vvImage * other);
@@ -66,8 +66,8 @@ private:
   ~vvImage();
 
   std::vector< ConverterPointer > mItkToVtkConverters;
-  std::vector<vtkImageData*> mVtkImages;
-  vtkSmartPointer<vtkTransform> mTransform;
+  std::vector< vtkImageData* > mVtkImages;
+  std::vector< vtkSmartPointer<vtkTransform> > mTransform;
 
   double mTimeOrigin;
   double mTimeSpacing;
index 14da10a227f7d825cde021a143b8c2f84a74d7bb..55b785fb4814571fd4c0a7788699d03c848b937f 100644 (file)
@@ -50,7 +50,8 @@ void vvImage::AddItkImage(TItkImageType *input)
   // GetDirection provides the forward transform, vtkImageReslice wants the inverse
   matrix->Invert();
 
-  mTransform->SetMatrix(matrix);
+  mTransform.push_back(vtkSmartPointer<vtkTransform>::New());
+  mTransform.back()->SetMatrix(matrix);
 }
 //--------------------------------------------------------------------
 
index 0205355f6fafc40acd2dc82984ce11f1412dddc4..c795cd9299697c7a34c784c1973541c7012e777d 100644 (file)
@@ -110,37 +110,37 @@ void vvImageReader::SetInputFilenames(const std::vector<std::string> & filenames
 
 //------------------------------------------------------------------------------
 //Read transformation in NKI format (Xdr, transposed, cm)
-void vvImageReader::ReadNkiImageTransform()
-{
-  bool bRead=false;
-  std::string filename = mInputFilenames[0]+".MACHINEORIENTATION";
-  if(itksys::SystemTools::FileExists(filename.c_str())){
-    typedef itk::ImageFileReader< itk::Image< double, 2 > > MatrixReaderType;
-    MatrixReaderType::Pointer readerTransfo = MatrixReaderType::New();
-    readerTransfo->SetFileName(filename);
-    try {
-      bRead = true;
-      readerTransfo->Update();
-    } catch( itk::ExceptionObject & err ) {
-      bRead=false;
-      std::cerr << "Cannot read " << filename << std::endl
-                << "The error is: " << err << std::endl;
-    }
-
-    if (bRead) {
-      //Transpose matrix (NKI format)
-      for(int j=0; j<4; j++)
-        for(int i=0; i<4; i++)
-          mImage->GetTransform()->GetMatrix()->SetElement(j,i,readerTransfo->GetOutput()->GetBufferPointer()[4*i+j]);
-
-      //From cm to mm
-      for(int i=0; i<3; i++)
-        mImage->GetTransform()->GetMatrix()->SetElement(i,3,10*mImage->GetTransform()->GetMatrix()->GetElement(i,3));
-
-      mImage->GetTransform()->Inverse();
-    }
-  }
-}
+//void vvImageReader::ReadNkiImageTransform()
+//{
+//  bool bRead=false;
+//  std::string filename = mInputFilenames[0]+".MACHINEORIENTATION";
+//  if(itksys::SystemTools::FileExists(filename.c_str())){
+//    typedef itk::ImageFileReader< itk::Image< double, 2 > > MatrixReaderType;
+//    MatrixReaderType::Pointer readerTransfo = MatrixReaderType::New();
+//    readerTransfo->SetFileName(filename);
+//    try {
+//      bRead = true;
+//      readerTransfo->Update();
+//    } catch( itk::ExceptionObject & err ) {
+//      bRead=false;
+//      std::cerr << "Cannot read " << filename << std::endl
+//                << "The error is: " << err << std::endl;
+//    }
+
+//    if (bRead) {
+//      //Transpose matrix (NKI format)
+//      for(int j=0; j<4; j++)
+//        for(int i=0; i<4; i++)
+//          mImage->GetTransform()->GetMatrix()->SetElement(j,i,readerTransfo->GetOutput()->GetBufferPointer()[4*i+j]);
+
+//      //From cm to mm
+//      for(int i=0; i<3; i++)
+//        mImage->GetTransform()->GetMatrix()->SetElement(i,3,10*mImage->GetTransform()->GetMatrix()->GetElement(i,3));
+
+//      mImage->GetTransform()->Inverse();
+//    }
+//  }
+//}
 //------------------------------------------------------------------------------
 
 
@@ -192,9 +192,10 @@ void vvImageReader::ReadMatImageTransform()
       vtkGenericWarningMacro("Matrix in " << filename.c_str() << " cannot be inverted (determinant = 0)");
     }
 
-    mImage->GetTransform()->PostMultiply();
-    mImage->GetTransform()->Concatenate(matrix);
-    mImage->GetTransform()->Update();
+    // TODO SR and BP: check on the list of transforms and not the first only
+    mImage->GetTransform()[0]->PostMultiply();
+    mImage->GetTransform()[0]->Concatenate(matrix);
+    mImage->GetTransform()[0]->Update();
   }
 }
 //------------------------------------------------------------------------------
index dae05e47047ec4d9fb335491b03645b9588560f0..4348e0fac7e131f38aca7ab3d1ccb47d7851902b 100644 (file)
@@ -92,7 +92,7 @@ protected:
   std::string mInputPixelType;
 
   //====================================================================
-  void ReadNkiImageTransform();
+//  void ReadNkiImageTransform();
   void ReadMatImageTransform();
 private:
   vvImageReader();
index 6a4333ff3c59c055c704117954747e7f656a133b..9b0e21ae6c17f8fd498008272c53fa84a9aaaa5c 100644 (file)
@@ -187,12 +187,13 @@ void vvImageReader::UpdateWithDimAndInputPixelType()
                           0.,0.,1.,0.,
                           0.,-1.,0.,0.,
                           0.,0.,0.,1.};
+    // TODO SR and BP: check on the list of transforms and not the first only
     int i;
-    for(i=0; i<16 && m[i]==mImage->GetTransform()->GetMatrix()->GetElement(i%4, i/4); i++);
+    for(i=0; i<16 && m[i]==mImage->GetTransform()[0]->GetMatrix()->GetElement(i%4, i/4); i++);
     if(i==16) {
       itkWarningMacro(<< "Analyze image file format detected with unknown orientation. "
                       << "Forcing identity orientation, use other file format if not ok.");
-      mImage->GetTransform()->Identity();
+      mImage->GetTransform()[0]->Identity();
     }
   }
 }
@@ -259,13 +260,13 @@ void vvImageReader::UpdateWithDimAndInputVectorPixelType()
                           0.,-1.,0.,0.,
                           0.,0.,0.,1.};
     int i;
-    for (i = 0; i < 16 && m[i] == mImage->GetTransform()->GetMatrix()->GetElement(i % 4, i / 4); i++)
+    for (i = 0; i < 16 && m[i] == mImage->GetTransform()[0]->GetMatrix()->GetElement(i % 4, i / 4); i++)
       ;
     if (i == 16)
     {
       itkWarningMacro(<< "Analyze image file format detected with unknown orientation. "
                       << "Forcing identity orientation, use other file format if not ok.");
-      mImage->GetTransform()->Identity();
+      mImage->GetTransform()[0]->Identity();
     }
   }
 }
index 0640f0cd3645bd3d036facd374f6949225718d5d..0705197fd49b4f4d1394eb864c2175e2681464f2 100644 (file)
@@ -73,7 +73,8 @@ void vvImageWriter::UpdateWithDimAndOutputPixelType()
     itk::Matrix<double, 4, 4> trans;
     for(int i=0; i<4; i++)
       for(int j=0; j<4; j++)
-        trans[i][j] = mImage->GetTransform()->GetMatrix()->GetElement(i,j);
+        // TODO SR and BP: check on the list of transforms and not the first only
+        trans[i][j] = mImage->GetTransform()[0]->GetMatrix()->GetElement(i,j);
     trans = trans.GetInverse();
 
     // Direction
index 38f4f8b8d643ab72ca8c93ac28dbe55d3badd4ce..4e70cd415ae45f378ab8a823a4c825f1cdacecde 100644 (file)
@@ -952,6 +952,8 @@ void vvMainWindow::LoadImages(std::vector<std::string> files, vvImageReader::Loa
                 this,SLOT(UpdateSlice(int,int)));
         connect(mSlicerManagers.back(), SIGNAL(UpdateTSlice(int, int)),
                 this,SLOT(UpdateTSlice(int, int)));
+        connect(mSlicerManagers.back(), SIGNAL(UpdateTSlice(int, int)),
+                this,SLOT(ImageInfoChanged()));
         connect(mSlicerManagers.back(), SIGNAL(UpdateSliceRange(int,int,int,int,int)),
                 this,SLOT(UpdateSliceRange(int,int,int,int,int)));
         connect(mSlicerManagers.back(), SIGNAL(UpdateLinkManager(std::string,int,double,double,double,int)),
@@ -1139,7 +1141,7 @@ void vvMainWindow::ImageInfoChanged()
     infoPanel->setOrigin(GetVectorDoubleAsString(origin));
     infoPanel->setSpacing(GetVectorDoubleAsString(inputSpacing));
     infoPanel->setNPixel(QString::number(NPixel)+" ("+inputSizeInBytes+")");
-    transformation = imageSelected->GetTransform()->GetMatrix();
+    transformation = imageSelected->GetTransform()[mSlicerManagers[index]->GetTSlice()]->GetMatrix();
     infoPanel->setTransformation(Get4x4MatrixDoubleAsString(transformation));
 
     landmarksPanel->SetCurrentLandmarks(mSlicerManagers[index]->GetLandmarks(),
@@ -1727,7 +1729,7 @@ void vvMainWindow::UpdateSlicingPreset()
 {
   if (DataTree->selectedItems().size()) {
     int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
-    mSlicerManagers[index]->SetSlicingPreset(slicingPresetComboBox->currentIndex());
+    mSlicerManagers[index]->SetSlicingPreset(vvSlicerManager::SlicingPresetType(slicingPresetComboBox->currentIndex()));
   }
 }
 //------------------------------------------------------------------------------
@@ -2319,7 +2321,8 @@ void vvMainWindow::SaveAs()
       bool bId = true;
       for(int i=0; i<4; i++)
         for(int j=0; j<4; j++) {
-          double elt = mSlicerManagers[index]->GetImage()->GetTransform()->GetMatrix()->GetElement(i,j);
+          // TODO SR and BP: check on the list of transforms and not the first only
+          double elt = mSlicerManagers[index]->GetImage()->GetTransform()[0]->GetMatrix()->GetElement(i,j);
           if(i==j && elt!=1.)
             bId = false;
           if(i!=j && elt!=0.)
@@ -3090,6 +3093,8 @@ vvSlicerManager* vvMainWindow::AddImage(vvImage::Pointer image,std::string filen
           this,SLOT(UpdateSlice(int,int)));
   connect(mSlicerManagers.back(), SIGNAL(UpdateTSlice(int, int)),
           this,SLOT(UpdateTSlice(int, int)));
+  connect(mSlicerManagers.back(), SIGNAL(UpdateTSlice(int, int)),
+          this,SLOT(ImageInfoChanged()));
   connect(mSlicerManagers.back(), SIGNAL(UpdateSliceRange(int,int,int,int,int)),
           this,SLOT(UpdateSliceRange(int,int,int,int,int)));
   connect(mSlicerManagers.back(), SIGNAL(UpdateLinkManager(std::string,int,double,double,double,int)),
index 52fa161c14178a73db07815e46056d403c60c458..2a5c9247bbe3b0884d392521fa302a81c5e8c797 100644 (file)
@@ -326,7 +326,7 @@ void vvSlicer::SetImage(vvImage::Pointer image)
     }
 
     mConcatenatedTransform->Identity();
-    mConcatenatedTransform->Concatenate(mImage->GetTransform());
+    mConcatenatedTransform->Concatenate(mImage->GetTransform()[0]);
     mConcatenatedTransform->Concatenate(mSlicingTransform);
     mImageReslice->SetResliceTransform(mConcatenatedTransform);
     mImageReslice->SetInput(0, mImage->GetFirstVTKImageData());
@@ -369,7 +369,7 @@ void vvSlicer::SetOverlay(vvImage::Pointer overlay)
       mOverlayReslice->AutoCropOutputOn();
       mOverlayReslice->SetBackgroundColor(-1000,-1000,-1000,1);
     }
-    mOverlayReslice->SetResliceTransform(mOverlay->GetTransform());
+    mOverlayReslice->SetResliceTransform(mOverlay->GetTransform()[0]);
     mOverlayReslice->SetInput(0, mOverlay->GetFirstVTKImageData());
 
     if (!mOverlayMapper)
@@ -416,7 +416,7 @@ void vvSlicer::SetFusion(vvImage::Pointer fusion)
       mFusionReslice->AutoCropOutputOn();
       mFusionReslice->SetBackgroundColor(-1000,-1000,-1000,1);
     }
-    mFusionReslice->SetResliceTransform(mFusion->GetTransform());
+    mFusionReslice->SetResliceTransform(mFusion->GetTransform()[0]);
     mFusionReslice->SetInput(0, mFusion->GetFirstVTKImageData());
 
     if (!mFusionMapper)
@@ -698,6 +698,12 @@ void vvSlicer::SetTSlice(int t)
   else if ((unsigned int)t >= mImage->GetVTKImages().size())
     t = mImage->GetVTKImages().size() -1;
 
+  // Update transform
+  mConcatenatedTransform->Identity();
+  mConcatenatedTransform->Concatenate(mImage->GetTransform()[t]);
+  mConcatenatedTransform->Concatenate(mSlicingTransform);
+
+  // Update image data
   mCurrentTSlice = t;
   mImageReslice->SetInput( mImage->GetVTKImages()[mCurrentTSlice] );
   if (mVF && mVFActor->GetVisibility()) {
index 18049702c0845fc89bcde6798a81c7aa8257fdf3..b6f21562a6e19887cdb921f01f784aa6e900c2ff 100644 (file)
@@ -72,7 +72,7 @@ vvSlicerManager::vvSlicerManager(int numberOfSlicers)
 
   mPreviousSlice.resize(numberOfSlicers);
   mPreviousTSlice.resize(numberOfSlicers);
-  mSlicingPreset = 0;
+  mSlicingPreset = WORLD_SLICING;
 }
 //----------------------------------------------------------------------------
 
@@ -427,6 +427,13 @@ void vvSlicerManager::SetSliceOrientation(int slicer, int orientation)
 }
 //----------------------------------------------------------------------------
 
+//----------------------------------------------------------------------------
+int vvSlicerManager::GetTSlice()
+{
+  return mSlicers[0]->GetTSlice();
+}
+//----------------------------------------------------------------------------
+
 //----------------------------------------------------------------------------
 void vvSlicerManager::SetTSlice(int slice)
 {
@@ -439,7 +446,7 @@ void vvSlicerManager::SetTSlice(int slice)
   for ( unsigned int i = 0; i < mSlicers.size(); i++) {
     if (slice != mSlicers[i]->GetTSlice()) {
       mSlicers[i]->SetTSlice(slice);
-        UpdateTSlice(i);
+      UpdateTSlice(i);
     }
   }
 }
@@ -499,6 +506,13 @@ void vvSlicerManager::SetTSliceInSlicer(int tslice, int slicer)
 
   if (mSlicers[slicer]->GetTSlice() == tslice) return;
 
+  if(mSlicingPreset==VOXELS_SLICING) {
+    vtkMatrix4x4 *imageTransformInverse = vtkMatrix4x4::New();
+    mImage->GetTransform()[tslice]->GetInverse(imageTransformInverse);
+    this->GetSlicer(slicer)->GetSlicingTransform()->SetMatrix(imageTransformInverse);
+    imageTransformInverse->Delete();
+  }
+
   mSlicers[slicer]->SetTSlice(tslice);
   UpdateTSlice(slicer);
 }
@@ -808,13 +822,17 @@ bool vvSlicerManager::GetLinkOverlayWindowLevel() const
 void vvSlicerManager::ResetTransformationToIdentity(const std::string actorType)
 {
   if(actorType == "image")
-    this->GetImage()->GetTransform()->Identity();
+    for(unsigned int i=0; i<this->GetImage()->GetTransform().size(); i++)
+      this->GetImage()->GetTransform()[i]->Identity();
   else if(actorType == "overlay")
-    this->GetSlicer(0)->GetOverlay()->GetTransform()->Identity();
+    for(unsigned int i=0; i<this->GetImage()->GetTransform().size(); i++)
+      this->GetSlicer(0)->GetOverlay()->GetTransform()[i]->Identity();
   else if(actorType == "fusion")
-    this->GetSlicer(0)->GetFusion()->GetTransform()->Identity();
+    for(unsigned int i=0; i<this->GetImage()->GetTransform().size(); i++)
+      this->GetSlicer(0)->GetFusion()->GetTransform()[i]->Identity();
   else if(actorType == "vf")
-    this->GetVF()->GetTransform()->Identity();
+    for(unsigned int i=0; i<this->GetImage()->GetTransform().size(); i++)
+      this->GetVF()->GetTransform()[i]->Identity();
   else
     return;
 
@@ -1072,25 +1090,25 @@ void vvSlicerManager::UpdateSliceRange(int slicer)
 //----------------------------------------------------------------------------
 
 //----------------------------------------------------------------------------
-void vvSlicerManager::SetSlicingPreset(int preset)
+void vvSlicerManager::SetSlicingPreset(SlicingPresetType preset)
 {
   if(mSlicingPreset==preset)
     return;
 
-  vtkMatrix4x4 *mImageTransformInverse = vtkMatrix4x4::New();
-  mImage->GetTransform()->GetInverse(mImageTransformInverse);
+  vtkMatrix4x4 *imageTransformInverse = vtkMatrix4x4::New();
+  mImage->GetTransform()[this->GetTSlice()]->GetInverse(imageTransformInverse);
 
   for(int i=0; i< this->GetNumberOfSlicers(); i++){
     switch(preset)
     {
-    case 0: // World
+    case WORLD_SLICING:
       this->GetSlicer(i)->GetSlicingTransform()->Identity();
       break;
-    case 1: // Voxels
-      this->GetSlicer(i)->GetSlicingTransform()->SetMatrix(mImageTransformInverse);
+    case VOXELS_SLICING:
+      this->GetSlicer(i)->GetSlicingTransform()->SetMatrix(imageTransformInverse);
       break;
     default:
-      mImageTransformInverse->Delete();
+      imageTransformInverse->Delete();
       return;
     }
     this->GetSlicer(i)->ForceUpdateDisplayExtent();
@@ -1098,7 +1116,7 @@ void vvSlicerManager::SetSlicingPreset(int preset)
     this->GetSlicer(i)->Render();
   }
 
-  mImageTransformInverse->Delete();
+  imageTransformInverse->Delete();
   mSlicingPreset = preset;
 }
 
@@ -1162,11 +1180,11 @@ void vvSlicerManager::SetPreset(int preset)
 void vvSlicerManager::SetLocalColorWindowing(const int slicer, const bool bCtrlKey)
 {
   double min, max;
-  int t = this->mSlicers[slicer]->GetTSlice();
+  int t = this->GetTSlice();
   if(bCtrlKey && this->mSlicers[slicer]->GetFusion()) {
     this->mSlicers[slicer]->GetExtremasAroundMousePointer(min, max,
                                                           this->mSlicers[slicer]->GetFusion()->GetVTKImages()[t],
-                                                          this->mSlicers[slicer]->GetFusion()->GetTransform());
+                                                          this->mSlicers[slicer]->GetFusion()->GetTransform()[t]);
     this->SetFusionWindow(max-min);
     this->SetFusionLevel(0.5*(min+max));
     this->SetColorMap(mColorMap);
@@ -1174,7 +1192,7 @@ void vvSlicerManager::SetLocalColorWindowing(const int slicer, const bool bCtrlK
   else if(bCtrlKey && this->mSlicers[slicer]->GetOverlay()) {
     this->mSlicers[slicer]->GetExtremasAroundMousePointer(min, max,
                                                           this->mSlicers[slicer]->GetOverlay()->GetVTKImages()[t],
-                                                          this->mSlicers[slicer]->GetOverlay()->GetTransform());
+                                                          this->mSlicers[slicer]->GetOverlay()->GetTransform()[t]);
     if(this->mSlicers[slicer]->GetLinkOverlayWindowLevel()){
       this->SetColorWindow(max-min);
       this->SetColorLevel(0.5*(min+max));
index b469277ff38d84f407aac0752cf30dfba1961946..50a31ba913eb31ba8b133a65acdb283f42633768 100644 (file)
@@ -52,6 +52,7 @@ class vvSlicerManager : public QObject {
   Q_OBJECT
 
   public:
+  typedef enum {WORLD_SLICING, VOXELS_SLICING} SlicingPresetType;
   vvSlicerManager(int numberOfSlicers);
   ~vvSlicerManager();
 
@@ -103,6 +104,7 @@ class vvSlicerManager : public QObject {
   void SetFilename(std::string f, int number=0);
 
   void SetSliceOrientation(int slicer, int orientation);
+  int GetTSlice();
   void SetTSlice(int slice);
   void SetNextTSlice(int originating_slicer);
   void SetPreviousTSlice(int originating_slicer);
@@ -151,7 +153,7 @@ class vvSlicerManager : public QObject {
   int GetPreset() {
     return mPreset;
   }
-  int GetSlicingPreset() {
+  SlicingPresetType GetSlicingPreset() {
     return mSlicingPreset;
   }
   int GetOverlayColor() const {
@@ -206,7 +208,7 @@ class vvSlicerManager : public QObject {
   void UpdateSlice(int slicer);
   void UpdateTSlice(int slicer);
   void UpdateSliceRange(int slicer);
-  void SetSlicingPreset(int preset);
+  void SetSlicingPreset(SlicingPresetType preset);
 
   vvLandmarks *GetLandmarks();
   void AddLandmark(float x,float y,float z,float t);
@@ -255,7 +257,7 @@ protected:
   bool mFusionShowLegend;
 
   int mPreset;
-  int mSlicingPreset;
+  SlicingPresetType mSlicingPreset;
   vvImageReader::LoadedImageType mType;
   std::string mVFComponent;
   std::string mOverlayComponent;
index 28591ba05ed1b6c6cc8af79af440ef5eaea6eb37..508551da86a7dec2ed064921e170439f2d6faeff 100644 (file)
@@ -118,7 +118,8 @@ void vvToolRigidReg::InputIsSelected(vvSlicerManager *input)
   //backup original matrix
   for(int j=0; j<4; j++)
     for(int i=0; i<4; i++)
-      mInitialMatrix->SetElement(i,j, mCurrentSlicerManager->GetImage()->GetTransform()->GetMatrix()->GetElement(i,j));
+      // TODO SR and BP: check on the list of transforms and not the first only
+      mInitialMatrix->SetElement(i,j, mCurrentSlicerManager->GetImage()->GetTransform()[0]->GetMatrix()->GetElement(i,j));
   QString origTransformString = dynamic_cast<vvMainWindow*>(mMainWindow)->Get4x4MatrixDoubleAsString(mInitialMatrix);
   transformationLabel->setText(origTransformString);
   SetTransform(mInitialMatrix);
@@ -242,7 +243,8 @@ void vvToolRigidReg::SpinBoxChange(double newVal)
   }
 
   // Compute transform and set
-  vtkSmartPointer<vtkTransform> transform_final=mInput->GetImage()->GetTransform();
+  // TODO SR and BP: check on the list of transforms and not the first only
+  vtkSmartPointer<vtkTransform> transform_final=mInput->GetImage()->GetTransform()[0];
   transform_final->Identity();
   transform_final->PostMultiply();
 
@@ -294,7 +296,8 @@ void vvToolRigidReg::SaveFile()
 
   QFile file(filename);
   if (file.open(QFile::WriteOnly | QFile::Truncate)) {
-    vtkMatrix4x4* matrix = mCurrentSlicerManager->GetImage()->GetTransform()->GetMatrix();
+    // TODO SR and BP: check on the list of transforms and not the first only
+    vtkMatrix4x4* matrix = mCurrentSlicerManager->GetImage()->GetTransform()[0]->GetMatrix();
     QString matrixStr = dynamic_cast<vvMainWindow*>(mMainWindow)->Get4x4MatrixDoubleAsString(matrix,16);
     QTextStream out(&file);
     out << matrixStr;
@@ -332,7 +335,8 @@ void vvToolRigidReg::LoadFile()
 //------------------------------------------------------------------------------
 void vvToolRigidReg::ChangeOfRotationCenter()
 {
-  SetTransform(mCurrentSlicerManager->GetImage()->GetTransform()->GetMatrix());
+  // TODO SR and BP: check on the list of transforms and not the first only
+  SetTransform(mCurrentSlicerManager->GetImage()->GetTransform()[0]->GetMatrix());
 }
 //------------------------------------------------------------------------------
 
@@ -347,7 +351,8 @@ void vvToolRigidReg::ResetTransform()
 void vvToolRigidReg::SetTransform(vtkMatrix4x4 *matrix)
 {
   vtkSmartPointer<vtkTransform> transform=vtkSmartPointer<vtkTransform>::New();
-  mCurrentSlicerManager->GetImage()->GetTransform()->SetMatrix(matrix);
+  // TODO SR and BP: check on the list of transforms and not the first only
+  mCurrentSlicerManager->GetImage()->GetTransform()[0]->SetMatrix(matrix);
   transform->Update();
   Render();
   dynamic_cast<vvMainWindow*>(mMainWindow)->ImageInfoChanged();