Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Example user class that can be used as an interface between the computer and
- # the state machine running on the pyboard.
- # This class can respond to states, events, prints, variable changes, and analog data
- # This file will be running on your desktop computer and can therefore be used
- # for heavy processing or to interact with programs outside of PyControl GUI using
- # whatever Python libraries you'd like.
- import random
- from source.gui.api import Api
- # This class should be have the same name as the file and inherit the API class
- # look at gui/api.py to see what functions can be redefined and called
- class bias_detection(Api):
- def __init__(self):
- self.current_states=""
- self.current_events=""
- self.current_prints=""
- self.current_vars=""
- #bias and stimulus
- self.bias_correction_counter___=0
- # 0-A 1-B 2-catch trial
- self.correction_stimulus___ = 0 # mark which stimulus to trigger for bias correction
- # v.current_stimulus___ = 0
- # 0-A 1-B 2-catch trial
- self.last_trials_stimuli___=[]
- # 0-A 1-B 2-none
- self.last_trials_lick___=[]
- # this runs at the start of sessoin
- def run_start(self):
- pass
- # use this function
- def process_data_user(self, data):
- self.print_to_log(str(data))
- start_trial_state=""
- start_trial_event=""
- finished_startup=""
- trial_count=""
- #only update state when it changes (when state is constant data[states] is empty)
- if data["states"]:
- self.current_states = data["states"]
- if data["events"]:
- self.current_events = data["events"]
- if data["vars"]:
- self.current_vars = data["vars"]
- if data["prints"]:
- self.current_prints = data["prints"]
- #experiment setup:
- if self.current_states:
- start_trial_state = [state.name=="start_trial" for state in self.current_states]
- if self.current_events:
- start_trial_event = [event.name =="start_trial_event" for event in self.current_events]
- if self.current_vars:
- finished_startup = [var.name=="finished_startup___" for var in self.current_vars]
- trial_count = [var.name=="trial_counter___" for var in self.current_vars]
- self.print_to_log(str([start_trial_event,start_trial_state,finished_startup,trial_count]))
- # if (v.trial_counter___==0):#update list lengths
- # # 0-A 1-B 2-catch trial
- # v.last_trials_stimuli___=[0]*v.accuracy_history_limit #list used for saving the last shown stimuli
- # # 0-A 1-B 2-none
- # v.last_trials_lick___=[0]*v.accuracy_history_limit #last licks of the mouse
- def run_stop(self):
- pass
Advertisement
Add Comment
Please, Sign In to add comment