561 lines
12 KiB
C++
561 lines
12 KiB
C++
#include "DRTMetaInformation.h"
|
|
|
|
|
|
static double HFS2IEC[9] = {
|
|
1, 0, 0,
|
|
0, 0, 1,
|
|
0, -1, 0};
|
|
|
|
static double FFS2IEC[9] = {
|
|
-1, 0, 0,
|
|
0, 0, -1,
|
|
0, -1, 0};
|
|
|
|
|
|
namespace itk
|
|
{
|
|
|
|
TopogramImageMetaInformation::
|
|
TopogramImageMetaInformation(){
|
|
|
|
this->m_PatientOrientation =
|
|
tPatOrientation::NotDefined;
|
|
|
|
this->m_ProjectionOrientation =
|
|
tProjOrientationType::NA;
|
|
|
|
this->m_WLLevel = 0.;
|
|
|
|
this->m_WLWindow = 0.;
|
|
|
|
this->m_LPS2IECDirections.SetIdentity();
|
|
|
|
}
|
|
|
|
void
|
|
TopogramImageMetaInformation
|
|
::PrintSelf(std::ostream& os, itk::Indent indent) const
|
|
{
|
|
Superclass::PrintSelf(os, indent);
|
|
}
|
|
|
|
TopogramImageMetaInformation
|
|
::~TopogramImageMetaInformation ()
|
|
{
|
|
|
|
}
|
|
|
|
void TopogramImageMetaInformation ::
|
|
SetPatientOrientation(tPatOrientation m_orient)
|
|
{
|
|
this->m_PatientOrientation = m_orient;
|
|
|
|
for(int iIdx = 0 ; iIdx < 3; iIdx++){
|
|
for(int jIdx = 0 ; jIdx < 3; jIdx++){
|
|
|
|
switch (this->m_PatientOrientation) {
|
|
case tPatOrientation::HFS:
|
|
m_LPS2IECDirections.GetVnlMatrix()[iIdx][jIdx] = HFS2IEC[jIdx+iIdx*3];
|
|
break;
|
|
case tPatOrientation ::FFS:
|
|
m_LPS2IECDirections.GetVnlMatrix()[iIdx][jIdx] = FFS2IEC[jIdx+iIdx*3];
|
|
break;
|
|
default:
|
|
m_LPS2IECDirections.SetIdentity();
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
DRTImageMetaInformation::
|
|
DRTImageMetaInformation(){
|
|
|
|
|
|
this->m_Size.Fill(0.);
|
|
|
|
this->m_Spacing.Fill(0.);
|
|
|
|
//this->m_Origin.Fill(0.);
|
|
|
|
this->m_ProjectionOriginLPS.Fill(0.);
|
|
|
|
this->m_ProjectionOriginLPSZero.Fill(0.);
|
|
|
|
this->m_ProjectionAngleLPS = 0.;
|
|
|
|
this->m_SCD = 0.;
|
|
|
|
this->m_ImageDirectionsLPS.SetIdentity();
|
|
|
|
this->m_OriginLPS.Fill(0.);
|
|
|
|
this->m_PanelOffsetPGeo = 0.;
|
|
|
|
}
|
|
|
|
void
|
|
DRTImageMetaInformation
|
|
::PrintSelf(std::ostream& os, itk::Indent indent) const
|
|
{
|
|
Superclass::PrintSelf(os, indent);
|
|
}
|
|
|
|
|
|
DRTImageMetaInformation
|
|
::~DRTImageMetaInformation ()
|
|
{
|
|
|
|
}
|
|
|
|
DRTImageMetaInformation::PointType
|
|
DRTImageMetaInformation::GetOrigin()
|
|
{
|
|
|
|
//PointType Origin;
|
|
PointType Origin;
|
|
double o2Dx, o2Dy;
|
|
|
|
o2Dx = ((double)this->m_Size[0] - 1.) / 2.;
|
|
o2Dy = ((double)this->m_Size[1] - 1.) / 2.;
|
|
// Compute the origin (in mm) of the 2D Image
|
|
Origin[0] = -(this->m_Spacing[0]) * o2Dx;
|
|
Origin[1] = -(this->m_Spacing[1]) * o2Dy;
|
|
Origin[2] = -(this->m_SCD) ;
|
|
|
|
return
|
|
Origin;
|
|
}
|
|
|
|
void DRTImageMetaInformation::SetSizeWithBounds(
|
|
double* dBounds,
|
|
SizeType MaxSize,
|
|
SpacingType Spacing)
|
|
{
|
|
|
|
m_Size[0] = MaxSize[0];
|
|
m_Size[1] = MaxSize[1];
|
|
m_Size[2] = 1;
|
|
|
|
m_Spacing = Spacing;
|
|
|
|
return;
|
|
}
|
|
|
|
DRTImageMetaInformation::PointType
|
|
DRTImageMetaInformation::GetLPStoProjectionGeoLPSOffset()
|
|
{
|
|
|
|
PointType pOffset;
|
|
|
|
pOffset[0] = - m_ProjectionOriginLPS [0] + m_ProjectionOriginLPSZero [0];
|
|
pOffset[1] = - m_ProjectionOriginLPS [1] + m_ProjectionOriginLPSZero [1];
|
|
pOffset[2] = - m_ProjectionOriginLPS [2] + m_ProjectionOriginLPSZero [2];
|
|
|
|
return
|
|
pOffset;
|
|
}
|
|
|
|
DRTImageMetaInformation ::PointType
|
|
DRTImageMetaInformation ::GetCOV()
|
|
{
|
|
|
|
/* calculate image size in 3D Space by finding the last voxel position */
|
|
PointType Dest;
|
|
Dest[0]=(m_Size[0]-1) * m_Spacing [0];
|
|
Dest[1]=(m_Size[1]-1) * m_Spacing [1];
|
|
Dest[2]=(m_Size[2]-1) * m_Spacing [2];
|
|
|
|
PointType LastVoxelPosition = Dest;
|
|
|
|
PointType Origin = this->GetOrigin();
|
|
LastVoxelPosition [0] += Origin[0];
|
|
LastVoxelPosition [1] += Origin[1];
|
|
LastVoxelPosition [2] += Origin[2];
|
|
|
|
PointType image3DCOV;
|
|
image3DCOV[0] = (Origin [0] + LastVoxelPosition[0])/2.;
|
|
image3DCOV[1] = (Origin [1] + LastVoxelPosition[1])/2.;
|
|
image3DCOV[2] = (Origin [2] + LastVoxelPosition[2])/2.;
|
|
|
|
return
|
|
image3DCOV;
|
|
}
|
|
|
|
CTVolumeImageMetaInformation::PointType
|
|
CTVolumeImageMetaInformation::ConvertIECPointToLPSPoint(
|
|
PointType IECPoint){
|
|
|
|
DirectionType IECtoLPS_Directions;
|
|
IECtoLPS_Directions = this->m_LPS2IECDirections.GetTranspose();
|
|
|
|
PointType m_LPSPoint;
|
|
m_LPSPoint =
|
|
IECtoLPS_Directions * IECPoint;
|
|
|
|
return
|
|
m_LPSPoint;
|
|
}
|
|
|
|
CTVolumeImageMetaInformation::PointType
|
|
CTVolumeImageMetaInformation::GetProjectionOriginLPS(
|
|
PointType ProjectionCenter)
|
|
{
|
|
|
|
DirectionType IECtoLPS_Directions;
|
|
IECtoLPS_Directions = this->m_LPS2IECDirections.GetTranspose();
|
|
|
|
|
|
PointType m_ProjectionOriginLPS;
|
|
m_ProjectionOriginLPS =
|
|
IECtoLPS_Directions * ProjectionCenter;
|
|
|
|
/* in longitudinal direction (Sup-Inf), we put it in the
|
|
* middle of the volume */
|
|
m_ProjectionOriginLPS[2] = this->GetCOV()[2] - this->m_ImportOffset[2];
|
|
|
|
return
|
|
m_ProjectionOriginLPS;
|
|
|
|
}
|
|
|
|
CTVolumeImageMetaInformation::PointType
|
|
CTVolumeImageMetaInformation::GetProjectionOriginLPSZero(
|
|
PointType ProjectionCenter)
|
|
{
|
|
|
|
PointType Origin;
|
|
Origin = this->m_OriginLPS;
|
|
Origin = Origin - this->m_ImportOffset;
|
|
|
|
|
|
DirectionType IECtoLPS_Directions;
|
|
IECtoLPS_Directions = this->m_LPS2IECDirections.GetTranspose();
|
|
|
|
PointType m_ProjectionOriginLPS;
|
|
m_ProjectionOriginLPS =
|
|
IECtoLPS_Directions * ProjectionCenter;
|
|
/* in longitudinal direction (Sup-Inf), we put it in the
|
|
* middle of the volume */
|
|
m_ProjectionOriginLPS[2] = this->GetCOV()[2] - this->m_ImportOffset[2];
|
|
|
|
|
|
return
|
|
m_ProjectionOriginLPS - Origin;
|
|
|
|
}
|
|
|
|
const std::vector<double>
|
|
CTVolumeImageMetaInformation::CalculateRegions(PointType pProjectionOriginLPS)
|
|
{
|
|
|
|
/* calculate image size in 3D Space by finding the last voxel position */
|
|
PointType Dest;
|
|
Dest[0]=(m_Size[0]-1) * m_Spacing [0];
|
|
Dest[1]=(m_Size[1]-1) * m_Spacing [1];
|
|
Dest[2]=(m_Size[2]-1) * m_Spacing [2];
|
|
|
|
PointType LastVoxelPosition =
|
|
(m_ImageDirections * Dest);
|
|
|
|
LastVoxelPosition [0] += m_OriginLPS[0];
|
|
LastVoxelPosition [1] += m_OriginLPS[1];
|
|
LastVoxelPosition [2] += m_OriginLPS[2];
|
|
|
|
std::vector <double> vBounds;
|
|
vBounds.clear();
|
|
vBounds.push_back( pProjectionOriginLPS[0] - LastVoxelPosition [0] );
|
|
vBounds.push_back( pProjectionOriginLPS[1] - LastVoxelPosition [1] );
|
|
vBounds.push_back( pProjectionOriginLPS[2] - LastVoxelPosition [2] );
|
|
vBounds.push_back( pProjectionOriginLPS[0] - m_OriginLPS [0] );
|
|
vBounds.push_back( pProjectionOriginLPS[1] - m_OriginLPS [1] );
|
|
vBounds.push_back( pProjectionOriginLPS[2] - m_OriginLPS [2] );
|
|
|
|
return
|
|
vBounds;
|
|
|
|
}
|
|
|
|
CTVolumeImageMetaInformation::
|
|
CTVolumeImageMetaInformation(){
|
|
|
|
this->m_PatientOrientation =
|
|
tPatOrientation::NotDefined;
|
|
|
|
this->m_Spacing.Fill(0.);
|
|
|
|
this->m_Size.Fill(0.);
|
|
|
|
this->m_OriginLPS.Fill(0.);
|
|
|
|
this->m_ImageDirections.SetIdentity();
|
|
|
|
this->m_LPS2IECDirections.SetIdentity();
|
|
|
|
this->m_ImportOffset.Fill(0.);
|
|
}
|
|
|
|
void
|
|
CTVolumeImageMetaInformation
|
|
::PrintSelf(std::ostream& os, itk::Indent indent) const
|
|
{
|
|
Superclass::PrintSelf(os, indent);
|
|
}
|
|
|
|
CTVolumeImageMetaInformation
|
|
::~CTVolumeImageMetaInformation ()
|
|
{
|
|
|
|
}
|
|
|
|
void CTVolumeImageMetaInformation::
|
|
SetPatientOrientation(tPatOrientation m_orient)
|
|
{
|
|
this->m_PatientOrientation = m_orient;
|
|
|
|
for(int iIdx = 0 ; iIdx < 3; iIdx++){
|
|
for(int jIdx = 0 ; jIdx < 3; jIdx++){
|
|
|
|
switch (this->m_PatientOrientation) {
|
|
case tPatOrientation::HFS:
|
|
m_LPS2IECDirections.GetVnlMatrix()[iIdx][jIdx] = HFS2IEC[jIdx+iIdx*3];
|
|
break;
|
|
case tPatOrientation ::FFS:
|
|
m_LPS2IECDirections.GetVnlMatrix()[iIdx][jIdx] = FFS2IEC[jIdx+iIdx*3];
|
|
break;
|
|
default:
|
|
m_LPS2IECDirections.SetIdentity();
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|
|
CTVolumeImageMetaInformation::PointType
|
|
CTVolumeImageMetaInformation::GetCOV()
|
|
{
|
|
|
|
/* calculate image size in 3D Space by finding the last voxel position */
|
|
PointType Dest;
|
|
Dest[0]=(m_Size[0]-1) * m_Spacing [0];
|
|
Dest[1]=(m_Size[1]-1) * m_Spacing [1];
|
|
Dest[2]=(m_Size[2]-1) * m_Spacing [2];
|
|
|
|
PointType LastVoxelPosition =
|
|
(m_ImageDirections * Dest);
|
|
|
|
LastVoxelPosition [0] += m_OriginLPS[0];
|
|
LastVoxelPosition [1] += m_OriginLPS[1];
|
|
LastVoxelPosition [2] += m_OriginLPS[2];
|
|
|
|
PointType image3DCOVLPS;
|
|
image3DCOVLPS[0] = (m_OriginLPS[0] + LastVoxelPosition[0])/2.;
|
|
image3DCOVLPS[1] = (m_OriginLPS[1] + LastVoxelPosition[1])/2.;
|
|
image3DCOVLPS[2] = (m_OriginLPS[2] + LastVoxelPosition[2])/2.;
|
|
|
|
return
|
|
image3DCOVLPS;
|
|
}
|
|
|
|
CTVolumeImageMetaInformation::PointType
|
|
CTVolumeImageMetaInformation::GetOriginWOffset(){
|
|
return
|
|
this->m_OriginLPS - this->m_ImportOffset;
|
|
}
|
|
|
|
DRTProjectionGeometryImageMetaInformation::
|
|
DRTProjectionGeometryImageMetaInformation(){
|
|
|
|
this->m_ProjectionAngle1IEC = 0.;
|
|
|
|
this->m_ProjectionAngle2IEC = 0.;
|
|
|
|
this->m_ProjectionAngle1OffsetIEC = 0.;
|
|
|
|
this->m_ProjectionAngle2OffsetIEC = 0.;
|
|
|
|
this->m_SCD1 = 0.;
|
|
|
|
this->m_SCD2 = 0.;
|
|
|
|
this->m_SCD1Offset = 0.;
|
|
|
|
this->m_SCD2Offset = 0.;
|
|
|
|
this->m_Panel1Offset = 0.;
|
|
|
|
this->m_Panel2Offset = 0.;
|
|
|
|
this->m_IntensityThreshold=0.;
|
|
|
|
this->m_DRT1Size.Fill(0.);
|
|
|
|
this->m_DRT2Size.Fill(0.);
|
|
|
|
this->m_DRT1Spacing.Fill(0.);
|
|
|
|
this->m_DRT2Spacing.Fill(0.);
|
|
|
|
this->m_IECS2IECScannerT.Fill(0.);
|
|
|
|
this->m_IECS2IECScannerR.Fill(0.);
|
|
|
|
this->m_ProjectionCenterOffset1.Fill(0.);
|
|
|
|
this->m_ProjectionCenterOffset2.Fill(0.);
|
|
|
|
this->m_ProjectionCenter.Fill(0.);
|
|
|
|
this->m_UseRotationsForHiddenTransform = true;
|
|
|
|
}
|
|
|
|
void
|
|
DRTProjectionGeometryImageMetaInformation
|
|
::PrintSelf(std::ostream& os, itk::Indent indent) const
|
|
{
|
|
Superclass::PrintSelf(os, indent);
|
|
}
|
|
|
|
DRTProjectionGeometryImageMetaInformation
|
|
::~DRTProjectionGeometryImageMetaInformation ()
|
|
{
|
|
|
|
}
|
|
|
|
RTGeometryMetaInformation::
|
|
RTGeometryMetaInformation(){
|
|
|
|
this->m_IsocenterLPS.Fill(0.);
|
|
|
|
this->m_IsocenterIECS.Fill(0.);
|
|
|
|
|
|
}
|
|
|
|
void
|
|
RTGeometryMetaInformation
|
|
::PrintSelf(std::ostream& os, itk::Indent indent) const
|
|
{
|
|
Superclass::PrintSelf(os, indent);
|
|
}
|
|
|
|
RTGeometryMetaInformation
|
|
::~RTGeometryMetaInformation()
|
|
{
|
|
|
|
}
|
|
|
|
InternalTransformMetaInformation::InternalTransformMetaInformation(){
|
|
|
|
|
|
m_pCalProjCenter.Fill(0.);
|
|
m_pRTIsocenter.Fill(0.);
|
|
|
|
m_IECtoLPSDirs.SetIdentity();
|
|
|
|
}
|
|
|
|
void
|
|
InternalTransformMetaInformation
|
|
::PrintSelf(std::ostream& os, itk::Indent indent) const
|
|
{
|
|
Superclass::PrintSelf(os, indent);
|
|
}
|
|
|
|
InternalTransformMetaInformation
|
|
::~InternalTransformMetaInformation ()
|
|
{
|
|
|
|
}
|
|
|
|
R23MetaInformation::
|
|
R23MetaInformation (){
|
|
|
|
m_DegreeOfFreedom = tDegreeOfFreedomEnum::UNKNOWN;
|
|
m_OptimizerType = tOptimizerTypeEnum::POWELL;
|
|
m_MetricType = tMetricTypeEnum::NCC;
|
|
}
|
|
|
|
void
|
|
R23MetaInformation
|
|
::PrintSelf(std::ostream& os, itk::Indent indent) const
|
|
{
|
|
Superclass::PrintSelf(os, indent);
|
|
}
|
|
|
|
R23MetaInformation
|
|
::~R23MetaInformation ()
|
|
{
|
|
|
|
}
|
|
|
|
TransformMetaInformation ::
|
|
TransformMetaInformation (){
|
|
|
|
m_HiddenTranslations.Fill(0.);
|
|
|
|
m_HiddenRotations.Fill(0.);
|
|
|
|
m_UserRotations.Fill(0.);
|
|
|
|
m_UserTranslations.Fill(0.);
|
|
|
|
//m_ReferenceTransform.Fill(0.);
|
|
|
|
//m_CurrentTransform.Fill(0.);
|
|
|
|
// m_DegreeOfFreedom = tDegreeOfFreedomEnum::UNKNOWN;
|
|
|
|
}
|
|
|
|
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
|
|
{
|
|
Superclass::PrintSelf(os, indent);
|
|
}
|
|
|
|
|
|
TransformMetaInformation
|
|
::~TransformMetaInformation ()
|
|
{
|
|
|
|
}
|
|
|
|
|
|
}
|