Displaced detector#877
Merged
Merged
Conversation
SimonRit
requested changes
May 11, 2026
SimonRit
left a comment
Collaborator
There was a problem hiding this comment.
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 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); | ||
| } |
Collaborator
There was a problem hiding this comment.
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.
24e99e7 to
2a61d90
Compare
SimonRit
approved these changes
Jun 22, 2026
SimonRit
left a comment
Collaborator
There was a problem hiding this comment.
Thanks, I think it will do. We might consider merging DisplacedDetectorImageFilter and DisplacedDetectorForOffsetFieldOfViewImageFilter in the future but that would require a bit more thinking.
Collaborator
|
The failing CI is unrelated. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix #480
Closes #509