Exemplo n.º 1
0
    
    #%% Initialize the buffers for storing raw EEG and features

    # Initialize raw EEG data buffer (for plotting)
    eeg_buffer = np.zeros((params['sampling frequency']*eeg_buffer_secs, 
                           len(params['names of channels']))) 
    
    # Compute the number of windows in "eeg_buffer_secs" (used for plotting)
    n_win_test = int(np.floor((eeg_buffer_secs - win_test_secs) / float(shift_secs) + 1))
    
    # Initialize the feature data buffer (for plotting)
    feat_buffer = np.zeros((n_win_test, len(names_of_features)))
        
    # Initialize the plots
    plotter_eeg = BCIw.dataPlotter(params['sampling frequency']*eeg_buffer_secs,
                                   params['names of channels'],
                                   params['sampling frequency'])
    
    plotter_feat = BCIw.dataPlotter(n_win_test,
                                    names_of_features,
                                    1/float(shift_secs))
                                    
    
    #%% Start pulling data
    
    mules_client.flushdata()  # Flush old data from MuLES       
    BCIw.beep() # Beep sound  
    
    
    # The try/except structure allows to quit the while loop by aborting the 
    # script with <Ctrl-C>
Exemplo n.º 2
0
    feat_matrix1 = BCIw.compute_feature_matrix(eeg_epochs1, params['sampling frequency'])

    #%% Train classifier    

    [classifier, mu_ft, std_ft] = BCIw.classifier_train(feat_matrix0, feat_matrix1, 'SVM')
    BCIw.beep(500,300)


    #%% Initialize the buffers for storing raw EEG and decisions
    
    eeg_buffer = np.zeros((params['sampling frequency']*eeg_buffer_secs, len(params['data format']))) 
    decision_buffer = np.zeros((30,1))

    mules_client.flushdata()  # Flushes old data from MuLES
    
    plotter_decision = BCIw.dataPlotter(30, ['Decision'])
    
    #BCIw.plot_classifier_training(feat_matrix0, feat_matrix1) # This will plot the decision boundary of a 2-feature SVM
    
    
    #%% Start pulling data and classifying in real-time
    
    BCIw.beep() # Beep sound
    
    # The try/except structure allows to quit the while loop by aborting the 
    # script with <Ctrl-C>
    print(' Press Ctrl-C in the console to break the While Loop')
    try:    
        
        while True: 
            
Exemplo n.º 3
0
    #%% Train classifier

    [classifier, mu_ft,
     std_ft] = BCIw.classifier_train(feat_matrix0, feat_matrix1, 'SVM')
    BCIw.beep(500, 300)

    #%% Initialize the buffers for storing raw EEG and decisions

    eeg_buffer = np.zeros((params['sampling frequency'] * eeg_buffer_secs,
                           len(params['data format'])))
    decision_buffer = np.zeros((30, 1))

    mules_client.flushdata()  # Flushes old data from MuLES

    plotter_decision = BCIw.dataPlotter(30, ['Decision'])

    #BCIw.plot_classifier_training(feat_matrix0, feat_matrix1) # This will plot the decision boundary of a 2-feature SVM

    #%% Start pulling data and classifying in real-time

    BCIw.beep()  # Beep sound

    # The try/except structure allows to quit the while loop by aborting the
    # script with <Ctrl-C>
    print(' Press Ctrl-C in the console to break the While Loop')
    try:

        while True:
            """ 1- ACQUIRE DATA """
            eeg_data = mules_client.getdata(

    #%% Initialize the buffers for storing raw EEG and features

    # Initialize raw EEG data buffer (for plotting) 
    eeg_buffer = np.zeros((params['sampling frequency']*eeg_buffer_secs, len(params['names of channels'])))  
    
    # Compute the number of windows in "eeg_buffer_secs" (used for plotting)
    n_win_test = int(np.floor((eeg_buffer_secs - win_test_secs) / float(shift_secs) + 1))
    
    # Initialize the feature data buffer (for plotting)
    feat_buffer = np.zeros((n_win_test, len(names_of_features)))
        
    # Initialize the plots
    plotter_eeg = BCIw.dataPlotter(params['sampling frequency']*eeg_buffer_secs,
                                   params['names of channels'],
                                   params['sampling frequency'])
    
    plotter_feat = BCIw.dataPlotter(n_win_test,
                                    names_of_features,
                                    1 / float(shift_secs))
    

    #%% Start pulling data    
    
    mules_client.flushdata()  # Flush old data from MuLES
    BCIw.beep() # Beep sound 
    
    # The try/except structure allows to quit the while loop by aborting the 
    # script with <Ctrl-C>
    print(' Press Ctrl-C in the console to break the While Loop')