Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add inverse capability to KernelTransform #4529

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dzenanz
Copy link
Member

@dzenanz dzenanz commented Mar 19, 2024

PR Checklist

@dzenanz dzenanz requested a review from N-Dekker March 19, 2024 18:37
@github-actions github-actions bot added the area:Core Issues affecting the Core module label Mar 19, 2024
Copy link
Member

@thewtex thewtex left a comment

Choose a reason for hiding this comment

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

Please add a test.

@N-Dekker
Copy link
Contributor

Please add a test.

It would be nice to have a test that converts a small (e.g. 8x8) image A to B, using KernelImage, and then from B to C, using its inverse. Then EXPECT_EQ(C, A) 😃

Comment on lines +534 to +535
typename PointSetType::Pointer sourceLandmarks = PointSetType::New();
typename PointSetType::Pointer targetLandmarks = PointSetType::New();
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

const auto would be even nicer 😇

    const auto sourceLandmarks = PointSetType::New();
    const auto targetLandmarks = PointSetType::New();

Comment on lines +536 to +537
deepCopyLandmarks(this->GetSourceLandmarks(), sourceLandmarks);
deepCopyLandmarks(this->GetTargetLandmarks(), targetLandmarks);
Copy link
Contributor

Choose a reason for hiding this comment

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

Please consider directly copying the internal STL containers of the landmarks:

  sourceLandmarks->GetPoints()->CastToSTLContainer() =
    m_SourceLandmarks->GetPoints()->CastToSTLConstContainer();
  targetLandmarks->GetPoints()->CastToSTLContainer() =
    m_TargetLandmarks->GetPoints()->CastToSTLConstContainer();

@dzenanz
Copy link
Member Author

dzenanz commented Mar 20, 2024

Just as I was making a pull request, I realized that a test is needed. I don't really have time to make a meaningful test (aside from the use in my own program). I also see that

errorCount += TransformTest<itk::ElasticBodyReciprocalSplineKernelTransform<double, 3>>();
is crashing, probably meaning the inversion method I added is not thread-safe. It would be good if someone took over this PR (I am eying you Niels 😄). Otherwise it is likely going to fester for a long time.

Comment on lines +540 to +542
inverseTransform->SetSourceLandmarks(targetLandmarks);
inverseTransform->SetTargetLandmarks(sourceLandmarks);
inverseTransform->SetStiffness(this->GetStiffness());
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's OK for a class to directly access its own data members, without calling Get and Set. So more like:

  inverseTransform->m_SourceLandmarks = targetLandmarks;
  inverseTransform->m_TargetLandmarks = sourceLandmarks;
  inverseTransform->m_Stiffness = m_Stiffness;

Right?

@N-Dekker
Copy link
Contributor

It would be good if someone took over this PR

I can ask next week if it may be of interest to elastix. But otherwise this PR does not have a high priority to me. Does it have priority to you? If so, then I think you should try to make it ready, including a simple little test 🤷 Otherwise, just postpone until the summer 🌞 holidays 😸

@dzenanz
Copy link
Member Author

dzenanz commented Mar 20, 2024

It is not of high priority to me either. So it would be good if you added it to your TODO list for summer holidays 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:Core Issues affecting the Core module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants