]> Creatis software - clitk.git/commitdiff
Open Dicom with imaging machine coordinate system (Identity matrix) by default
authortbaudier <thomas.baudier@creatis.insa-lyon.fr>
Thu, 16 Nov 2017 14:49:32 +0000 (15:49 +0100)
committertbaudier <thomas.baudier@creatis.insa-lyon.fr>
Thu, 16 Nov 2017 14:49:32 +0000 (15:49 +0100)
Add a check box to open it with patient coordinate system

common/vvImage.cxx
common/vvImage.h
common/vvImageReader.cxx
common/vvImageReader.h
common/vvImageReader.txx
vv/qt_ui/vvDicomSeriesSelector.ui
vv/vvMainWindow.cxx
vv/vvQDicomSeriesSelector.cxx
vv/vvQDicomSeriesSelector.h
vv/vvSlicerManager.cxx
vv/vvSlicerManager.h

index 48f2e1fd94507e30b4102d979b04a80e0a71cc85..f75d3212267441b0ee75e2a0ffe221d00ad9066a 100644 (file)
@@ -261,6 +261,15 @@ const std::vector< vtkSmartPointer<vtkTransform> >& vvImage::GetTransform()
 //--------------------------------------------------------------------
 
 
+//--------------------------------------------------------------------
+void vvImage::InitializeTransform()
+{
+  for (int i = 0; i < mTransform.size(); i++)
+    mTransform[i]->Identity();
+}
+//--------------------------------------------------------------------
+
+
 //--------------------------------------------------------------------
 std::vector< std::vector<double> > vvImage::GetDirection()
 {
index 09cb4d94bcd7bb4d58b8378a8fb3430efc2112fa..cbb0284ce0e925f706032825c7e8888da7744987 100644 (file)
@@ -68,6 +68,7 @@ public :
   bool IsScalarTypeInteger();
   bool IsScalarTypeInteger(int t);
   const std::vector< vtkSmartPointer<vtkTransform> >& GetTransform();
+  void InitializeTransform();
   void SetTimeSpacing(double s) { mTimeSpacing = s; }
   void SetTimeOrigin(double o) { mTimeOrigin = o; }
   bool HaveSameSizeAndSpacingThan(vvImage * other);
index 5e7d90364dc6ee28e067cfd18c7aa0a8169a07a4..a2fc4e964ab8edeeef1e57cb0f6a4b742c371d44 100644 (file)
@@ -33,6 +33,7 @@ vvImageReader::vvImageReader()
   mLastError = "";
   mType = UNDEFINEDIMAGETYPE;
   mSlice = 0;
+  mPatientCoordinateSystem = false;
 }
 //------------------------------------------------------------------------------
 
@@ -50,6 +51,14 @@ void vvImageReader::Update()
 //------------------------------------------------------------------------------
 
 
+//------------------------------------------------------------------------------
+void vvImageReader::SetPatientCoordinateSystem(bool patientCoordinateSystem)
+{
+  mPatientCoordinateSystem = patientCoordinateSystem;
+}
+//------------------------------------------------------------------------------
+
+
 //------------------------------------------------------------------------------
 void vvImageReader::Update(LoadedImageType type)
 {
index 4dc3f409d3d193520439e534e90e17309fdd8d98..6f3dbc3d0f3e4573f3fe6886f862c4e278dcf78a 100644 (file)
@@ -59,6 +59,7 @@ public:
   }
 
   void SetSlice(unsigned int i) { mSlice = i; }
+  void SetPatientCoordinateSystem(bool patientCoordinateSystem);
 
   //====================================================================
   // Main function
@@ -91,6 +92,7 @@ protected:
   void UpdateWithDimAndInputVectorPixelType();
   ///Input dimension and pixel type
   int mDim;
+  bool mPatientCoordinateSystem;
   std::string mInputPixelType;
 
   //====================================================================
index a9f17ab6afe7c8d08aec0ffa2ba2613885304983..2eba11c81bc628f107d7f738c0a6d750fba7ef8f 100644 (file)
@@ -257,6 +257,9 @@ void vvImageReader::UpdateWithDimAndInputPixelType()
       }
     }
   }
+
+  if (mType == DICOM && !mPatientCoordinateSystem)
+    mImage->InitializeTransform();
 }
 //----------------------------------------------------------------------------
 
index f7e71323c2a7a44190af2fb9be219de154087a4d..110993b1ce7c4f1ed985d0b9fdabc695a689e6e7 100644 (file)
             <number>0</number>
            </property>
            <item>
-            <widget class="QLabel" name="mLabelSelected_3" >
-             <property name="sizePolicy" >
-              <sizepolicy vsizetype="Minimum" hsizetype="Preferred" >
-               <horstretch>0</horstretch>
-               <verstretch>0</verstretch>
-              </sizepolicy>
-             </property>
-             <property name="text" >
-              <string>&lt;b>Files in current DICOM serie&lt;/b></string>
-             </property>
-             <property name="textFormat" >
-              <enum>Qt::RichText</enum>
-             </property>
-            </widget>
+            <layout class="QHBoxLayout" name="horizontalLayout_3" >
+             <item>
+              <widget class="QLabel" name="mLabelSelected_3" >
+               <property name="sizePolicy" >
+                <sizepolicy vsizetype="Minimum" hsizetype="Preferred" >
+                 <horstretch>0</horstretch>
+                 <verstretch>0</verstretch>
+                </sizepolicy>
+               </property>
+               <property name="text" >
+                <string>&lt;b>Files in current DICOM serie&lt;/b></string>
+               </property>
+               <property name="textFormat" >
+                <enum>Qt::RichText</enum>
+               </property>
+              </widget>
+             </item>
+             <item>
+              <widget class="QCheckBox" name="mIsMatrixCheckBox" >
+               <property name="text" >
+                <string>Patient coordinate system</string>
+               </property>
+              </widget>
+             </item>
+            </layout>
            </item>
            <item>
             <widget class="QListWidget" name="mDicomDetailsListWidget" >
index 9801e8bbb65575c3a080bed78f6ff8d92ce2b7ab..e88a5d9695b961b8a410467d4d1f1de783c21adf 100644 (file)
@@ -902,11 +902,13 @@ void vvMainWindow::LoadImages(std::vector<std::string> files, vvImageReader::Loa
       // Change filename if an image with the same already exist
       int number = GetImageDuplicateFilenameNumber(files[i] + std::string("_slice"));
 
-      if (filetype == vvImageReader::IMAGE || filetype == vvImageReader::IMAGEWITHTIME || filetype == vvImageReader::SLICED) {
+      if (filetype == vvImageReader::IMAGE || filetype == vvImageReader::IMAGEWITHTIME || filetype == vvImageReader::SLICED)
         SetImageSucceed = imageManager->SetImage(files[i],filetype, number, j);
-      } else {
+      else if (filetype == vvImageReader::DICOM)
+        SetImageSucceed = imageManager->SetImages(files,filetype, number, dicomSeriesSelector->IsPatientCoordianteSystemChecked());
+      else
         SetImageSucceed = imageManager->SetImages(files,filetype, number);
-      }
+
       if (!SetImageSucceed) {
         QApplication::restoreOverrideCursor();
         QString error = "Cannot open file \n";
index 44850bb158aadbd504b4d2edd3c033023e1d2ec5..9c279827128062caf963b9207ff8d247ced02664 100644 (file)
@@ -58,6 +58,8 @@ vvDicomSeriesSelector::vvDicomSeriesSelector(QWidget* parent)
           this, SLOT(itemSelectionChanged()));
   connect(ui.mDicomDetailsListWidget, SIGNAL(itemSelectionChanged()),
           this, SLOT(itemDetailsSelectionChanged()));
+  connect(ui.mIsMatrixCheckBox, SIGNAL(stateChanged(int)),
+          this, SLOT(itemMatrixSelectionChanged(int)));
 
   // Initialization
   /*   if (config::get_current_path() != QString(0))
@@ -67,6 +69,8 @@ vvDicomSeriesSelector::vvDicomSeriesSelector(QWidget* parent)
 
   mPreviousPath = mFoldername;
   ui.mFolderLineEdit->setText(mFoldername);
+  ui.mIsMatrixCheckBox->setChecked(0);
+  mPatientCoordinateSystem = false;
   //  ui.mTableWidget->setRowCount(0);
 }
 //====================================================================
@@ -401,4 +405,13 @@ void vvDicomSeriesSelector::AddSerieToTheTable(int i, std::vector<std::string> &
 }
 //====================================================================
 
+
+//====================================================================
+void vvDicomSeriesSelector::itemMatrixSelectionChanged(int state)
+{
+  mPatientCoordinateSystem = state;
+}
+//====================================================================
+
+
 #endif // VVDICOMSERIESSELECTOR_CXX
index 8b3aaac0deab00f0f8f3f5e3e8da3fcc28380a57..aa905fcfead1932b43474dd4afd732dc1f74a729 100644 (file)
@@ -37,12 +37,14 @@ public:
     std::vector<std::string> * GetFilenames() {
         return mFilenames;
     }
+    bool IsPatientCoordianteSystemChecked() { return mPatientCoordinateSystem; }
 
 protected slots:
     void BrowseButtonRelease();
     void SearchButtonRelease();
     void itemSelectionChanged();
     void itemDetailsSelectionChanged();
+    void itemMatrixSelectionChanged(int state);
 
 protected:
     QString mPreviousPath;
@@ -68,6 +70,7 @@ private:
     std::map<std::string, gdcm::File*> mDicomHeader;
 #endif
     std::map<std::string, std::string> mDicomDetails;
+    bool mPatientCoordinateSystem;
 };
 
 #endif // VVDICOMSERIESSELECTOR_H
index 139c8089afc5d8a61d07db22f7d11c75e787a7d8..089001cabb1dc23c778427fe0beebdc7c9ef235f 100644 (file)
@@ -221,7 +221,7 @@ void vvSlicerManager::SetImage(vvImage::Pointer image)
 
 
 //----------------------------------------------------------------------------
-bool vvSlicerManager::SetImages(std::vector<std::string> filenames, vvImageReader::LoadedImageType type, int n)
+bool vvSlicerManager::SetImages(std::vector<std::string> filenames, vvImageReader::LoadedImageType type, int n, bool patientCoordinateSystem)
 { 
   mType = type;
   std::string fileWithoutExtension = vtksys::SystemTools::GetFilenameWithoutExtension(filenames[0]);
@@ -237,6 +237,8 @@ bool vvSlicerManager::SetImages(std::vector<std::string> filenames, vvImageReade
   if (mReader.IsNull())
     mReader = vvImageReader::New();
   mReader->SetInputFilenames(filenames);
+  if (type == vvImageReader::DICOM)
+    mReader->SetPatientCoordinateSystem(patientCoordinateSystem);
   mReader->Update(type);
 
   mBaseFileName = vtksys::SystemTools::GetFilenameName(vtksys::SystemTools::GetFilenameWithoutLastExtension(mFileName));
index 0d5c9aee218eacc9be8b615a1ce98608ce8d4eed..4acb1668cd22ed64e4b20abf07e883671771982a 100644 (file)
@@ -74,7 +74,7 @@ class vvSlicerManager : public QObject {
 
   bool SetImage(std::string filename, vvImageReader::LoadedImageType type, int n=0, unsigned int slice=0);
   void SetImage(vvImage::Pointer image);
-  bool SetImages(std::vector<std::string> filenames, vvImageReader::LoadedImageType type, int n=0);
+  bool SetImages(std::vector<std::string> filenames, vvImageReader::LoadedImageType type, int n=0, bool patientCoordinateSystem=0);
 
   bool SetOverlay(std::vector<std::string> filenames, int dim, std::string component, vvImageReader::LoadedImageType type);
   bool SetFusion(std::vector<std::string> filenames,int dim, std::string component, vvImageReader::LoadedImageType type);