Exemplo n.º 1
0
            Feature, EEG_Recording = FeatureExtraction(Sample, Feature,
                                                       EEG_Recording)

    # Signal Start
    FIFO.Rewrite(Trigger_Log, "Trial Start")
    print 'Write "Trial Start"'
    Trigger = np.concatenate((Trigger, np.array([[len(Feature),
                                                  TRIAL_START]])))

    Max_Power = np.percentile(
        Feature[range(
            len(Feature) - 5 * TaskSetting['Fixation'] -
            5 * TaskSetting['Trial Start'], len(Feature))], 90)
    print Max_Power
    if not Max_Power == Min_Power:
        Classifier, Offset = Process.Linear_Regression(
            (Min_Power, Max_Power), (Movement_Range_Min, Movement_Range_Max))
        print Classifier
    else:
        print 'ERROR'
        Classifier = 0
        Offset = 0

    # Clean up the Queue to keep Data in real time
    if Data_Queue.empty():
        print 'No Left Behind'
    else:
        while not Data_Queue.empty():
            Sample = Data_Queue.get()
            Feature, EEG_Recording = FeatureExtraction(Sample, Feature,
                                                       EEG_Recording)
    Current_Index = len(Feature)
Exemplo n.º 2
0
screenWidth, screenHeight = gui.size()
gui.FAILSAFE = False
MovementRange_X = [-5.0 * (screenWidth / 100.0), 5.0 * (screenWidth / 100.0)]
MovementRange_Y = [-5.0 * (screenHeight / 100.0), 5.0 * (screenHeight / 100.0)]

while True:
    if not Data_Queue.empty():
        Sample = Data_Queue.get()
        Sample[:, range(1, 9)] = Process.Common_Average_Reference(
            Sample[:, range(1, 9)])
        Feature1.append(
            Process.PowerExtraction(Sample[:, 4], FS, Frequency_Range))
        Feature2.append(
            Process.PowerExtraction(Sample[:, 7], FS, Frequency_Range))
        Classifier_X, Offset_X = Process.Linear_Regression(
            Feature1, MovementRange_X)
        Classifier_Y, Offset_Y = Process.Linear_Regression(
            Feature2, MovementRange_Y)
        if not Classifier_X == np.inf and not Classifier_Y == np.inf:
            break

while len(Feature1) < 70:
    if not Data_Queue.empty():
        Sample = Data_Queue.get()
        Sample[:, range(1, 9)] = Process.Common_Average_Reference(
            Sample[:, range(1, 9)])
        Feature1.append(
            Process.PowerExtraction(Sample[:, 4], FS, Frequency_Range))
        Feature2.append(
            Process.PowerExtraction(Sample[:, 7], FS, Frequency_Range))
        Distance_X = Feature1[len(Feature1) - 1] * Classifier_X + Offset_X