UseOfRotations for hidden transform and station name

- itkDRT has method to set whether rotations should be used for import offset and hidden transform. Results checked against external code for final PAT conversion.
- helpers for query of station name and Fov moved to helpers functions file
- preparation of station name check in scout processor load of 2D and 3D images
This commit is contained in:
Proton local user
2023-05-17 10:49:22 +02:00
parent 21751524bb
commit ab29d81e5e
6 changed files with 132 additions and 53 deletions

View File

@ -474,6 +474,8 @@ DRTProjectionGeometryImageMetaInformation(){
this->m_ProjectionCenter.Fill(0.);
this->m_UseRotationsForHiddenTransform = true;
}
void

View File

@ -408,6 +408,10 @@ public:
itkSetMacro(ProjectionCenter, PointType);
itkGetMacro(ProjectionCenter, PointType);
itkSetMacro(UseRotationsForHiddenTransform, bool);
itkGetMacro(UseRotationsForHiddenTransform, bool);
protected:
double
@ -447,6 +451,9 @@ protected:
m_ProjectionCenterOffset2;
bool
m_UseRotationsForHiddenTransform;
/** Default Constructor **/
DRTProjectionGeometryImageMetaInformation ();
/** Default Destructor **/

View File

@ -36,29 +36,6 @@ gfattori 08.11.2021
namespace itk
{
//FUNCTION DECLARATION NECESSARY FOR COPY/PASTE FROM vtkGDCMImageReader
// const char *gGetStringValueFromTag(const gdcm::Tag& t, const gdcm::DataSet& ds);
const char *gGetStringValueFromTag(const gdcm::Tag& t, const gdcm::DataSet& ds)
{
static std::string buffer;
buffer = ""; // cleanup previous call
if( ds.FindDataElement( t ) )
{
const gdcm::DataElement& de = ds.GetDataElement( t );
const gdcm::ByteValue *bv = de.GetByteValue();
if( bv ) // Can be Type 2
{
buffer = std::string( bv->GetPointer(), bv->GetLength() );
// Will be padded with at least one \0
}
}
// Since return is a const char* the very first \0 will be considered
return buffer.c_str();
};
itkImageProcessor::itkImageProcessor()
{
iNWUnits = 1;
@ -296,6 +273,17 @@ itkImageProcessor::GetDegreeOfFreedom()
m_r23MetaInfo->GetDegreeOfFreedom();
}
void itkImageProcessor::SetUseRotationsForImportOffset(bool bVal){
if(m_DRTGeometryMetaInfo == NULL){
return;
}
m_DRTGeometryMetaInfo->SetUseRotationsForHiddenTransform(bVal);
return;
}
void itkImageProcessor::SetCustom_ImportTransform(double dTx,
double dTy,
double dTz,
@ -1060,25 +1048,25 @@ int itkImageProcessor::load2D(const char * pcFName){
int itkImageProcessor::query2DimageReconstructionDiameter(const char *pcFName){
//int itkImageProcessor::query2DimageReconstructionDiameter(const char *pcFName){
/* Check if we can open the file */
gdcm::Reader R;
R.SetFileName(pcFName);
if(!R.Read())
{ cerr<<"ERROR: cannot read file: "<<pcFName<<endl;
return -1;
}
// /* Check if we can open the file */
// gdcm::Reader R;
// R.SetFileName(pcFName);
// if(!R.Read())
// { cerr<<"ERROR: cannot read file: "<<pcFName<<endl;
// return -1;
// }
/* Check if it's a localizer image */
const gdcm::File &file = R.GetFile();
const gdcm::DataSet &ds = file.GetDataSet();
// /* Check if it's a localizer image */
// const gdcm::File &file = R.GetFile();
// const gdcm::DataSet &ds = file.GetDataSet();
char* sTmpString = new char [255];
strcpy( sTmpString,gGetStringValueFromTag(gdcm::Tag(0x0018,0x1100), ds));
// char* sTmpString = new char [255];
// strcpy( sTmpString,gGetStringValueFromTag(gdcm::Tag(0x0018,0x1100), ds));
return std::atoi(sTmpString);
}
// return std::atoi(sTmpString);
//}
double itkImageProcessor::GetLocalizerDisplayWindowLevel(int iImg)
@ -1750,18 +1738,26 @@ void itkImageProcessor::loadRTPlanInfo(
m_RTMetaInfo->SetIsocenterIECS(Point);
ImageType3D::PointType
pZero (3);
pZero.Fill(0.);
m_CTMetaInfo->SetImportOffset(
CalcImportVolumeOffset(
m_RTMetaInfo->GetIsocenterIECS(),
m_CTMetaInfo->GetLPS2IECDirections(),
m_RTMetaInfo->GetIsocenterLPS(),
m_DRTGeometryMetaInfo->GetIECS2IECScannerT(),
m_DRTGeometryMetaInfo->GetIECS2IECScannerR()
(m_DRTGeometryMetaInfo->GetUseRotationsForHiddenTransform() ?
m_DRTGeometryMetaInfo->GetIECS2IECScannerR() : pZero)
)
);
m_TransformMetaInfo->SetHiddenRotations(
m_DRTGeometryMetaInfo->GetIECS2IECScannerR());
(m_DRTGeometryMetaInfo->GetUseRotationsForHiddenTransform() ?
m_DRTGeometryMetaInfo->GetIECS2IECScannerR() : pZero)
);
this->UpdateProjectionGeometryMeta();

View File

@ -87,7 +87,7 @@ public:
int load2D(const char *);
int unload2DAndMeta(int);
int query2DimageReconstructionDiameter(const char*);
//int query2DimageReconstructionDiameter(const char*);
void loadRTPlanInfo(double, double, double, double, double ,double);
int unloadRTPlanAndMeta();
@ -121,7 +121,6 @@ public:
tDegreeOfFreedomEnum GetDegreeOfFreedom();
void SetCustom_ProjectionCenterOffsetFixedAxes_IEC(double,double,double,double,double,double);
void SetCustom_ProjectionCenterFixedAxes_IEC(double,double,double);
/** Intensity threshold used for image projection,
@ -131,8 +130,16 @@ public:
/** Custom settings of the projection images */
void SetCustom_2Dres(double,double,double,double);
void SetCustom_2Dsize(int,int,int,int);
/** Custom transform to map IEC of imaging device into IEC-Support
* Tx Ty Tz [mm] Rx Ry Rz [deg]
*/
void SetCustom_ImportTransform(double, double, double,
double, double, double);
/** Should rotations be used when computing import offset and hidden transform? */
void SetUseRotationsForImportOffset(bool bVal);
void SetCustom_UpdateMetaInfo();
@ -172,10 +179,8 @@ public:
*/
const CTVolumeImageMetaInformation::Pointer
GetCTMetaInfo();
const RTGeometryMetaInformation::Pointer
GetRTMetaInfo();
const DRTProjectionGeometryImageMetaInformation::Pointer
GetDRTGeoMetaInfo();
@ -230,9 +235,6 @@ public:
void SetRegionFixed1(int,int,int,int);
void SetRegionFixed2(int,int,int,int);
/** Optimizer which tries to find the minimn (Powell Optimizer)*/
using OptimizerType = itk::PowellOptimizer;
protected:
/** Various pixel types */
using InternalPixelType = float;
@ -263,12 +265,11 @@ private:
/** The following lines define each of the components used in the
registration: The transform, optimizer, metric, interpolator and
the registration method itself. */
//using TransformType = itk::Euler3DTransform<double>;
using InterpolatorType = itk::gSiddonJacobsRayCastInterpolateImageFunction<InternalImageType, double>;
using ResampleFilterType = itk::ResampleImageFilter<InternalImageType, InternalImageType>;
//using gTransformType = itk::gEuler3DTransform<double>;
/** Optimizer which tries to find the minimun (Powell Optimizer)*/
using OptimizerType = itk::PowellOptimizer;
/** Optimizer which tries to find the minimn (Powell Optimizer)*/
using AmoebaOptimizerType = itk::AmoebaOptimizer;
/** Optimizer which samples the whol space */
@ -395,9 +396,6 @@ private:
* m_Projection1VTKTransform,
* m_Projection2VTKTransform;
///*Transformation Parameters */
// double dTransfParam[6];
/**
* Many meta containers
*/

View File

@ -1,4 +1,6 @@
#include "itkImageProcessorHelpers.h"
#include <gdcmReader.h>
#include <stdio.h>
namespace itk {
@ -95,4 +97,69 @@ CalculateInternalTransformV3(
}
const char* queryStationName(const char* pcFName){
static std::string buffer;
/* Check if we can open the file */
gdcm::Reader R;
R.SetFileName(pcFName);
if(!R.Read())
{std::cerr<<"ERROR: cannot read file: "<<pcFName<<std::endl;
return "\n";
}
const gdcm::File &file = R.GetFile();
const gdcm::DataSet &ds = file.GetDataSet();
std::string s (gGetStringValueFromTag(gdcm::Tag(0x0008,0x1010), ds));
std::copy(s.rbegin(), s.rend(), std::back_inserter(buffer));
std::reverse(buffer.begin(),buffer.end());
return buffer.c_str();
}
int query2DimageReconstructionDiameter(const char *pcFName){
/* Check if we can open the file */
gdcm::Reader R;
R.SetFileName(pcFName);
if(!R.Read())
{std::cerr<<"ERROR: cannot read file: "<<pcFName<<std::endl;
return -1;
}
const gdcm::File &file = R.GetFile();
const gdcm::DataSet &ds = file.GetDataSet();
char* sTmpString = new char [255];
strcpy( sTmpString,gGetStringValueFromTag(gdcm::Tag(0x0018,0x1100), ds));
return std::atoi(sTmpString);
}
//FUNCTION DECLARATION NECESSARY FOR COPY/PASTE FROM vtkGDCMImageReader
// const char *gGetStringValueFromTag(const gdcm::Tag& t, const gdcm::DataSet& ds);
const char *gGetStringValueFromTag(const gdcm::Tag& t, const gdcm::DataSet& ds)
{
static std::string buffer;
buffer = ""; // cleanup previous call
if( ds.FindDataElement( t ) )
{
const gdcm::DataElement& de = ds.GetDataElement( t );
const gdcm::ByteValue *bv = de.GetByteValue();
if( bv ) // Can be Type 2
{
buffer = std::string( bv->GetPointer(), bv->GetLength() );
// Will be padded with at least one \0
}
}
// Since return is a const char* the very first \0 will be considered
return buffer.c_str();
}
}

View File

@ -10,6 +10,9 @@
#include "itkObject.h"
#include "itkObjectFactory.h"
#include <gdcmTag.h>
#include <gdcmDataSet.h>
namespace itk
{
@ -40,7 +43,13 @@ TransformType::Pointer
InternalImageType::DirectionType m_IECtoLPSDirections
);
const char *gGetStringValueFromTag(const gdcm::Tag& t, const gdcm::DataSet& ds);
int query2DimageReconstructionDiameter(const char*);
const char* queryStationName(const char*);
}
#endif