Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

dynamic_ranges.py 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import matplotlib.pyplot as plt
  2. import numpy as np
  3. import yaml
  4. import aux
  5. from helpers import data_management as dm
  6. import modules.classifier as clf
  7. import analytics
  8. import os
  9. import itertools
  10. from collections.abc import Iterable
  11. params = aux.load_config()
  12. if params.speller.type == 'exploration':
  13. data_tot, tt, triggers_tot, ch_rec_list, file_names = dm.get_raw(n_triggers=params.classifier.n_classes,
  14. exploration=True, trigger_pos=params.classifier.trigger_pos)
  15. elif params.speller.type == 'feedback':
  16. data_tot, tt, triggers_tot, ch_rec_list, file_names = dm.get_raw(n_triggers=params.classifier.n_classes,
  17. feedback=True, trigger_pos=params.classifier.trigger_pos)
  18. else:
  19. data_tot, tt, triggers_tot, ch_rec_list, file_names = dm.get_raw(n_triggers=params.classifier.n_classes,
  20. trigger_pos=params.classifier.trigger_pos)
  21. data = np.empty((0, params.daq.n_channels))
  22. for fids in range(data_tot.shape[0]):
  23. data = np.concatenate((data, data_tot[fids,0]))
  24. pp = np.percentile(data, params.daq.normalization.range, axis=0)
  25. def create_channels_yaml(channels):
  26. out_dict = {'channels': []}
  27. for ch in channels:
  28. out_dict['channels'].append({'id': int(ch['id']),
  29. 'bottom': float(pp[0, ch['id']]),
  30. 'top': float(pp[1, ch['id']]),
  31. 'invert': ch['invert']}
  32. )
  33. return out_dict
  34. print(f"\n\nSelected channels dynamic ranges:\n\n{yaml.dump(create_channels_yaml(params.daq.normalization.channels), sort_keys=False, default_flow_style=None)}\n")
  35. # print(yaml.dump(out_dict, sort_keys=False, default_flow_style=None))
  36. other_channels = [{'id':item, 'invert':False} for item in range(params.daq.n_channels) if item not in [ch.id for ch in params.daq.normalization.channels]]
  37. print(f"\nOther channels dynamic ranges (nb: 'invert' is set to default!):\n\n{yaml.dump(create_channels_yaml(other_channels), sort_keys=False, default_flow_style=None)}\n")
  38. pp_all = np.percentile(np.nanmean(data, axis=1), params.daq.normalization.range, axis=0)
  39. out_dict = {'all_channels': {'bottom': float(pp_all[0]), 'top': float(pp_all[1]), 'invert': params.daq.normalization.all_channels.invert}}
  40. print(f"All Channels bounds:\n\n{yaml.dump(out_dict, sort_keys=False, default_flow_style=None)}")