Set functions for RTPlan related data
Some clean up
This commit is contained in:
@ -18,7 +18,9 @@ SET(SRCS
|
||||
)
|
||||
|
||||
SET(HDR
|
||||
itkImageProcessor.h itkgSiddonJacobsRayCastInterpolateImageFunction.h itkgSiddonJacobsRayCastInterpolateImageFunction.hxx
|
||||
itkImageProcessor.h
|
||||
itkgSiddonJacobsRayCastInterpolateImageFunction.h
|
||||
itkgSiddonJacobsRayCastInterpolateImageFunction.hxx
|
||||
)
|
||||
|
||||
ADD_LIBRARY(${LIB_NAME} ${SRCS} ${HDR})
|
||||
@ -37,4 +39,4 @@ TARGET_LINK_LIBRARIES(
|
||||
|
||||
target_include_directories (${LIB_NAME}
|
||||
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
)
|
||||
|
@ -31,13 +31,6 @@ gfattori 08.11.2021
|
||||
|
||||
#define CT_DEFAULT_TABLEHEIGHT 175
|
||||
|
||||
/* From Files */
|
||||
#define RT_iso_x 0
|
||||
#define RT_iso_y 0
|
||||
#define RT_iso_z 0
|
||||
#define RT_LAT 0
|
||||
#define RT_LNG 0
|
||||
#define RT_VRT 0
|
||||
|
||||
|
||||
namespace itk
|
||||
@ -104,17 +97,12 @@ itkImageProcessor::itkImageProcessor()
|
||||
interpolator1 = InterpolatorType::New();
|
||||
interpolator2 = InterpolatorType::New();
|
||||
|
||||
//imageSeriesReader3D = ImageSeriesReaderType3D::New();
|
||||
|
||||
d_scd = 1000.; // Source to isocenter distance
|
||||
d_intensityThreshold = 0.;
|
||||
projAngle1 = -999.;
|
||||
projAngle2 = -999.;
|
||||
|
||||
isocenter[0]=isocenter[1]=isocenter[2] = 0.;
|
||||
image1res[0]=image2res[1]= 2.;
|
||||
//image1center[0]=image1center[1]= 0.;
|
||||
//image2center[0]=image2center[1]= 0.;
|
||||
image1Size[0] = image1Size[1] = 512;
|
||||
image2Size[0] = image2Size[1] = 512;
|
||||
|
||||
@ -123,18 +111,17 @@ itkImageProcessor::itkImageProcessor()
|
||||
|
||||
TZero[0]=TZero[1]=TZero[2]=0.;
|
||||
RZero[0]=RZero[1]=RZero[2]=0.;
|
||||
customized_iso = false;
|
||||
// customized_2DCX = false;
|
||||
customized_2DRES = false;
|
||||
customized_2DSIZE = false;
|
||||
customized_ImportTransform = false;
|
||||
customized_ProjectionCenter = false;
|
||||
customized_RTCouchSetup = false;
|
||||
customized_RTIsocenter = false;
|
||||
|
||||
image2D1Loaded= false;
|
||||
image2D2Loaded= false;
|
||||
image3DLoaded= false;
|
||||
|
||||
// caster3D = CastFilterType3D::New();
|
||||
|
||||
|
||||
toVTK2D1 = ITKtoVTKFilterType::New();
|
||||
toVTK2D2 = ITKtoVTKFilterType::New();
|
||||
toVTKLocalizer1 = ITKtoVTKFilterType::New();
|
||||
@ -146,17 +133,21 @@ itkImageProcessor::itkImageProcessor()
|
||||
m_PASourceDupli = DuplicatorType::New();
|
||||
m_VolumeSourceDupli = DuplicatorType::New();
|
||||
|
||||
Std_DRT2LPS.SetIdentity();
|
||||
for(int iIdx = 0 ; iIdx < 3; iIdx++){
|
||||
for(int jIdx = 0 ; jIdx < 3; jIdx++){
|
||||
Std_DRT2LPS.GetVnlMatrix()[iIdx][jIdx] = Standard_DRT2LPS [jIdx+iIdx*3];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
m_3DInputChangeInformationToZero =
|
||||
ChangeInformationFilterType::New();
|
||||
|
||||
IEC2DCMMapT.Fill(0.);
|
||||
IEC2DCMMapR.Fill(0.);
|
||||
rtIsocenterLPS.Fill(0.);
|
||||
rtCouchOffset.Fill(0.);
|
||||
ProjectionCenterFixedAxes.Fill(0.);
|
||||
|
||||
}
|
||||
|
||||
@ -180,12 +171,50 @@ void itkImageProcessor::SetSCD(double dDist)
|
||||
d_scd = dDist;
|
||||
}
|
||||
|
||||
void itkImageProcessor::SetCustom_Isocenter(double dX,double dY,double dZ)
|
||||
void itkImageProcessor::SetCustom_ImportTransform(double dTx,
|
||||
double dTy,
|
||||
double dTz,
|
||||
double dRx,
|
||||
double dRy,
|
||||
double dRz)
|
||||
{
|
||||
isocenter[0] = dX;
|
||||
isocenter[1] = dY;
|
||||
isocenter[2] = dZ;
|
||||
customized_iso = true;
|
||||
IEC2DCMMapT[0] = dTx;
|
||||
IEC2DCMMapT[1] = dTy;
|
||||
IEC2DCMMapT[2] = dTz;
|
||||
IEC2DCMMapR[0] = dRx;
|
||||
IEC2DCMMapR[1] = dRy;
|
||||
IEC2DCMMapR[2] = dRz;
|
||||
customized_ImportTransform = true;
|
||||
}
|
||||
|
||||
void itkImageProcessor::SetCustom_RTCouchSetup_IEC(double dLAT,
|
||||
double dVRT,
|
||||
double dLNG)
|
||||
{
|
||||
rtCouchOffset[0] = dLAT;
|
||||
rtCouchOffset[1] = dVRT;
|
||||
rtCouchOffset[2] = dLNG;
|
||||
customized_RTCouchSetup = true;
|
||||
}
|
||||
|
||||
void itkImageProcessor::SetCustom_RTIsocenter_LPS(double dX,
|
||||
double dY,
|
||||
double dZ)
|
||||
{
|
||||
rtIsocenterLPS[0] = dX;
|
||||
rtIsocenterLPS[1] = dY;
|
||||
rtIsocenterLPS[2] = dZ;
|
||||
customized_RTIsocenter = true;
|
||||
}
|
||||
|
||||
void itkImageProcessor::SetCustom_ProjectionCenterFixedAxes_IEC(double dX,
|
||||
double dY,
|
||||
double dZ)
|
||||
{
|
||||
ProjectionCenterFixedAxes[0] = dX;
|
||||
ProjectionCenterFixedAxes[1] = dY;
|
||||
ProjectionCenterFixedAxes[2] = dZ;
|
||||
customized_ProjectionCenter = true;
|
||||
}
|
||||
|
||||
void itkImageProcessor::SetCustom_2Dres(double nX1,double nY1,double nX2,double nY2)
|
||||
@ -206,14 +235,6 @@ void itkImageProcessor::SetCustom_2Dsize(int nX1, int nY1,int nX2,int nY2)
|
||||
customized_2DSIZE = true;
|
||||
}
|
||||
|
||||
//void itkImageProcessor::SetCustom_2Dcenter(double dX1,double dY1, double dX2,double dY2)
|
||||
//{
|
||||
// image1center[0] = dX1;
|
||||
// image1center[1] = dY1;
|
||||
// image2center[0] = dX2;
|
||||
// image2center[1] = dY2;
|
||||
// customized_2DCX = true;
|
||||
//}
|
||||
|
||||
int itkImageProcessor::load3DSerie(const char * pcDirName)
|
||||
{
|
||||
@ -400,29 +421,19 @@ void itkImageProcessor::ApplyVolumeImportTransform(){
|
||||
|
||||
|
||||
|
||||
/* TODO: here is the right place to change origin when required
|
||||
* after this point, reference info are saved */
|
||||
ImageType3D::PointType ImportOffset;
|
||||
|
||||
ImageType3D::PointType rtCouchOffset;
|
||||
rtCouchOffset[0]=9.60802;
|
||||
rtCouchOffset[1]=1333.925;
|
||||
rtCouchOffset[2]=12.2;
|
||||
|
||||
ImageType3D::PointType rtIsocenterLPS;
|
||||
rtIsocenterLPS[0]= 9.01502;
|
||||
rtIsocenterLPS[1]= -157.708;
|
||||
rtIsocenterLPS[2]= -1186.84;
|
||||
|
||||
ImageType3D::PointType IEC2DCMMapT;
|
||||
IEC2DCMMapT[0]= 4.10766744;
|
||||
IEC2DCMMapT[1]= -2316.44798289;
|
||||
IEC2DCMMapT[2]= 172.82908123;
|
||||
|
||||
ImageType3D::PointType ImportOffset=
|
||||
this->CalcImportVolumeOffset(rtCouchOffset,
|
||||
LPStoIEC_Directions,
|
||||
rtIsocenterLPS,
|
||||
IEC2DCMMapT);
|
||||
if(customized_ImportTransform &&
|
||||
customized_RTCouchSetup &&
|
||||
customized_RTIsocenter ){
|
||||
ImportOffset=
|
||||
this->CalcImportVolumeOffset(rtCouchOffset,
|
||||
LPStoIEC_Directions,
|
||||
rtIsocenterLPS,
|
||||
IEC2DCMMapT);
|
||||
} else {
|
||||
ImportOffset.Fill(0.);
|
||||
}
|
||||
|
||||
ImageType3D::PointType Origin;
|
||||
Origin = m_VolumeSourceDupli->GetOutput()->GetOrigin();
|
||||
@ -474,23 +485,24 @@ void itkImageProcessor::ApplyVolumeImportTransform(){
|
||||
image3DCOVLPS[1] = (m_3DOriginLPS[1]+LastVoxelPosition[1])/2;
|
||||
image3DCOVLPS[2] = (m_3DOriginLPS[2]+LastVoxelPosition[2])/2;
|
||||
|
||||
|
||||
/* Calculate center of projection in patient coordinates */
|
||||
|
||||
/* center of projection in an IEC reference at Patient Origin */
|
||||
ImageType3D::PointType ProjectionCenterFixedAxes;
|
||||
ProjectionCenterFixedAxes[0] = 0.;
|
||||
ProjectionCenterFixedAxes[1] = 0.;
|
||||
ProjectionCenterFixedAxes[2] = CT_DEFAULT_TABLEHEIGHT;
|
||||
|
||||
|
||||
InternalImageType::DirectionType IECtoLPS_Directions;
|
||||
IECtoLPS_Directions = LPStoIEC_Directions.GetTranspose();
|
||||
|
||||
m_3DProjectionOriginLPS =
|
||||
IECtoLPS_Directions * ProjectionCenterFixedAxes ;
|
||||
/* in longitudinal direction (Sup-Inf), we put it in the
|
||||
* middle of the volume */
|
||||
m_3DProjectionOriginLPS[2] = image3DCOVLPS[2];
|
||||
if(customized_ProjectionCenter)
|
||||
{
|
||||
m_3DProjectionOriginLPS =
|
||||
IECtoLPS_Directions * ProjectionCenterFixedAxes ;
|
||||
/* in longitudinal direction (Sup-Inf), we put it in the
|
||||
* middle of the volume */
|
||||
m_3DProjectionOriginLPS[2] = image3DCOVLPS[2];
|
||||
|
||||
} else {
|
||||
m_3DProjectionOriginLPS = image3DCOVLPS;
|
||||
}
|
||||
|
||||
|
||||
/* calculate also the same center with zero origin
|
||||
* This is required to bring back the DRT into LPS */
|
||||
@ -857,7 +869,9 @@ void itkImageProcessor::InitializeProjector()
|
||||
|
||||
|
||||
itkImageProcessor::InternalImageType::DirectionType
|
||||
itkImageProcessor::CalcDRTImageDirections(double angle){
|
||||
itkImageProcessor::CalcDRTImageDirections(
|
||||
double angle,
|
||||
InternalImageType::DirectionType DRT2LPS){
|
||||
|
||||
|
||||
InternalImageType::DirectionType
|
||||
@ -869,7 +883,7 @@ itkImageProcessor::CalcDRTImageDirections(double angle){
|
||||
DRTDirs. GetVnlMatrix()[1][0] = sin (angle*itk::Math::pi/180);
|
||||
DRTDirs. GetVnlMatrix()[1][1] = cos (angle*itk::Math::pi/180);
|
||||
|
||||
DRTDirs *= Std_DRT2LPS;
|
||||
DRTDirs *= DRT2LPS;
|
||||
|
||||
return
|
||||
DRTDirs;
|
||||
@ -917,7 +931,7 @@ itkImageProcessor::CalcDRTImageOrigin(itkImageProcessor::InternalImageType::Poin
|
||||
DRTCOV[2] = (( m_Image ->GetOrigin())[2]+LastVoxelPosition[2])/2;
|
||||
|
||||
itkImageProcessor::InternalImageType::DirectionType DRT2LPS
|
||||
= this->CalcDRTImageDirections(dAngle);
|
||||
= this->CalcDRTImageDirections(dAngle, Std_DRT2LPS);
|
||||
|
||||
ImageType3D::PointType NewOrigin =
|
||||
m_VolCOOV + DRT2LPS * (m_Image ->GetOrigin() - DRTCOV);
|
||||
@ -1061,7 +1075,8 @@ void itkImageProcessor::GetProjectionImages(){
|
||||
m_3DProjectionOriginLPS,
|
||||
projAngle1);
|
||||
InternalImageType::DirectionType DRT2LPS1 =
|
||||
this->CalcDRTImageDirections(projAngle1);
|
||||
this->CalcDRTImageDirections(projAngle1,
|
||||
Std_DRT2LPS);
|
||||
|
||||
filter1->SetInput( resampleFilter1->GetOutput() );
|
||||
filter1->SetOutputDirection(DRT2LPS1 );//IECtoLPS_Directions);
|
||||
@ -1081,7 +1096,8 @@ void itkImageProcessor::GetProjectionImages(){
|
||||
projAngle2);
|
||||
|
||||
DRT2LPS1 =
|
||||
this->CalcDRTImageDirections(projAngle2);
|
||||
this->CalcDRTImageDirections(projAngle2,
|
||||
Std_DRT2LPS);
|
||||
|
||||
|
||||
|
||||
|
@ -43,41 +43,6 @@ namespace itk
|
||||
{
|
||||
|
||||
|
||||
//class CommandIterationUpdate : public itk::Command
|
||||
//{
|
||||
//public:
|
||||
// using Self = CommandIterationUpdate;
|
||||
// using Superclass = itk::Command;
|
||||
// using Pointer = itk::SmartPointer<Self>;
|
||||
// itkNewMacro(Self);
|
||||
|
||||
//protected:
|
||||
// CommandIterationUpdate() = default;
|
||||
|
||||
//public:
|
||||
// using OptimizerType = itk::PowellOptimizer;
|
||||
// using OptimizerPointer = const OptimizerType *;
|
||||
|
||||
// void
|
||||
// Execute(itk::Object * caller, const itk::EventObject & event) override
|
||||
// {
|
||||
// Execute((const itk::Object *)caller, event);
|
||||
// }
|
||||
|
||||
// void
|
||||
// Execute(const itk::Object * object, const itk::EventObject & event) override
|
||||
// {
|
||||
// auto optimizer = dynamic_cast<OptimizerPointer>(object);
|
||||
// if (typeid(event) != typeid(itk::IterationEvent))
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
// std::cout << "Iteration: " << optimizer->GetCurrentIteration() << std::endl;
|
||||
// std::cout << "Similarity: " << optimizer->GetValue() << std::endl;
|
||||
// std::cout << "Position: " << optimizer->GetCurrentPosition() << std::endl;
|
||||
// }
|
||||
//};
|
||||
|
||||
|
||||
/* reference string required for comparison with tag values */
|
||||
static const char *ImageOrientationStrings[] = {
|
||||
@ -107,8 +72,6 @@ public:
|
||||
/** Input data load methods*/
|
||||
int load3DSerie(const char* );
|
||||
int load2D(const char *);
|
||||
int loadRTPlan(const char *);
|
||||
int loadRTStruct(const char *);
|
||||
|
||||
|
||||
/** Projection angles - Gantry angle IEC */
|
||||
@ -124,9 +87,14 @@ public:
|
||||
void SetIntensityThreshold(double);
|
||||
|
||||
/** Custom settings of the projection images */
|
||||
void SetCustom_Isocenter(double,double,double);
|
||||
// void SetCustom_Isocenter(double,double,double);
|
||||
void SetCustom_2Dres(double,double,double,double);
|
||||
void SetCustom_2Dsize(int,int,int,int);
|
||||
void SetCustom_RTIsocenter_LPS(double, double, double);
|
||||
void SetCustom_RTCouchSetup_IEC(double, double, double);
|
||||
void SetCustom_ImportTransform(double, double, double,
|
||||
double, double, double);
|
||||
void SetCustom_ProjectionCenterFixedAxes_IEC(double,double,double);
|
||||
|
||||
/** Set transform parameters for 3D Volume */
|
||||
void SetInitialTranslations(double, double, double);
|
||||
@ -266,7 +234,8 @@ private:
|
||||
LPStoIEC_Directions;
|
||||
|
||||
InternalImageType::DirectionType
|
||||
CalcDRTImageDirections(double angle);
|
||||
CalcDRTImageDirections(double angle,
|
||||
InternalImageType::DirectionType DRT2LPS);
|
||||
|
||||
ImageType3D::PointType
|
||||
CalcDRTImageOrigin(InternalImageType::Pointer m_Image,
|
||||
@ -288,7 +257,6 @@ private:
|
||||
|
||||
double image1res[2], image2res[2];
|
||||
int image1Size[2], image2Size[2];
|
||||
double isocenter[3];
|
||||
|
||||
double
|
||||
d_scd,
|
||||
@ -300,15 +268,45 @@ private:
|
||||
double TZero[3], RZero[3];
|
||||
|
||||
|
||||
bool customized_iso,/*customized_2DCX,*/customized_2DRES, customized_2DSIZE;
|
||||
bool image2D1Loaded, image2D2Loaded, image3DLoaded;
|
||||
bool
|
||||
customized_2DRES,
|
||||
customized_2DSIZE,
|
||||
customized_RTIsocenter,
|
||||
customized_RTCouchSetup,
|
||||
customized_ImportTransform,
|
||||
customized_ProjectionCenter;
|
||||
|
||||
bool
|
||||
image2D1Loaded,
|
||||
image2D2Loaded,
|
||||
image3DLoaded;
|
||||
|
||||
double
|
||||
d_image1IntensityWindow[2],
|
||||
d_image2IntensityWindow[2];
|
||||
|
||||
/* Transform between IEC Support and
|
||||
* IEC Scanner frame of reference */
|
||||
ImageType3D::PointType
|
||||
IEC2DCMMapT,
|
||||
IEC2DCMMapR;
|
||||
|
||||
InternalImageType::DirectionType Std_DRT2LPS;
|
||||
/* RT Plan isocenter in LPS coordinates */
|
||||
ImageType3D::PointType
|
||||
rtIsocenterLPS;
|
||||
|
||||
/* RT Plan couch SETUP offset corresponding to
|
||||
* the RT Plan isocenter */
|
||||
ImageType3D::PointType
|
||||
rtCouchOffset;
|
||||
|
||||
/* center of projection in an IEC reference at
|
||||
* Patient Origin of fixed images. Positioning scanner */
|
||||
ImageType3D::PointType
|
||||
ProjectionCenterFixedAxes;
|
||||
|
||||
InternalImageType::DirectionType
|
||||
Std_DRT2LPS;
|
||||
|
||||
};
|
||||
|
||||
|
@ -149,13 +149,12 @@ gSiddonJacobsRayCastInterpolateImageFunction<TInputImage, TCoordRep>::Evaluate(c
|
||||
}
|
||||
|
||||
|
||||
//std::cout<<"drrPixelWorld: "<< point <<std::endl;
|
||||
drrPixelWorld = m_InverseTransform->TransformPoint(point);
|
||||
//std::cout<<"drrPixelWorld: "<< drrPixelWorld <<std::endl;
|
||||
|
||||
//std::cout<<"m_SourcePoint : "<<m_SourcePoint <<std::endl;
|
||||
PointType SlidingSourcePoint = m_SourcePoint;
|
||||
SlidingSourcePoint[0] = 0.;
|
||||
SlidingSourcePoint[1] = point[1];
|
||||
SlidingSourcePoint[2] = 0.;
|
||||
//PointType SourceWorld = m_InverseTransform->TransformPoint(m_SourcePoint);
|
||||
PointType SourceWorld = m_InverseTransform->TransformPoint(SlidingSourcePoint);
|
||||
|
||||
@ -176,9 +175,6 @@ gSiddonJacobsRayCastInterpolateImageFunction<TInputImage, TCoordRep>::Evaluate(c
|
||||
|
||||
|
||||
|
||||
//slide source along z axis...
|
||||
//SourceWorld[2] = drrPixelWorld[2];
|
||||
|
||||
// calculate the detector position for this pixel center by moving
|
||||
// 2*m_FocalPointToIsocenterDistance from the source in the pixel
|
||||
// directions
|
||||
@ -223,11 +219,6 @@ gSiddonJacobsRayCastInterpolateImageFunction<TInputImage, TCoordRep>::Evaluate(c
|
||||
rayVector[1] = pDest[1] - SourceWorld[1];
|
||||
rayVector[2] = pDest[2] - SourceWorld[2];
|
||||
|
||||
//rayVector[2] = drrPixelWorld[2] - SourceWorld[2];
|
||||
|
||||
//std::cout<< "rayVector "<<rayVector <<std::endl;
|
||||
|
||||
//return 0;
|
||||
|
||||
/* Calculate the parametric values of the first and the last
|
||||
intersection points of the ray with the X, Y, and Z-planes that
|
||||
|
Reference in New Issue
Block a user