cwmok / Fast-Symmetric-Diffeomorphic-Image-Registration-with-Convolutional-Neural-Networks

Fast Symmetric Diffeomorphic Image Registration with Convolutional Neural Networks
MIT License
147 stars 36 forks source link

About the number of non-positive Jacobian determinant #18

Closed zhenyu202020 closed 1 year ago

zhenyu202020 commented 1 year ago

Hi, @cwmok, Thanks for your great job. I have a little question. I reproduced the SYMNet on the OASIS DataSet, and I compute the number of non-positive Jacobian determinant. But the number of non-positive Jacobian determinant is too large as shown below: image

image

I don't know what's wrong and would appreciate your help! Looking forward to your reply!

cwmok commented 1 year ago

Hi @zhenyu202020, Which Jacobian_determinant function are you using? I guess the problem is in the Jacobian_determinant. Because for any identity deformation (empty displacement), the Jacobian determinant should be 1 ("after *-1 should be -1), but your function returns 0. Perhaps you should add the identity grid to the F_BA before using this function.

zhenyu202020 commented 1 year ago

Thank you very much for your reply! I have changed the calculation function and added the identity grid as follows, but still have the problem. image image image image I've tested 20 consecutive numbers and they're all zero. image

cwmok commented 1 year ago

Could you use F_BA*0.0 as input for the Jaco function to see if the function works properly or not?

cwmok commented 1 year ago

I see the problem. The "F.relu" is an inplace operation. Try removing the "F.relu" operation.

zhenyu202020 commented 1 year ago

As you said we used F_BA*0.0 as input, and the results are shown below: image I've removed the "F.relu" operation, but there is still a problem image I've tested 20 consecutive numbers and they're still all zero. image

cwmok commented 1 year ago

The result is correct now. You can see most values in neg_Jet are close to 1. Since this method is a diffeomorphic method, you will observe 0 voxels with negative Jdet for most of the cases.

If you prefer a non-smooth solution, you can fine-tune the weights of smoothness and Jaco regularization in the training.

zhenyu202020 commented 1 year ago

Thank you very much for the patient answers! This helps a lot!