-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Stein's Unbiased Risk Estimator (SURE) loss and Conjugate Gradient #7308
Conversation
Signed-off-by: chaoliu <chaoliu@nvidia.com>
Signed-off-by: chaoliu <chaoliu@nvidia.com>
Signed-off-by: chaoliu <chaoliu@nvidia.com>
for more information, see https://pre-commit.ci
@marksgraham you may want to coordinate here with other diffusion work being integrated into core. |
Sorry @ericspod, I accidentally deleted your comment, I just wanted to delete the pending one from me which duplicate with yours. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, would be great add some user guide in the tutorial repo perhaps after all components added. Could you please help fix the CI error?
Thanks @ericspod. This PR looks complementary - @cxlcl let me know if you want to discuss when you get onto adding the generation step work mentioned in your original issue. MONAI Generative is currently being ported into core so we need to make sure these additions work together :) |
@marksgraham For the generation step, I was planning to use the two components in this PR (CG and SURE loss) to replace the ones in the original implementation in Reference [2]. This is done locally and I will upload it to the research repo of MONA as an example of how to use CG and SURE during the sampling stage. Will let you know once it's done. So that we may start from there. |
Signed-off-by: cxlcl <chaoliucxl@gmail.com>
Will work on that. Thanks for the suggestion on making a suer guide. Is there a guidance on making a tutorial or exemplar tutorial I can follow? |
Here is a contribution guide for tutorial repo. |
One quick question related to the data used for the tutorial: can we include it in the tutorial itself, or shall we include it anywhere else (such as a link) and then use wget to download it? |
If you can include the data directly in the notebook (ie. in a cell) you can do that, otherwise please host it elsewhere such that it can be downloaded through the browser or with a tool like gdown that's readily available. |
Signed-off-by: chaoliu <chaoliucxl@gmail.com>
Signed-off-by: chaoliu <chaoliucxl@gmail.com>
for more information, see https://pre-commit.ci
Signed-off-by: chaoliu <chaoliucxl@gmail.com>
Signed-off-by: chaoliu <chaoliucxl@gmail.com>
for more information, see https://pre-commit.ci
Signed-off-by: chaoliu <chaoliucxl@gmail.com>
Signed-off-by: chaoliu <chaoliucxl@gmail.com>
Hi, maybe I didn't quite get how the script It turns out that the before (in: monai/data/decathlon_datalist.py)
after
These changes are applied to multiple files and lead to the following error in the CI test [link to the error message]
As suggested in the guideline, I've tried to run Maybe I'm missing something, like the configuration for autofix? |
Hi @cxlcl, it looks like it was introduced by the new release from black. |
Thanks for the reply. Is there anything I can do from my end to pass the CI test to ignore E704? I guess it is a server-side modification for testing. |
Co-authored-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> Signed-off-by: cxlcl <chaoliucxl@gmail.com>
for more information, see https://pre-commit.ci
Signed-off-by: chaoliu <chaoliucxl@gmail.com>
for more information, see https://pre-commit.ci
Signed-off-by: chaoliu <chaoliucxl@gmail.com>
Hi @ericspod , thanks a lot for the comments and suggestions. I did some modifications based on the suggestions in the new commit. Please let me know if there's any modification needed. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good now. There's a minor PEP8 complaint but otherwise it's fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good to me, thanks!
Co-authored-by: YunLiu <55491388+KumoLiu@users.noreply.github.com> Signed-off-by: cxlcl <chaoliucxl@gmail.com>
Co-authored-by: YunLiu <55491388+KumoLiu@users.noreply.github.com> Signed-off-by: cxlcl <chaoliucxl@gmail.com>
Co-authored-by: YunLiu <55491388+KumoLiu@users.noreply.github.com> Signed-off-by: cxlcl <chaoliucxl@gmail.com>
Co-authored-by: YunLiu <55491388+KumoLiu@users.noreply.github.com> Signed-off-by: cxlcl <chaoliucxl@gmail.com>
Co-authored-by: YunLiu <55491388+KumoLiu@users.noreply.github.com> Signed-off-by: cxlcl <chaoliucxl@gmail.com>
Co-authored-by: YunLiu <55491388+KumoLiu@users.noreply.github.com> Signed-off-by: cxlcl <chaoliucxl@gmail.com>
Co-authored-by: YunLiu <55491388+KumoLiu@users.noreply.github.com> Signed-off-by: cxlcl <chaoliucxl@gmail.com>
Co-authored-by: YunLiu <55491388+KumoLiu@users.noreply.github.com> Signed-off-by: cxlcl <chaoliucxl@gmail.com>
Co-authored-by: YunLiu <55491388+KumoLiu@users.noreply.github.com> Signed-off-by: cxlcl <chaoliucxl@gmail.com>
Co-authored-by: YunLiu <55491388+KumoLiu@users.noreply.github.com> Signed-off-by: cxlcl <chaoliucxl@gmail.com>
Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
/build |
/build |
…roject-MONAI#7308) ### Description Based on the discussion topic [here](Project-MONAI#7161 (comment)), we implemented the Conjugate-Gradient algorithm for linear operator inversion, and Stein's Unbiased Risk Estimator (SURE) [1] loss for ground-truth-date free diffusion process guidance that is proposed in [2] and illustrated in the algorithm below: <img width="650" alt="Screenshot 2023-12-10 at 10 19 25 PM" src="https://github.com/Project-MONAI/MONAI/assets/8581162/97069466-cbaf-44e0-b7a7-ae9deb8fd7f2"> The Conjugate-Gradient (CG) algorithm is used to solve for the inversion of the linear operator in Line-4 in the algorithm above, where the linear operator is too large to store explicitly as a matrix (such as FFT/IFFT of an image) and invert directly. Instead, we can solve for the linear inversion iteratively as in CG. The SURE loss is applied for Line-6 above. This is a differentiable loss function that can be used to train/giude an operator (e.g. neural network), where the pseudo ground truth is available but the reference ground truth is not. For example, in the MRI reconstruction, the pseudo ground truth is the zero-filled reconstruction and the reference ground truth is the fully sampled reconstruction. The reference ground truth is not available due to the lack of fully sampled. **Reference** [1] Stein, C.M.: Estimation of the mean of a multivariate normal distribution. Annals of Statistics 1981 [[paper link](https://projecteuclid.org/journals/annals-of-statistics/volume-9/issue-6/Estimation-of-the-Mean-of-a-Multivariate-Normal-Distribution/10.1214/aos/1176345632.full)] [2] B. Ozturkler et al. SMRD: SURE-based Robust MRI Reconstruction with Diffusion Models. MICCAI 2023 [[paper link](https://arxiv.org/pdf/2310.01799.pdf)] ### Types of changes <!--- Put an `x` in all the boxes that apply, and remove the not applicable items --> - [x] Non-breaking change (fix or new feature that would not break existing functionality). - [ ] Breaking change (fix or new feature that would cause existing functionality to change). - [x] New tests added to cover the changes. - [x] Integration tests passed locally by running `./runtests.sh -f -u --net --coverage`. - [x] Quick tests passed locally by running `./runtests.sh --quick --unittests --disttests`. - [x] In-line docstrings updated. - [x] Documentation updated, tested `make html` command in the `docs/` folder. --------- Signed-off-by: chaoliu <chaoliu@nvidia.com> Signed-off-by: cxlcl <chaoliucxl@gmail.com> Signed-off-by: chaoliu <chaoliucxl@gmail.com> Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: YunLiu <55491388+KumoLiu@users.noreply.github.com> Co-authored-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> Signed-off-by: Juan Pablo de la Cruz Gutiérrez <juampatronics@gmail.com>
…roject-MONAI#7308) ### Description Based on the discussion topic [here](Project-MONAI#7161 (comment)), we implemented the Conjugate-Gradient algorithm for linear operator inversion, and Stein's Unbiased Risk Estimator (SURE) [1] loss for ground-truth-date free diffusion process guidance that is proposed in [2] and illustrated in the algorithm below: <img width="650" alt="Screenshot 2023-12-10 at 10 19 25 PM" src="https://github.com/Project-MONAI/MONAI/assets/8581162/97069466-cbaf-44e0-b7a7-ae9deb8fd7f2"> The Conjugate-Gradient (CG) algorithm is used to solve for the inversion of the linear operator in Line-4 in the algorithm above, where the linear operator is too large to store explicitly as a matrix (such as FFT/IFFT of an image) and invert directly. Instead, we can solve for the linear inversion iteratively as in CG. The SURE loss is applied for Line-6 above. This is a differentiable loss function that can be used to train/giude an operator (e.g. neural network), where the pseudo ground truth is available but the reference ground truth is not. For example, in the MRI reconstruction, the pseudo ground truth is the zero-filled reconstruction and the reference ground truth is the fully sampled reconstruction. The reference ground truth is not available due to the lack of fully sampled. **Reference** [1] Stein, C.M.: Estimation of the mean of a multivariate normal distribution. Annals of Statistics 1981 [[paper link](https://projecteuclid.org/journals/annals-of-statistics/volume-9/issue-6/Estimation-of-the-Mean-of-a-Multivariate-Normal-Distribution/10.1214/aos/1176345632.full)] [2] B. Ozturkler et al. SMRD: SURE-based Robust MRI Reconstruction with Diffusion Models. MICCAI 2023 [[paper link](https://arxiv.org/pdf/2310.01799.pdf)] ### Types of changes <!--- Put an `x` in all the boxes that apply, and remove the not applicable items --> - [x] Non-breaking change (fix or new feature that would not break existing functionality). - [ ] Breaking change (fix or new feature that would cause existing functionality to change). - [x] New tests added to cover the changes. - [x] Integration tests passed locally by running `./runtests.sh -f -u --net --coverage`. - [x] Quick tests passed locally by running `./runtests.sh --quick --unittests --disttests`. - [x] In-line docstrings updated. - [x] Documentation updated, tested `make html` command in the `docs/` folder. --------- Signed-off-by: chaoliu <chaoliu@nvidia.com> Signed-off-by: cxlcl <chaoliucxl@gmail.com> Signed-off-by: chaoliu <chaoliucxl@gmail.com> Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: YunLiu <55491388+KumoLiu@users.noreply.github.com> Co-authored-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> Signed-off-by: Nikolas Schmitz <nikolas.schmitz@rwth-aachen.de>
…roject-MONAI#7308) ### Description Based on the discussion topic [here](Project-MONAI#7161 (comment)), we implemented the Conjugate-Gradient algorithm for linear operator inversion, and Stein's Unbiased Risk Estimator (SURE) [1] loss for ground-truth-date free diffusion process guidance that is proposed in [2] and illustrated in the algorithm below: <img width="650" alt="Screenshot 2023-12-10 at 10 19 25 PM" src="https://github.com/Project-MONAI/MONAI/assets/8581162/97069466-cbaf-44e0-b7a7-ae9deb8fd7f2"> The Conjugate-Gradient (CG) algorithm is used to solve for the inversion of the linear operator in Line-4 in the algorithm above, where the linear operator is too large to store explicitly as a matrix (such as FFT/IFFT of an image) and invert directly. Instead, we can solve for the linear inversion iteratively as in CG. The SURE loss is applied for Line-6 above. This is a differentiable loss function that can be used to train/giude an operator (e.g. neural network), where the pseudo ground truth is available but the reference ground truth is not. For example, in the MRI reconstruction, the pseudo ground truth is the zero-filled reconstruction and the reference ground truth is the fully sampled reconstruction. The reference ground truth is not available due to the lack of fully sampled. **Reference** [1] Stein, C.M.: Estimation of the mean of a multivariate normal distribution. Annals of Statistics 1981 [[paper link](https://projecteuclid.org/journals/annals-of-statistics/volume-9/issue-6/Estimation-of-the-Mean-of-a-Multivariate-Normal-Distribution/10.1214/aos/1176345632.full)] [2] B. Ozturkler et al. SMRD: SURE-based Robust MRI Reconstruction with Diffusion Models. MICCAI 2023 [[paper link](https://arxiv.org/pdf/2310.01799.pdf)] ### Types of changes <!--- Put an `x` in all the boxes that apply, and remove the not applicable items --> - [x] Non-breaking change (fix or new feature that would not break existing functionality). - [ ] Breaking change (fix or new feature that would cause existing functionality to change). - [x] New tests added to cover the changes. - [x] Integration tests passed locally by running `./runtests.sh -f -u --net --coverage`. - [x] Quick tests passed locally by running `./runtests.sh --quick --unittests --disttests`. - [x] In-line docstrings updated. - [x] Documentation updated, tested `make html` command in the `docs/` folder. --------- Signed-off-by: chaoliu <chaoliu@nvidia.com> Signed-off-by: cxlcl <chaoliucxl@gmail.com> Signed-off-by: chaoliu <chaoliucxl@gmail.com> Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: YunLiu <55491388+KumoLiu@users.noreply.github.com> Co-authored-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> Signed-off-by: Yu0610 <612410030@alum.ccu.edu.tw>
Description
Based on the discussion topic here, we implemented the Conjugate-Gradient algorithm for linear operator inversion, and Stein's Unbiased Risk Estimator (SURE) [1] loss for ground-truth-date free diffusion process guidance that is proposed in [2] and illustrated in the algorithm below:
The Conjugate-Gradient (CG) algorithm is used to solve for the inversion of the linear operator in Line-4 in the algorithm above, where the linear operator is too large to store explicitly as a matrix (such as FFT/IFFT of an image) and invert directly. Instead, we can solve for the linear inversion iteratively as in CG.
The SURE loss is applied for Line-6 above. This is a differentiable loss function that can be used to train/giude an operator (e.g. neural network), where the pseudo ground truth is available but the reference ground truth is not. For example, in the MRI reconstruction, the pseudo ground truth is the zero-filled reconstruction and the reference ground truth is the fully sampled reconstruction. The reference ground truth is not available due to the lack of fully sampled.
Reference
[1] Stein, C.M.: Estimation of the mean of a multivariate normal distribution. Annals of Statistics 1981 [paper link]
[2] B. Ozturkler et al. SMRD: SURE-based Robust MRI Reconstruction with Diffusion Models. MICCAI 2023
[paper link]
Types of changes
./runtests.sh -f -u --net --coverage
../runtests.sh --quick --unittests --disttests
.make html
command in thedocs/
folder.