Simplified CalcInternalTransformV3 which makes use of T and R calculated by the transform Meta

This commit is contained in:
Proton local user
2023-05-12 14:55:17 +02:00
parent c67281a10a
commit 9a8faa0693
4 changed files with 261 additions and 212 deletions

View File

@ -543,9 +543,9 @@ R23MetaInformation
TransformMetaInformation ::
TransformMetaInformation (){
m_Translations.Fill(0.);
m_HiddenTranslations.Fill(0.);
m_Rotations.Fill(0.);
m_HiddenRotations.Fill(0.);
m_UserRotations.Fill(0.);
@ -559,6 +559,36 @@ TransformMetaInformation (){
}
TransformMetaInformation::PointType
TransformMetaInformation::GetT(){
PointType
pT;
pT[0] = m_UserTranslations[0] + m_HiddenTranslations[0];
pT[1] = m_UserTranslations[1] + m_HiddenTranslations[1];
pT[2] = m_UserTranslations[2] + m_HiddenTranslations[2];
return
pT;
}
TransformMetaInformation::PointType
TransformMetaInformation::TransformMetaInformation::GetR(){
PointType
pR;
pR[0] = m_UserRotations[0] + m_HiddenRotations[0];
pR[1] = m_UserRotations[1] + m_HiddenRotations[1];
pR[2] = m_UserRotations[2] + m_HiddenRotations[2];
return
pR;
}
void
TransformMetaInformation
::PrintSelf(std::ostream& os, itk::Indent indent) const

View File

@ -577,11 +577,11 @@ public:
void PrintSelf(std::ostream& os, itk::Indent indent) const;
itkSetMacro(Translations,PointType);
itkGetMacro(Translations,PointType);
itkSetMacro(HiddenTranslations,PointType);
itkGetMacro(HiddenTranslations,PointType);
itkSetMacro(Rotations,PointType);
itkGetMacro(Rotations,PointType);
itkSetMacro(HiddenRotations,PointType);
itkGetMacro(HiddenRotations,PointType);
itkSetMacro(UserTranslations,PointType);
itkGetMacro(UserTranslations,PointType);
@ -589,29 +589,17 @@ public:
itkSetMacro(UserRotations,PointType);
itkGetMacro(UserRotations,PointType);
// itkSetMacro(ReferenceTransform,TransformMatrixType);
// itkGetMacro(ReferenceTransform,TransformMatrixType);
// itkSetMacro(CurrentTransform,TransformMatrixType);
// itkGetMacro(CurrentTransform,TransformMatrixType);
// itkSetEnumMacro(DegreeOfFreedom, tDegreeOfFreedomEnum);
// itkGetEnumMacro(DegreeOfFreedom, tDegreeOfFreedomEnum);
PointType GetT();
PointType GetR();
protected:
PointType
m_Translations,
m_Rotations,
m_HiddenTranslations,
m_HiddenRotations,
m_UserTranslations,
m_UserRotations;
// TransformMatrixType
// m_ReferenceTransform,
// m_CurrentTransform;
// tDegreeOfFreedomEnum
// m_DegreeOfFreedom;
/** Default Constructor **/
TransformMetaInformation ();

View File

@ -136,7 +136,7 @@ itkImageProcessor::itkImageProcessor()
Point3D[1]=0.;
Point3D[2]=175.;
m_DRTGeometryMetaInfo->SetProjectionCenter(Point3D);
// m_DRTGeometryMetaInfo->SetProjectionCenter(Point3D);
// m_DRTGeometryMetaInfo->SetProjectionCenter(Point3D);
ImageType3D::SizeType
ImageSize;
ImageSize[0]=512;
@ -287,7 +287,7 @@ double itkImageProcessor::GetPanelOffset2(){
void itkImageProcessor::SetDegreeOfFreedom(tDegreeOfFreedomEnum dof)
{
// m_TransformMetaInfo->SetDegreeOfFreedom(dof);
// m_TransformMetaInfo->SetDegreeOfFreedom(dof);
m_r23MetaInfo->SetDegreeOfFreedom(dof);
}
@ -296,7 +296,7 @@ itkImageProcessor::GetDegreeOfFreedom()
{
return
m_r23MetaInfo->GetDegreeOfFreedom();
//m_TransformMetaInfo->GetDegreeOfFreedom();
//m_TransformMetaInfo->GetDegreeOfFreedom();
}
void itkImageProcessor::SetCustom_ImportTransform(double dTx,
@ -523,11 +523,11 @@ int itkImageProcessor::load3DSerieFromFiles( std::vector<std::string> v_fnames){
if (m_VolumeSourceDupli == NULL)
std::cout << "NEVER HERE m_VolumeSourceDupli" << std::endl;
// if (m_VolumeSourceDupli) {
// std::cout << "NEVER HERE m_VolumeSourceDupli" << std::endl;
// m_VolumeSourceDupli = NULL;
// m_VolumeSourceDupli = DuplicatorType::New();
// }
// if (m_VolumeSourceDupli) {
// std::cout << "NEVER HERE m_VolumeSourceDupli" << std::endl;
// m_VolumeSourceDupli = NULL;
// m_VolumeSourceDupli = DuplicatorType::New();
// }
m_VolumeSourceDupli->SetInputImage(caster3D->GetOutput());
m_VolumeSourceDupli->Update();
@ -538,7 +538,7 @@ int itkImageProcessor::load3DSerieFromFiles( std::vector<std::string> v_fnames){
}
catch (itk::ExceptionObject & ex)
{
// std::cout << ex << std::endl;
// std::cout << ex << std::endl;
return EXIT_FAILURE;
}
@ -755,22 +755,22 @@ int itkImageProcessor::fill3DVolumeMeta(
m_DRTGeometryMetaInfo->GetSCD2Offset()
);
// std::cout<< "///////////////// 3D VOLUME BEG ///////////////" <<std::endl;
// std::cout<< "///////////////// 3D VOLUME BEG ///////////////" <<std::endl;
// std::cout<< "OriginLPS"<< m_CTMetaInfo->GetOriginLPS() <<std::endl;
// std::cout<< "COV"<< m_CTMetaInfo->GetCOV() <<std::endl;
// std::cout<< "OriginLPS"<< m_CTMetaInfo->GetOriginLPS() <<std::endl;
// std::cout<< "COV"<< m_CTMetaInfo->GetCOV() <<std::endl;
std::cout<< "ImportOffset"<< m_CTMetaInfo->GetImportOffset() <<std::endl;
// std::cout<< "LPS2IEC"<< m_CTMetaInfo->GetLPS2IECDirections() <<std::endl;
// std::cout<< "Size"<< m_CTMetaInfo->GetSize() <<std::endl;
// std::cout<< "Spacing"<< m_CTMetaInfo->GetSpacing() <<std::endl;
// std::cout<< "LPS2IEC"<< m_CTMetaInfo->GetLPS2IECDirections() <<std::endl;
// std::cout<< "Size"<< m_CTMetaInfo->GetSize() <<std::endl;
// std::cout<< "Spacing"<< m_CTMetaInfo->GetSpacing() <<std::endl;
// std::cout<< "pAngleLPS1"<< m_DRTImage1MetaInfo->GetProjectionAngleLPS() <<std::endl;
// std::cout<< "SCD1"<< m_DRTImage1MetaInfo->GetSCD() <<std::endl;
// std::cout<< "pAngleLPS1"<< m_DRTImage1MetaInfo->GetProjectionAngleLPS() <<std::endl;
// std::cout<< "SCD1"<< m_DRTImage1MetaInfo->GetSCD() <<std::endl;
// std::cout<< "pAngleLPS2"<< m_DRTImage2MetaInfo->GetProjectionAngleLPS() <<std::endl;
// std::cout<< "SCD2"<< m_DRTImage2MetaInfo->GetSCD() <<std::endl;
// std::cout<< "pAngleLPS2"<< m_DRTImage2MetaInfo->GetProjectionAngleLPS() <<std::endl;
// std::cout<< "SCD2"<< m_DRTImage2MetaInfo->GetSCD() <<std::endl;
// std::cout<< "///////////////// 3D VOLUME END ///////////////" <<std::endl;
// std::cout<< "///////////////// 3D VOLUME END ///////////////" <<std::endl;
this->UpdateProjectionGeometryMeta();
@ -911,7 +911,7 @@ void itkImageProcessor::SetProjectionAngleOffsetIEC(double dOff1, double dOff2)
m_DRTGeometryMetaInfo->SetProjectionAngle1OffsetIEC(dOff1);
m_DRTGeometryMetaInfo->SetProjectionAngle2OffsetIEC(dOff2);
std::cout << "SetProjectionAngleOffsetIEC " << dOff1 << " " << dOff2 << std::endl;
std::cout << "SetProjectionAngleOffsetIEC " << dOff1 << " " << dOff2 << std::endl;
}
@ -986,7 +986,7 @@ int itkImageProcessor::load2D(const char * pcFName){
strcpy( sTmpString,gGetStringValueFromTag( gdcm::Tag(0x0008,0x0008), ds));
std::string sLocalizerString = "LOCALIZER";
if (std::string(sTmpString).find(sLocalizerString) != std::string::npos) {
// std::cout << "Loading Localizer: "<<pcFName << '\n';
// std::cout << "Loading Localizer: "<<pcFName << '\n';
} else {
cerr << "ERROR: the image "<<pcFName <<" is not a LOCALIZER" << '\n';
free (sTmpString);
@ -1022,7 +1022,7 @@ int itkImageProcessor::load2D(const char * pcFName){
}
tokens.clear();
// std::cout<<"Intensity window center and width: "<< dIntensityWindow[0] <<" "<< dIntensityWindow[1] <<std::endl;
// std::cout<<"Intensity window center and width: "<< dIntensityWindow[0] <<" "<< dIntensityWindow[1] <<std::endl;
/* Image orientation */
eImageOrientationType
@ -1031,10 +1031,10 @@ int itkImageProcessor::load2D(const char * pcFName){
*std::remove(sTmpString, sTmpString + strlen(sTmpString), ' ') = 0;
if(!strcmp(sTmpString,ImageOrientationStrings[eImageOrientationType::HFS])){
// std::cout<<"Image orientation: HFS"<<std::endl;
// std::cout<<"Image orientation: HFS"<<std::endl;
currImgOrient = eImageOrientationType::HFS;
} else if(!strcmp(sTmpString,ImageOrientationStrings[eImageOrientationType::FFS])){
// std::cout<<"Image orientation: FFS"<<std::endl;
// std::cout<<"Image orientation: FFS"<<std::endl;
currImgOrient = eImageOrientationType::FFS;
} else {
std::cerr<< "Image Orientation: unrecognised"<< sTmpString <<std::endl;
@ -1066,7 +1066,7 @@ int itkImageProcessor::load2D(const char * pcFName){
ImageDirectionType3D LocalizerImagDirectionDCM =
imageReader2D->GetOutput()->GetDirection();
// std::cout<<"LocalizerImagDirectionDCM " <<LocalizerImagDirectionDCM <<std::endl;
// std::cout<<"LocalizerImagDirectionDCM " <<LocalizerImagDirectionDCM <<std::endl;
InternalImageType::DirectionType toIECDirection;
@ -1110,10 +1110,10 @@ int itkImageProcessor::load2D(const char * pcFName){
/* dot shoudl be 1 or -1 if the normal is parallel */
if(dSumPA == 1 || dSumPA == -1){
currProjOrientation = PA;
// std::cout<<"It's a PA image"<<std::endl;
// std::cout<<"It's a PA image"<<std::endl;
} else if (dSumLAT == 1 || dSumLAT == -1){
currProjOrientation = LAT;
// std::cout<<"It's a LAT image"<<std::endl;
// std::cout<<"It's a LAT image"<<std::endl;
} else {
return -1;
}
@ -1182,14 +1182,14 @@ int itkImageProcessor::load2D(const char * pcFName){
m_Duplicator->Update();
// std::cout<< " ////////////// 2D Topo BEG " <<std::endl;
// std::cout<< " ////////////// 2D Topo BEG " <<std::endl;
// std::cout<<"GetDirection()"<<m_Duplicator->GetOutput()->GetDirection()<<std::endl;
// std::cout<<"GetOrigin()"<<m_Duplicator->GetOutput()->GetOrigin()<<std::endl;
// std::cout<<"GetSpacing()"<<m_Duplicator->GetOutput()->GetSpacing()<<std::endl;
// std::cout<<"GetSize()"<<m_Duplicator->GetOutput()->GetLargestPossibleRegion().GetSize()<<std::endl;
// std::cout<<"GetDirection()"<<m_Duplicator->GetOutput()->GetDirection()<<std::endl;
// std::cout<<"GetOrigin()"<<m_Duplicator->GetOutput()->GetOrigin()<<std::endl;
// std::cout<<"GetSpacing()"<<m_Duplicator->GetOutput()->GetSpacing()<<std::endl;
// std::cout<<"GetSize()"<<m_Duplicator->GetOutput()->GetLargestPossibleRegion().GetSize()<<std::endl;
// std::cout<< " ////////////// 2D Topo END " <<std::endl;
// std::cout<< " ////////////// 2D Topo END " <<std::endl;
return
(int) currProjOrientation;
@ -1420,6 +1420,39 @@ itkImageProcessor::CalculateInternalTransformV2(
}
itkImageProcessor::TransformType::Pointer
itkImageProcessor::CalculateInternalTransformV3(
ImageType3D::PointType m_Translation, //IEC
ImageType3D::PointType m_Rotation, //IEC
ImageType3D::PointType m_CalibratedProjectionCenter, //LPS
ImageType3D::PointType m_RTIsocenter, //LPS
InternalImageType::DirectionType m_IECtoLPSDirections
)
{
//Convert all inputs into LPS
ImageType3D::PointType m_TLPS =
m_IECtoLPSDirections * m_Translation;
ImageType3D::PointType m_RLPS =
m_IECtoLPSDirections * m_Rotation;
// Map offset to the projection center
TransformType::Pointer m_outputTransform =
MapTransformToNewOrigin (
m_CalibratedProjectionCenter - m_RTIsocenter,
m_TLPS,
m_RLPS
);
m_outputTransform->SetCenter(m_CalibratedProjectionCenter);
return m_outputTransform;
}
void itkImageProcessor::InitializeRegistration(
double stepLength,
double maxTranslation,
@ -1443,7 +1476,7 @@ void itkImageProcessor::InitializeRegistration(
metric->SetSubtractMean(true);
metric->SetMaxTranslation(maxTranslation);
// m_TransformMetaInfo->SetDegreeOfFreedom(dof);
// m_TransformMetaInfo->SetDegreeOfFreedom(dof);
m_r23MetaInfo->SetDegreeOfFreedom(dof);
mimetric->ComputeGradientOff();
@ -1487,7 +1520,7 @@ void itkImageProcessor::InitializeRegistration(
}
// registration->SetTransformMetaInfo(m_TransformMetaInfo);
// registration->SetTransformMetaInfo(m_TransformMetaInfo);
registration->SetTransformMetaInfo(m_r23MetaInfo);
registration->SetFilter1(filter1);
@ -1504,28 +1537,27 @@ void itkImageProcessor::InitializeRegistration(
if(m_RTMetaInfo == NULL)
{
CurrTransform =
CalculateInternalTransformV2(
ZeroPoint,
ZeroPoint,
m_TransformMetaInfo->GetTranslations(),
m_TransformMetaInfo->GetRotations(),
CalculateInternalTransformV3(
m_TransformMetaInfo->GetT(),
m_TransformMetaInfo->GetR(),
m_DRTImage1MetaInfo->GetProjectionOriginLPSZero(),
m_DRTImage1MetaInfo->GetProjectionOriginLPS(),
IECtoLPS_Directions
);
IECtoLPS_Directions);
} else {
CurrTransform = CalculateInternalTransformV2(
ZeroPoint ,
m_DRTGeometryMetaInfo->GetIECS2IECScannerR(),
m_TransformMetaInfo->GetTranslations(),
m_TransformMetaInfo->GetRotations(),
CurrTransform =
CalculateInternalTransformV3(
m_TransformMetaInfo->GetT(),
m_TransformMetaInfo->GetR(),
m_DRTImage1MetaInfo->GetProjectionOriginLPSZero(),
m_RTMetaInfo->GetIsocenterLPS() - m_CTMetaInfo->GetOriginLPS(),
IECtoLPS_Directions
);
}
@ -1548,29 +1580,26 @@ void itkImageProcessor::InitializeRegistration(
/********* BEGIN CALCULATION OF INTERNAL TRANSFORM FOR PROJ2 *********/
if(m_RTMetaInfo == NULL)
{
CurrTransform =
CalculateInternalTransformV2(
ZeroPoint,
ZeroPoint,
m_TransformMetaInfo->GetTranslations(),
m_TransformMetaInfo->GetRotations(),
m_DRTImage2MetaInfo->GetProjectionOriginLPSZero(),
m_DRTImage2MetaInfo->GetProjectionOriginLPS(),
IECtoLPS_Directions
);
CurrTransform =
CalculateInternalTransformV3(
m_TransformMetaInfo->GetT(),
m_TransformMetaInfo->GetR(),
m_DRTImage2MetaInfo->GetProjectionOriginLPSZero(),
m_DRTImage2MetaInfo->GetProjectionOriginLPS(),
IECtoLPS_Directions);
} else {
CurrTransform = CalculateInternalTransformV2(
ZeroPoint,
m_DRTGeometryMetaInfo->GetIECS2IECScannerR(),
m_TransformMetaInfo->GetTranslations(),
m_TransformMetaInfo->GetRotations(),
m_DRTImage2MetaInfo->GetProjectionOriginLPSZero(),
m_RTMetaInfo->GetIsocenterLPS() - m_CTMetaInfo->GetOriginLPS(),
IECtoLPS_Directions
);
CurrTransform =
CalculateInternalTransformV3(
m_TransformMetaInfo->GetT(),
m_TransformMetaInfo->GetR(),
m_DRTImage2MetaInfo->GetProjectionOriginLPSZero(),
m_RTMetaInfo->GetIsocenterLPS() - m_CTMetaInfo->GetOriginLPS(),
IECtoLPS_Directions
);
}
@ -1707,10 +1736,10 @@ int itkImageProcessor::StartRegistration(std::string extraInfo)
}
try {
// timer.Start("Registration");
// timer.Start("Registration");
// Start the registration.
registration->StartRegistration();
// timer.Stop("Registration");
// timer.Stop("Registration");
} catch (itk::ExceptionObject& err) {
registration->ResetPipeline();
@ -1818,29 +1847,25 @@ void itkImageProcessor::InitializeProjector()
if(m_RTMetaInfo == NULL)
{
CurrTransform = CalculateInternalTransformV2(
ZeroPoint ,
ZeroPoint ,
m_TransformMetaInfo->GetTranslations(),
m_TransformMetaInfo->GetRotations(),
m_DRTImage1MetaInfo->GetProjectionOriginLPSZero(),
m_DRTImage1MetaInfo->GetProjectionOriginLPS(),
IECtoLPS_Directions
);
CurrTransform = CalculateInternalTransformV3(
m_TransformMetaInfo->GetT(),
m_TransformMetaInfo->GetR(),
m_DRTImage1MetaInfo->GetProjectionOriginLPSZero(),
m_DRTImage1MetaInfo->GetProjectionOriginLPS(),
IECtoLPS_Directions);
} else {
CurrTransform = CalculateInternalTransformV2(
ZeroPoint ,
m_DRTGeometryMetaInfo->GetIECS2IECScannerR(),
m_TransformMetaInfo->GetTranslations(),
m_TransformMetaInfo->GetRotations(),
m_DRTImage1MetaInfo->GetProjectionOriginLPSZero(),
m_RTMetaInfo->GetIsocenterLPS() - m_CTMetaInfo->GetOriginLPS(),
IECtoLPS_Directions
);
CurrTransform =
CalculateInternalTransformV3(
m_TransformMetaInfo->GetT(),
m_TransformMetaInfo->GetR(),
m_DRTImage1MetaInfo->GetProjectionOriginLPSZero(),
m_RTMetaInfo->GetIsocenterLPS() - m_CTMetaInfo->GetOriginLPS(),
IECtoLPS_Directions
);
}
@ -1877,28 +1902,25 @@ void itkImageProcessor::InitializeProjector()
{
CurrTransform =
CalculateInternalTransformV2(
ZeroPoint,
ZeroPoint,
m_TransformMetaInfo->GetTranslations(),
m_TransformMetaInfo->GetRotations(),
m_DRTImage2MetaInfo->GetProjectionOriginLPSZero(),
m_DRTImage2MetaInfo->GetProjectionOriginLPS(),
IECtoLPS_Directions
);
CalculateInternalTransformV3(
m_TransformMetaInfo->GetT(),
m_TransformMetaInfo->GetR(),
m_DRTImage2MetaInfo->GetProjectionOriginLPSZero(),
m_DRTImage2MetaInfo->GetProjectionOriginLPS(),
IECtoLPS_Directions);
} else {
CurrTransform = CalculateInternalTransformV2(
ZeroPoint,
m_DRTGeometryMetaInfo->GetIECS2IECScannerR(),
m_TransformMetaInfo->GetTranslations(),
m_TransformMetaInfo->GetRotations(),
CurrTransform = CalculateInternalTransformV3(
m_TransformMetaInfo->GetT(),
m_TransformMetaInfo->GetR(),
m_DRTImage2MetaInfo->GetProjectionOriginLPSZero(),
m_RTMetaInfo->GetIsocenterLPS() - m_CTMetaInfo->GetOriginLPS(),
IECtoLPS_Directions
);
}
@ -1985,7 +2007,7 @@ void itkImageProcessor::InitializeProjector()
filter1->ChangeOriginOn();
filter1->UpdateOutputInformation();
// std::cout<< "itkImageProcessor::InitializeProjector() " <<std::endl;
// std::cout<< "itkImageProcessor::InitializeProjector() " <<std::endl;
/* Again.. */
resampleFilter2->Update();
@ -2033,7 +2055,14 @@ int itkImageProcessor::unloadRTPlanAndMeta(){
std::cout << "*" << __COMPACT_PRETTY_FUNCTION__ << std::endl;
m_RTMetaInfo = NULL;
return 1;
ImageType3D::PointType
pZero;
pZero.Fill(0.);
m_CTMetaInfo->SetImportOffset(pZero);
m_TransformMetaInfo->SetHiddenRotations(pZero);
return 0;
}
@ -2082,6 +2111,9 @@ void itkImageProcessor::loadRTPlanInfo(
)
);
m_TransformMetaInfo->SetHiddenRotations(
m_DRTGeometryMetaInfo->GetIECS2IECScannerR());
this->UpdateProjectionGeometryMeta();
this->InitializeProjector();
@ -2133,11 +2165,11 @@ void itkImageProcessor::UpdateProjectionGeometryMeta(){
IsocenterOffsetLPS = m_CTMetaInfo->ConvertIECPointToLPSPoint(
m_DRTGeometryMetaInfo->GetProjectionCenterOffset1());
// std::cout<< "///////////////// PGEOM META BEG ///////////////" <<std::endl;
// std::cout<<"NominalIsocenter IEC"<< m_DRTGeometryMetaInfo->GetProjectionCenter() <<std::endl;
// std::cout<<"CALIBRATION NominalIsocenter_wZcorrectionLPS "<<NominalIsocenter_wZcorrectionLPS<<std::endl;
// std::cout<<"CALIBRATION NominalIsocenterZero_wZcorrectionLPS "<<NominalIsocenterZero_wZcorrectionLPS<<std::endl;
// std::cout<<"CALIBRATION IsocenterOffsetLPS "<<IsocenterOffsetLPS<<std::endl;
// std::cout<< "///////////////// PGEOM META BEG ///////////////" <<std::endl;
// std::cout<<"NominalIsocenter IEC"<< m_DRTGeometryMetaInfo->GetProjectionCenter() <<std::endl;
// std::cout<<"CALIBRATION NominalIsocenter_wZcorrectionLPS "<<NominalIsocenter_wZcorrectionLPS<<std::endl;
// std::cout<<"CALIBRATION NominalIsocenterZero_wZcorrectionLPS "<<NominalIsocenterZero_wZcorrectionLPS<<std::endl;
// std::cout<<"CALIBRATION IsocenterOffsetLPS "<<IsocenterOffsetLPS<<std::endl;
ImageType3D::PointType CalibratedIsocenterLPS;
@ -2148,7 +2180,7 @@ void itkImageProcessor::UpdateProjectionGeometryMeta(){
CalibratedIsocenterLPS[2] = NominalIsocenter_wZcorrectionLPS[2] +
IsocenterOffsetLPS[2];
// std::cout<<"CALIBRATION CalibratedIsocenterLPS "<<CalibratedIsocenterLPS<<std::endl;
// std::cout<<"CALIBRATION CalibratedIsocenterLPS "<<CalibratedIsocenterLPS<<std::endl;
ImageType3D::PointType CalibratedIsocenterZeroLPS;
@ -2158,7 +2190,7 @@ void itkImageProcessor::UpdateProjectionGeometryMeta(){
IsocenterOffsetLPS[1];
CalibratedIsocenterZeroLPS[2] = NominalIsocenterZero_wZcorrectionLPS[2] +
IsocenterOffsetLPS[2];
// std::cout<<"CALIBRATION CalibratedIsocenterZeroLPS "<<CalibratedIsocenterZeroLPS<<std::endl;
// std::cout<<"CALIBRATION CalibratedIsocenterZeroLPS "<<CalibratedIsocenterZeroLPS<<std::endl;
m_DRTImage1MetaInfo->SetProjectionAngleLPS(
this->CalcProjectionAngleLPS(
@ -2334,7 +2366,7 @@ itkImageProcessor::CalcDRTImageOrigin(
void itkImageProcessor::GetProjectionImages(){
// std::cout<< "itkImageProcessor::GetProjectionImages" <<std::endl;
// std::cout<< "itkImageProcessor::GetProjectionImages" <<std::endl;
if(m_DRTImage1MetaInfo == NULL ||
m_DRTImage2MetaInfo == NULL ||
m_DRTGeometryMetaInfo == NULL ||
@ -2363,27 +2395,23 @@ void itkImageProcessor::GetProjectionImages(){
if(m_RTMetaInfo == NULL)
{
CurrTransform =
CalculateInternalTransformV2(
ZeroPoint,
ZeroPoint,
m_TransformMetaInfo->GetTranslations(),
m_TransformMetaInfo->GetRotations(),
m_DRTImage1MetaInfo->GetProjectionOriginLPSZero(),
m_DRTImage1MetaInfo->GetProjectionOriginLPS(),
IECtoLPS_Directions
);
CalculateInternalTransformV3(
m_TransformMetaInfo->GetT(),
m_TransformMetaInfo->GetR(),
m_DRTImage1MetaInfo->GetProjectionOriginLPSZero(),
m_DRTImage1MetaInfo->GetProjectionOriginLPS(),
IECtoLPS_Directions);
} else {
CurrTransform = CalculateInternalTransformV2(
ZeroPoint ,
m_DRTGeometryMetaInfo->GetIECS2IECScannerR(),
m_TransformMetaInfo->GetTranslations(),
m_TransformMetaInfo->GetRotations(),
m_DRTImage1MetaInfo->GetProjectionOriginLPSZero(),
m_RTMetaInfo->GetIsocenterLPS() - m_CTMetaInfo->GetOriginLPS(),
IECtoLPS_Directions
);
CurrTransform =
CalculateInternalTransformV3(
m_TransformMetaInfo->GetT(),
m_TransformMetaInfo->GetR(),
m_DRTImage1MetaInfo->GetProjectionOriginLPSZero(),
m_RTMetaInfo->GetIsocenterLPS() - m_CTMetaInfo->GetOriginLPS(),
IECtoLPS_Directions
);
}
@ -2425,23 +2453,18 @@ void itkImageProcessor::GetProjectionImages(){
{
CurrTransform =
CalculateInternalTransformV2(
ZeroPoint,
ZeroPoint,
m_TransformMetaInfo->GetTranslations(),
m_TransformMetaInfo->GetRotations(),
m_DRTImage2MetaInfo->GetProjectionOriginLPSZero(),
m_DRTImage2MetaInfo->GetProjectionOriginLPS(),
IECtoLPS_Directions
);
CalculateInternalTransformV3(
m_TransformMetaInfo->GetT(),
m_TransformMetaInfo->GetR(),
m_DRTImage2MetaInfo->GetProjectionOriginLPSZero(),
m_DRTImage2MetaInfo->GetProjectionOriginLPS(),
IECtoLPS_Directions);
} else {
CurrTransform = CalculateInternalTransformV2(
ZeroPoint,
m_DRTGeometryMetaInfo->GetIECS2IECScannerR(),
m_TransformMetaInfo->GetTranslations(),
m_TransformMetaInfo->GetRotations(),
CurrTransform = CalculateInternalTransformV3(
m_TransformMetaInfo->GetT(),
m_TransformMetaInfo->GetR(),
m_DRTImage2MetaInfo->GetProjectionOriginLPSZero(),
m_RTMetaInfo->GetIsocenterLPS() - m_CTMetaInfo->GetOriginLPS(),
IECtoLPS_Directions
@ -2634,22 +2657,22 @@ vtkImageData* itkImageProcessor::GetLocalizer1VTK()
ImageType3D::PointType LastVoxelPosition =
origin3D + (imagDirection * Dest);
// std::cout<<" -------- Localizer 1 ITK --------"<<std::endl;
// std::cout<<"size3D " <<size3D <<std::endl;
// std::cout<<"resolution3D " <<resolution3D <<std::endl;
// std::cout<<"imagDirection " <<imagDirection <<std::endl;
// std::cout<<"First Voxel position " <<origin3D <<std::endl;
// std::cout<<"Last Voxel position: "<<LastVoxelPosition<<std::endl;
// std::cout<<" -------- Localizer 1 ITK --------"<<std::endl;
// std::cout<<"size3D " <<size3D <<std::endl;
// std::cout<<"resolution3D " <<resolution3D <<std::endl;
// std::cout<<"imagDirection " <<imagDirection <<std::endl;
// std::cout<<"First Voxel position " <<origin3D <<std::endl;
// std::cout<<"Last Voxel position: "<<LastVoxelPosition<<std::endl;
double* dBounds = toVTKLocalizer1->GetOutput()->GetBounds();
// std::cout<< "-------- Localizer 1 VTK --------" <<std::endl;
// std::cout<<"Bounds: "<<dBounds[0]<<" "<<dBounds[1]<<" "
// <<dBounds[2]<<" "<<dBounds[3]<<" "
// <<dBounds[4]<<" "<<dBounds[5]<<std::endl;
// std::cout<< "-------- -------- --------" <<std::endl;
// std::cout<< "-------- Localizer 1 VTK --------" <<std::endl;
// std::cout<<"Bounds: "<<dBounds[0]<<" "<<dBounds[1]<<" "
// <<dBounds[2]<<" "<<dBounds[3]<<" "
// <<dBounds[4]<<" "<<dBounds[5]<<std::endl;
// std::cout<< "-------- -------- --------" <<std::endl;
}
return
@ -2737,20 +2760,20 @@ vtkImageData* itkImageProcessor::GetProjection1VTK()
rescaler1->SetInput( imageDRT1In );
rescaler1->Update();
// using ImageCalculatorFilterType = itk::MinimumMaximumImageCalculator<InternalImageType>;
// auto imageCalculatorFilter = ImageCalculatorFilterType::New();
// imageCalculatorFilter->SetImage(imageDRT1In);
// imageCalculatorFilter->Compute();
// using ImageCalculatorFilterType = itk::MinimumMaximumImageCalculator<InternalImageType>;
// auto imageCalculatorFilter = ImageCalculatorFilterType::New();
// imageCalculatorFilter->SetImage(imageDRT1In);
// imageCalculatorFilter->Compute();
// std::cout<< "itkImageProcessor::imageDRT1In() " <<
// imageCalculatorFilter <<std::endl;
// std::cout<< "itkImageProcessor::imageDRT1In() " <<
// imageCalculatorFilter <<std::endl;
// using ImageCalculatorFilterType2 = itk::MinimumMaximumImageCalculator<OutputImageType>;
// auto imageCalculatorFilter2 = ImageCalculatorFilterType2::New();
// imageCalculatorFilter2->SetImage(rescaler1->GetOutput());
// imageCalculatorFilter2->Compute();
// std::cout<< "itkImageProcessor::imageDRT2In() " <<
// imageCalculatorFilter2 <<std::endl;
// using ImageCalculatorFilterType2 = itk::MinimumMaximumImageCalculator<OutputImageType>;
// auto imageCalculatorFilter2 = ImageCalculatorFilterType2::New();
// imageCalculatorFilter2->SetImage(rescaler1->GetOutput());
// imageCalculatorFilter2->Compute();
// std::cout<< "itkImageProcessor::imageDRT2In() " <<
// imageCalculatorFilter2 <<std::endl;
toVTK2D1->SetInput(rescaler1->GetOutput());
toVTK2D1->Update();
@ -2908,12 +2931,12 @@ vtkImageData* itkImageProcessor::GetProjection2VTK()
//double* dBounds = toVTK2D2->GetOutput()->GetBounds();
// std::cout<< "-------- Proj 2 --------" <<std::endl;
// std::cout<<"Bounds: "<<dBounds[0]<<" "<<dBounds[1]<<" "
// <<dBounds[2]<<" "<<dBounds[3]<<" "
// <<dBounds[4]<<" "<<dBounds[5]<<std::endl;
// std::cout<< "-------- -------- --------" <<std::endl;
//double* dBounds = toVTK2D2->GetOutput()->GetBounds();
// std::cout<< "-------- Proj 2 --------" <<std::endl;
// std::cout<<"Bounds: "<<dBounds[0]<<" "<<dBounds[1]<<" "
// <<dBounds[2]<<" "<<dBounds[3]<<" "
// <<dBounds[4]<<" "<<dBounds[5]<<std::endl;
// std::cout<< "-------- -------- --------" <<std::endl;
return
toVTK2D2->GetOutput();
@ -2947,7 +2970,7 @@ void itkImageProcessor::WriteProjectionImages()
try
{
// std::cout << "Writing image 1 " << std::endl;
// std::cout << "Writing image 1 " << std::endl;
writer1->Update();
}
catch (itk::ExceptionObject & err)
@ -2961,7 +2984,7 @@ void itkImageProcessor::WriteProjectionImages()
try
{
// std::cout << "Writing image 2" << std::endl;
// std::cout << "Writing image 2" << std::endl;
writer2->Update();
}
catch (itk::ExceptionObject & err)
@ -2983,13 +3006,12 @@ void itkImageProcessor::SetInitialTranslations(double dX, double dY, double dZ)
//todo
}
ImageType3D::PointType Translations;
Translations[0]= dX;
Translations[1]= dY;
Translations[2]= dZ;
m_TransformMetaInfo->SetTranslations(Translations);
m_TransformMetaInfo->SetUserTranslations(Translations);
}
void itkImageProcessor::SetInitialRotations(double dX, double dY, double dZ)
@ -2999,18 +3021,19 @@ void itkImageProcessor::SetInitialRotations(double dX, double dY, double dZ)
Rotations[1]= dY;
Rotations[2]= dZ;
m_TransformMetaInfo->SetRotations(Rotations);
m_TransformMetaInfo->SetUserRotations(Rotations);
}
// THIS IS READ FOR EXPORT. TO FIX.
double* itkImageProcessor::GetTransformParameters(){
ImageType3D::PointType Translations;
ImageType3D::PointType Rotations;
Translations = m_TransformMetaInfo->GetTranslations();
Rotations = m_TransformMetaInfo->GetRotations();
Translations = m_TransformMetaInfo->GetUserTranslations();
Rotations = m_TransformMetaInfo->GetUserRotations();
dTransfParam[0] = Translations[0];
dTransfParam[1] = Translations[1];
@ -3023,27 +3046,26 @@ double* itkImageProcessor::GetTransformParameters(){
return dTransfParam;
}
// Doubts about this user thing
// THESE ARE CALLED AT THE END OF REG
void itkImageProcessor::GetFinalTranslations(double& dX, double& dY, double& dZ)
{
ImageType3D::PointType translations = m_TransformMetaInfo->GetTranslations();
ImageType3D::PointType userTranslations = m_TransformMetaInfo->GetUserTranslations();
dX = translations[0] + userTranslations[0];
dY = translations[1] + userTranslations[1];
dZ = translations[2] + userTranslations[2];
dX = userTranslations[0];
dY = userTranslations[1];
dZ = userTranslations[2];
}
// THESE ARE CALLED AT THE END OF REG
void itkImageProcessor::GetFinalRotations(double& dRX, double& dRY, double& dRZ)
{
ImageType3D::PointType rotations = m_TransformMetaInfo->GetRotations();
ImageType3D::PointType userRotations = m_TransformMetaInfo->GetUserRotations();
dRX = rotations[0] + userRotations[0];
dRY = rotations[1] + userRotations[1];
dRZ = rotations[2] + userRotations[2];
}
dRX = userRotations[0];
dRY = userRotations[1];
dRZ = userRotations[2];
}
double itkImageProcessor::GetOptimizerValue()
{

View File

@ -282,6 +282,15 @@ private:
InternalImageType::DirectionType m_IECtoLPSDirections
);
TransformType::Pointer
CalculateInternalTransformV3(
ImageType3D::PointType m_Translation,
ImageType3D::PointType m_Rotation,
ImageType3D::PointType m_CalibratedProjectionCenter,
ImageType3D::PointType m_RTIsocenter,
InternalImageType::DirectionType m_IECtoLPSDirections
);
TransformType::Pointer
transform1,
transform2;