BruceResearch / BiTr-Unet

This repo is the source code for [BiTr-Unet: a CNN-Transformer Combined Network for MRI Brain Tumor Segmentation].
Apache License 2.0
32 stars 8 forks source link

DICE #2

Closed H-CODE6 closed 2 years ago

H-CODE6 commented 2 years ago

Hello, your code has been reproduced recently. We can't know the Dice coefficient after the test. How did you get the coefficient

BruceResearch commented 2 years ago

Hi, I added a new folder name "evaluation" for you to calculate the Dice score for the validation data. However, this equation for my Dice score may not be the same as that for the BraTS Challenge. If https://www.synapse.org/#!Synapse:syn25829067/wiki/611501 still accepts validation submission, you might want to download the official validation data and upload your segmentation for an official Dice score to evaluate your trained model.

H-CODE6 commented 2 years ago

Thank you. Can you provide a trained model epoch last. PTH so that I can reproduce your effect.

BruceResearch commented 2 years ago

So you would like me to upload my trained final model?

H-CODE6 commented 2 years ago

Yes, thank you for your reply.

BruceResearch commented 2 years ago

https://drive.google.com/file/d/13Vom6579mXtt0M3AnXt9pWIlhIDckTMM/view?usp=sharing I have uploaded the trained model that I submitted for the testing phase of BraTS 2021 on Google Drive. Please unzip it for the pth file.

H-CODE6 commented 2 years ago

OK, thank you very much for your reply.

BruceResearch commented 2 years ago

No problem. Note that this model is trained with all the training data.

H-CODE6 commented 2 years ago

Have you trained all the data of brats2021? What test set and verification set do you use for testing?

BruceResearch commented 2 years ago

Validation data can be downloaded from https://www.synapse.org/#!Synapse:syn25829067/wiki/611501 However, the ground-truth segmentation is unavailable for us. Thus, I need to submit the segmentation images for the website to validate the score for us. That was how I did last year, so I did not need to do the training/validation split. There is a detailed introduction on that website. However, I am not sure if they are still accepting validation requests.

H-CODE6 commented 2 years ago

OK, thank you for replying to my question. Thank you very much.

BruceResearch commented 2 years ago

You are welcome.

H-CODE6 commented 2 years ago

Hello, author. Do you have a pre training model in the resume when you first started training? Or do you just train to get the model epoch Last, finally test.

BruceResearch commented 2 years ago

https://drive.google.com/file/d/1YAVylEuPz1DDZOTUPdS2YGGYquuOUtYs/view?usp=sharing

Uploaded another model with 1600 epochs, which is the one with the fewest epochs I can possibly find.

BruceResearch commented 2 years ago

Yes, I continually saved my models and validate their performances while training.

H-CODE6 commented 2 years ago

OK, if I want to train my model, is it running train Py, nothing is filled in the resume, but I find a line of re-training prompt when running, and then start training. Does this sentence have any impact? Or the normal operation process?

BruceResearch commented 2 years ago

line 102 determines the save frequency, the default is to save the model for every 50 epochs.

Yeah I read through the code, if u provide a trained model for resuming, it will print "Successfully loading checkpoint {} and training from epoch: {}" If you dont provide and leave resume empty, it will print 're-training!!!'

Sorry for the confusion as it shall not say 're-training!!!' when u are training from epoch 0.

H-CODE6 commented 2 years ago

Yes, I want to train my own model. At the beginning, I don't fill in anything in the resume, and finally get my own training model epoch Last, I wonder if my understanding is correct?

BruceResearch commented 2 years ago

yes, just leave the resume blank

H-CODE6 commented 2 years ago

Thank you for your answer. Thank you very much. I ran your evaluation code today and found that only WT, TC, mean dice, et and mean hausdorff95 (mm) in your paper can not be evaluated. I wonder if it will take your valuable time to update the evaluation code so that we can better understand the paper and compare the results.

BruceResearch commented 2 years ago

Sorry, I never wrote or adapted any code for calculating hausdorff95 (mm). All the results that I obtained are from the validation from the official BraTS host. Please look up other repos to adopt the function of calculating hausdorff95 (mm) for BraTS data.

H-CODE6 commented 2 years ago

OK, thank you very much for your reply. Since I haven't conducted the evaluation on the official brats host again, is it convenient for you to tell me the evaluation process?

BruceResearch commented 2 years ago

There is a very detailed instruction on https://www.synapse.org/#!Synapse:syn25829067/wiki/611501 You just need to uplead the segmentation files following a certain format, which my code already handles.

H-CODE6 commented 2 years ago

OK, thank you very much for your answer

H-CODE6 commented 2 years ago

Hello, data postprocessing cannot run successfully after the test. Can you tell me which parameters to change in the code? Or download those files?

BruceResearch commented 2 years ago

The performance of the method of connected_components.py is not ideal after experiments, and in my paper we use majority voting only. Thus, please just run ensemble_by_majority_voting.py as your post process procedure. You need to specify test_path (main folder where stores segmentation outputs from each model) and model_list(specific folder names of each model's outputs). When running ensemble_by_majority_voting.py, specify the method, which is" python ensemble_by_majority_voting.py --m 0"

H-CODE6 commented 2 years ago

Excuse me, model list is the specific folder name of each model output you refer to on the list? I only generated a model on the checkpoint epoch last. pth ,and other files, as well as the above result path,pred path,prob_ Does path need to be modified?

BruceResearch commented 2 years ago

You can not do the ensemble with only one model. You have to generate several sets of outputs from different models to do the ensemble.

H-CODE6 commented 2 years ago

Well, thank you very much.

H-CODE6 commented 2 years ago

Hello, what is the best effect of your final experimental results? What are the dice and other coefficients respectively? I want to compare it with the results I reproduced.

BruceResearch commented 2 years ago

Please refer to Table 1 in the paper : https://arxiv.org/pdf/2109.12271.pdf

H-CODE6 commented 2 years ago

Yes, I have read your paper completely and am interested in the coefficients of Table 2 and table 3. How do you realize it?

BruceResearch commented 2 years ago

Those summary statistics are provided and calculated by the BraTS official validation result.

BruceResearch commented 2 years ago

We still mainly look at the mean result. My table 2 and table 3 provide other summary statistics, which only serve as a supplementary perspective of evaluating the performance.

H-CODE6 commented 2 years ago

OK, thank you very much for your answer

H-CODE6 commented 2 years ago

Hello, I just used Dual_focal_loss in the loss function, The performance test of the loss function shows that the image background of the final test output is blue, and the test result is not very normal. Do you want to modify the code when using other loss functions.

H-CODE6 commented 2 years ago

Hello, author. I've been studying your code recently, at bitrunet.py Some of are not very clear. Can you comment on the specific functions in front of each function and class? So that our readers can better understand the paper.

BruceResearch commented 2 years ago

Hi, Sorry I have been very busy these days. I have added some comments for each class to illustrate their roles. The main idea is just that I define the encoder class and decoder class separately, and finally, combine them in one def.

H-CODE6 commented 2 years ago

OK, thank you very much for your reply to me in your busy schedule. I would like to express my deep gratitude to you again.

H-CODE6 commented 2 years ago

Hello, after using your evaluation file, it is found that ET performance cannot be evaluated. Can you update the code to facilitate our evaluation? We look forward to your reply.

BruceResearch commented 2 years ago

I see where the problem is. It should be fixed now. Please let me know if it works.

H-CODE6 commented 2 years ago

OK, thank you very much. I'll give you feedback immediately after my evaluation. Thank you again

BruceResearch commented 2 years ago

Just updated again, found a typo

H-CODE6 commented 2 years ago

The following error occurred

Traceback (most recent call last): File "evaluation.py", line 90, in dice = dice_of_brats_data_set(gt_names, seg_names, type_idx) File "evaluation.py", line 55, in dice_of_brats_data_set s_volume[s_volume == 2 or s_volume ==1] = 0 ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

BruceResearch commented 2 years ago

what about now

H-CODE6 commented 2 years ago

It can be run. At that time, the final result of the same data WT and TC is very different from that of the code that has not been updated before

H-CODE6 commented 2 years ago

now: tissue type ET dice mean [0.83201768] dice std [0.23055119] tissue type WT dice mean [0.80649212] dice std [0.1666985] tissue type TC dice mean [0.71619503] dice std [0.28385196]

old: tissue type whole dice mean [0.90952711] dice std [0.10472148] tissue type core dice mean [0.88381648] dice std [0.18333644] tissue type all tissue label [1, 2, 3, 4] dice mean [0.71619503 0.80649212 1. 0.83201768] dice std [0.28385196 0.1666985 0. 0.23055119]

BruceResearch commented 2 years ago

That is right, the old code is totally wrong for the tumor label since I actually did not use them at all. Based on the info on BraTS website, "Annotations comprise the GD-enhancing tumor (ET — label 4), the peritumoral edematous/invaded tissue (ED — label 2), and the necrotic tumor core (NCR — label 1)", I modified the code.

BruceResearch commented 2 years ago

I see, it can still be changed, give me a minute.

BruceResearch commented 2 years ago

updated

H-CODE6 commented 2 years ago

No problem. Can you tell me why