【发布时间】:2021-03-19 07:38:27
【问题描述】:
我正在使用 Spyder IDE 并在定义输入后在 Ipython shell 中调用以下函数。但是,我得到了位置参数错误!也许有什么争论,但我仍然无法解决。你能帮忙吗?代码如下:
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() 缺少 1 个必需的位置参数:'mask'
【问题讨论】:
-
您的最后一次编辑似乎删除了代码和错误。
-
欢迎来到 Stack Overflow。请编辑问题以包含"Minimal, Reproducible, Example."
-
@抱歉,这里可以看到代码!但问题再次出现!