cleaning and moving things around. Better definition of isocenter projection
This commit is contained in:
@ -25,6 +25,28 @@ gfattori 08.11.2021
|
||||
|
||||
#include <string>
|
||||
|
||||
/* Some parameters that need to be in settings or read from files */
|
||||
|
||||
/* Settings */
|
||||
|
||||
#define CT_IMPORTOFFSET_TXIEC 0
|
||||
#define CT_IMPORTOFFSET_TYIEC 0
|
||||
#define CT_IMPORTOFFSET_TZIEC 0
|
||||
#define CT_IMPORTOFFSET_RXIEC 0
|
||||
#define CT_IMPORTOFFSET_RYIEC 0
|
||||
#define CT_IMPORTOFFSET_RZIEC 0
|
||||
|
||||
#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
|
||||
{
|
||||
|
||||
@ -84,7 +106,7 @@ const char *gGetStringValueFromTag(const gdcm::Tag& t, const gdcm::DataSet& ds)
|
||||
itkImageProcessor::itkImageProcessor()
|
||||
{
|
||||
|
||||
// std::cout<<"itkImageProcessor::itkImageProcessor contructor"<<std::endl;
|
||||
// std::cout<<"itkImageProcessor::itkImageProcessor contructor"<<std::endl;
|
||||
transform = TransformType::New();
|
||||
interpolator1 = InterpolatorType::New();
|
||||
interpolator2 = InterpolatorType::New();
|
||||
@ -103,7 +125,7 @@ itkImageProcessor::itkImageProcessor()
|
||||
image2center[0]=image2center[1]= 0.;
|
||||
image1Size[0] = image1Size[1] = 512;
|
||||
image2Size[0] = image2Size[1] = 512;
|
||||
image3DCOV[0] = image3DCOV[1] = image3DCOV[2] = 0.;
|
||||
// image3DCOV[0] = image3DCOV[1] = image3DCOV[2] = 0.;
|
||||
|
||||
image1IntensityWindow[0] = image1IntensityWindow[1] = 0.;
|
||||
image2IntensityWindow[0] = image2IntensityWindow[1] = 0.;
|
||||
@ -141,6 +163,13 @@ itkImageProcessor::itkImageProcessor()
|
||||
}
|
||||
|
||||
|
||||
d_CTImportOffset_txiec = CT_IMPORTOFFSET_TXIEC;
|
||||
d_CTImportOffset_tyiec = CT_IMPORTOFFSET_TYIEC;
|
||||
d_CTImportOffset_tziec = CT_IMPORTOFFSET_TZIEC;
|
||||
d_CTImportOffset_rxiec = CT_IMPORTOFFSET_RXIEC;
|
||||
d_CTImportOffset_ryiec = CT_IMPORTOFFSET_RYIEC;
|
||||
d_CTImportOffset_rziec = CT_IMPORTOFFSET_RZIEC;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -202,7 +231,7 @@ void itkImageProcessor::SetCustom_2Dcenter(double dX1,double dY1, double dX2,dou
|
||||
int itkImageProcessor::load3DSerie(const char * pcDirName)
|
||||
{
|
||||
|
||||
// std::cout<<"itkImageProcessor::load3DSerie"<<std::endl;
|
||||
// std::cout<<"itkImageProcessor::load3DSerie"<<std::endl;
|
||||
|
||||
using NamesGeneratorType = itk::GDCMSeriesFileNames;
|
||||
NamesGeneratorType::Pointer nameGenerator = NamesGeneratorType::New();
|
||||
@ -267,8 +296,8 @@ int itkImageProcessor::load3DSerie(const char * pcDirName)
|
||||
|
||||
imageSeriesReader3D->Update();
|
||||
|
||||
eImageOrientationType
|
||||
currImgOrient;
|
||||
// eImageOrientationType
|
||||
// currImgOrient;
|
||||
/* check patient orientation */
|
||||
if(fileNames.size()>0){
|
||||
|
||||
@ -288,11 +317,11 @@ int itkImageProcessor::load3DSerie(const char * pcDirName)
|
||||
|
||||
if(!strcmp(sTmpString,ImageOrientationStrings[eImageOrientationType::HFS])){
|
||||
std::cout<<"Image Orientation: HFS"<<std::endl;
|
||||
currImgOrient = eImageOrientationType::HFS;
|
||||
// currImgOrient = eImageOrientationType::HFS;
|
||||
m_3DPatOrientation = eImageOrientationType::HFS;
|
||||
} else if(!strcmp(sTmpString,ImageOrientationStrings[eImageOrientationType::FFS])){
|
||||
std::cout<<"Image Orientation: FFS"<<std::endl;
|
||||
currImgOrient = eImageOrientationType::FFS;
|
||||
// currImgOrient = eImageOrientationType::FFS;
|
||||
m_3DPatOrientation = eImageOrientationType::FFS;
|
||||
|
||||
} else {
|
||||
@ -308,7 +337,7 @@ int itkImageProcessor::load3DSerie(const char * pcDirName)
|
||||
for(int iIdx = 0 ; iIdx < 3; iIdx++){
|
||||
for(int jIdx = 0 ; jIdx < 3; jIdx++){
|
||||
|
||||
switch (currImgOrient) {
|
||||
switch (m_3DPatOrientation) {
|
||||
case eImageOrientationType::HFS:
|
||||
LPStoIEC_Directions.GetVnlMatrix()[iIdx][jIdx] = HFS2IEC[jIdx+iIdx*3];
|
||||
break;
|
||||
@ -323,11 +352,19 @@ int itkImageProcessor::load3DSerie(const char * pcDirName)
|
||||
|
||||
|
||||
/* Calculate projection angle IEC to LPS */
|
||||
projAngle1 = CalcProjectionAngleLPS(currImgOrient, projAngle1_IEC);
|
||||
projAngle2 = CalcProjectionAngleLPS(currImgOrient, projAngle2_IEC);
|
||||
projAngle1 = CalcProjectionAngleLPS(m_3DPatOrientation, projAngle1_IEC);
|
||||
projAngle2 = CalcProjectionAngleLPS(m_3DPatOrientation, projAngle2_IEC);
|
||||
|
||||
|
||||
image3DIn = imageSeriesReader3D->GetOutput();
|
||||
|
||||
|
||||
/* TODO: here is the right place to change origin when required
|
||||
* after this point, reference info are saved */
|
||||
|
||||
/* End of origin change */
|
||||
|
||||
|
||||
/* before changing origin for projection, let's save the center of volume */
|
||||
using ImageRegionType3D = ImageType3D::RegionType;
|
||||
using SizeType3D = ImageRegionType3D::SizeType;
|
||||
@ -335,14 +372,15 @@ int itkImageProcessor::load3DSerie(const char * pcDirName)
|
||||
|
||||
ImageRegionType3D region3D = image3DIn->GetBufferedRegion();
|
||||
SizeType3D size3D = region3D.GetSize();
|
||||
ImageType3D::PointType origin3D = image3DIn->GetOrigin();
|
||||
// ImageType3D::PointType origin3D = image3DIn->GetOrigin();
|
||||
const itk::Vector<double, 3> resolution3D = image3DIn->GetSpacing();
|
||||
ImageDirectionType3D imagDirection = image3DIn->GetDirection();
|
||||
|
||||
/* 3D volume origin in patient coordinates */
|
||||
m_3DOriginLPS = image3DIn->GetOrigin();
|
||||
|
||||
|
||||
|
||||
/* calculate image size in 3D Space by fiding the last voxel position */
|
||||
/* calculate image size in 3D Space by finding the last voxel position */
|
||||
using VectorType = itk::Vector<double, 3>;
|
||||
VectorType Dest;
|
||||
Dest[0]=(size3D[0]-1) * resolution3D[0];
|
||||
@ -350,22 +388,49 @@ int itkImageProcessor::load3DSerie(const char * pcDirName)
|
||||
Dest[2]=(size3D[2]-1) * resolution3D[2];
|
||||
|
||||
ImageType3D::PointType LastVoxelPosition =
|
||||
origin3D + (imagDirection * Dest);
|
||||
m_3DOriginLPS + (imagDirection * Dest);
|
||||
|
||||
ImageType3D::PointType image3DCOVLPS;
|
||||
image3DCOVLPS[0] = (m_3DOriginLPS[0]+LastVoxelPosition[0])/2;
|
||||
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];
|
||||
|
||||
/* calculate also the same center with zero origin
|
||||
* This is required to bring back the DRT into LPS */
|
||||
m_3DProjectionOriginLPSZero =
|
||||
m_3DProjectionOriginLPS - m_3DOriginLPS;
|
||||
|
||||
|
||||
|
||||
image3DCOV[0] = ((origin3D)[0]+LastVoxelPosition[0])/2;
|
||||
image3DCOV[1] = ((origin3D)[1]+LastVoxelPosition[1])/2;
|
||||
image3DCOV[2] = ((origin3D)[2]+LastVoxelPosition[2])/2;
|
||||
|
||||
if(true){
|
||||
std::cout<<" -------- 3D IMAGE --------"<<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<<"First Voxel position (origin) " <<m_3DOriginLPS <<std::endl;
|
||||
std::cout<<"Last Voxel position: "<<LastVoxelPosition<<std::endl;
|
||||
std::cout<<"Image 3D COV: "<<image3DCOV[0]<<" "
|
||||
<<image3DCOV[1]<<" "
|
||||
<<image3DCOV[2]<<" "<<std::endl;
|
||||
std::cout<<"Image 3D COV: "<<image3DCOVLPS <<std::endl;
|
||||
std::cout<<"Data collection center LPS: "<<m_3DProjectionOriginLPS <<std::endl;
|
||||
std::cout<<"Data collection center LPS (Zero Origin): "<<m_3DProjectionOriginLPSZero<<std::endl;
|
||||
std::cout<<" -------- -------- --------"<<std::endl;
|
||||
|
||||
}
|
||||
@ -405,11 +470,11 @@ int itkImageProcessor::load3DSerie(const char * pcDirName)
|
||||
}
|
||||
|
||||
double
|
||||
itkImageProcessor::CalcProjectionAngleLPS(
|
||||
itkImageProcessor::CalcProjectionAngleLPS(
|
||||
tPatOrientation pOrient,
|
||||
double pAngleIEC){
|
||||
|
||||
// std::cout<< "CalcProjectèionAngleLPS :: pAngleIEC " << pAngleIEC <<std::endl;
|
||||
// std::cout<< "CalcProjectèionAngleLPS :: pAngleIEC " << pAngleIEC <<std::endl;
|
||||
|
||||
double dProj = pAngleIEC;
|
||||
|
||||
@ -438,8 +503,6 @@ double
|
||||
|
||||
}
|
||||
|
||||
// std::cout<<"currIECtoLPS: "<< currIECtoLPS <<std::endl;
|
||||
|
||||
InternalImageType::DirectionType
|
||||
DRTDirsIEC;
|
||||
|
||||
@ -450,18 +513,12 @@ double
|
||||
DRTDirsIEC. GetVnlMatrix()[2][2] = cos (pAngleIEC * itk::Math::pi/180);
|
||||
|
||||
|
||||
// std::cout<<"DRTDirsIEC: "<< DRTDirsIEC <<std::endl;
|
||||
|
||||
InternalImageType::DirectionType
|
||||
DRTtoCurrPatientOrient;
|
||||
|
||||
DRTtoCurrPatientOrient =
|
||||
currIECtoLPS * DRTDirsIEC;
|
||||
|
||||
|
||||
// std::cout<<"DRTtoCurrPatientOrient: "<< DRTtoCurrPatientOrient <<std::endl;
|
||||
|
||||
|
||||
ImageType3D::PointType SourcePositionIEC;
|
||||
SourcePositionIEC [0] = 0;
|
||||
SourcePositionIEC [1] = 0;
|
||||
@ -470,13 +527,9 @@ double
|
||||
ImageType3D::PointType SourcePositionPatOrient =
|
||||
DRTtoCurrPatientOrient * SourcePositionIEC;
|
||||
|
||||
// std::cout<<"SourcePositionPatOrient: "<< SourcePositionPatOrient <<std::endl;
|
||||
|
||||
dProj =
|
||||
(atan2(SourcePositionPatOrient [1], SourcePositionPatOrient [0]) - atan2(-1,0)) * 180 / itk::Math::pi;
|
||||
|
||||
// std::cout<< "Projection Angle corrected for patient orientation: "<< dProj <<std::endl;
|
||||
|
||||
return
|
||||
dProj;
|
||||
|
||||
@ -652,42 +705,20 @@ int itkImageProcessor::load2D(const char * pcFName){
|
||||
InternalImageType::Pointer MyLocalizerImage =
|
||||
caster2DInput->GetOutput();
|
||||
|
||||
ImageType3D::PointType image3DOrigin;
|
||||
image3DOrigin[0]=image3DCOV[0];
|
||||
image3DOrigin[1]=image3DCOV[1];
|
||||
image3DOrigin[2]=image3DCOV[2];
|
||||
// ChangeInformationFilterType::Pointer filter = ChangeInformationFilterType::New();
|
||||
// filter->SetInput(MyLocalizerImage);
|
||||
|
||||
ImageType3D::PointType image2Dcenter_3DCOV;
|
||||
InternalImageType::DirectionType image2D1InDirectionInv;
|
||||
image2D1InDirectionInv.GetVnlMatrix() = MyLocalizerImage->GetDirection().GetTranspose();
|
||||
// try
|
||||
// {
|
||||
// filter->UpdateOutputInformation();
|
||||
// }
|
||||
// catch (itk::ExceptionObject & error)
|
||||
// {
|
||||
// std::cerr << "Error: " << error << std::endl;
|
||||
// return EXIT_FAILURE;
|
||||
// }
|
||||
|
||||
image2Dcenter_3DCOV = -
|
||||
(
|
||||
image2D1InDirectionInv * (image3DOrigin - MyLocalizerImage->GetOrigin())
|
||||
);
|
||||
|
||||
/*
|
||||
We have to set the z coordinate to the focal distance, it would be 0 otherwise...
|
||||
*/
|
||||
image2Dcenter_3DCOV[2] = -scd;
|
||||
|
||||
ChangeInformationFilterType::Pointer filter = ChangeInformationFilterType::New();
|
||||
filter->SetInput(MyLocalizerImage);
|
||||
|
||||
const InternalImageType::DirectionType newDirection =
|
||||
MyLocalizerImage->GetDirection() * image2D1InDirectionInv;
|
||||
|
||||
try
|
||||
{
|
||||
filter->UpdateOutputInformation();
|
||||
}
|
||||
catch (itk::ExceptionObject & error)
|
||||
{
|
||||
std::cerr << "Error: " << error << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
filter->Update();
|
||||
// filter->Update();
|
||||
|
||||
|
||||
double* m_ImageIntensity;
|
||||
@ -700,7 +731,7 @@ int itkImageProcessor::load2D(const char * pcFName){
|
||||
|
||||
m_ImageIntensity = image1IntensityWindow;
|
||||
m_Duplicator = m_PASourceDupli;
|
||||
m_ImLoaded = &image2D1Loaded;
|
||||
// m_ImLoaded = &image2D1Loaded;
|
||||
|
||||
break;
|
||||
|
||||
@ -708,7 +739,7 @@ int itkImageProcessor::load2D(const char * pcFName){
|
||||
|
||||
m_ImageIntensity = image2IntensityWindow;
|
||||
m_Duplicator = m_LATSourceDupli;
|
||||
m_ImLoaded = &image2D2Loaded;
|
||||
// m_ImLoaded = &image2D2Loaded;
|
||||
|
||||
break;
|
||||
|
||||
@ -720,11 +751,9 @@ int itkImageProcessor::load2D(const char * pcFName){
|
||||
|
||||
memcpy(m_ImageIntensity,dIntensityWindow, 2*sizeof(double));
|
||||
|
||||
m_Duplicator->SetInputImage(filter->GetOutput());
|
||||
m_Duplicator->SetInputImage(caster2DInput->GetOutput() );//filter->GetOutput());
|
||||
m_Duplicator->Update();
|
||||
|
||||
// m_FlipFilter->SetInput(m_Image);
|
||||
|
||||
|
||||
return
|
||||
(int) currProjOrientation;
|
||||
@ -768,39 +797,15 @@ void itkImageProcessor::InitializeProjector()
|
||||
const double dtr = (atan(1.0) * 4.0) / 180.0;
|
||||
transform->SetRotation(dtr * RZero[0], dtr * RZero[1], dtr * RZero[2]);
|
||||
|
||||
// The centre of rotation is set by default to the centre of the 3D
|
||||
// volume but can be offset from this position using a command
|
||||
// line specified translation [cx,cy,cz]
|
||||
isocenter3D = m_3DProjectionOriginLPSZero;
|
||||
|
||||
ImageType3D::PointType origin3D = caster3D->GetOutput()->GetOrigin();
|
||||
const itk::Vector<double, 3> resolution3D = caster3D->GetOutput()->GetSpacing();
|
||||
|
||||
using ImageRegionType3D = ImageType3D::RegionType;
|
||||
using SizeType3D = ImageRegionType3D::SizeType;
|
||||
// std::cout<<" -------- PROJECTOR GEOMETRY --------"<<std::endl;
|
||||
std::cout<<"Projector Isocenter "<<isocenter3D[0]<<" "<<isocenter3D[1]<<" "<<isocenter3D[2] <<std::endl;
|
||||
// std::cout<<origin3D[0]<<" "<<resolution3D[0]<<" "<<static_cast<double>(size3D[0])<<" "<<static_cast<double>(size3D[0]) / 2.0<<std::endl;
|
||||
|
||||
ImageRegionType3D region3D = caster3D->GetOutput()->GetBufferedRegion();
|
||||
SizeType3D size3D = region3D.GetSize();
|
||||
|
||||
if (customized_iso)
|
||||
{
|
||||
// Isocenter location given by the user.
|
||||
isocenter3D[0] = origin3D[0] + resolution3D[0] * isocenter[0];
|
||||
isocenter3D[1] = origin3D[1] + resolution3D[1] * isocenter[1];
|
||||
isocenter3D[2] = origin3D[2] + resolution3D[2] * isocenter[2];
|
||||
// std::cout<<"Isocenter location given by the user"<<std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set the center of the image as the isocenter.
|
||||
isocenter3D[0] = origin3D[0] + resolution3D[0] * static_cast<double>(size3D[0]) / 2.0;
|
||||
isocenter3D[1] = origin3D[1] + resolution3D[1] * static_cast<double>(size3D[1]) / 2.0;
|
||||
isocenter3D[2] = origin3D[2] + resolution3D[2] * static_cast<double>(size3D[2]) / 2.0;
|
||||
}
|
||||
|
||||
// std::cout<<" -------- PROJECTOR GEOMETRY --------"<<std::endl;
|
||||
// std::cout<<"Projector Isocenter "<<isocenter3D[0]<<" "<<isocenter3D[1]<<" "<<isocenter3D[2] <<std::endl;
|
||||
// std::cout<<"Projector scd "<<scd <<std::endl;
|
||||
// std::cout<<" -------- -------- --------"<<std::endl;
|
||||
// std::cout<<"Projector scd "<<scd <<std::endl;
|
||||
// std::cout<<" -------- -------- --------"<<std::endl;
|
||||
|
||||
transform->SetCenter(isocenter3D);
|
||||
// 2D Image 1
|
||||
@ -823,8 +828,9 @@ void itkImageProcessor::InitializeProjector()
|
||||
|
||||
#include <math.h>
|
||||
|
||||
|
||||
itkImageProcessor::InternalImageType::DirectionType
|
||||
itkImageProcessor::CalcDRTImageDirections(double angle){
|
||||
itkImageProcessor::CalcDRTImageDirections(double angle){
|
||||
|
||||
|
||||
InternalImageType::DirectionType
|
||||
@ -850,7 +856,7 @@ itkImageProcessor::InternalImageType::DirectionType
|
||||
|
||||
*/
|
||||
itkImageProcessor::ImageType3D::PointType
|
||||
itkImageProcessor::CalcDRTImageOrigin(itkImageProcessor::InternalImageType::Pointer m_Image,
|
||||
itkImageProcessor::CalcDRTImageOrigin(itkImageProcessor::InternalImageType::Pointer m_Image,
|
||||
itkImageProcessor::ImageType3D::PointType m_VolCOOV,
|
||||
double dAngle
|
||||
){
|
||||
@ -935,9 +941,9 @@ void itkImageProcessor::GetProjectionImages(){
|
||||
|
||||
if(false){
|
||||
// if(image2D1Loaded){
|
||||
// resampleFilter1->SetSize(m_Input2DImage_PA ->GetLargestPossibleRegion().GetSize());
|
||||
// resampleFilter1->SetOutputOrigin(m_Input2DImage_PA ->GetOrigin());
|
||||
// resampleFilter1->SetOutputSpacing(m_Input2DImage_PA ->GetSpacing());
|
||||
// resampleFilter1->SetSize(m_Input2DImage_PA ->GetLargestPossibleRegion().GetSize());
|
||||
// resampleFilter1->SetOutputOrigin(m_Input2DImage_PA ->GetOrigin());
|
||||
// resampleFilter1->SetOutputSpacing(m_Input2DImage_PA ->GetSpacing());
|
||||
|
||||
// std::cout<<"Size "<<caster2D1->GetOutput()->GetLargestPossibleRegion().GetSize()<<std::endl;
|
||||
// std::cout<<"Origin "<<caster2D1->GetOutput()->GetOrigin()<<std::endl;
|
||||
@ -979,9 +985,9 @@ void itkImageProcessor::GetProjectionImages(){
|
||||
|
||||
if(false){
|
||||
// if(image2D2Loaded){
|
||||
// resampleFilter2->SetSize(m_Input2DImage_LAT->GetLargestPossibleRegion().GetSize());
|
||||
// resampleFilter2->SetOutputOrigin(m_Input2DImage_LAT ->GetOrigin());
|
||||
// resampleFilter2->SetOutputSpacing(m_Input2DImage_LAT ->GetSpacing());
|
||||
// resampleFilter2->SetSize(m_Input2DImage_LAT->GetLargestPossibleRegion().GetSize());
|
||||
// resampleFilter2->SetOutputOrigin(m_Input2DImage_LAT ->GetOrigin());
|
||||
// resampleFilter2->SetOutputSpacing(m_Input2DImage_LAT ->GetSpacing());
|
||||
|
||||
} else {
|
||||
|
||||
@ -1026,16 +1032,16 @@ void itkImageProcessor::GetProjectionImages(){
|
||||
|
||||
/* First of all we need the center of the Projection images in its reference frame */
|
||||
|
||||
ImageType3D::PointType image3DOrigin;
|
||||
image3DOrigin[0]=image3DCOV[0];
|
||||
image3DOrigin[1]=image3DCOV[1];
|
||||
image3DOrigin[2]=image3DCOV[2];
|
||||
ImageType3D::PointType image3DOrigin = m_3DProjectionOriginLPS;
|
||||
// image3DOrigin[0]=image3DCOV[0];
|
||||
// image3DOrigin[1]=image3DCOV[1];
|
||||
// image3DOrigin[2]=image3DCOV[2];
|
||||
|
||||
resampleFilter1->Update();
|
||||
|
||||
ImageType3D::PointType NewOrigin =
|
||||
this->CalcDRTImageOrigin(resampleFilter1->GetOutput(),
|
||||
image3DOrigin,
|
||||
m_3DProjectionOriginLPS,
|
||||
projAngle1);
|
||||
InternalImageType::DirectionType DRT2LPS1 =
|
||||
this->CalcDRTImageDirections(projAngle1);
|
||||
@ -1049,8 +1055,8 @@ void itkImageProcessor::GetProjectionImages(){
|
||||
|
||||
|
||||
|
||||
InternalImageType::DirectionType LATtoHFS =
|
||||
this->CalcDRTImageDirections(projAngle2);
|
||||
// InternalImageType::DirectionType LATtoHFS =
|
||||
// this->CalcDRTImageDirections(projAngle2);
|
||||
|
||||
|
||||
/* Again.. */
|
||||
@ -1058,7 +1064,7 @@ void itkImageProcessor::GetProjectionImages(){
|
||||
|
||||
NewOrigin =
|
||||
this->CalcDRTImageOrigin(resampleFilter2->GetOutput(),
|
||||
image3DOrigin,
|
||||
m_3DProjectionOriginLPS,
|
||||
projAngle2);
|
||||
|
||||
DRT2LPS1 =
|
||||
@ -1239,19 +1245,19 @@ vtkImageData* itkImageProcessor::GetLocalizer2VTK()
|
||||
ImageType3D::PointType LastVoxelPosition =
|
||||
origin3D + (imagDirection * Dest);
|
||||
|
||||
// std::cout<<" -------- Localizer 2 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 2 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 = toVTKLocalizer2->GetOutput()->GetBounds();
|
||||
// std::cout<< "-------- Localizer 2 VTK --------" <<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 = toVTKLocalizer2->GetOutput()->GetBounds();
|
||||
// std::cout<< "-------- Localizer 2 VTK --------" <<std::endl;
|
||||
// std::cout<<"Bounds: "<<dBounds[0]<<" "<<dBounds[1]<<" "
|
||||
// <<dBounds[2]<<" "<<dBounds[3]<<" "
|
||||
// <<dBounds[4]<<" "<<dBounds[5]<<std::endl;
|
||||
// std::cout<< "-------- -------- --------" <<std::endl;
|
||||
|
||||
}
|
||||
|
||||
@ -1270,7 +1276,7 @@ vtkImageData* itkImageProcessor::GetProjection1VTK()
|
||||
rescaler1->SetOutputMinimum(0);
|
||||
rescaler1->SetOutputMaximum(255);
|
||||
rescaler1->SetInput( imageDRT1In );
|
||||
// flipFilter1->GetOutput());
|
||||
// flipFilter1->GetOutput());
|
||||
|
||||
rescaler1->Update();
|
||||
|
||||
@ -1278,41 +1284,41 @@ vtkImageData* itkImageProcessor::GetProjection1VTK()
|
||||
toVTK2D1->Update();
|
||||
|
||||
|
||||
// using ImageRegionType3D = ImageType3D::RegionType;
|
||||
// using SizeType3D = ImageRegionType3D::SizeType;
|
||||
// using ImageDirectionType3D = ImageType3D::DirectionType;
|
||||
// using ImageRegionType3D = ImageType3D::RegionType;
|
||||
// using SizeType3D = ImageRegionType3D::SizeType;
|
||||
// using ImageDirectionType3D = ImageType3D::DirectionType;
|
||||
|
||||
// ImageRegionType3D region3D = rescaler1->GetOutput()->GetBufferedRegion();
|
||||
// SizeType3D size3D = region3D.GetSize();
|
||||
// ImageType3D::PointType origin3D = rescaler1->GetOutput()->GetOrigin();
|
||||
// const itk::Vector<double, 3> resolution3D = rescaler1->GetOutput()->GetSpacing();
|
||||
// ImageDirectionType3D imagDirection = rescaler1->GetOutput()->GetDirection();
|
||||
// ImageRegionType3D region3D = rescaler1->GetOutput()->GetBufferedRegion();
|
||||
// SizeType3D size3D = region3D.GetSize();
|
||||
// ImageType3D::PointType origin3D = rescaler1->GetOutput()->GetOrigin();
|
||||
// const itk::Vector<double, 3> resolution3D = rescaler1->GetOutput()->GetSpacing();
|
||||
// ImageDirectionType3D imagDirection = rescaler1->GetOutput()->GetDirection();
|
||||
|
||||
// /* calculate image size in 3D Space */
|
||||
// using VectorType = itk::Vector<double, 3>;
|
||||
// VectorType Dest;
|
||||
// Dest[0]=(size3D[0]-1) * resolution3D[0];
|
||||
// Dest[1]=(size3D[1]-1) * resolution3D[1];
|
||||
// Dest[2]=(size3D[2]-1) * resolution3D[2];
|
||||
// /* calculate image size in 3D Space */
|
||||
// using VectorType = itk::Vector<double, 3>;
|
||||
// VectorType Dest;
|
||||
// Dest[0]=(size3D[0]-1) * resolution3D[0];
|
||||
// Dest[1]=(size3D[1]-1) * resolution3D[1];
|
||||
// Dest[2]=(size3D[2]-1) * resolution3D[2];
|
||||
|
||||
// ImageType3D::PointType LastVoxelPosition =
|
||||
// origin3D + (imagDirection * Dest);
|
||||
// ImageType3D::PointType LastVoxelPosition =
|
||||
// origin3D + (imagDirection * Dest);
|
||||
|
||||
// std::cout<<" -------- Projection 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<<" -------- Projection 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 = toVTK2D1->GetOutput()->GetBounds();
|
||||
// double* dBounds = toVTK2D1->GetOutput()->GetBounds();
|
||||
|
||||
// std::cout<< "-------- Proj 1 --------" <<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<< "-------- Proj 1 --------" <<std::endl;
|
||||
// std::cout<<"Bounds: "<<dBounds[0]<<" "<<dBounds[1]<<" "
|
||||
// <<dBounds[2]<<" "<<dBounds[3]<<" "
|
||||
// <<dBounds[4]<<" "<<dBounds[5]<<std::endl;
|
||||
// std::cout<< "-------- -------- --------" <<std::endl;
|
||||
|
||||
return
|
||||
toVTK2D1->GetOutput();
|
||||
@ -1327,50 +1333,50 @@ vtkImageData* itkImageProcessor::GetProjection2VTK()
|
||||
rescaler2->SetOutputMinimum(0);
|
||||
rescaler2->SetOutputMaximum(255);
|
||||
rescaler2->SetInput( imageDRT2In );
|
||||
// flipFilter2->GetOutput());
|
||||
// flipFilter2->GetOutput());
|
||||
|
||||
rescaler2->Update();
|
||||
|
||||
// rescaler2->Print(std::cout);
|
||||
// rescaler2->Print(std::cout);
|
||||
|
||||
// using ImageRegionType3D = ImageType3D::RegionType;
|
||||
// using SizeType3D = ImageRegionType3D::SizeType;
|
||||
// using ImageDirectionType3D = ImageType3D::DirectionType;
|
||||
// using ImageRegionType3D = ImageType3D::RegionType;
|
||||
// using SizeType3D = ImageRegionType3D::SizeType;
|
||||
// using ImageDirectionType3D = ImageType3D::DirectionType;
|
||||
|
||||
// ImageRegionType3D region3D = rescaler2->GetOutput()->GetBufferedRegion();
|
||||
// SizeType3D size3D = region3D.GetSize();
|
||||
// ImageType3D::PointType origin3D = rescaler2->GetOutput()->GetOrigin();
|
||||
// const itk::Vector<double, 3> resolution3D = rescaler2->GetOutput()->GetSpacing();
|
||||
// ImageDirectionType3D imagDirection = rescaler2->GetOutput()->GetDirection();
|
||||
// ImageRegionType3D region3D = rescaler2->GetOutput()->GetBufferedRegion();
|
||||
// SizeType3D size3D = region3D.GetSize();
|
||||
// ImageType3D::PointType origin3D = rescaler2->GetOutput()->GetOrigin();
|
||||
// const itk::Vector<double, 3> resolution3D = rescaler2->GetOutput()->GetSpacing();
|
||||
// ImageDirectionType3D imagDirection = rescaler2->GetOutput()->GetDirection();
|
||||
|
||||
/* calculate image size in 3D Space */
|
||||
// using VectorType = itk::Vector<double, 3>;
|
||||
// VectorType Dest;
|
||||
// Dest[0]=(size3D[0]-1) * resolution3D[0];
|
||||
// Dest[1]=(size3D[1]-1) * resolution3D[1];
|
||||
// Dest[2]=(size3D[2]-1) * resolution3D[2];
|
||||
// using VectorType = itk::Vector<double, 3>;
|
||||
// VectorType Dest;
|
||||
// Dest[0]=(size3D[0]-1) * resolution3D[0];
|
||||
// Dest[1]=(size3D[1]-1) * resolution3D[1];
|
||||
// Dest[2]=(size3D[2]-1) * resolution3D[2];
|
||||
|
||||
// ImageType3D::PointType LastVoxelPosition =
|
||||
// origin3D + (imagDirection * Dest);
|
||||
// ImageType3D::PointType LastVoxelPosition =
|
||||
// origin3D + (imagDirection * Dest);
|
||||
|
||||
// std::cout<<" -------- Projection 2 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<<" -------- Projection 2 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;
|
||||
|
||||
|
||||
toVTK2D2->SetInput(rescaler2->GetOutput());
|
||||
toVTK2D2->Update();
|
||||
|
||||
// double* dBounds = toVTK2D2->GetOutput()->GetBounds();
|
||||
// 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;
|
||||
// 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();
|
||||
@ -1386,13 +1392,13 @@ void itkImageProcessor::WriteProjectionImages()
|
||||
rescaler1->SetOutputMinimum(0);
|
||||
rescaler1->SetOutputMaximum(255);
|
||||
rescaler1->SetInput( imageDRT1In );
|
||||
// flipFilter1->GetOutput());
|
||||
// flipFilter1->GetOutput());
|
||||
|
||||
RescaleFilterType::Pointer rescaler2 = RescaleFilterType::New();
|
||||
rescaler2->SetOutputMinimum(0);
|
||||
rescaler2->SetOutputMaximum(255);
|
||||
rescaler2->SetInput( imageDRT2In );
|
||||
// flipFilter2->GetOutput());
|
||||
// flipFilter2->GetOutput());
|
||||
|
||||
|
||||
using WriterType = itk::ImageFileWriter<OutputImageType>;
|
||||
@ -1454,8 +1460,8 @@ void itkImageProcessor::SetInitialTranslations(double dX, double dY, double dZ)
|
||||
TZero[2]= LPSTranslations[2];
|
||||
|
||||
|
||||
// std::cout<< "itkImageProcessor::SetInitialTranslations IEC : "<<IECTranslations <<std::endl;
|
||||
// std::cout<< "itkImageProcessor::SetInitialTranslations LPS : "<<TZero[0]<<" "<<TZero[1]<<" "<<TZero[2] <<std::endl;
|
||||
// std::cout<< "itkImageProcessor::SetInitialTranslations IEC : "<<IECTranslations <<std::endl;
|
||||
// std::cout<< "itkImageProcessor::SetInitialTranslations LPS : "<<TZero[0]<<" "<<TZero[1]<<" "<<TZero[2] <<std::endl;
|
||||
}
|
||||
|
||||
void itkImageProcessor::SetInitialRotations(double dX, double dY, double dZ)
|
||||
|
@ -253,6 +253,14 @@ private:
|
||||
|
||||
tPatOrientation
|
||||
m_3DPatOrientation;
|
||||
|
||||
ImageType3D :: PointType
|
||||
m_3DOriginLPS,
|
||||
m_3DProjectionOriginLPS,
|
||||
m_3DProjectionOriginLPSZero;
|
||||
|
||||
|
||||
|
||||
InternalImageType::DirectionType
|
||||
LPStoIEC_Directions;
|
||||
|
||||
@ -270,6 +278,15 @@ private:
|
||||
tPatOrientation pOrient,
|
||||
double pAngleIEC);
|
||||
|
||||
// ImageType3D::PointType
|
||||
// CalcDataCollectionCenterLPS_ZeroOrigin(
|
||||
// tPatOrientation pOrient,
|
||||
// ImageType3D::PointType m_CollectionCenterIEC,
|
||||
// ImageType3D::PointType m_CTOriginLPS);
|
||||
|
||||
|
||||
|
||||
|
||||
double image1res[2], image2res[2];
|
||||
double image1center[2], image2center[2];
|
||||
int image1Size[2], image2Size[2];
|
||||
@ -280,7 +297,7 @@ private:
|
||||
double projAngle1_IEC, projAngle2_IEC;
|
||||
|
||||
double TZero[3], RZero[3];
|
||||
double image3DCOV[3];
|
||||
|
||||
|
||||
bool customized_iso,customized_2DCX,customized_2DRES, customized_2DSIZE;
|
||||
bool image2D1Loaded, image2D2Loaded, image3DLoaded;
|
||||
@ -288,6 +305,15 @@ private:
|
||||
double image1IntensityWindow[2], image2IntensityWindow[2];
|
||||
|
||||
|
||||
|
||||
double
|
||||
d_CTImportOffset_txiec,
|
||||
d_CTImportOffset_tyiec,
|
||||
d_CTImportOffset_tziec,
|
||||
d_CTImportOffset_rxiec,
|
||||
d_CTImportOffset_ryiec,
|
||||
d_CTImportOffset_rziec;
|
||||
|
||||
InternalImageType::DirectionType Std_DRT2LPS;
|
||||
|
||||
};
|
||||
|
Reference in New Issue
Block a user