Project-MONAI / MONAI

AI Toolkit for Healthcare Imaging
https://monai.io/
Apache License 2.0
5.5k stars 1.01k forks source link

fix implementation mistakes and add conjugate gradients solver #7876

Closed MrGranddy closed 1 day ago

MrGranddy commented 4 days ago

Fixes #6767

Description

Fixed two minor implementation differences between the official MATLAB code and the MONAI implementation, to confirm also added a new test case where two images and their confidence maps calculated by the official code is added to tests and the MONAI implementation results are checked against there results created by the official code.

Also fixing the issue: added the conjugate gradients solver option. Now the users can utilize it to run the algorithm faster with a trade-off of accuracy of the end result, a range of speed-ups can be achieved with little to no quality loss by tweaking the parameters, the optimal parameters between quality and speed in my experience is set as the default parameters, namely 'cg_tol' and 'cg_maxiter'.

For the CG solver installing PyAMG (https://github.com/pyamg/pyamg) is a requirement, this is because we use it to generate a preconditioner, without it CG does not provide any speed-ups, even slows down the algorithm. This part can be changed if the requirement is not ideal, yet this was the best solution as far as my knowledge goes.

Types of changes

KumoLiu commented 4 days ago

Could you please also take a look at the CI error: https://github.com/Project-MONAI/MONAI/actions/runs/9655433015/job/26631317948?pr=7876#step:13:19809?

ericspod commented 2 days ago

The current twine issue appears related to a new version of a dependent package: https://github.com/pypa/twine/issues/977#issuecomment-2186916888 We could add a value in one of our config files to include the missing key or fix the version of importlib_metadata to be less than 8.0.

KumoLiu commented 2 days ago

The current twine issue appears related to a new version of a dependent package: pypa/twine#977 (comment) We could add a value in one of our config files to include the missing key or fix the version of importlib_metadata to be less than 8.0.

twine==5.1.0 has been yanked: https://pypi.org/project/twine/#history. I just rerun the job, it works well now.

KumoLiu commented 1 day ago

Hi @ericspod, do you have any more comments on this one?

KumoLiu commented 1 day ago

/build