state_timer=tph.iti_error, state_change_conditions={'Tup': 'exit'}, output_actions=[tph.out_noise]) sma.add_state(state_name='reward', state_timer=tph.reward_valve_time, state_change_conditions={'Tup': 'correct'}, output_actions=[('Valve1', 255)]) sma.add_state(state_name='correct', state_timer=tph.iti_correct, state_change_conditions={'Tup': 'exit'}, output_actions=[]) # Send state machine description to Bpod device bpod.send_state_machine(sma) # Run state machine bpod.run_state_machine(sma) # Locks until state machine 'exit' is reached tph = tph.trial_completed(bpod.session.current_trial.export()) as_data = tph.save_ambient_sensor_data(bpod, sph.SESSION_RAW_DATA_FOLDER) tph.show_trial_log() # Update online plots op.update_fig(f, axes, tph) tph.check_sync_pulses() stop_crit = tph.check_stop_criterions() if stop_crit and sph.USE_AUTOMATIC_STOPPING_CRITERIONS: if stop_crit == 1: msg = "STOPPING CRITERIA Nº1: PLEASE STOP TASK AND REMOVE MOUSE\
state_name='TimerTrig', # Trigger global timer state_timer=0, state_change_conditions={Bpod.Events.Tup: 'Port1Active1'}, output_actions=[(Bpod.OutputChannels.GlobalTimerTrig, 1)]) # Infinite loop (with next state). Only a global timer can save us. sma.add_state( state_name='Port1Active1', state_timer=0, state_change_conditions={Bpod.Events.Port1In: 'Port2Active1', Bpod.Events.GlobalTimer1_End: 'exit'}, output_actions=[(Bpod.OutputChannels.PWM1, 255)]) sma.add_state( state_name='Port2Active1', state_timer=0, state_change_conditions={Bpod.Events.Port2In: 'Port3Active1', Bpod.Events.GlobalTimer1_End: 'exit'}, output_actions=[(Bpod.OutputChannels.PWM2, 255)]) sma.add_state( state_name='Port3Active1', state_timer=0, state_change_conditions={Bpod.Events.Port3In: 'Port1Active1', Bpod.Events.GlobalTimer1_End: 'exit'}, output_actions=[(Bpod.OutputChannels.PWM3, 255)]) my_bpod.send_state_machine(sma) my_bpod.run_state_machine(sma) print("Current trial info: {0}".format(my_bpod.session.current_trial)) my_bpod.close()
state_name='FlashStimulus', state_timer=0.1, state_change_conditions={Bpod.Events.Tup: 'WaitForResponse'}, output_actions=[(stimulus, 255)]) sma.add_state( state_name='WaitForResponse', state_timer=1, state_change_conditions={Bpod.Events.Port1In: leftAction, Bpod.Events.Port3In: rightAction}, output_actions=[]) sma.add_state( state_name='Reward', state_timer=0.1, state_change_conditions={Bpod.Events.Tup: 'exit'}, output_actions=[(Bpod.OutputChannels.Valve, rewardValve)]) # Reward correct choice sma.add_state( state_name='Punish', state_timer=3, state_change_conditions={Bpod.Events.Tup: 'exit'}, output_actions=[(Bpod.OutputChannels.LED, 1), (Bpod.OutputChannels.LED, 2), (Bpod.OutputChannels.LED, 3)]) # Signal incorrect choice my_bpod.send_state_machine(sma) # Send state machine description to Bpod device print("Waiting for poke. Reward: ", 'left' if thisTrialType == 1 else 'right') my_bpod.run_state_machine(sma) # Run state machine print("Current trial info: {0}".format(my_bpod.session.current_trial)) my_bpod.close() # Disconnect Bpod