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

standalone ICON and GradICON losses for registration network training #80

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

Conversation

BailiangJ
Copy link

Hi @HastingsGreer ,

Thanks a lot for sharing the code.

I have created the standalone ICON and GradICON losses with Pytorch, which can be directly used in general registration network training. Modification would be much simpler to plug in and play with them.

Relevant to issue #79

Double check is needed to see if there is any error in the implementation. :)

Cheers,
Bailiang

@BailiangJ
Copy link
Author

Since the flow field in the official code is normalized to [-1,1] while the implementation here is the displacement in the original resolution, epsilon = torch.randn_like(forward_flow) * (1.0 / self.image_size[-1]) in line 313,382 and delta in GradICONLoss might need to be changed accordingly.

@HastingsGreer
Copy link
Collaborator

This is good code, but I don't think it's a good fit for the icon_registration codebase.

There is a distinction between a framework and a library, and the code in this pull request would be a great implementation of the GradICON loss in a library.

However, icon_registration really is an opinionated framework that wants to do the whole registration training and deployment process in it's idiosyncratic way, more than a library that plugs into a larger codebase. This was a hard choice to make! In general, a library is a better choice than a framework because of the additional flexibility and reduced time to learn it. However, in our lab we've found that there's real synergy between the GradICON loss, the specific implementation of multi-step registration via composed TwoStep operators, the decision to represent transforms as python functions instead of raw displacement fields, and the final wrapper that allows ITK code to interface with registration in a way that respects spatial metadata. This has motivated the decision to stay as a tightly integrated framework.

If you end up hosting this version of the GradICON loss in a different repository with tests and documentation, I'd be happy to link to it in the readme

@BailiangJ
Copy link
Author

Hi @HastingsGreer ,

Thank you for the reply. I fully understand your choice of design for the gradICON framework.

Before I host this version of GradICON loss in another repo, how about we leave the PR open so people can check it directly in this repo?

Btw, could you do me a favor to code review my implementation? I have already checked multiple times by comparing it to your codebase. Just want to make sure I didn't make a mistake :). I have used it for training, and it looks stable, and the output flow fields are smooth.

Cheers,
Bailiang

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.

2 participants