adding meta info classes

This commit is contained in:
2022-02-16 22:58:33 +01:00
parent 7756fafc58
commit 2207f9e68c
5 changed files with 539 additions and 32 deletions

View File

@ -15,14 +15,17 @@ INCLUDE_DIRECTORIES(${GDCM_INCLUDE_DIRS})
SET(SRCS
itkImageProcessor.cpp
vtkContourTopogramProjectionFilter.cxx
DRTMetaInformation.cpp
)
SET(HDR
itkImageProcessor.h
itkgSiddonJacobsRayCastInterpolateImageFunction.h
itkgSiddonJacobsRayCastInterpolateImageFunction.hxx
vtkContourTopogramProjectionFilter.cxx
vtkContourTopogramProjectionFilter.h
DRTMetaInformation.h
)
ADD_LIBRARY(${LIB_NAME} ${SRCS} ${HDR})

View File

@ -0,0 +1,220 @@
#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_RequestedSize.Fill(0.);
this->m_Size.Fill(0.);
this->m_Spacing.Fill(0.);
this->m_Origin.Fill(0.);
}
void
DRTImageMetaInformation
::PrintSelf(std::ostream& os, itk::Indent indent) const
{
Superclass::PrintSelf(os, indent);
}
DRTImageMetaInformation
::~DRTImageMetaInformation ()
{
}
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();
}
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()
{
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;
}
DRTProjectionGeometryImageMetaInformation::
DRTProjectionGeometryImageMetaInformation(){
this->m_ProjectionAngle1IEC = 0.;
this->m_ProjectionAngle2IEC = 0.;
this->m_SCD = 0.;
this->m_ProjectionOriginLPS.Fill(0.);
this->m_ProjectionOriginLPSZero.Fill(0.);
this->m_ProjectionCenter.Fill(0.);
}
void
DRTProjectionGeometryImageMetaInformation
::PrintSelf(std::ostream& os, itk::Indent indent) const
{
Superclass::PrintSelf(os, indent);
}
DRTProjectionGeometryImageMetaInformation
::~DRTProjectionGeometryImageMetaInformation ()
{
}
}

View File

@ -0,0 +1,292 @@
#ifndef DRTMETAINFORMATION_H
#define DRTMETAINFORMATION_H
#include "itkObject.h"
#include "itkObjectFactory.h"
#include "itkSmartPointer.h"
#include "itkMacro.h"
#include "itkImage.h"
namespace itk
{
typedef enum eProjectionOrientationType
{NA = 0, LAT=2, PA=1}
tProjOrientationType;
/** Enum type for Orientation */
typedef enum eImageOrientationType
{NotDefined = 0, HFS = 1, FFS = 2}
tPatOrientation;
class TopogramImageMetaInformation :
public itk::Object{
public:
/** standard typedefs **/
typedef TopogramImageMetaInformation Self;
typedef itk::Object Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::Matrix<double, 3, 3> DirectionType;
/** Method for creation through the object factory. */
itkNewMacro(Self);
/** Run-time type information (and related methods). */
itkTypeMacro(TopogramImageMetaInformation, itk::Object);
/** object information streaming **/
void PrintSelf(std::ostream& os, itk::Indent indent) const;
void SetPatientOrientation(tPatOrientation);
itkGetEnumMacro(PatientOrientation, tPatOrientation);
itkSetEnumMacro(ProjectionOrientation, tProjOrientationType);
itkGetEnumMacro(ProjectionOrientation, tProjOrientationType);
itkSetMacro(WLLevel,double);
itkGetMacro(WLLevel,double);
itkSetMacro(WLWindow,double);
itkGetMacro(WLWindow,double);
itkSetMacro(LPS2IECDirections,DirectionType);
itkGetMacro(LPS2IECDirections,DirectionType);
protected:
tPatOrientation
m_PatientOrientation;
tProjOrientationType
m_ProjectionOrientation;
/** preferred level (windowing) **/
double m_WLLevel;
/** preferred window (windowing) **/
double m_WLWindow;
DirectionType
m_LPS2IECDirections;
/** Default Constructor **/
TopogramImageMetaInformation ();
/** Default Destructor **/
virtual ~TopogramImageMetaInformation ();
private:
/** purposely not implemented **/
TopogramImageMetaInformation (const Self&);
/** purposely not implemented **/
void operator=(const Self&);
};
class DRTImageMetaInformation :
public itk::Object{
public:
/** standard typedefs **/
typedef DRTImageMetaInformation Self;
typedef itk::Object Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::Point<double, 3> PointType;
typedef itk::FixedArray<double, 3> SpacingType;
typedef itk::FixedArray<unsigned int, 3> SizeType;
/** Method for creation through the object factory. */
itkNewMacro(Self);
/** Run-time type information (and related methods). */
itkTypeMacro(DRTImageMetaInformation, itk::Object);
/** object information streaming **/
void PrintSelf(std::ostream& os, itk::Indent indent) const;
itkSetMacro(RequestedSize,SizeType);
itkGetMacro(RequestedSize,SizeType);
itkSetMacro(Size,SizeType);
itkGetMacro(Size,SizeType);
itkSetMacro(Spacing,SpacingType);
itkGetMacro(Spacing,SpacingType);
itkSetMacro(Origin,PointType);
itkGetMacro(Origin,PointType);
protected:
SizeType
m_RequestedSize,
m_Size;
SpacingType
m_Spacing;
PointType
m_Origin;
/** Default Constructor **/
DRTImageMetaInformation ();
/** Default Destructor **/
virtual ~DRTImageMetaInformation ();
private:
/** purposely not implemented **/
DRTImageMetaInformation(const Self&);
/** purposely not implemented **/
void operator=(const Self&);
};
class CTVolumeImageMetaInformation :
public itk::Object{
public:
/** standard typedefs **/
typedef CTVolumeImageMetaInformation Self;
typedef itk::Object Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::Matrix<double, 3, 3> DirectionType;
typedef itk::Point<double, 3> PointType;
typedef itk::FixedArray<double, 3> SpacingType;
typedef itk::FixedArray<unsigned int, 3> SizeType;
/** Method for creation through the object factory. */
itkNewMacro(Self);
/** Run-time type information (and related methods). */
itkTypeMacro(CTVolumeImageMetaInformation , itk::Object);
/** object information streaming **/
void PrintSelf(std::ostream& os, itk::Indent indent) const;
void SetPatientOrientation(tPatOrientation);
itkGetEnumMacro(PatientOrientation, tPatOrientation);
itkSetMacro(Spacing,SpacingType);
itkGetMacro(Spacing,SpacingType);
itkSetMacro(Size,SizeType);
itkGetMacro(Size,SizeType);
itkSetMacro(OriginLPS,PointType);
itkGetMacro(OriginLPS,PointType);
itkSetMacro(LPS2IECDirections,DirectionType);
itkGetMacro(LPS2IECDirections,DirectionType);
PointType GetCOV();
protected:
tPatOrientation
m_PatientOrientation;
SpacingType
m_Spacing;
SizeType
m_Size;
PointType
m_OriginLPS;
DirectionType
m_ImageDirections,
m_LPS2IECDirections;
/** Default Constructor **/
CTVolumeImageMetaInformation ();
/** Default Destructor **/
virtual ~CTVolumeImageMetaInformation ();
private:
/** purposely not implemented **/
CTVolumeImageMetaInformation (const Self&);
/** purposely not implemented **/
void operator=(const Self&);
};
class DRTProjectionGeometryImageMetaInformation :
public itk::Object{
public:
/** standard typedefs **/
typedef DRTProjectionGeometryImageMetaInformation Self;
typedef itk::Object Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::Point<double, 3> PointType;
/** Method for creation through the object factory. */
itkNewMacro(Self);
/** Run-time type information (and related methods). */
itkTypeMacro(DRTProjectionGeometryImageMetaInformation , itk::Object);
/** object information streaming **/
void PrintSelf(std::ostream& os, itk::Indent indent) const;
itkSetMacro(ProjectionAngle1IEC, double);
itkGetMacro(ProjectionAngle1IEC, double);
itkSetMacro(ProjectionAngle2IEC, double);
itkGetMacro(ProjectionAngle2IEC, double);
itkSetMacro(SCD, double);
itkGetMacro(SCD, double);
itkSetMacro(ProjectionOriginLPS,PointType);
itkGetMacro(ProjectionOriginLPS,PointType);
itkSetMacro(ProjectionOriginLPSZero,PointType);
itkGetMacro(ProjectionOriginLPSZero,PointType);
itkSetMacro(ProjectionCenter, PointType);
itkGetMacro(ProjectionCenter, PointType);
protected:
double
m_ProjectionAngle1IEC,
m_ProjectionAngle2IEC,
m_SCD;
PointType
m_ProjectionOriginLPS,
m_ProjectionOriginLPSZero,
m_ProjectionCenter;
/** Default Constructor **/
DRTProjectionGeometryImageMetaInformation ();
/** Default Destructor **/
virtual ~DRTProjectionGeometryImageMetaInformation ();
private:
/** purposely not implemented **/
DRTProjectionGeometryImageMetaInformation (const Self&);
/** purposely not implemented **/
void operator=(const Self&);
};
}
#endif

View File

@ -154,6 +154,10 @@ itkImageProcessor::itkImageProcessor()
m_Projection1VTKTransform->Identity();
m_Projection2VTKTransform = vtkMatrix4x4::New();
m_Projection2VTKTransform->Identity();
m_CTMetaInfo = NULL;
}
itkImageProcessor::~itkImageProcessor()
@ -416,6 +420,8 @@ int itkImageProcessor::load3DSerie(const char * pcDirName)
return EXIT_FAILURE;
}
m_CTMetaInfo = CTVolumeImageMetaInformation::New();
@ -808,7 +814,6 @@ int itkImageProcessor::load2D(const char * pcFName){
caster2DInput->GetOutput();
double* m_ImageIntensity;
FlipFilterType::Pointer m_FlipFilter;
DuplicatorType::Pointer m_Duplicator;
bool* m_ImLoaded;
@ -906,7 +911,6 @@ void itkImageProcessor::InitializeProjector()
}
#include <math.h>
itkImageProcessor::InternalImageType::DirectionType

View File

@ -13,24 +13,22 @@ gfattori 08.11.2021
#define ITKIMAGEPROCESSOR_H
#include "DRTMetaInformation.h"
#include "itkCommand.h"
#include "itkPowellOptimizer.h"
#include "itkgSiddonJacobsRayCastInterpolateImageFunction.h"
#include "itkEuler3DTransform.h"
#include "itkTwoProjectionImageRegistrationMethod.h"
#include "itkResampleImageFilter.h"
#include "itkCastImageFilter.h"
#include "itkRescaleIntensityImageFilter.h"
#include "itkFlipImageFilter.h"
#include "itkChangeInformationImageFilter.h"
#include "itkTimeProbesCollectorBase.h"
#include "itkNormalizedCorrelationTwoImageToOneImageMetric.h"
#include "itkGDCMImageIO.h"
#include "itkMetaDataObject.h"
#include "itkImageDuplicator.h"
#include "gdcmGlobal.h"
#include "itkObject.h"
#include "itkObjectFactory.h"
#include "itkSmartPointer.h"
#include "itkImageToVTKImageFilter.h"
@ -38,16 +36,16 @@ gfattori 08.11.2021
#include "itkImageFileWriter.h"
#include "itkImageSeriesReader.h"
#include "gdcmGlobal.h"
#include "vtkImageData.h"
#include "vtkTransform.h"
#include "vtkSmartPointer.h"
namespace itk
{
/* reference string required for comparison with tag values */
static const char *ImageOrientationStrings[] = {
"NotDefined",
@ -55,7 +53,7 @@ static const char *ImageOrientationStrings[] = {
"FFS"
};
class ITK_EXPORT itkImageProcessor : public Object
class ITK_EXPORT itkImageProcessor : public itk::Object
{
constexpr static unsigned int Dimension = 3;
@ -66,8 +64,8 @@ public:
/** Standard "Superclass" typedef. */
typedef Object Superclass;
/** Smart pointer typedef support */
typedef SmartPointer<Self> Pointer;
typedef SmartPointer<const Self> ConstPointer;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
/** Method of creation through the object factory. */
itkNewMacro(Self);
/** Run-time type information (and related methods). */
@ -115,7 +113,7 @@ public:
const double* GetLPStoProjectionGeoLPSOffset();
/** Get Projection origin in LPS coordinates*/
const double* GetRTImportOffset();
const double* GetRTImportOffset();
/** Apply transform to CT volume.
@ -140,8 +138,6 @@ public:
vtkMatrix4x4 * GetProjection1VTKTransform();
vtkMatrix4x4 * GetProjection2VTKTransform();
vtkTransform * GetProjection1vtkTransform();
/** Debug writers */
void WriteProjectionImages();
void Write2DImages();
@ -154,18 +150,12 @@ public:
using ImageType3D = itk::Image<PixelType3D, Dimension>;
using InternalImageType = itk::Image<InternalPixelType, Dimension>;
typedef enum eProjectionOrientationType
{NA = 0, LAT=2, PA=1}
tProjOrientationType;
/** Enum type for Orientation */
typedef enum eImageOrientationType
{ NotDefined = 0, HFS = 1, FFS = 2}
tPatOrientation;
protected:
itkImageProcessor();
virtual ~itkImageProcessor();
void PrintSelf(std::ostream& os, Indent indent) const;
void PrintSelf(std::ostream& os, itk::Indent indent) const;
@ -185,11 +175,7 @@ private:
registration: The transform, optimizer, metric, interpolator and
the registration method itself. */
using TransformType = itk::Euler3DTransform<double>;
using OptimizerType = itk::PowellOptimizer;
using MetricType = itk::NormalizedCorrelationTwoImageToOneImageMetric<InternalImageType, InternalImageType>;
using InterpolatorType = itk::gSiddonJacobsRayCastInterpolateImageFunction<InternalImageType, double>;
using RegistrationType = itk::TwoProjectionImageRegistrationMethod<InternalImageType, InternalImageType>;
using ParametersType = RegistrationType::ParametersType;
/** Image reader types */
using ImageReaderType2D = itk::ImageFileReader<ImageType2D>;
@ -199,7 +185,6 @@ private:
using DuplicatorType = itk::ImageDuplicator<InternalImageType>;
/** widely used filters: flip, cast, rescale, ... */
using FlipFilterType = itk::FlipImageFilter<InternalImageType>;
using Input2DRescaleFilterType = itk::RescaleIntensityImageFilter<InternalImageType, InternalImageType>;
using CastFilterType3D = itk::CastImageFilter<ImageType3D, InternalImageType>;
using ChangeInformationFilterType = itk::ChangeInformationImageFilter<InternalImageType>;
@ -337,6 +322,9 @@ ImageType3D::PointType ImportOffset;
* m_Projection2VTKTransform;
CTVolumeImageMetaInformation::Pointer
m_CTMetaInfo;
};