@testing.requires_testing_data
def test_label_in_src():
 src = read_source_spaces(src_fname)
 label = read_label(v1_label_fname)
 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)
 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)
 value_idx = np.digitize(src[0]['nearest'][vertices_in], vert_in_src, True)
 assert_array_equal(label_src.values, values_in_src[value_idx])
 vertices = np.append([(-1)], vert_in_src)
 assert_raises(ValueError, Label(vertices, hemi='lh').fill, src)

@ testing . requires_testing_data def test_label_in_src ( ) : src = read_source_spaces ( src_fname ) label = read_label ( v1_label_fname ) 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 ) 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 ) value_idx = np . digitize ( src [ 0 ] [ 'nearest' ] [ vertices_in ] , vert_in_src , True ) assert_array_equal ( label_src . values , values_in_src [ value_idx ] ) vertices = np . append ( [ ( - 1 ) ] , vert_in_src ) assert_raises ( ValueError , Label ( vertices , hemi = 'lh' ) . fill , src )
test label in src .