def __init__(self, param=DefaultParam): self.param = param self.experiment = self.param['experiment'] self.experiment_time = self.param['experiment_time'] self.time_start = time.time() # Set up Phidget channels self.aout_channel_yaw = 0 self.aout_channel_x = 1 self.aout_channel_yaw_gain = 2 self.aout_channel_y = 3 self.aout_max_volt = 10.0 self.aout_min_volt = 0.0 # Setup analog output YAW self.aout_yaw = VoltageOutput() self.aout_yaw.setChannel(self.aout_channel_yaw) self.aout_yaw.openWaitForAttachment(5000) self.aout_yaw.setVoltage(0.0) # Setup analog output X self.aout_x = VoltageOutput() self.aout_x.setChannel(self.aout_channel_x) self.aout_x.openWaitForAttachment(5000) self.aout_x.setVoltage(0.0) # Setup analog output YAW gain self.aout_yaw_gain = VoltageOutput() self.aout_yaw_gain.setChannel(self.aout_channel_yaw_gain) self.aout_yaw_gain.openWaitForAttachment(5000) self.aout_yaw_gain.setVoltage(0.0) # Setup analog output Y self.aout_y = VoltageOutput() self.aout_y.setChannel(self.aout_channel_y) self.aout_y.openWaitForAttachment(5000) self.aout_y.setVoltage(0.0) self.print = True # Set up socket info self.HOST = '127.0.0.1' # The (receiving) host IP address (sock_host) self.PORT = 65432 # The (receiving) host port (sock_port) self.done = False self.gain_yaw = 1 self.heading_with_gain = 0 self.jump = True self.time_between_jumps = 90 self.jump_size = 0 #set up logger to save hd5f file self.logger = H5Logger( filename=self.param['logfile_name'], auto_incr=self.param['logfile_auto_incr'], auto_incr_format=self.param['logfile_auto_incr_format'], param_attr=self.param)
def __init__(self, param=DefaultParam): self.param = param self.experiment = self.param['experiment'] self.stim_speed = self.param['stim_speed'] self.turn_type = self.param['turn_type'] self.bar_offset = self.param[ 'bar_offset'] # bar relative to wind [deg] self.experiment_time = self.param['experiment_time'] self.time_start = time.time( ) # get the current time and use it as a ref for elapsed time self.stim_dir = 0 self.offset_adjust = 15 # use this offset to make bars perfectly aligned to wind, hard coded (deg) self.fly_heading = 0 # for calculating heading of the fly (rad) self.first_time_in_loop = True self.print = True # for printing the current values on the console # specify the time epochs in the experiment self.time_baseline = 10 # [s] baseline period self.epoch_dur = 200 # [s] duration of an individual epoch self.epoch_num = 6 # total number of epochs # set voltage range for Phidget self.aout_max_volt = 10.0 self.aout_min_volt = 0.0 # set up two Phidgets self.phidget_vision = 525577 # for writing Fictrac x, y, and panels (yaw_gain) self.phidget_wind = 589946 # for sending the position of the motor to NI-DAQ, actual animal yaw # Set up Phidget channels in device 1 for vision (0-index) self.aout_channel_ydimension = 0 self.aout_channel_x = 1 self.aout_channel_y = 3 self.aout_channel_yaw_gain = 2 # Setup analog output X self.aout_x = VoltageOutput() self.aout_x.setDeviceSerialNumber(self.phidget_vision) self.aout_x.setChannel(self.aout_channel_x) self.aout_x.openWaitForAttachment(5000) self.aout_x.setVoltage(0.0) # Setup analog output Y self.aout_y = VoltageOutput() self.aout_y.setDeviceSerialNumber(self.phidget_vision) self.aout_y.setChannel(self.aout_channel_y) self.aout_y.openWaitForAttachment(5000) self.aout_y.setVoltage(0.0) # Setup analog output YAW (use this channel to turn panels on and off) self.aout_ydim = VoltageOutput() self.aout_ydim.setDeviceSerialNumber(self.phidget_vision) self.aout_ydim.setChannel(self.aout_channel_ydimension) self.aout_ydim.openWaitForAttachment(5000) self.aout_ydim.setVoltage(0.0) # Setup analog output YAW gain (use this channel to control panel bar position) self.aout_yaw_gain = VoltageOutput() self.aout_yaw_gain.setDeviceSerialNumber(self.phidget_vision) self.aout_yaw_gain.setChannel(self.aout_channel_yaw_gain) self.aout_yaw_gain.openWaitForAttachment(5000) self.aout_yaw_gain.setVoltage(0.0) # Set up Phidget channels in device 2 for wind (0-index) self.aout_channel_motor = 0 self.aout_channel_yaw = 1 # for recording the actual yaw of the fly self.aout_channel_wind_valve = 2 # Setup analog output motor self.aout_motor = VoltageOutput() self.aout_motor.setDeviceSerialNumber(self.phidget_wind) self.aout_motor.setChannel(self.aout_channel_motor) self.aout_motor.openWaitForAttachment(5000) self.aout_motor.setVoltage(0.0) # Setup analog output for yaw self.aout_yaw = VoltageOutput() self.aout_yaw.setDeviceSerialNumber(self.phidget_wind) self.aout_yaw.setChannel(self.aout_channel_yaw) self.aout_yaw.openWaitForAttachment(5000) self.aout_yaw.setVoltage(0.0) # Setup analog output wind valve self.aout_wind_valve = VoltageOutput() self.aout_wind_valve.setDeviceSerialNumber(self.phidget_wind) self.aout_wind_valve.setChannel(self.aout_channel_wind_valve) self.aout_wind_valve.openWaitForAttachment(5000) self.aout_wind_valve.setVoltage(0.0) # Set up socket info for connecting with the FicTrac self.HOST = '127.0.0.1' # The (receiving) host IP address (sock_host) self.PORT = 65432 # The (receiving) host port (sock_port) # Set up Arduino connection self.COM = 'COM4' # serial port self.baudrate = 115200 # 9600 self.serialTimeout = 0.001 # blocking timeout for readline() # flag for indicating when the trial is done self.done = False #set up logger to save hd5f file self.logger_fictrac = H5Logger( filename=self.param['logfile_name'], auto_incr=self.param['logfile_auto_incr'], auto_incr_format=self.param['logfile_auto_incr_format'], param_attr=self.param) #set up logger to save hd5f file self.logger_arduino = H5Logger( filename=(self.param['logfile_name']).replace( '.hdf5', '_arduino.hdf5'), auto_incr=self.param['logfile_auto_incr'], auto_incr_format=self.param['logfile_auto_incr_format'], param_attr=self.param)
def __init__(self, param=DefaultParam): self.param = param self.experiment = self.param['experiment'] self.experiment_time = self.param['experiment_time'] self.time_start = time.time() # Set up Phidget channels self.aout_channel_ydimension = 0 #I'm setting up a channel such that I can change the y dimension of the panels sending a signal through here self.aout_channel_x = 1 self.aout_channel_yaw_gain = 2 self.aout_channel_y = 3 self.aout_max_volt = 10.0 self.aout_min_volt = 0.0 # Set up Phidget serial numbers for using two devices self.phidget_vision = 525577 # written on the back of the Phidget self.phidget_wind = 589946 # for sending the position of the motor to NI-DAQ # Setup analog output YAW self.aout_ydim = VoltageOutput() self.aout_ydim.setDeviceSerialNumber(self.phidget_vision) self.aout_ydim.setChannel(self.aout_channel_ydimension) self.aout_ydim.openWaitForAttachment(5000) self.aout_ydim.setVoltage(0.0) # Setup analog output X self.aout_x = VoltageOutput() self.aout_x.setDeviceSerialNumber(self.phidget_vision) self.aout_x.setChannel(self.aout_channel_x) self.aout_x.openWaitForAttachment(5000) self.aout_x.setVoltage(0.0) # Setup analog output YAW gain self.aout_yaw_gain = VoltageOutput() self.aout_yaw_gain.setDeviceSerialNumber(self.phidget_vision) self.aout_yaw_gain.setChannel(self.aout_channel_yaw_gain) self.aout_yaw_gain.openWaitForAttachment(5000) self.aout_yaw_gain.setVoltage(0.0) # Setup analog output Y self.aout_y = VoltageOutput() self.aout_y.setDeviceSerialNumber(self.phidget_vision) self.aout_y.setChannel(self.aout_channel_y) self.aout_y.openWaitForAttachment(5000) self.aout_y.setVoltage(9.0) # Set up Phidget channels in device 2 for wind self.aout_channel_motor = 0 self.aout_channel_wind_valve = 2 # Setup analog output motor self.aout_motor = VoltageOutput() self.aout_motor.setDeviceSerialNumber(self.phidget_wind) self.aout_motor.setChannel(self.aout_channel_motor) self.aout_motor.openWaitForAttachment(5000) self.aout_motor.setVoltage(0.0) # Setup analog output wind valve self.aout_wind_valve = VoltageOutput() self.aout_wind_valve.setDeviceSerialNumber(self.phidget_wind) self.aout_wind_valve.setChannel(self.aout_channel_wind_valve) self.aout_wind_valve.openWaitForAttachment(5000) self.aout_wind_valve.setVoltage(0.0) self.print = True # Set up socket info self.HOST = '127.0.0.1' # The (receiving) host IP address (sock_host) self.PORT = 65432 # The (receiving) host port (sock_port) # Set up Arduino connection self.COM = 'COM4' # serial port self.baudrate = 115200 # 9600 self.serialTimeout = 0.001 # blocking timeout for readline() self.done = False self.gain_yaw = 1 self.heading_with_gain = 0 self.bar_jump = True self.bar_jump_size = 0 self.wind_jump = True self.wind_jump_size = 0 #initialize the bar on and the wind off self.bar = False self.wind = True #initialize heading with respect to panels to be starting position self.motor_command = 0 self.bar_position = np.deg2rad(360 - self.param['offset']) #set up logger to save hd5f file self.logger_fictrac = H5Logger( filename=self.param['logfile_name'], auto_incr=self.param['logfile_auto_incr'], auto_incr_format=self.param['logfile_auto_incr_format'], param_attr=self.param) #set up logger to save hd5f file self.logger_arduino = H5Logger( filename=(self.param['logfile_name']).replace( '.hdf5', '_arduino.hdf5'), auto_incr=self.param['logfile_auto_incr'], auto_incr_format=self.param['logfile_auto_incr_format'], param_attr=self.param) #specify a variable for the first message being read self.first_time_in_loop = True
def __init__(self, param=DefaultParam): self.param = param self.experiment = self.param['experiment'] self.experiment_time = self.param['experiment_time'] self.time_start = time.time( ) # get the current time and use it as a ref for elapsed time #get gain for the panels and wind self.gain_panels = self.param['gain_panels'] self.gain_wind = self.param['gain_wind'] # Set up Phidget serial numbers for using two devices self.phidget_vision = 525577 # written on the back of the Phidget self.phidget_wind = 589946 # for sending the position of the motor to NI-DAQ # Set up Phidget channels in device 1 for vision (0-index) self.aout_channel_yaw = 0 self.aout_channel_x = 1 self.aout_channel_yaw_gain = 2 self.aout_channel_y = 3 self.aout_max_volt = 10.0 self.aout_min_volt = 0.0 # Setup analog output YAW self.aout_yaw = VoltageOutput() self.aout_yaw.setDeviceSerialNumber(self.phidget_vision) self.aout_yaw.setChannel(self.aout_channel_yaw) self.aout_yaw.openWaitForAttachment(5000) self.aout_yaw.setVoltage(0.0) # Setup analog output X self.aout_x = VoltageOutput() self.aout_x.setDeviceSerialNumber(self.phidget_vision) self.aout_x.setChannel(self.aout_channel_x) self.aout_x.openWaitForAttachment(5000) self.aout_x.setVoltage(0.0) # Setup analog output YAW gain self.aout_yaw_gain = VoltageOutput() self.aout_yaw_gain.setDeviceSerialNumber(self.phidget_vision) self.aout_yaw_gain.setChannel(self.aout_channel_yaw_gain) self.aout_yaw_gain.openWaitForAttachment(5000) self.aout_yaw_gain.setVoltage(0.0) # Setup analog output Y self.aout_y = VoltageOutput() self.aout_y.setDeviceSerialNumber(self.phidget_vision) self.aout_y.setChannel(self.aout_channel_y) self.aout_y.openWaitForAttachment(5000) self.aout_y.setVoltage(0.0) # Set up Phidget channels in device 2 for wind (0-index) self.aout_channel_motor = 0 self.aout_channel_wind_valve = 2 # Setup analog output motor self.aout_motor = VoltageOutput() self.aout_motor.setDeviceSerialNumber(self.phidget_wind) self.aout_motor.setChannel(self.aout_channel_motor) self.aout_motor.openWaitForAttachment(5000) self.aout_motor.setVoltage(0.0) # Setup analog output wind valve self.aout_wind_valve = VoltageOutput() self.aout_wind_valve.setDeviceSerialNumber(self.phidget_wind) self.aout_wind_valve.setChannel(self.aout_channel_wind_valve) self.aout_wind_valve.openWaitForAttachment(5000) self.aout_wind_valve.setVoltage(0.0) self.print = True # Set up socket info for connecting with the FicTrac self.HOST = '127.0.0.1' # The (receiving) host IP address (sock_host) self.PORT = 65432 # The (receiving) host port (sock_port) # Set up Arduino connection self.COM = 'COM4' # serial port self.baudrate = 115200 # 9600 self.serialTimeout = 0.001 # blocking timeout for readline() # flag for indicating when the trial is done self.done = False #initialize heading with respect to panels to be starting position self.motor_command = 0 self.bar_position = np.deg2rad(360 - self.param['offset']) self.jump = True self.time_between_jumps = 90 # [s] self.jump_mag = 90 # [deg] jump magnitude self.jump_size = 0 # default value is zero #set up logger to save hd5f file self.logger_fictrac = H5Logger( filename=self.param['logfile_name'], auto_incr=self.param['logfile_auto_incr'], auto_incr_format=self.param['logfile_auto_incr_format'], param_attr=self.param) #set up logger to save hd5f file self.logger_arduino = H5Logger( filename=(self.param['logfile_name']).replace( '.hdf5', '_arduino.hdf5'), auto_incr=self.param['logfile_auto_incr'], auto_incr_format=self.param['logfile_auto_incr_format'], param_attr=self.param) #specify a variable for the first message being read self.first_time_in_loop = True
def __init__(self, param=DefaultParam): self.param = param self.experiment = self.param['experiment'] self.stim_speed = self.param['stim_speed'] self.turn_type = self.param['turn_type'] self.experiment_time = self.param['experiment_time'] self.time_start = time.time( ) # get the current time and use it as a ref for elapsed time self.current_wind_dir = 0 # Set up Phidget serial numbers for using two devices self.phidget_vision = 525577 # written on the back of the Phidget self.phidget_wind = 589946 # for sending the position of the motor to NI-DAQ # Set up Phidget channels in device 1 for vision (0-index) self.aout_channel_yaw = 0 self.aout_channel_x = 1 self.aout_channel_yaw_gain = 2 self.aout_channel_y = 3 self.aout_max_volt = 10.0 self.aout_min_volt = 0.0 # Setup analog output YAW self.aout_yaw = VoltageOutput() self.aout_yaw.setDeviceSerialNumber(self.phidget_vision) self.aout_yaw.setChannel(self.aout_channel_yaw) self.aout_yaw.openWaitForAttachment(5000) self.aout_yaw.setVoltage(0.0) # Setup analog output X self.aout_x = VoltageOutput() self.aout_x.setDeviceSerialNumber(self.phidget_vision) self.aout_x.setChannel(self.aout_channel_x) self.aout_x.openWaitForAttachment(5000) self.aout_x.setVoltage(0.0) # Setup analog output YAW gain self.aout_yaw_gain = VoltageOutput() self.aout_yaw_gain.setDeviceSerialNumber(self.phidget_vision) self.aout_yaw_gain.setChannel(self.aout_channel_yaw_gain) self.aout_yaw_gain.openWaitForAttachment(5000) self.aout_yaw_gain.setVoltage(0.0) # Setup analog output Y self.aout_y = VoltageOutput() self.aout_y.setDeviceSerialNumber(self.phidget_vision) self.aout_y.setChannel(self.aout_channel_y) self.aout_y.openWaitForAttachment(5000) self.aout_y.setVoltage(0.0) # Set up Phidget channels in device 2 for wind (0-index) self.aout_channel_motor = 0 self.aout_channel_wind_valve = 2 # Setup analog output motor self.aout_motor = VoltageOutput() self.aout_motor.setDeviceSerialNumber(self.phidget_wind) self.aout_motor.setChannel(self.aout_channel_motor) self.aout_motor.openWaitForAttachment(5000) self.aout_motor.setVoltage(0.0) # Setup analog output wind valve self.aout_wind_valve = VoltageOutput() self.aout_wind_valve.setDeviceSerialNumber(self.phidget_wind) self.aout_wind_valve.setChannel(self.aout_channel_wind_valve) self.aout_wind_valve.openWaitForAttachment(5000) self.aout_wind_valve.setVoltage(0.0) self.print = True # Set up socket info for connecting with the FicTrac self.HOST = '127.0.0.1' # The (receiving) host IP address (sock_host) self.PORT = 65432 # The (receiving) host port (sock_port) # Set up Arduino connection self.COM = 'COM4' # serial port self.baudrate = 115200 # 9600 self.serialTimeout = 0.001 # blocking timeout for readline() # flag for indicating when the trial is done self.done = False #set up logger to save hd5f file self.logger_fictrac = H5Logger( filename=self.param['logfile_name'], auto_incr=self.param['logfile_auto_incr'], auto_incr_format=self.param['logfile_auto_incr_format'], param_attr=self.param) #set up logger to save hd5f file self.logger_arduino = H5Logger( filename=(self.param['logfile_name']).replace( '.hdf5', '_arduino.hdf5'), auto_incr=self.param['logfile_auto_incr'], auto_incr_format=self.param['logfile_auto_incr_format'], param_attr=self.param)
def __init__(self, param=DefaultParam): self.param = param self.experiment = self.param['experiment'] self.experiment_time = self.param['experiment_time'] self.time_start = time.time() # Set up Phidget channels self.aout_channel_ydimension = 0 self.aout_channel_x = 1 self.aout_channel_yaw_gain = 2 self.aout_channel_y = 3 self.aout_max_volt = 10.0 self.aout_min_volt = 0.0 # Set up Phidget serial numbers for using two devices self.phidget_vision = 525577 # written on the back of the Phidget self.phidget_heading = 589946 # Setup analog output y dim, to change the y dimension of the stimulus self.aout_ydim = VoltageOutput() self.aout_ydim.setDeviceSerialNumber(self.phidget_vision) self.aout_ydim.setChannel(self.aout_channel_ydimension) self.aout_ydim.openWaitForAttachment(5000) self.aout_ydim.setVoltage(0.0) # Setup analog output X self.aout_x = VoltageOutput() self.aout_x.setDeviceSerialNumber(self.phidget_vision) self.aout_x.setChannel(self.aout_channel_x) self.aout_x.openWaitForAttachment(5000) self.aout_x.setVoltage(0.0) # Setup analog output YAW gain self.aout_yaw_gain = VoltageOutput() self.aout_yaw_gain.setDeviceSerialNumber(self.phidget_vision) self.aout_yaw_gain.setChannel(self.aout_channel_yaw_gain) self.aout_yaw_gain.openWaitForAttachment(5000) self.aout_yaw_gain.setVoltage(0.0) # Setup analog output Y self.aout_y = VoltageOutput() self.aout_y.setDeviceSerialNumber(self.phidget_vision) self.aout_y.setChannel(self.aout_channel_y) self.aout_y.openWaitForAttachment(5000) self.aout_y.setVoltage(9.0) # Set up Phidget channels in device 2 to save the heading self.aout_heading_channel = 1 # Setup analog output motor self.aout_heading = VoltageOutput() self.aout_heading.setDeviceSerialNumber(self.phidget_heading) self.aout_heading.setChannel(self.aout_heading_channel) self.aout_heading.openWaitForAttachment(5000) self.aout_heading.setVoltage(0.0) self.print = True # Set up socket info self.HOST = '127.0.0.1' # The (receiving) host IP address (sock_host) self.PORT = 65432 # The (receiving) host port (sock_port) # Set up Arduino connection self.COM = 'COM4' # serial port self.baudrate = 115200 # 9600 self.serialTimeout = 0.001 # blocking timeout for readline() self.done = False self.gain_yaw = 1 self.heading_with_gain = 0 self.bar_jump = True self.bar_jump_size = 0 #initialize the bar on self.bar = True self.bar_moving = True #define times when bar will be turned off self.turn_off_times = np.linspace(900, 3525, 26) #self.turn_off_times = np.linspace(30,300,7) #uncomment for testing #initialize heading with respect to panels to be starting position self.bar_position = np.deg2rad(360 - self.param['offset']) #set up logger to save hd5f file self.logger_fictrac = H5Logger( filename=self.param['logfile_name'], auto_incr=self.param['logfile_auto_incr'], auto_incr_format=self.param['logfile_auto_incr_format'], param_attr=self.param) #specify a variable for the first message being read self.first_time_in_loop = True
def __init__(self, param=DefaultParam): self.param = param self.experiment = self.param['experiment'] self.experiment_time = self.param['experiment_time'] self.time_start = time.time() # Set up Phidget channels self.aout_channel_yaw = 0 self.aout_channel_x = 1 self.aout_channel_yaw_gain = 2 self.aout_channel_y = 3 self.aout_max_volt = 10.0 self.aout_min_volt = 0.0 # Set up Phidget serial numbers for using two devices self.phidget_vision = 525577 # written on the back of the Phidget self.phidget_wind = 589946 # for sending the position of the motor to NI-DAQ # Setup analog output YAW self.aout_yaw = VoltageOutput() self.aout_yaw.setDeviceSerialNumber(self.phidget_vision) self.aout_yaw.setChannel(self.aout_channel_yaw) self.aout_yaw.openWaitForAttachment(5000) self.aout_yaw.setVoltage(0.0) # Setup analog output X self.aout_x = VoltageOutput() self.aout_x.setDeviceSerialNumber(self.phidget_vision) self.aout_x.setChannel(self.aout_channel_x) self.aout_x.openWaitForAttachment(5000) self.aout_x.setVoltage(0.0) # Setup analog output YAW gain self.aout_yaw_gain = VoltageOutput() self.aout_yaw_gain.setDeviceSerialNumber(self.phidget_vision) self.aout_yaw_gain.setChannel(self.aout_channel_yaw_gain) self.aout_yaw_gain.openWaitForAttachment(5000) self.aout_yaw_gain.setVoltage(0.0) # Setup analog output Y self.aout_y = VoltageOutput() self.aout_y.setDeviceSerialNumber(self.phidget_vision) self.aout_y.setChannel(self.aout_channel_y) self.aout_y.openWaitForAttachment(5000) self.aout_y.setVoltage(0.0) self.print = True # Set up socket info self.HOST = '127.0.0.1' # The (receiving) host IP address (sock_host) #self.HOST = '10.119.97.141' self.PORT = 65432 # The (receiving) host port (sock_port) self.done = False # Set initial bar position self.bar_position = np.deg2rad( 360 - self.param['offset']) # right to the fly is +90 deg #set up logger to save hd5f file self.logger = H5Logger( filename=self.param['logfile_name'], auto_incr=self.param['logfile_auto_incr'], auto_incr_format=self.param['logfile_auto_incr_format'], param_attr=self.param) #specify a variable for the first message being read self.first_time_in_loop = True