Problem with real time neurofeedback system
Posted: Fri Jan 19, 2024 8:02 am
Problem with real time neurofeedback system
I am trying to play a beep sound for 0.5s after the classifier predicts prediction == [1](Mind Wandering), then waits for 4 seconds.
However, when it predicts prediction == [1]:, it keeps giving me a beep sound without waiting for 4 seconds. I tried with other numbers, but the same thing happens. My classifier is working and only gives prediction == [1] when it needs to.
Your help is appreciated. Thank you so much.
Here is my dispatcher
I am trying to play a beep sound for 0.5s after the classifier predicts prediction == [1](Mind Wandering), then waits for 4 seconds.
However, when it predicts prediction == [1]:, it keeps giving me a beep sound without waiting for 4 seconds. I tried with other numbers, but the same thing happens. My classifier is working and only gives prediction == [1] when it needs to.
Your help is appreciated. Thank you so much.
Code: Select all
def abs_handler(address: str, *args):
global abs_waves, last_sound_time
wave = args[0][0]
elif len(args) == 5:
for i in range(4):
abs_waves[wave].append(args[i + 1])
if all(len(abs_wave) > 40 for abs_wave in abs_waves):
new_data = [abs_wave[-40:] for abs_wave in abs_waves]
features = extract_features(new_data)
prediction = classifier.predict([features])
if prediction == [1]:
os.system('afplay -t 0.5 B.mp3')
time.sleep(4)
Code: Select all
dispatcher.map("/muse/elements/delta_absolute", abs_handler,0)
dispatcher.map("/muse/elements/theta_absolute", abs_handler,1)
dispatcher.map("/muse/elements/alpha_absolute", abs_handler,2)
dispatcher.map("/muse/elements/beta_absolute", abs_handler,3)
dispatcher.map("/muse/elements/gamma_absolute", abs_handler,4)