Merge branch 'ScoutRTRelease' into 'master'

RTSMarker bug

See merge request cpt_bioeng/drt!63
This commit is contained in:
2025-04-17 13:54:52 +02:00
8 changed files with 134 additions and 77 deletions

View File

@ -6,6 +6,12 @@
#include <cstring>
#include <iterator>
#ifdef __GNUC__
#define VARIABLE_IS_NOT_USED __attribute__ ((unused))
#else
#define VARIABLE_IS_NOT_USED
#endif
//Function to get method and class name for logging purposes.
template <size_t FL, size_t PFL>
const char* computeMethodName(const char (&function)[FL], const char (&prettyFunction)[PFL])
@ -24,7 +30,7 @@ const char* computeMethodName(const char (&function)[FL], const char (&prettyFun
namespace itk {
/* reference string required for comparison with tag values */
static const char* ImageOrientationStrings[] = {
static const char VARIABLE_IS_NOT_USED *ImageOrientationStrings[] = {
"NotDefined",
"HFS",
"FFS",
@ -40,49 +46,49 @@ static const bool verbose = false;
/* this is in the end a IEC to HFS...
* but we keep this for ourselves...
*/
static double Standard_DRT2LPS[9] = {
static double VARIABLE_IS_NOT_USED Standard_DRT2LPS[9] = {
1, 0, 0,
0, 0, -1,
0, 1, 0
};
static double PAElementsIEC[9] = {
static double VARIABLE_IS_NOT_USED PAElementsIEC[9] = {
1, 0, 0,
0, -1, 0,
0, 0, -1
};
static double LATElementsIEC[9] = {
static double VARIABLE_IS_NOT_USED LATElementsIEC[9] = {
0, 0, -1,
0, -1, 0,
-1, 0, 0
};
static double HFS2IEC[9] = {
static double VARIABLE_IS_NOT_USED HFS2IEC[9] = {
1, 0, 0,
0, 0, 1,
0, -1, 0
};
static double FFS2IEC[9] = {
static double VARIABLE_IS_NOT_USED FFS2IEC[9] = {
-1, 0, 0,
0, 0, -1,
0, -1, 0
};
static double HFP2IEC[9] = {
static double VARIABLE_IS_NOT_USED HFP2IEC[9] = {
-1, 0, 0,
0, 0, 1,
0, 1, 0
};
static double FFP2IEC[9] = {
static double VARIABLE_IS_NOT_USED FFP2IEC[9] = {
1, 0, 0,
0, 0, -1,
0, 1, 0
};
static double PAT2IEC[9] = {
static double VARIABLE_IS_NOT_USED PAT2IEC[9] = {
1, 0, 0,
0, 0, 1,
0, -1, 0

View File

@ -143,7 +143,7 @@ MutualInformationTwoImageToOneImageMetric<TFixedImage, TMovingImage>::GetValue()
//std::cout<< "-----> Mutual :: fixedImageRegion1: "<< metric1->GetFixedImageRegion() << std::endl;
auto movingImageRegion = this->m_Filter1->GetOutput()->GetBufferedRegion();
unsigned int numberOfPixels = movingImageRegion.GetNumberOfPixels();
//unsigned int numberOfPixels = movingImageRegion.GetNumberOfPixels();
//auto numberOfSamples = static_cast<unsigned int>(numberOfPixels * 0.50); //100%
// since we have a ROI, then we should not set allPixels to TRUE.
@ -180,7 +180,7 @@ MutualInformationTwoImageToOneImageMetric<TFixedImage, TMovingImage>::GetValue()
//std::cout<< "-----> Mutual :: fixedImageRegion2: "<< metric2->GetFixedImageRegion() << std::endl;
movingImageRegion = this->m_Filter2->GetOutput()->GetBufferedRegion();
numberOfPixels = movingImageRegion.GetNumberOfPixels();
//numberOfPixels = movingImageRegion.GetNumberOfPixels();
//numberOfSamples = static_cast<unsigned int>(numberOfPixels * 0.50); //100%
//metric2->SetNumberOfSpatialSamples(numberOfSamples);

View File

@ -262,7 +262,7 @@ NormalizedCorrelationTwoImageToOneImageMetric<TFixedImage, TMovingImage>::GetVal
}
// Calculate the measure value between fixed image 1 and the moving image
auto oldprecision = std::cout.precision();
//auto oldprecision = std::cout.precision();
// std::cout<<"Region " <<this->GetFixedImageRegion1() <<std::endl;

View File

@ -2127,14 +2127,13 @@ void itkImageProcessor::Write2DImages(){
vtkImageData* itkImageProcessor::GetLocalizer1VTK()
{
// Rescale the intensity of the projection images to 0-32768 for output.
using RescaleFilterType = itk::RescaleIntensityImageFilter<InternalImageType, OutputImageType>;
RescaleFilterType::Pointer rescaler1 = RescaleFilterType::New();
rescaler1->SetOutputMinimum(0);
rescaler1->SetOutputMaximum(32768);
rescaler1->SetInput(m_PASourceDupli->GetOutput());
rescaler1->SetOutputMaximum(IMG_VIS_MAXIMUM_RANGE);
rescaler1->SetInput( m_PASourceDupli->GetOutput() );
rescaler1->Update();
toVTKLocalizer1->SetInput(rescaler1->GetOutput());
@ -2187,22 +2186,18 @@ vtkImageData* itkImageProcessor::GetLocalizer1VTK()
vtkImageData* itkImageProcessor::GetLocalizer2VTK()
{
// Rescale the intensity of the projection images to 0-32768 for output.
using RescaleFilterType = itk::RescaleIntensityImageFilter<InternalImageType, OutputImageType>;
RescaleFilterType::Pointer rescaler2 = RescaleFilterType::New();
rescaler2->SetOutputMinimum(0);
rescaler2->SetOutputMaximum(32768);
rescaler2->SetInput(m_LATSourceDupli ->GetOutput());
rescaler2->SetOutputMaximum(IMG_VIS_MAXIMUM_RANGE);
rescaler2->SetInput( m_LATSourceDupli->GetOutput() );
rescaler2->Update();
toVTKLocalizer2->SetInput(rescaler2->GetOutput());
toVTKLocalizer2->Update();
// if(true) {
// using ImageRegionType3D = ImageType3D::RegionType;
// using SizeType3D = ImageRegionType3D::SizeType;
@ -2246,6 +2241,7 @@ vtkImageData* itkImageProcessor::GetLocalizer2VTK()
toVTKLocalizer2->GetOutput();
}
vtkImageData* itkImageProcessor::GetProjection1VTK()
{
@ -2256,33 +2252,60 @@ vtkImageData* itkImageProcessor::GetProjection1VTK()
//TODO
}
// Rescale the intensity of the projection images to 0-32768 for output.
using RescaleFilterType = itk::RescaleIntensityImageFilter<InternalImageType, OutputImageType>;
RescaleFilterType::Pointer rescaler1 = RescaleFilterType::New();
rescaler1->SetOutputMinimum(0);
rescaler1->SetOutputMaximum(32768);
rescaler1->SetOutputMaximum(IMG_VIS_MAXIMUM_RANGE);
rescaler1->SetInput( imageDRT1In );
rescaler1->Update();
// using ImageCalculatorFilterType = itk::MinimumMaximumImageCalculator<InternalImageType>;
// auto imageCalculatorFilter = ImageCalculatorFilterType::New();
// imageCalculatorFilter->SetImage(imageDRT1In);
// imageCalculatorFilter->Compute();
// std::cout<< "itkImageProcessor::imageDRT1In() " <<
// imageCalculatorFilter <<std::endl;
// using ImageCalculatorFilterType2 = itk::MinimumMaximumImageCalculator<OutputImageType>;
// auto imageCalculatorFilter2 = ImageCalculatorFilterType2::New();
// imageCalculatorFilter2->SetImage(rescaler1->GetOutput());
// imageCalculatorFilter2->Compute();
// std::cout<< "itkImageProcessor::imageDRT2In() " <<
// imageCalculatorFilter2 <<std::endl;
toVTK2D1->SetInput(rescaler1->GetOutput());
toVTK2D1->Update();
return
toVTK2D1->GetOutput();
}
vtkImageData* itkImageProcessor::GetProjection1VTKToWrite()
{
if(m_DRTImage1MetaInfo == NULL ||
m_DRTGeometryMetaInfo == NULL ||
m_TransformMetaInfo == NULL ){
return NULL;
//TODO
}
using ImageCalculatorFilterType = itk::MinimumMaximumImageCalculator<InternalImageType>;
auto imageCalculatorFilter = ImageCalculatorFilterType::New();
imageCalculatorFilter->SetImage(imageDRT1In);
imageCalculatorFilter->Compute();
using IntWindowType = itk::IntensityWindowingImageFilter<InternalImageType, OutputImageType>;
auto intWindowFilter = IntWindowType::New();
intWindowFilter->SetWindowMinimum(imageCalculatorFilter->GetMinimum());
intWindowFilter->SetWindowMaximum(imageCalculatorFilter->GetMaximum());
intWindowFilter->SetOutputMinimum(0);
if(imageCalculatorFilter->GetMaximum() > SHRT_MAX){
intWindowFilter->SetOutputMaximum(SHRT_MAX);
}else
intWindowFilter->SetOutputMaximum(imageCalculatorFilter->GetMaximum());
intWindowFilter->SetInput(imageDRT1In);
intWindowFilter->Update();
toVTK2D1->SetInput(intWindowFilter->GetOutput());
toVTK2D1->Update();
// using ImageCalculatorFilterType2 = itk::MinimumMaximumImageCalculator<OutputImageType>;
// auto imageCalculatorFilter2 = ImageCalculatorFilterType2::New();
// imageCalculatorFilter2->SetImage(intWindowFilter->GetOutput());
// imageCalculatorFilter2->Compute();
// std::cout<< "itkImageProcessor::imageCalculatorFilter2() " <<
// imageCalculatorFilter2->GetMinimum() << " " << imageCalculatorFilter2->GetMaximum() <<std::endl;
// using ImageRegionType3D = ImageType3D::RegionType;
// using SizeType3D = ImageRegionType3D::SizeType;
@ -2387,19 +2410,63 @@ vtkImageData* itkImageProcessor::GetProjection2VTK()
//TODO
}
// Rescale the intensity of the projection images to 0-32768 for output.
using RescaleFilterType = itk::RescaleIntensityImageFilter<InternalImageType, OutputImageType>;
RescaleFilterType::Pointer rescaler2 = RescaleFilterType::New();
rescaler2->SetOutputMinimum(0);
rescaler2->SetOutputMaximum(32768);
rescaler2->SetOutputMaximum(IMG_VIS_MAXIMUM_RANGE);
rescaler2->SetInput( imageDRT2In );
rescaler2->Update();
toVTK2D2->SetInput(rescaler2->GetOutput());
toVTK2D2->Update();
// rescaler2->Print(std::cout);
return
toVTK2D2->GetOutput();
}
vtkImageData* itkImageProcessor::GetProjection2VTKToWrite()
{
if(m_DRTImage2MetaInfo == NULL ||
m_DRTGeometryMetaInfo == NULL ||
m_TransformMetaInfo == NULL ){
return NULL;
//TODO
}
using ImageCalculatorFilterType = itk::MinimumMaximumImageCalculator<InternalImageType>;
auto imageCalculatorFilter = ImageCalculatorFilterType::New();
imageCalculatorFilter->SetImage(imageDRT2In);
imageCalculatorFilter->Compute();
using IntWindowType = itk::IntensityWindowingImageFilter<InternalImageType, OutputImageType>;
auto intWindowFilter = IntWindowType::New();
intWindowFilter->SetWindowMinimum(imageCalculatorFilter->GetMinimum());
intWindowFilter->SetWindowMaximum(imageCalculatorFilter->GetMaximum());
intWindowFilter->SetOutputMinimum(0);
if(imageCalculatorFilter->GetMaximum() > SHRT_MAX)
intWindowFilter->SetOutputMaximum(SHRT_MAX);
else
intWindowFilter->SetOutputMaximum(imageCalculatorFilter->GetMaximum());
intWindowFilter->SetInput(imageDRT2In);
intWindowFilter->Update();
toVTK2D2->SetInput(intWindowFilter->GetOutput());
toVTK2D2->Update();
// using ImageCalculatorFilterType2 = itk::MinimumMaximumImageCalculator<OutputImageType>;
// auto imageCalculatorFilter2 = ImageCalculatorFilterType2::New();
// imageCalculatorFilter2->SetImage(intWindowFilter->GetOutput());
// imageCalculatorFilter2->Compute();
// std::cout<< "itkImageProcessor::imageCalculatorFilter2() " <<
// imageCalculatorFilter2->GetMinimum() << " " << imageCalculatorFilter2->GetMaximum() <<std::endl;
// using ImageRegionType3D = ImageType3D::RegionType;
// using SizeType3D = ImageRegionType3D::SizeType;

View File

@ -22,6 +22,7 @@ gfattori 08.11.2021
#include "itkResampleImageFilter.h"
#include "itkCastImageFilter.h"
#include "itkRescaleIntensityImageFilter.h"
#include "itkIntensityWindowingImageFilter.h"
#include "itkChangeInformationImageFilter.h"
#include "itkGDCMImageIO.h"
#include "itkMetaDataObject.h"
@ -49,6 +50,8 @@ gfattori 08.11.2021
#include "itkReg23.h"
#include "itkReg23MetaInformation.h"
#define IMG_VIS_MAXIMUM_RANGE 2048
namespace itk
{
@ -242,6 +245,10 @@ public:
vtkImageData* GetProjection1VTK();
vtkImageData* GetProjection2VTK();
/** Conveniency methods to get VTK images for rendering */
vtkImageData* GetProjection1VTKToWrite();
vtkImageData* GetProjection2VTKToWrite();
vtkImageData* GetLocalizer1VTK();
vtkImageData* GetLocalizer2VTK();

View File

@ -139,6 +139,7 @@ gSiddonJacobsRayCastInterpolateImageFunction<TInputImage, TCoordRep>::Evaluate(c
const OutputType minOutputValue = itk::NumericTraits<OutputType>::NonpositiveMin();
const OutputType maxOutputValue = itk::NumericTraits<OutputType>::max();
// If the volume was shifted, recalculate the overall inverse transform
unsigned long int interpMTime = this->GetMTime();
unsigned long int vTransformMTime = m_Transform->GetMTime();

View File

@ -139,7 +139,6 @@ int vtkContourTopogramProjectionFilter::RequestData(
for(vtkIdType ii = 0; ii < points->GetNumberOfPoints() ; ii++){
/** input points are in LPS, should be corrected for import offset and mapped onto
* the projection geometry origin */
pp0[0] = points->GetPoint(ii)[0] + dProjectionLPSOffset [0] - dImportOffsetLPS[0];
@ -168,52 +167,29 @@ int vtkContourTopogramProjectionFilter::RequestData(
pp2[1] -= dProjectionLPSOffset [1];
pp2[2] -= dProjectionLPSOffset [2];
// // Workaround to account for PA-LAT HFS-FFS
// switch (this->m_ProjectionOrientation) {
// case itk::PA:
// pp2[0] += dPOffset;
// break;
// case itk::LAT:
// switch (this->m_PatientOrientation) {
// case itk::FFS:
// pp2[1] += dPOffset;
// break;
// case itk::HFS:
// pp2[1] -= dPOffset;
// break;
// default:
// break;
// }
// break;
// default:
// break;
// }
// std::cout << ii << " " << pp2[0] << " " << pp2[1] << " " << pp2[2] << std::endl;
PrjPoints->InsertPoint(ii,pp2);
}
output->SetPoints( PrjPoints );
// if (psInput)
// {
// output->GetPointData()->PassData(psInput->GetPointData());
// }
// else
// {
// output->GetPointData()->PassData(graphInput->GetVertexData());
// }
vtkIdType numPoints = points->GetNumberOfPoints();
VTK_CREATE(vtkCellArray, cells);
cells->AllocateEstimate(numPoints, 1);
if (cells->AllocateEstimate(numPoints, 1) == true){
} else {
std::cout << "vtkContourTopogramProjectionFilter Can't allocate cells " << std::endl;
PrjPoints->Delete();
return 1;
}
for (vtkIdType i = 0; i < numPoints; i++)
{
cells->InsertNextCell(1, &i);
}
output->SetVerts(cells);
PrjPoints->Delete();

View File

@ -19,7 +19,7 @@
#include "vtkMatrix4x4.h"
#include "vtkTransform.h"
#include "itkMacro.h"
//#include "itkMacro.h"
#include "DRTMetaInformation.h"
class VTKFILTERSCORE_EXPORT vtkContourTopogramProjectionFilter :