Skip to content

Displaced detector#877

Merged
SimonRit merged 2 commits into
RTKConsortium:mainfrom
axel-grc:DisplacedDetector
Jun 22, 2026
Merged

Displaced detector#877
SimonRit merged 2 commits into
RTKConsortium:mainfrom
axel-grc:DisplacedDetector

Conversation

@axel-grc

@axel-grc axel-grc commented Dec 19, 2025

Copy link
Copy Markdown
Collaborator

Fix #480
Closes #509

@axel-grc axel-grc requested a review from SimonRit December 19, 2025 09:48
@axel-grc axel-grc changed the title ENH: Add exception handling for parallel geometry in DisplacedDetector filters Displaced detector Dec 19, 2025

@SimonRit SimonRit left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest "solving" the problem by an error message instead of copy pasting code. You can check in the test that an error message is thrown, I know there is an ITK macro for this.

Comment thread include/rtkDisplacedDetectorImageFilter.h
Comment on lines +116 to +152
// If the user manually set offsets, apply the same corner-based logic as the base class
typename Superclass::InputImageType::PointType corner;
inputPtr->TransformIndexToPhysicalPoint(inputPtr->GetLargestPossibleRegion().GetIndex(), corner);
double inferiorCorner = corner[0];
double superiorCorner = inferiorCorner;
if (inputPtr->GetSpacing()[0] < 0.)
inferiorCorner += inputPtr->GetSpacing()[0] * (outputLargestPossibleRegion.GetSize(0) - 1);
else
superiorCorner += inputPtr->GetSpacing()[0] * (outputLargestPossibleRegion.GetSize(0) - 1);

inferiorCorner += this->GetMaximumOffset();
superiorCorner += this->GetMinimumOffset();

if (inferiorCorner > 0. || superiorCorner < 0.)
{
itkGenericExceptionMacro(<< "Cannot account for detector displacement larger than 50% of panel size."
<< " Corner inf=" << inferiorCorner << " and corner sup=" << superiorCorner);
}
else if ((itk::Math::abs(inferiorCorner + superiorCorner) <
0.1 * itk::Math::abs(superiorCorner - inferiorCorner)) ||
!this->m_PadOnTruncatedSide)
{
// nothing to do, keep region
}
else if (superiorCorner + inferiorCorner > 0.)
{
this->SetInPlace(false);
typename itk::Index<3>::IndexValueType index =
outputLargestPossibleRegion.GetIndex()[0] - outputLargestPossibleRegion.GetSize()[0];
outputLargestPossibleRegion.SetIndex(0, index);
outputLargestPossibleRegion.SetSize(0, outputLargestPossibleRegion.GetSize()[0] * 2);
}
else
{
this->SetInPlace(false);
outputLargestPossibleRegion.SetSize(0, outputLargestPossibleRegion.GetSize()[0] * 2);
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should do the same as in the base class. I suggest to throw an error message instead of copy pasting code, that's will be simpler.

Comment thread test/rtkdisplaceddetectorcompoffsettest.cxx
@SimonRit SimonRit added this to the RTK 3.0 milestone May 20, 2026
@axel-grc axel-grc force-pushed the DisplacedDetector branch from 24e99e7 to 2a61d90 Compare June 18, 2026 08:38

@SimonRit SimonRit left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I think it will do. We might consider merging DisplacedDetectorImageFilter and DisplacedDetectorForOffsetFieldOfViewImageFilter in the future but that would require a bit more thinking.

@SimonRit

Copy link
Copy Markdown
Collaborator

The failing CI is unrelated.

@SimonRit SimonRit merged commit bbebeb5 into RTKConsortium:main Jun 22, 2026
34 of 49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DisplacedDetectorForOffsetFieldOfViewImageFilter discards manually set offset rtkfdk app returns NaN values for parallel geometry

2 participants