From: tbaudier Date: Thu, 16 Nov 2017 14:49:32 +0000 (+0100) Subject: Open Dicom with imaging machine coordinate system (Identity matrix) by default X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=768d2a323265bc8f800fadea925ab9f3a0f8cf24;p=clitk.git Open Dicom with imaging machine coordinate system (Identity matrix) by default Add a check box to open it with patient coordinate system --- diff --git a/common/vvImage.cxx b/common/vvImage.cxx index 48f2e1f..f75d321 100644 --- a/common/vvImage.cxx +++ b/common/vvImage.cxx @@ -261,6 +261,15 @@ const std::vector< vtkSmartPointer >& vvImage::GetTransform() //-------------------------------------------------------------------- +//-------------------------------------------------------------------- +void vvImage::InitializeTransform() +{ + for (int i = 0; i < mTransform.size(); i++) + mTransform[i]->Identity(); +} +//-------------------------------------------------------------------- + + //-------------------------------------------------------------------- std::vector< std::vector > vvImage::GetDirection() { diff --git a/common/vvImage.h b/common/vvImage.h index 09cb4d9..cbb0284 100644 --- a/common/vvImage.h +++ b/common/vvImage.h @@ -68,6 +68,7 @@ public : bool IsScalarTypeInteger(); bool IsScalarTypeInteger(int t); const std::vector< vtkSmartPointer >& GetTransform(); + void InitializeTransform(); void SetTimeSpacing(double s) { mTimeSpacing = s; } void SetTimeOrigin(double o) { mTimeOrigin = o; } bool HaveSameSizeAndSpacingThan(vvImage * other); diff --git a/common/vvImageReader.cxx b/common/vvImageReader.cxx index 5e7d903..a2fc4e9 100644 --- a/common/vvImageReader.cxx +++ b/common/vvImageReader.cxx @@ -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) { diff --git a/common/vvImageReader.h b/common/vvImageReader.h index 4dc3f40..6f3dbc3 100644 --- a/common/vvImageReader.h +++ b/common/vvImageReader.h @@ -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; //==================================================================== diff --git a/common/vvImageReader.txx b/common/vvImageReader.txx index a9f17ab..2eba11c 100644 --- a/common/vvImageReader.txx +++ b/common/vvImageReader.txx @@ -257,6 +257,9 @@ void vvImageReader::UpdateWithDimAndInputPixelType() } } } + + if (mType == DICOM && !mPatientCoordinateSystem) + mImage->InitializeTransform(); } //---------------------------------------------------------------------------- diff --git a/vv/qt_ui/vvDicomSeriesSelector.ui b/vv/qt_ui/vvDicomSeriesSelector.ui index f7e7132..110993b 100644 --- a/vv/qt_ui/vvDicomSeriesSelector.ui +++ b/vv/qt_ui/vvDicomSeriesSelector.ui @@ -216,20 +216,31 @@ 0 - - - - 0 - 0 - - - - <b>Files in current DICOM serie</b> - - - Qt::RichText - - + + + + + + 0 + 0 + + + + <b>Files in current DICOM serie</b> + + + Qt::RichText + + + + + + + Patient coordinate system + + + + diff --git a/vv/vvMainWindow.cxx b/vv/vvMainWindow.cxx index 9801e8b..e88a5d9 100644 --- a/vv/vvMainWindow.cxx +++ b/vv/vvMainWindow.cxx @@ -902,11 +902,13 @@ void vvMainWindow::LoadImages(std::vector 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"; diff --git a/vv/vvQDicomSeriesSelector.cxx b/vv/vvQDicomSeriesSelector.cxx index 44850bb..9c27982 100644 --- a/vv/vvQDicomSeriesSelector.cxx +++ b/vv/vvQDicomSeriesSelector.cxx @@ -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 & } //==================================================================== + +//==================================================================== +void vvDicomSeriesSelector::itemMatrixSelectionChanged(int state) +{ + mPatientCoordinateSystem = state; +} +//==================================================================== + + #endif // VVDICOMSERIESSELECTOR_CXX diff --git a/vv/vvQDicomSeriesSelector.h b/vv/vvQDicomSeriesSelector.h index 8b3aaac..aa905fc 100644 --- a/vv/vvQDicomSeriesSelector.h +++ b/vv/vvQDicomSeriesSelector.h @@ -37,12 +37,14 @@ public: std::vector * 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 mDicomHeader; #endif std::map mDicomDetails; + bool mPatientCoordinateSystem; }; #endif // VVDICOMSERIESSELECTOR_H diff --git a/vv/vvSlicerManager.cxx b/vv/vvSlicerManager.cxx index 139c808..089001c 100644 --- a/vv/vvSlicerManager.cxx +++ b/vv/vvSlicerManager.cxx @@ -221,7 +221,7 @@ void vvSlicerManager::SetImage(vvImage::Pointer image) //---------------------------------------------------------------------------- -bool vvSlicerManager::SetImages(std::vector filenames, vvImageReader::LoadedImageType type, int n) +bool vvSlicerManager::SetImages(std::vector 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 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)); diff --git a/vv/vvSlicerManager.h b/vv/vvSlicerManager.h index 0d5c9ae..4acb166 100644 --- a/vv/vvSlicerManager.h +++ b/vv/vvSlicerManager.h @@ -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 filenames, vvImageReader::LoadedImageType type, int n=0); + bool SetImages(std::vector filenames, vvImageReader::LoadedImageType type, int n=0, bool patientCoordinateSystem=0); bool SetOverlay(std::vector filenames, int dim, std::string component, vvImageReader::LoadedImageType type); bool SetFusion(std::vector filenames,int dim, std::string component, vvImageReader::LoadedImageType type);