ZAX130 / SmileCode

The public code of SMILE LAB
31 stars 3 forks source link

Question about 'dice_val_VOI' in utils.py for LPBA40 dataset #3

Closed Marceloxo closed 1 year ago

Marceloxo commented 1 year ago
def dice_val_VOI(y_pred, y_true):
    VOI_lbls = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
                12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
                24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
                36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
                48, 49, 50, 51, 52, 53, 54]

    pred = y_pred.detach().cpu().numpy()[0, 0, ...]
    true = y_true.detach().cpu().numpy()[0, 0, ...]
    DSCs = np.zeros((len(VOI_lbls), 1))
    idx = 0
    for i in VOI_lbls:
        pred_i = pred == i
        true_i = true == i
        intersection = pred_i * true_i
        intersection = np.sum(intersection)
        union = np.sum(pred_i) + np.sum(true_i)
        dsc = (2.*intersection) / (union + 1e-5)
        DSCs[idx] =dsc
        idx += 1
    return np.mean(DSCs)

Hello, I noticed that the "dice_val_VOI" in your code under the "utils.py" file doesn't seem to correspond to the labels of the LPBA40 dataset. Where does the data in this list come from, and what is it used for? I would appreciate your guidance.

ZAX130 commented 1 year ago

Actually, the 'Seg_norm' function in /data/trans.py can convert discontinuous labels into continuous ones. So when calculating the Dice metric, continuous labels can be used naturally.

Marceloxo commented 1 year ago

Thank you for your prompt response. I have now prepared my own dataset in '.pkl' format. Can I use your data reading logic to perform the inter-patient brain MR registration task? Apart from modifying 'seg_table' in the 'Seg_norm' function to match the labels of my own data, do I need to customize the values in the 'VOI_lbls' list?

Marceloxo commented 1 year ago

As a side note, I have encapsulated my dataset in a manner consistent with the 'TransMorph' approach.

ZAX130 commented 1 year ago

The seg_table and seg_list should be changed along with the dataset changes.

Marceloxo commented 1 year ago

Thank you once again for your response amidst your busy schedule. My question has been resolved. Wishing you success in your work and studies!