@testing.requires_testing_data
def test_label_sign_flip():
    src = read_source_spaces(src_fname)
    label = Label(vertices=src[0]['vertno'][:5], hemi='lh')
    src[0]['nn'][label.vertices] = np.array(
        [[1., 0., 0.],
         [0.,  1., 0.],
         [0,  0, 1.],
         [1. / np.sqrt(2), 1. / np.sqrt(2), 0.],
         [1. / np.sqrt(2), 1. / np.sqrt(2), 0.]])
    known_flips = np.array([1, 1, np.nan, 1, 1])
    idx = [0, 1, 3, 4]  # indices that are usable (third row is orthognoal)
    flip = label_sign_flip(label, src)
    # Need the abs here because the direction is arbitrary
    assert_array_almost_equal(np.abs(np.dot(flip[idx], known_flips[idx])),
                              len(idx))
dataset/ETHPy150Open mne-tools/mne-python/mne/tests/test_label.py/test_label_sign_flip/original