Guest User

Untitled

a guest
Sep 8th, 2025
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.81 KB | None | 0 0
  1. # Example user class that can be used as an interface between the computer and
  2. # the state machine running on the pyboard.
  3. # This class can respond to states, events, prints, variable changes, and analog data
  4. # This file will be running on your desktop computer and can therefore be used
  5. # for heavy processing or to interact with programs outside of PyControl GUI using
  6. # whatever Python libraries you'd like.
  7.  
  8.  
  9. import random
  10. from source.gui.api import Api
  11.  
  12.  
  13. # This class should be have the same name as the file and inherit the API class
  14. # look at gui/api.py to see what functions can be redefined and called
  15. class bias_detection(Api):
  16. def __init__(self):
  17. self.current_states=""
  18. self.current_events=""
  19. self.current_prints=""
  20. self.current_vars=""
  21.  
  22. #bias and stimulus
  23.  
  24. self.bias_correction_counter___=0
  25.  
  26.  
  27. # 0-A 1-B 2-catch trial
  28. self.correction_stimulus___ = 0 # mark which stimulus to trigger for bias correction
  29. # v.current_stimulus___ = 0
  30. # 0-A 1-B 2-catch trial
  31. self.last_trials_stimuli___=[]
  32. # 0-A 1-B 2-none
  33. self.last_trials_lick___=[]
  34.  
  35.  
  36. # this runs at the start of sessoin
  37. def run_start(self):
  38. pass
  39.  
  40. # use this function
  41. def process_data_user(self, data):
  42. self.print_to_log(str(data))
  43. start_trial_state=""
  44. start_trial_event=""
  45. finished_startup=""
  46. trial_count=""
  47. #only update state when it changes (when state is constant data[states] is empty)
  48. if data["states"]:
  49. self.current_states = data["states"]
  50. if data["events"]:
  51. self.current_events = data["events"]
  52. if data["vars"]:
  53. self.current_vars = data["vars"]
  54. if data["prints"]:
  55. self.current_prints = data["prints"]
  56. #experiment setup:
  57. if self.current_states:
  58. start_trial_state = [state.name=="start_trial" for state in self.current_states]
  59. if self.current_events:
  60. start_trial_event = [event.name =="start_trial_event" for event in self.current_events]
  61. if self.current_vars:
  62. finished_startup = [var.name=="finished_startup___" for var in self.current_vars]
  63. trial_count = [var.name=="trial_counter___" for var in self.current_vars]
  64. self.print_to_log(str([start_trial_event,start_trial_state,finished_startup,trial_count]))
  65. # if (v.trial_counter___==0):#update list lengths
  66. # # 0-A 1-B 2-catch trial
  67. # v.last_trials_stimuli___=[0]*v.accuracy_history_limit #list used for saving the last shown stimuli
  68. # # 0-A 1-B 2-none
  69. # v.last_trials_lick___=[0]*v.accuracy_history_limit #last licks of the mouse
  70.  
  71.  
  72. def run_stop(self):
  73. pass
  74.  
Advertisement
Add Comment
Please, Sign In to add comment