Skip to content

Commit

Permalink
pytest expand
Browse files Browse the repository at this point in the history
  • Loading branch information
LMBooth committed Nov 29, 2023
1 parent dff62f9 commit 1a8cebf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
20 changes: 18 additions & 2 deletions Tests/test_Simple.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
from pybci import PyBCI
import time
from pybci.Configuration.EpochSettings import GlobalEpochSettings

gs = GlobalEpochSettings()
gs.tmax = 1 # grab 1 second after marker
gs.tmin = 0 # grab 0 seconds before marker
gs.splitCheck = True # splits samples between tmin and tmax
gs.windowLength = 0.5 #
gs.windowOverlap = 0.5 # windows overap by 50%, so for a total len

def test_run_bci():
bci = PyBCI(minimumEpochsRequired = 3, createPseudoDevice=True)
bci = PyBCI(minimumEpochsRequired = 3, createPseudoDevice=True, globalEpochSettings=gs, loggingLevel = "TIMING")

while not bci.connected:
bci.Connect()
time.sleep(1)
bci.TrainMode()
accuracy_achieved = False
marker_received = False
in_test_mode = False
accuracy=None
while True:
currentMarkers = bci.ReceivedMarkerCount() # check to see how many received epochs, if markers sent to close together will be ignored till done processing
Expand All @@ -24,7 +33,14 @@ def test_run_bci():
# set to above 0 to show some accuracy was retruend from model
accuracy_achieved = True
bci.StopThreads()
bci.TestMode()
break
#if min([currentMarkers[key][1] for key in currentMarkers]) > bci.minimumEpochsRequired+4:
# break
assert accuracy_achieved and marker_received
while True:
markerGuess = bci.CurrentClassifierMarkerGuess() # when in test mode only y_pred returned
guess = [key for key, value in currentMarkers.items() if value[0] == markerGuess]
in_test_mode = True
break
#print("Current marker estimation: " + str(guess), end=" \r")
assert accuracy_achieved and marker_received and in_test_mode
2 changes: 1 addition & 1 deletion pybci/Examples/testEpochTimingsConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
gs.windowOverlap = 0.5 # windows overap by 50%, so for a total len

if __name__ == '__main__': # Note: this line is needed when calling pseudoDevice as by default runs in a multiprocessed operation
bci = PyBCI(minimumEpochsRequired = 4, createPseudoDevice=True, globalEpochSettings=gs)#, loggingLevel = Logger.TIMING)
bci = PyBCI(minimumEpochsRequired = 4, createPseudoDevice=True, globalEpochSettings=gs, loggingLevel = "TIMING")
while not bci.connected: # check to see if lsl marker and datastream are available
bci.Connect()
time.sleep(1)
Expand Down

0 comments on commit 1a8cebf

Please sign in to comment.