pygame.display.update()
                bci.restart()
                start_time = time.time()
                continue
            if finish_button.is_pushed():
                bci.set_new_class(None)
                crashed = True
                # home = True
    pygame.display.update()
    clock.tick(30)
    if (time.time() - start_time) * 1000 >= window_duration:
        bci.set_new_class(current_class)
        current_class = class_updater.get_next()
        start_time = time.time()

data_x, data_y = bci.get_data()
date_time = datetime.datetime.now().strftime("%b_%d_%Y_%H%M")
directory = date_time
if not os.path.exists(directory):
    os.makedirs(directory)
data = {'X': data_x, 'Y': data_y}
with open(directory + "/Data.pickle", 'wb') as handle:
    pickle.dump(data, handle, protocol=pickle.HIGHEST_PROTOCOL)
preprocessor = BatyaGGPreprocessor(data_x.shape[0], bands=[8, 28])
data_x, data_y = preprocessor.fit_train(data_x, data_y)
clf = BatyaGGClassifier(zero_thresh=0.4)
clf.fit(data_x, data_y)
results_position = (0.2*width, 0.4*height, 0.6*width, 0.1*height)
with open(directory + "/Model.pickle", 'wb') as handle:
    pickle.dump(clf, handle, protocol=pickle.HIGHEST_PROTOCOL)
accur = clf.score(data_x, data_y);