-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
40 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from pybci import PyBCI | ||
import time | ||
|
||
from sklearn.neural_network import MLPClassifier | ||
# Test case using the fixture | ||
|
||
def test_run_bci(): | ||
clf = MLPClassifier(max_iter = 1000, solver ="lbfgs")#solver=clf, alpha=alpha,hidden_layer_sizes=hid) | ||
bci = PyBCI(minimumEpochsRequired=5, createPseudoDevice=True) | ||
while not bci.connected: | ||
bci.Connect() | ||
time.sleep(1) | ||
bci.TrainMode() | ||
accuracy_achieved = False | ||
marker_received = False | ||
accuracy=0 | ||
while True: | ||
currentMarkers = bci.ReceivedMarkerCount() # check to see how many received epochs, if markers sent to close together will be ignored till done processing | ||
time.sleep(0.5) # wait for marker updates | ||
print("Markers received: " + str(currentMarkers) +" Accuracy: " + str(round(accuracy,2)), end=" \r") | ||
if len(currentMarkers) > 1: # check there is more then one marker type received | ||
marker_received = True | ||
if min([currentMarkers[key][1] for key in currentMarkers]) > bci.minimumEpochsRequired: | ||
classInfo = bci.CurrentClassifierInfo() # hangs if called too early | ||
accuracy = classInfo["accuracy"]### | ||
if accuracy > 0.75: | ||
accuracy_achieved = True | ||
bci.StopThreads() | ||
break | ||
if min([currentMarkers[key][1] for key in currentMarkers]) > bci.minimumEpochsRequired+4: | ||
break | ||
#assert accuracy_achieved and marker_received | ||
if __name__ == '__main__': | ||
test_run_bci() |