Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
LMBooth authored Sep 3, 2023
1 parent 6df7521 commit 00fe084
Showing 1 changed file with 22 additions and 21 deletions.
43 changes: 22 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,28 +40,29 @@ Earlier packages may work but are not guaranteed to be supported.
```python
import time
from pybci import PyBCI
if __name__ == '__main__':
bci = PyBCI(createPseudoDevice=True) # set default epoch timing, looks for first available lsl marker stream and all data streams
bci.TrainMode() # assume both marker and datastreams available to start training on received epochs
accuracy = 0
try:
while(True): # training based on couple epochs more then min threshold for classifying
currentMarkers = bci.ReceivedMarkerCount() # check to see how many received epochs, if markers sent are too close together will be ignored till done processing
time.sleep(1) # wait for marker updates
print("Markers received: " + str(currentMarkers) +" Class accuracy: " + str(accuracy), end="\r")
if len(currentMarkers) > 1: # check there is more then one marker type received
if min([currentMarkers[key][1] for key in currentMarkers]) > bci.minimumEpochsRequired:
classInfo = bci.CurrentClassifierInfo() # hangs if called too early
accuracy = classInfo["accuracy"]
if min([currentMarkers[key][1] for key in currentMarkers]) > bci.minimumEpochsRequired+1:
bci.TestMode()
break
while True: # now sufficient epochs gathered start testing
markerGuess = bci.CurrentClassifierMarkerGuess() # when in test mode only y_pred returned
guess = [key for key, value in currentMarkers.items() if value[0] == markerGuess]
print("Current marker estimation: " + str(guess), end="\r")
time.sleep(0.5)
except KeyboardInterrupt: # allow user to break while loop
pass
bci.TrainMode() # assume both marker and datastreams available to start training on received epochs
accuracy = 0
try:
while(True): # training based on couple epochs more then min threshold for classifying
currentMarkers = bci.ReceivedMarkerCount() # check to see how many received epochs, if markers sent are too close together will be ignored till done processing
time.sleep(1) # wait for marker updates
print("Markers received: " + str(currentMarkers) +" Class accuracy: " + str(accuracy), end="\r")
if len(currentMarkers) > 1: # check there is more then one marker type received
if min([currentMarkers[key][1] for key in currentMarkers]) > bci.minimumEpochsRequired:
classInfo = bci.CurrentClassifierInfo() # hangs if called too early
accuracy = classInfo["accuracy"]
if min([currentMarkers[key][1] for key in currentMarkers]) > bci.minimumEpochsRequired+1:
bci.TestMode()
break
while True: # now sufficient epochs gathered start testing
markerGuess = bci.CurrentClassifierMarkerGuess() # when in test mode only y_pred returned
guess = [key for key, value in currentMarkers.items() if value[0] == markerGuess]
print("Current marker estimation: " + str(guess), end="\r")
time.sleep(0.5)
except KeyboardInterrupt: # allow user to break while loop
pass
```

## Background Information
Expand Down

0 comments on commit 00fe084

Please sign in to comment.