save_question_results.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import importlib
  2. import os
  3. import matplotlib.pyplot as plt
  4. import numpy as np
  5. import modules.classifier as classifier
  6. import aux
  7. from helpers import data_management as dm
  8. from analytics import analytics1
  9. importlib.reload(classifier)
  10. importlib.reload(dm)
  11. importlib.reload(analytics1)
  12. aux.config_logging()
  13. params = aux.load_config()
  14. features_fname = params.file_handling.datafile_path + '/train_trials.pkl' # name of features array
  15. # fids = np.arange(51,63) # 22.5.19-24.5.19 ids of sessions, NOTE: this will change if sessions from the past are added
  16. # fids = np.arange(51,56) # 22.5.19
  17. fids = np.array([60, 61, 62, 64, 65]) # 24.5.19
  18. # fids = np.append(fids,[64,65])
  19. psth_tot1 = np.empty((0,140, 128))
  20. psth_tot2 = np.empty((0,140, 128))
  21. for ii in range(fids.size): # stack psth from different sessions
  22. data_tot, tt, triggers, ch_rec_list, file_names = dm.get_raw(n_triggers=params.classifier.n_classes, fids=[fids[ii]])
  23. clf = classifier.Classifier(params)
  24. clf.get_trials_kiap(data_tot[:, :], triggers, features_fname=features_fname)
  25. psth_tot1 = np.vstack((psth_tot1, clf.psth[0]))
  26. psth_tot2 = np.vstack((psth_tot2, clf.psth[1]))
  27. clf.psth[0] = psth_tot1
  28. clf.psth[1] = psth_tot2
  29. fig_name0 = os.path.basename(os.path.splitext(file_names[0])[0])
  30. fig_name = params.file_handling.results+fig_name0 + '/'
  31. if not os.path.exists(fig_name):
  32. os.mkdir(fig_name)
  33. fig_name = fig_name + fig_name0
  34. plt.close('all')
  35. plt.figure(1, figsize=[10 , 7])
  36. for ii in range(128):
  37. analytics1.plot_psth2(clf,[ii],fig_name)