From 292032fca2186c9dc8c784c58bec31ed408e407f Mon Sep 17 00:00:00 2001 From: Proton local user Date: Fri, 28 Apr 2023 18:51:28 +0200 Subject: [PATCH] Major modifications to account for introducing in the calibration paramters the panel center offset: This include as most important changes: - itkImageProcessor UpdateProjectionGeometryMeta - SetOriginLPS now includes that offset - ui_qvtk_handler: change in overlapping of two images. This now use the vtk provided image center which also consider image orientation and allows us to work under no assumption of center at same position between DRT and TOPO This release was tested on Imaging calibration data. Consistency was good. On Phantom data also good consistency on Correction Vector between SHORT and LONG --- .../itkDTRrecon/DRTMetaInformation.cpp | 4 + .../itkDTRrecon/DRTMetaInformation.h | 8 + .../itkDTRrecon/itkImageProcessor.cpp | 163 ++++++++++++++---- .../itkDTRrecon/itkImageProcessor.h | 14 ++ 4 files changed, 156 insertions(+), 33 deletions(-) diff --git a/reg23Topograms/itkDTRrecon/DRTMetaInformation.cpp b/reg23Topograms/itkDTRrecon/DRTMetaInformation.cpp index 748cded..55ada69 100644 --- a/reg23Topograms/itkDTRrecon/DRTMetaInformation.cpp +++ b/reg23Topograms/itkDTRrecon/DRTMetaInformation.cpp @@ -450,6 +450,10 @@ DRTProjectionGeometryImageMetaInformation(){ this->m_SCD2Offset = 0.; + this->m_Panel1Offset = 0.; + + this->m_Panel2Offset = 0.; + this->m_IntensityThreshold=0.; this->m_DRT1Size.Fill(0.); diff --git a/reg23Topograms/itkDTRrecon/DRTMetaInformation.h b/reg23Topograms/itkDTRrecon/DRTMetaInformation.h index d79ffd1..1f77f24 100644 --- a/reg23Topograms/itkDTRrecon/DRTMetaInformation.h +++ b/reg23Topograms/itkDTRrecon/DRTMetaInformation.h @@ -372,6 +372,12 @@ public: itkSetMacro(SCD2Offset, double); itkGetMacro(SCD2Offset, double); + itkSetMacro(Panel1Offset, double); + itkGetMacro(Panel1Offset, double); + + itkSetMacro(Panel2Offset, double); + itkGetMacro(Panel2Offset, double); + itkSetMacro(IntensityThreshold, double); itkGetMacro(IntensityThreshold, double); @@ -413,6 +419,8 @@ protected: m_SCD2, m_SCD1Offset, m_SCD2Offset, + m_Panel1Offset, + m_Panel2Offset, m_IntensityThreshold; diff --git a/reg23Topograms/itkDTRrecon/itkImageProcessor.cpp b/reg23Topograms/itkDTRrecon/itkImageProcessor.cpp index 04b0fca..8dfcc00 100644 --- a/reg23Topograms/itkDTRrecon/itkImageProcessor.cpp +++ b/reg23Topograms/itkDTRrecon/itkImageProcessor.cpp @@ -261,9 +261,27 @@ double itkImageProcessor::GetSCD1(){ } double itkImageProcessor::GetSCD2(){ return - m_DRTImage1MetaInfo ->GetSCD(); + m_DRTImage2MetaInfo ->GetSCD(); } +void itkImageProcessor::SetPanelOffsets(double dOff1, double dOff2) +{ + m_DRTGeometryMetaInfo->SetPanel1Offset(dOff1); + m_DRTGeometryMetaInfo->SetPanel2Offset(dOff2); +} + +double itkImageProcessor::GetPanelOffset1(){ + return + m_DRTGeometryMetaInfo->GetPanel1Offset(); +} + +double itkImageProcessor::GetPanelOffset2(){ + return + m_DRTGeometryMetaInfo ->GetPanel2Offset(); +} + + + void itkImageProcessor::SetDegreeOfFreedom(tDegreeOfFreedomEnum dof) { m_TransformMetaInfo->SetDegreeOfFreedom(dof); @@ -2020,7 +2038,7 @@ void itkImageProcessor::InitializeProjector() filter2->SetInput( resampleFilter2 ->GetOutput() ); filter2->SetOutputDirection(m_DRTImage2MetaInfo->GetImageDirectionsLPS() ); filter2->ChangeDirectionOn(); - filter2->SetOutputOrigin(m_DRTImage2MetaInfo->GetOriginLPS() ); + filter2->SetOutputOrigin(m_DRTImage2MetaInfo->GetOriginLPS() ); filter2->ChangeOriginOn(); filter2->UpdateOutputInformation(); @@ -2160,11 +2178,11 @@ void itkImageProcessor::UpdateProjectionGeometryMeta(){ IsocenterOffsetLPS = m_CTMetaInfo->ConvertIECPointToLPSPoint( m_DRTGeometryMetaInfo->GetProjectionCenterOffset1()); -// std::cout<< "///////////////// PGEOM META BEG ///////////////" <GetProjectionCenter() <GetProjectionCenter() <SetProjectionAngleLPS( this->CalcProjectionAngleLPS( @@ -2203,27 +2223,33 @@ void itkImageProcessor::UpdateProjectionGeometryMeta(){ m_DRTImage1MetaInfo->SetProjectionOriginLPSZero( CalibratedIsocenterZeroLPS); - // This is based on the calibrated iso to be sure... - std::vector vBounds = m_CTMetaInfo->CalculateRegions( - NominalIsocenter_wZcorrectionLPS -// m_DRTImage1MetaInfo->GetProjectionOriginLPS() - ); +// // This is based on the calibrated iso to be sure... +// std::vector vBounds = m_CTMetaInfo->CalculateRegions( +// NominalIsocenter_wZcorrectionLPS +//// m_DRTImage1MetaInfo->GetProjectionOriginLPS() +// ); -// std::cout<<"Bounds1: " -// <SetSizeWithBounds( - vBounds.data(), + NULL,//vBounds.data(), m_DRTGeometryMetaInfo->GetDRT1Size(), m_DRTGeometryMetaInfo->GetDRT1Spacing() ); + ImageType3D::PointType PanelOffsetIEC1; + + PanelOffsetIEC1[0] = -m_DRTGeometryMetaInfo->GetPanel1Offset(); + PanelOffsetIEC1[1] = 0.0; + PanelOffsetIEC1[2] = 0.0; + // This HAS TO be calculated from the nominal isocenter. m_DRTImage1MetaInfo->SetOriginLPS( CalcDRTImageOrigin( @@ -2235,8 +2261,17 @@ void itkImageProcessor::UpdateProjectionGeometryMeta(){ m_DRTGeometryMetaInfo->GetProjectionAngle1IEC() ), //m_DRTGeometryMetaInfo->GetProjectionAngle1IEC(),// m_DRTImage1MetaInfo->GetProjectionAngleLPS(), Std_DRT2LPS + ) - + CalcDRTImageOffset( + PanelOffsetIEC1, + this->CalcProjectionAngleLPS( + m_CTMetaInfo->GetPatientOrientation(), + m_DRTGeometryMetaInfo->GetProjectionAngle1IEC() ), + Std_DRT2LPS ) + ); + std::cout<<"CALIBRATION GetOriginLPS "<GetOriginLPS()<GetSize()"<< m_DRTImage1MetaInfo->GetSize() <GetSpacing()"<< m_DRTImage1MetaInfo->GetSpacing() <GetOrigin()"<< m_DRTImage1MetaInfo->GetOrigin() <CalcProjectionAngleLPS( + m_CTMetaInfo->GetPatientOrientation(), + m_DRTGeometryMetaInfo->GetProjectionAngle1IEC() ), + Std_DRT2LPS + ) <GetCOV()"<< m_DRTImage1MetaInfo->GetCOV() <GetOriginLPS()"<< m_DRTImage1MetaInfo->GetOriginLPS() <GetOriginLPS()"<< m_DRTImage1MetaInfo->GetOriginLPS() <GetProjectionAngleLPS()"<GetProjectionAngleLPS()<GetImageDirectionsLPS()"<< m_DRTImage1MetaInfo->GetImageDirectionsLPS() <GetProjectionCenter2()) // ); - vBounds.clear(); - vBounds = m_CTMetaInfo->CalculateRegions( - NominalIsocenter_wZcorrectionLPS//m_DRTImage2MetaInfo->GetProjectionOriginLPS() - ); +// vBounds.clear(); +// vBounds = m_CTMetaInfo->CalculateRegions( +// NominalIsocenter_wZcorrectionLPS//m_DRTImage2MetaInfo->GetProjectionOriginLPS() +// ); // std::cout<<"Bounds2: " // <SetSizeWithBounds( - vBounds.data(), + NULL,//vBounds.data(), m_DRTGeometryMetaInfo->GetDRT2Size(), m_DRTGeometryMetaInfo->GetDRT2Spacing() ); + + ImageType3D::PointType PanelOffsetIEC2; + + PanelOffsetIEC2[0] = -m_DRTGeometryMetaInfo->GetPanel2Offset(); + PanelOffsetIEC2[1] = 0.0; + PanelOffsetIEC2[2] = 0.0; + + m_DRTImage2MetaInfo->SetOriginLPS( CalcDRTImageOrigin( m_DRTImage2MetaInfo->GetOrigin(), @@ -2336,7 +2386,30 @@ void itkImageProcessor::UpdateProjectionGeometryMeta(){ m_DRTGeometryMetaInfo->GetProjectionAngle2IEC()) , //m_DRTGeometryMetaInfo->GetProjectionAngle2IEC(),//m_DRTImage2MetaInfo->GetProjectionAngleLPS(), Std_DRT2LPS + )); + + std::cout<<"m_DRTImage2MetaInfo->GetOriginLPS()"<< m_DRTImage2MetaInfo->GetOriginLPS() <SetOriginLPS( + CalcDRTImageOrigin( + m_DRTImage2MetaInfo->GetOrigin(), + m_DRTImage2MetaInfo->GetCOV(), + NominalIsocenter_wZcorrectionLPS,//m_DRTImage2MetaInfo->GetProjectionOriginLPS(), + this->CalcProjectionAngleLPS( + m_CTMetaInfo->GetPatientOrientation(), + m_DRTGeometryMetaInfo->GetProjectionAngle2IEC()) , + //m_DRTGeometryMetaInfo->GetProjectionAngle2IEC(),//m_DRTImage2MetaInfo->GetProjectionAngleLPS(), + Std_DRT2LPS + ) - + CalcDRTImageOffset( + PanelOffsetIEC2, + this->CalcProjectionAngleLPS( + m_CTMetaInfo->GetPatientOrientation(), + m_DRTGeometryMetaInfo->GetProjectionAngle2IEC() ), + Std_DRT2LPS ) + ); m_DRTImage2MetaInfo->SetImageDirectionsLPS( @@ -2354,8 +2427,15 @@ void itkImageProcessor::UpdateProjectionGeometryMeta(){ // std::cout<<"m_DRTImage2MetaInfo->GetSize()"<< m_DRTImage2MetaInfo->GetSize() <GetSpacing()"<< m_DRTImage2MetaInfo->GetSpacing() <GetOrigin()"<< m_DRTImage2MetaInfo->GetOrigin() <CalcProjectionAngleLPS( + m_CTMetaInfo->GetPatientOrientation(), + m_DRTGeometryMetaInfo->GetProjectionAngle2IEC() ), + Std_DRT2LPS + ) <GetCOV()"<< m_DRTImage2MetaInfo->GetCOV() <GetOriginLPS()"<< m_DRTImage2MetaInfo->GetOriginLPS() <GetOriginLPS() - Offset "<< m_DRTImage2MetaInfo->GetOriginLPS() <GetProjectionAngleLPS()"<GetProjectionAngleLPS()<GetImageDirectionsLPS()"<< m_DRTImage2MetaInfo->GetImageDirectionsLPS() <CalcDRTImageDirections(dAngle, stdDRT2LPS); + + ImageType3D::PointType NewOffset = + DRT2LPS * (m_DRTOffset); + + return + NewOffset; +} + void itkImageProcessor::GetProjectionImages(){ @@ -2997,13 +3094,13 @@ vtkImageData* itkImageProcessor::GetProjection2VTK() - // double* dBounds = toVTK2D2->GetOutput()->GetBounds(); + double* dBounds = toVTK2D2->GetOutput()->GetBounds(); - // std::cout<< "-------- Proj 2 --------" <GetOutput(); diff --git a/reg23Topograms/itkDTRrecon/itkImageProcessor.h b/reg23Topograms/itkDTRrecon/itkImageProcessor.h index 04adb49..3a1045b 100644 --- a/reg23Topograms/itkDTRrecon/itkImageProcessor.h +++ b/reg23Topograms/itkDTRrecon/itkImageProcessor.h @@ -106,6 +106,13 @@ public: double GetSCD1(); double GetSCD2(); + /** Panel offsets - panel offsets IEC */ + void SetPanelOffsets(double,double); + /** Get projection angles - Gantry angle LPS + * Only meaningful after a 3D Volume is loaded */ + double GetPanelOffset1(); + double GetPanelOffset2(); + /** Sets the degree of freedom for omptimzation*/ void SetDegreeOfFreedom(tDegreeOfFreedomEnum); tDegreeOfFreedomEnum GetDegreeOfFreedom(); @@ -338,6 +345,13 @@ private: ); + ImageType3D::PointType + CalcDRTImageOffset( + ImageType3D::PointType m_DRTOffset, + double dAngle, + InternalImageType::DirectionType stdDRT2LPS + ); + TransformType::Pointer MapTransformToNewOrigin( ImageType3D::PointType m_COR,