mobaidoctor / med-ddpm

GNU General Public License v3.0
133 stars 15 forks source link

When I use your checkpoint "model_brats.pt" to generate images, I can only obtain low-quality MRI sample #28

Closed TUAT-Novice closed 2 months ago

TUAT-Novice commented 2 months ago

Thank you so much for your outstanding work for the repository.

I want to use your brats model weights to generate some MRI data, but find that the artificial samples are with low quality. In my program, I:

  1. git clone your github repository, then prepare the required environment for the codes;
  2. download the model_brats.pt checkpoint from the Google Drive (put in ./model/);
  3. download the brats2021 dataset, then run the "preprocess_brats_data.py" script to prepare and preload the dataset (put in ./dataset/brats2021/);
  4. modify the "inputfolder" parameter, then run the "./scripts/sample_brats.sh" script to generate the artificial MRI with the brats2021 segmentation mask saving in directory ./dataset/brats2021/seg/

I am not very clear about what went wrong in the process. If possible, I hope you can provide some advice on this matter. Thank you so much for your kindest help.

mobaidoctor commented 2 months ago

@TUAT-Novice Thank you for your interest in our work and your inquiry. We apologize for the delayed response. If you use our pretrained weights and the provided preprocessing script for the segmentation mask during inference, it should work without issues. Could you please share your results with us? This will help us investigate the problem in detail. Thank you!

TUAT-Novice commented 2 months ago

@TUAT-Novice Thank you for your interest in our work and your inquiry. We apologize for the delayed response. If you use our pretrained weights and the provided preprocessing script for the segmentation mask during inference, it should work without issues. Could you please share your results with us? This will help us investigate the problem in detail. Thank you!

Of course! I have sent the results to you through email. Thank you so much for your help!

supgy commented 2 months ago

@TUAT-Novice Thank you for your interest in our work and your inquiry. We apologize for the delayed response. If you use our pretrained weights and the provided preprocessing script for the segmentation mask during inference, it should work without issues. Could you please share your results with us? This will help us investigate the problem in detail. Thank you!

Of course! I have sent the results to you through email. Thank you so much for your help!

Hello, I tried the same steps as you, but got the result like follows, do you know why did this result occur? image

TUAT-Novice commented 2 months ago

@TUAT-Novice Thank you for your interest in our work and your inquiry. We apologize for the delayed response. If you use our pretrained weights and the provided preprocessing script for the segmentation mask during inference, it should work without issues. Could you please share your results with us? This will help us investigate the problem in detail. Thank you!

Of course! I have sent the results to you through email. Thank you so much for your help!

Hello, I tried the same steps as you, but got the result like follows, do you know why did this result occur? image

I got the same results as you. But I can not solve the problem so far.

supgy commented 2 months ago

@TUAT-Novice Thank you for your interest in our work and your inquiry. We apologize for the delayed response. If you use our pretrained weights and the provided preprocessing script for the segmentation mask during inference, it should work without issues. Could you please share your results with us? This will help us investigate the problem in detail. Thank you!

Of course! I have sent the results to you through email. Thank you so much for your help!

Hello, I tried the same steps as you, but got the result like follows, do you know why did this result occur? image

I got the same results as you. But I can not solve the problem so far.

All rightT_T, but using the author's original data can yield accurate results

TUAT-Novice commented 2 months ago

@TUAT-Novice Thank you for your interest in our work and your inquiry. We apologize for the delayed response. If you use our pretrained weights and the provided preprocessing script for the segmentation mask during inference, it should work without issues. Could you please share your results with us? This will help us investigate the problem in detail. Thank you!

Of course! I have sent the results to you through email. Thank you so much for your help!

Hello, I tried the same steps as you, but got the result like follows, do you know why did this result occur? image

I got the same results as you. But I can not solve the problem so far.

All rightT_T, but using the author's original data can yield accurate results

Yes, I checked their .npy files and found their results are pretty good.

mobaidoctor commented 2 months ago

Hi, @TUAT-Novice and @supgy, thank you for your interest in our work. Our pre-trained BRATS model generates accurate images as it has been trained exclusively on carefully selected, high-quality BRATS images. Could you please send us the exact input mask image you used with the inference script?

@TUAT-Novice Sorry for the late response, we have been fully occupied with project tasks. We received your email, but it only contained the exported images. We need to verify the input mask you provided to the model. Please ensure that the mask image has been processed using the preprocess_seg function from the preprocess_brats_data.py file in our repository. Thank you.

TUAT-Novice commented 2 months ago

Hi, @TUAT-Novice and @supgy, thank you for your interest in our work. Our pre-trained BRATS model generates accurate images as it has been trained exclusively on carefully selected, high-quality BRATS images. Could you please send us the exact input mask image you used with the inference script?

@TUAT-Novice Sorry for the late response, we have been fully occupied with project tasks. We received your email, but it only contained the exported images. We need to verify the input mask you provided to the model. Please ensure that the mask image has been processed using the preprocess_seg function from the preprocess_brats_data.py file in our repository. Thank you.

Thank you so much for your reply. I just confirmed the email, and I found the output segmentation under the "./exports/seg/" directory. I'm not sure if such output is the same as the input mask. If they are not the same, I will save the preprocessed mask as an "npy" file and send it to you via email again. Thank you very much for your help again!

TUAT-Novice commented 2 months ago

Hi, @TUAT-Novice and @supgy, thank you for your interest in our work. Our pre-trained BRATS model generates accurate images as it has been trained exclusively on carefully selected, high-quality BRATS images. Could you please send us the exact input mask image you used with the inference script?

@TUAT-Novice Sorry for the late response, we have been fully occupied with project tasks. We received your email, but it only contained the exported images. We need to verify the input mask you provided to the model. Please ensure that the mask image has been processed using the preprocess_seg function from the preprocess_brats_data.py file in our repository. Thank you.

For the mask image, I think I have preprocessed with the preprocess_seg function, since I preprocess the whole brats dataset with the main function you provide in the "preprocess_brats_data.py" script, with the source data file and the target file as input. Then, I use the target file (e.g. "../dataset/brats2021/seg") as a novel "inputfolder" for sampling.

mobaidoctor commented 2 months ago

@TUAT-Novice If you used our preprocessing function, your input mask image must be in .nii.gz format because our model accepts only NIfTI images, not .npy files. The sample_brats code contains a processMsk function that modifies the exported images back to the original BRATS dataset format, such as the image size of (240, 240, 155), and adjusts the segmentation mask to the original BRATS format without the brain shape. Therefore, I need to know what your input NIfTI file was for the sampling script. Please send me your input file, not the output. Thank you.

TUAT-Novice commented 2 months ago

@TUAT-Novice If you used our preprocessing function, your input mask image must be in .nii.gz format because our model accepts only NIfTI images, not .npy files. The sample_brats code contains a processMsk function that modifies the exported images back to the original BRATS dataset format, such as the image size of (240, 240, 155), and adjusts the segmentation mask to the original BRATS format without the brain shape. Therefore, I need to know what your input NIfTI file was for the sampling script. Please send me your input file, not the output. Thank you.

Hi, @mobaidoctor . I have sent you another email. Thank you very much!!!

mobaidoctor commented 2 months ago

@TUAT-Novice @supgy Thank you so much for letting us know about the problem. The strange output happened because your input mask did not include the brain shape label, which we added as a new label for the segmentation mask before using it in the model. Then, we checked our preprocessing script and found a bug. When we combined our preprocessing functions into one file, we forgot to update the file path before the final preprocessing of segmentation masks. We are very sorry for the confusion this caused. We have fixed the bug and updated the script. You can now use it without any issues. We appreciate your feedback and support. Thank you again for bringing this to our attention.

image

TUAT-Novice commented 2 months ago

@TUAT-Novice @supgy Thank you so much for letting us know about the problem. The strange output happened because your input mask did not include the brain shape label, which we added as a new label for the segmentation mask before using it in the model. Then, we checked our preprocessing script and found a bug. When we combined our preprocessing functions into one file, we forgot to update the file path before the final preprocessing of segmentation masks. We are very sorry for the confusion this caused. We have fixed the bug and updated the script. You can now use it without any issues. We appreciate your feedback and support. Thank you again for bringing this to our attention.

image

Thank you for your checking~~ I can receive the results correctly. I will close the ISSUE.