0

I am using Spyder IDE and call the following function in the Ipython shell after defining the input. But, I get the positional argument error! Perhaps something with the argument, but still I couldnt settle. can you help plz! Here is the code:

def get_confusion_matrix(label, ref_label, mask):
    label = sitk.GetArrayFromImage(label)
    ref_label = sitk.GetArrayFromImage(ref_label)
    mask = sitk.GetArrayFromImage(mask)

    ref_label[(mask == 2) & (label > 0)] = label[(mask == 2) & (label > 0)]
    ref_label[(mask == 1) & (label == 0)] = 0
    return get_confusion_matrix(label.flatten(), ref_label.flatten())

def get_dices(label, ref_label, mask):
    cm = get_confusion_matrix(label, ref_label, mask)
    dice_st = 2*cm[1,1]/(np.sum(cm[:,1]) + np.sum(cm[1,:]))
    dice_sv = 2*cm[2,2]/(np.sum(cm[:,2]) + np.sum(cm[2,:]))
    return dice_st, dice_sv

TypeError: get_confusion_matrix() missing 1 required positional argument: 'mask'

Nick is tired
  • 6,860
  • 20
  • 39
  • 51
fred1
  • 3
  • 3
  • 1
    Your last edit appears to have removed the code and error. – Kemp Dec 08 '20 at 00:59
  • Welcome to Stack Overflow. Please edit the question to include a [*"Minimal, Reproducible, Example."*](https://stackoverflow.com/help/minimal-reproducible-example) – bad_coder Dec 08 '20 at 01:31
  • @ sorry, here you can see the code! but the problem persist again! – fred1 Dec 08 '20 at 15:45

1 Answers1

0

You have defined get_confusion_matrix as taking 3 arguments: label, ref_label, and mask. The error is because you are only passing two arguments to it when you call it with get_confusion_matrix(label.flatten(), ref_label.flatten()).

Kemp
  • 3,467
  • 1
  • 18
  • 27