本文整理匯總了Python中mne.label.Label.fill方法的典型用法代碼示例。如果您正苦於以下問題:Python Label.fill方法的具體用法?Python Label.fill怎麽用?Python Label.fill使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類mne.label.Label
的用法示例。
在下文中一共展示了Label.fill方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_label_in_src
# 需要導入模塊: from mne.label import Label [as 別名]
# 或者: from mne.label.Label import fill [as 別名]
def test_label_in_src():
"""Test label in src."""
src = read_source_spaces(src_fname)
label = read_label(v1_label_fname)
# construct label from source space vertices
vert_in_src = np.intersect1d(label.vertices, src[0]['vertno'], True)
where = np.in1d(label.vertices, vert_in_src)
pos_in_src = label.pos[where]
values_in_src = label.values[where]
label_src = Label(vert_in_src, pos_in_src, values_in_src,
hemi='lh').fill(src)
# check label vertices
vertices_status = np.in1d(src[0]['nearest'], label.vertices)
vertices_in = np.nonzero(vertices_status)[0]
vertices_out = np.nonzero(np.logical_not(vertices_status))[0]
assert_array_equal(label_src.vertices, vertices_in)
assert_array_equal(np.in1d(vertices_out, label_src.vertices), False)
# check values
value_idx = np.digitize(src[0]['nearest'][vertices_in], vert_in_src, True)
assert_array_equal(label_src.values, values_in_src[value_idx])
# test exception
vertices = np.append([-1], vert_in_src)
pytest.raises(ValueError, Label(vertices, hemi='lh').fill, src)
# test filling empty label
label = Label([], hemi='lh')
label.fill(src)
assert_array_equal(label.vertices, np.array([], int))