Displaced detector#877
Open
axel-grc wants to merge 2 commits into
Open
Conversation
SimonRit
requested changes
May 11, 2026
Collaborator
SimonRit
left a comment
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
+119
to
+125
| /** Returns true when offsets were explicitly provided */ | ||
| bool | ||
| GetOffsetsSet() const | ||
| { | ||
| return m_OffsetsSet; | ||
| } | ||
|
|
Collaborator
There was a problem hiding this comment.
Please use ITK's GetMacro for booleans
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.
Comment on lines
+99
to
+122
| { | ||
| constexpr double minOffset = -16.; | ||
| constexpr double maxOffset = 12.; | ||
|
|
||
| std::cout << "\n\n****** Case 4: manual offsets ******" << std::endl; | ||
|
|
||
| using OffsetDDFType = rtk::DisplacedDetectorForOffsetFieldOfViewImageFilter<OutputImageType>; | ||
| auto cudaddf = OffsetDDFType::New(); | ||
| cudaddf->SetInput(slp->GetOutput()); | ||
| cudaddf->SetGeometry(geometry); | ||
| cudaddf->SetOffsets(minOffset, maxOffset); | ||
| cudaddf->InPlaceOff(); | ||
| TRY_AND_EXIT_ON_ITK_EXCEPTION(cudaddf->Update()); | ||
|
|
||
| using CPUDDFType = rtk::DisplacedDetectorImageFilter<OutputImageType>; | ||
| auto cpuddf = CPUDDFType::New(); | ||
| cpuddf->SetInput(slp->GetOutput()); | ||
| cpuddf->SetGeometry(geometry); | ||
| cpuddf->SetOffsets(minOffset, maxOffset); | ||
| cpuddf->InPlaceOff(); | ||
| TRY_AND_EXIT_ON_ITK_EXCEPTION(cpuddf->Update()); | ||
|
|
||
| CheckImageQuality<OutputImageType>(cudaddf->GetOutput(), cpuddf->GetOutput(), 1.e-6, 100, 1.); | ||
| } |
Collaborator
There was a problem hiding this comment.
The problem of this test is that it is not an offset FOV. In this case, DisplacedDetectorImageFilter can be used.
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