How to use the pyriemann.classification.FgMDM function in pyriemann

To help you get started, we’ve selected a few pyriemann examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github alexandrebarachant / pyRiemann / tests / test_classification.py View on Github external
def test_FgMDM_init():
    """Test init of FgMDM"""
    FgMDM(metric='riemann')

    # Should raise if metric not string or dict
    assert_raises(TypeError, FgMDM, metric=42)

    # Should raise if metric is not contain bad keys
    assert_raises(KeyError, FgMDM, metric={'universe': 42})

    # should works with correct dict
    FgMDM(metric={'mean': 'riemann', 'distance': 'logeuclid'})
github alexandrebarachant / pyRiemann / tests / test_classification.py View on Github external
def test_FgMDM_predict():
    """Test prediction of FgMDM"""
    covset = generate_cov(100, 3)
    labels = np.array([0, 1]).repeat(50)
    fgmdm = FgMDM(metric='riemann')
    fgmdm.fit(covset, labels)
    fgmdm.predict(covset)
    fgmdm.transform(covset)
github alexandrebarachant / pyRiemann / tests / test_classification.py View on Github external
def test_FgMDM_init():
    """Test init of FgMDM"""
    FgMDM(metric='riemann')

    # Should raise if metric not string or dict
    assert_raises(TypeError, FgMDM, metric=42)

    # Should raise if metric is not contain bad keys
    assert_raises(KeyError, FgMDM, metric={'universe': 42})

    # should works with correct dict
    FgMDM(metric={'mean': 'riemann', 'distance': 'logeuclid'})
github alexandrebarachant / pyRiemann / tests / test_classification.py View on Github external
def test_FgMDM_init():
    """Test init of FgMDM"""
    FgMDM(metric='riemann')

    # Should raise if metric not string or dict
    assert_raises(TypeError, FgMDM, metric=42)

    # Should raise if metric is not contain bad keys
    assert_raises(KeyError, FgMDM, metric={'universe': 42})

    # should works with correct dict
    FgMDM(metric={'mean': 'riemann', 'distance': 'logeuclid'})
github alexandrebarachant / pyRiemann / examples / motor-imagery / single_subject_comparison.py View on Github external
tmin, tmax = 1., 2.
event_id = dict(hands=2, feet=3)
subjects = range(1,110)
# There is subject where MNE can read the file
subject_to_remove = [88,89,92,100]

for s in subject_to_remove:
    if s in subjects:
        subjects.remove(s)

runs = [6, 10, 14]  # motor imagery: hands vs feet


classifiers = {
                'mdm'  : make_pipeline(Covariances(),MDM(metric='riemann')),
                'fgmdm'  : make_pipeline(Covariances(),FgMDM(metric='riemann')),
                'tsLR' : make_pipeline(Covariances(),TangentSpace(),LogisticRegression()),
                'csp'  : make_pipeline(CSP(n_components=4, reg=None, log=True),LDA())       
                }

# cross validation

results = np.zeros((len(subjects),len(classifiers)))

for s,subject in enumerate(subjects):
    
    print('Processing Subject %s' %(subject))
    raw_files = [read_raw_edf(f, preload=True,verbose=False) for f in eegbci.load_data(subject, runs)]
    raw = concatenate_raws(raw_files)

    picks = pick_types(raw.info, meg=False, eeg=True, stim=False, eog=False,
                       exclude='bads')