Issue
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'
Solution
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())
.
Answered By - Kemp
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.