Skip to content

Commit 540ca1d

Browse files
Simon RitSimonRit
authored andcommitted
ENH: Allow no cropping for Elekta projections
Previously, the default value was 0 for the cropping except for Elekta for which it was 4. Setting the default value to the numerical max allows detecting if 0 is explicitely set for Elekta projections.
1 parent b708787 commit 540ca1d

File tree

3 files changed

+29
-26
lines changed

3 files changed

+29
-26
lines changed

include/rtkGgoFunctions.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -226,15 +226,17 @@ SetProjectionsReaderFromGgo(TProjectionsReaderType * reader, const TArgsInfo & a
226226
}
227227

228228
// Crop boundaries
229-
typename TProjectionsReaderType::OutputImageSizeType upperCrop, lowerCrop;
230-
upperCrop.Fill(0);
231-
lowerCrop.Fill(0);
229+
auto lowerCrop = itk::MakeFilled<typename TProjectionsReaderType::OutputImageSizeType>(0);
232230
for (unsigned int i = 0; i < args_info.lowercrop_given; i++)
233231
lowerCrop[i] = args_info.lowercrop_arg[i];
234-
reader->SetLowerBoundaryCropSize(lowerCrop);
232+
if (args_info.lowercrop_given)
233+
reader->SetLowerBoundaryCropSize(lowerCrop);
234+
235+
auto upperCrop = itk::MakeFilled<typename TProjectionsReaderType::OutputImageSizeType>(0);
235236
for (unsigned int i = 0; i < args_info.uppercrop_given; i++)
236237
upperCrop[i] = args_info.uppercrop_arg[i];
237-
reader->SetUpperBoundaryCropSize(upperCrop);
238+
if (args_info.uppercrop_given)
239+
reader->SetUpperBoundaryCropSize(upperCrop);
238240

239241
// Conditional median
240242
typename TProjectionsReaderType::MedianRadiusType medianRadius;

include/rtkProjectionsReader.h

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -322,19 +322,21 @@ class ITK_TEMPLATE_EXPORT ProjectionsReader : public itk::ImageSource<TOutputIma
322322
/** Copy of parameters for the mini-pipeline. Parameters are checked and
323323
* propagated when required in the GenerateOutputInformation. Refer to the
324324
* documentation of the corresponding filter for more information. */
325-
OutputImagePointType m_Origin;
326-
OutputImageSpacingType m_Spacing;
327-
OutputImageDirectionType m_Direction;
328-
OutputImageSizeType m_LowerBoundaryCropSize;
329-
OutputImageSizeType m_UpperBoundaryCropSize;
330-
ShrinkFactorsType m_ShrinkFactors;
331-
MedianRadiusType m_MedianRadius;
332-
double m_AirThreshold{ 32000 };
333-
double m_ScatterToPrimaryRatio{ 0. };
334-
double m_NonNegativityConstraintThreshold{ itk::NumericTraits<double>::NonpositiveMin() };
335-
double m_I0{ itk::NumericTraits<double>::NonpositiveMin() };
336-
double m_IDark{ 0. };
337-
double m_ConditionalMedianThresholdMultiplier{ 1. };
325+
OutputImagePointType m_Origin;
326+
OutputImageSpacingType m_Spacing;
327+
OutputImageDirectionType m_Direction;
328+
itk::SizeValueType m_DefaultBoundaryCropValue{ itk::NumericTraits<itk::SizeValueType>::max() };
329+
OutputImageSizeType m_DefaultBoundaryCropSize = itk::MakeFilled<OutputImageSizeType>(m_DefaultBoundaryCropValue);
330+
OutputImageSizeType m_LowerBoundaryCropSize{ m_DefaultBoundaryCropSize };
331+
OutputImageSizeType m_UpperBoundaryCropSize{ m_DefaultBoundaryCropSize };
332+
ShrinkFactorsType m_ShrinkFactors;
333+
MedianRadiusType m_MedianRadius;
334+
double m_AirThreshold{ 32000 };
335+
double m_ScatterToPrimaryRatio{ 0. };
336+
double m_NonNegativityConstraintThreshold{ itk::NumericTraits<double>::NonpositiveMin() };
337+
double m_I0{ itk::NumericTraits<double>::NonpositiveMin() };
338+
double m_IDark{ 0. };
339+
double m_ConditionalMedianThresholdMultiplier{ 1. };
338340
WaterPrecorrectionVectorType m_WaterPrecorrectionCoefficients;
339341
bool m_ComputeLineIntegral{ true };
340342
unsigned int m_VectorComponent{ 0 };

include/rtkProjectionsReader.hxx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,6 @@ ProjectionsReader<TOutputImage>::ProjectionsReader()
115115
m_Spacing.Fill(itk::NumericTraits<typename OutputImageType::SpacingValueType>::max());
116116
m_Origin.Fill(itk::NumericTraits<typename OutputImageType::PointValueType>::max());
117117
m_Direction.Fill(itk::NumericTraits<typename OutputImageType::PointValueType>::max());
118-
m_LowerBoundaryCropSize.Fill(0);
119-
m_UpperBoundaryCropSize.Fill(0);
120118
m_ShrinkFactors.Fill(1);
121119
m_MedianRadius.Fill(0);
122120
}
@@ -309,9 +307,8 @@ ProjectionsReader<TOutputImage>::GenerateOutputInformation()
309307
m_ElektaRawFilter = elekta;
310308

311309
// Backward compatibility for default Elekta parameters
312-
OutputImageSizeType defaultCropSize;
313-
defaultCropSize.Fill(0);
314-
if (m_LowerBoundaryCropSize == defaultCropSize && m_UpperBoundaryCropSize == defaultCropSize)
310+
if (m_LowerBoundaryCropSize == m_DefaultBoundaryCropSize &&
311+
m_UpperBoundaryCropSize == m_DefaultBoundaryCropSize)
315312
{
316313
m_LowerBoundaryCropSize.Fill(4);
317314
m_LowerBoundaryCropSize[2] = 0;
@@ -517,9 +514,7 @@ ProjectionsReader<TOutputImage>::PropagateParametersToMiniPipeline()
517514
}
518515

519516
// Crop
520-
OutputImageSizeType defaultCropSize;
521-
defaultCropSize.Fill(0);
522-
if (m_LowerBoundaryCropSize != defaultCropSize || m_UpperBoundaryCropSize != defaultCropSize)
517+
if (m_LowerBoundaryCropSize != m_DefaultBoundaryCropSize || m_UpperBoundaryCropSize != m_DefaultBoundaryCropSize)
523518
{
524519
if (m_CropFilter.GetPointer() == nullptr)
525520
{
@@ -530,7 +525,11 @@ ProjectionsReader<TOutputImage>::PropagateParametersToMiniPipeline()
530525
using CropType = itk::CropImageFilter<TInputImage, TInputImage>;
531526
auto * crop = dynamic_cast<CropType *>(m_CropFilter.GetPointer());
532527
assert(crop != nullptr);
528+
if (m_LowerBoundaryCropSize == m_DefaultBoundaryCropSize)
529+
m_LowerBoundaryCropSize.Fill(0);
533530
crop->SetLowerBoundaryCropSize(m_LowerBoundaryCropSize);
531+
if (m_UpperBoundaryCropSize == m_DefaultBoundaryCropSize)
532+
m_UpperBoundaryCropSize.Fill(0);
534533
crop->SetUpperBoundaryCropSize(m_UpperBoundaryCropSize);
535534
crop->SetInput(nextInput);
536535
nextInput = crop->GetOutput();

0 commit comments

Comments
 (0)