cwmok / LapIRN

Large Deformation Diffeomorphic Image Registration with Laplacian Pyramid Networks
MIT License
121 stars 21 forks source link

About generate_grid #9

Closed TVayne closed 2 years ago

TVayne commented 2 years ago

hi @cwmok I am sorry to bother you again.Why should I use def generate_grid(imgshape) function during the train?.And I should use the function generate_grid_unit (like centralization?)during my test on the label image's transformation. What's the difference between them? Screenshot from 2021-10-25 15-27-44

Looking forward to your reply.

cwmok commented 2 years ago

@tzp123456

generate_grid outputs the unnormalized grid with [min, max] -> [0, image dimension], while generate_grid_unit outputs the normalized grid that will fit the coordinate system used in affine_grid and grid_sample in Pytorch.

Technically, we don't need generate_grid to train our model. generate_grid is used for the computation of Jacobian determinant loss, in which the weight of it is set to zero by default. The Jacobian determinant loss is inherited from our previous work.

We train our model using generate_grid_unit and it shows slight improvement compared to the method using generate_grid. (And avoid a lot of unnecessary computation.)