DeepRegNet / DeepReg

Medical image registration using deep learning
Apache License 2.0
552 stars 76 forks source link

Designing a model that predicts an affine transformation #834

Closed tjhendrickson closed 1 year ago

tjhendrickson commented 1 year ago

Subject of the documentation

What are you trying to do and which part of the code is hard to understand or incorrect or missing? Please provide a link to the readthedocs page and code if available.

I'm attempting to design a model that performs registration on paired images. In addition to performing the registration I want the model to also predict an affine transformation. To design the model I followed the paired lung CT registration demo. I attempted to design the configuration file to predict an affine transformation by looking at the image registration page, however, it was a little unclear to me how to design the YAML configuration. It seems like I should use method: conditional, for the training method, but I'm not sure where I should add in affine.

If the documentation request is approved, would you be willing to submit a PR? (Help can be provided if you need assistance submitting a PR)

Yes

mathpluscode commented 1 year ago

predict an affine transformation

Hi @tjhendrickson, an example config for predicting affine transformation is here. Essentially, it should be changing backbone to global so that the backbone model will predict/return an affine transformation, based on which a discrete displacement field will be calculated. Please see the source code for more information. Thanks again for your interest!

tjhendrickson commented 1 year ago

@mathpluscode, ahh much thanks! This may be a dumb question but is the predicted/returned affine transformation also automatically written to a text file? I guess is there anything else that would have to go into the config that I need to add?

mathpluscode commented 1 year ago

@mathpluscode, ahh much thanks! This may be a dumb question but is the predicted/returned affine transformation also automatically written to a text file? I guess is there anything else that would have to go into the config that I need to add?

Hi @tjhendrickson, the parameters for affine transformation are named theta and it should have been saved inside a .npy file when you perform predictions. Hope the following links could help you.

https://github.com/DeepRegNet/DeepReg/blob/main/deepreg/model/network.py#L456

https://github.com/DeepRegNet/DeepReg/blob/main/deepreg/predict.py#L105