def setup_experiment(self, info):
        circuit = join(get_config('RCX_ROOT'), 'positive-behavior-v2')
        self.iface_behavior = self.process.load_circuit(circuit, 'RZ6')

        self.buffer_out = self.iface_behavior.get_buffer('out', 'w')
        self.buffer_TTL1 = self.iface_behavior.get_buffer('TTL', 'r',
                src_type='int8', dest_type='int8', block_size=24)
        self.buffer_TTL2 = self.iface_behavior.get_buffer('TTL2', 'r',
                src_type='int8', dest_type='int8', block_size=24)
        self.buffer_poke_start = self.iface_behavior.get_buffer('poke_all/',
                'r', src_type='int32', dest_type='int32', block_size=1)
        self.buffer_poke_end = self.iface_behavior.get_buffer('poke_all\\', 'r',
                src_type='int32', dest_type='int32', block_size=1)

        # microphone
        self.buffer_mic = self.iface_behavior.get_buffer('mic', 'r')
        self.model.data.microphone.fs = self.buffer_mic.fs

        self.fs_conversion = self.iface_behavior.get_tag('TTL_d')

        # Stored in TTL1
        self.model.data.spout_TTL.fs = self.buffer_TTL1.fs
        self.model.data.poke_TTL.fs = self.buffer_TTL1.fs
        self.model.data.signal_TTL.fs = self.buffer_TTL1.fs
        self.model.data.reaction_TTL.fs = self.buffer_TTL1.fs
        self.model.data.response_TTL.fs = self.buffer_TTL1.fs
        self.model.data.reward_TTL.fs = self.buffer_TTL1.fs

        # Stored in TTL2
        self.model.data.TO_TTL.fs = self.buffer_TTL2.fs

        # Timestamp data
        self.model.data.trial_epoch.fs = self.iface_behavior.fs
        self.model.data.signal_epoch.fs = self.iface_behavior.fs
        self.model.data.poke_epoch.fs = self.iface_behavior.fs
        self.model.data.all_poke_epoch.fs = self.iface_behavior.fs
        self.model.data.response_ts.fs = self.iface_behavior.fs

        targets1 = [self.model.data.poke_TTL, self.model.data.spout_TTL,
                    self.model.data.reaction_TTL, self.model.data.signal_TTL,
                    self.model.data.response_TTL, self.model.data.reward_TTL, ]
        targets2 = [None, self.model.data.TO_TTL]

        self.pipeline_TTL1 = deinterleave_bits(targets1)
        self.pipeline_TTL2 = deinterleave_bits(targets2)

        # Configure the pump
        self.iface_pump.set_trigger(start='rising', stop=None)
        self.iface_pump.set_direction('infuse')
    def setup_experiment(self, info):
        circuit = join(get_config("RCX_ROOT"), "positive-behavior-stage1")
        self.iface_behavior = self.process.load_circuit(circuit, "RZ6")
        self.buffer_signal = self.iface_behavior.get_buffer("signal", "w")
        self.buffer_TTL = self.iface_behavior.get_buffer("TTL", "r", block_size=24, src_type="int8", dest_type="int8")
        self.buffer_mic = self.iface_behavior.get_buffer("mic", "r")

        self.model.data.spout_TTL.fs = self.buffer_TTL.fs
        self.model.data.override_TTL.fs = self.buffer_TTL.fs
        self.model.data.pump_TTL.fs = self.buffer_TTL.fs
        self.model.data.signal_TTL.fs = self.buffer_TTL.fs
        self.model.data.free_run_TTL.fs = self.buffer_TTL.fs
        self.model.data.microphone.fs = self.buffer_mic.fs

        targets = [
            self.model.data.spout_TTL,
            self.model.data.override_TTL,
            self.model.data.pump_TTL,
            self.model.data.signal_TTL,
            self.model.data.free_run_TTL,
        ]
        self.pipeline_TTL = deinterleave_bits(targets)

        self.iface_pump.set_trigger(start="rising", stop="falling")
        self.iface_pump.set_direction("infuse")
        self.iface_pump.set_volume(0)
    def setup_experiment(self, info):
        self._setup_pump()
        self._setup_shock()
        self._setup_circuit()

        # Ensure that sampling frequencies are stored properly
        self.model.data.contact_digital.fs = self.buffer_TTL.fs
        self.model.data.contact_digital_mean.fs = self.buffer_contact.fs
        self.model.data.trial_running.fs = self.buffer_TTL.fs
        self.model.data.shock_running.fs = self.buffer_TTL.fs
        self.model.data.warn_running.fs = self.buffer_TTL.fs

        self.model.data.trial_epoch.fs = self.iface_behavior.fs
        self.model.data.spout_epoch.fs = self.iface_behavior.fs
        self.model.data.reaction_ts.fs = self.iface_behavior.fs

        # Since several streams of data are compressed into individual bits
        # (which are transmitted to the computer as an 8-bit integer), we need
        # to decompress them (via int_to_TTL) and store them in the appropriate
        # data buffers via deinterleave.
        targets = [ self.model.data.trial_running, 
                    self.model.data.contact_digital,
                    self.model.data.shock_running,
                    self.model.data.warn_running, ]
        self.pipeline_TTL = deinterleave_bits(targets)
        self.fs_conversion = self.iface_behavior.get_tag('TTL_d')

        # The buffer for contact_digital_mean does not need any processing, so
        # we just grab it and pass it along to the data buffer.
        self.pipeline_contact = self.model.data.contact_digital_mean
    def setup_experiment(self, info):
        filename = 'positive-behavior-training-contmask-v4'
        circuit = path.join(get_config('RCX_ROOT'), filename)
        self.iface_behavior = self.process.load_circuit(circuit, 'RZ6')
        self.buffer_masker = self.iface_behavior.get_buffer('masker', 'w')
        self.buffer_target = self.iface_behavior.get_buffer('target', 'w')

        self.buffer_TTL = self.iface_behavior.get_buffer('TTL', 'r',
                block_size=24, src_type='int8', dest_type='int8')
        self.buffer_mic = self.iface_behavior.get_buffer('mic', 'r')
        self.model.data.spout_TTL.fs = self.buffer_TTL.fs
        self.model.data.override_TTL.fs = self.buffer_TTL.fs
        self.model.data.pump_TTL.fs = self.buffer_TTL.fs
        self.model.data.signal_TTL.fs = self.buffer_TTL.fs
        self.model.data.free_run_TTL.fs = self.buffer_TTL.fs
        self.model.data.microphone.fs = self.buffer_mic.fs

        targets = [self.model.data.spout_TTL,
                   self.model.data.override_TTL,
                   self.model.data.pump_TTL, 
                   self.model.data.signal_TTL,
                   self.model.data.free_run_TTL ]
        self.pipeline_TTL = deinterleave_bits(targets)

        self.iface_pump.set_trigger(start='rising', stop='falling')
        self.iface_pump.set_direction('infuse')
        self.iface_pump.set_volume(0)
    def update_data(self):
        # Ensure that the data store has the correct sampling frequency
        for i in range(CHANNELS):
            data_spikes = self.model.data.spikes
            for src, dest in zip(self.buffer_spikes, data_spikes):
                dest.fs = src.fs
                dest.snippet_size = SPIKE_SNIPPET_SIZE
        self.model.data.raw.fs = self.buffer_raw.fs
        self.model.data.processed.fs = self.buffer_filt.fs
        self.model.data.ts.fs = self.iface_physiology.fs
        self.model.data.epoch.fs = self.iface_physiology.fs
        self.model.data.sweep.fs = self.buffer_ttl.fs

        # Setup the pipeline
        targets = [self.model.data.sweep]
        self.physiology_ttl_pipeline = deinterleave_bits(targets)
Esempio n. 6
0
    def setup_experiment(self, info):
        circuit = path.join(get_config('RCX_ROOT'), 'positive-behavior-contmask-v4')
        self.iface_behavior = self.process.load_circuit(circuit, 'RZ6')

        self.buffer_target = self.iface_behavior.get_buffer('target', 'w')
        self.buffer_masker = self.iface_behavior.get_buffer('masker', 'w')

        self.buffer_TTL1 = self.iface_behavior.get_buffer('TTL', 'r',
                src_type='int8', dest_type='int8', block_size=24)
        self.buffer_TTL2 = self.iface_behavior.get_buffer('TTL2', 'r',
                src_type='int8', dest_type='int8', block_size=24)
        self.buffer_poke_start = self.iface_behavior.get_buffer('poke_all/',
                'r', src_type='int32', dest_type='int32', block_size=1)
        self.buffer_poke_end = self.iface_behavior.get_buffer('poke_all\\', 'r',
                src_type='int32', dest_type='int32', block_size=1)

        # microphone
        self.buffer_mic = self.iface_behavior.get_buffer('mic', 'r')
        self.model.data.microphone.fs = self.buffer_mic.fs

        self.fs_conversion = self.iface_behavior.get_tag('TTL_d')

        # Stored in TTL1
        self.model.data.spout_TTL.fs = self.buffer_TTL1.fs
        self.model.data.poke_TTL.fs = self.buffer_TTL1.fs
        self.model.data.signal_TTL.fs = self.buffer_TTL1.fs
        self.model.data.reaction_TTL.fs = self.buffer_TTL1.fs
        self.model.data.response_TTL.fs = self.buffer_TTL1.fs
        self.model.data.reward_TTL.fs = self.buffer_TTL1.fs

        # Stored in TTL2
        self.model.data.TO_TTL.fs = self.buffer_TTL2.fs

        # Timestamp data
        self.model.data.trial_epoch.fs = self.iface_behavior.fs
        self.model.data.signal_epoch.fs = self.iface_behavior.fs
        self.model.data.poke_epoch.fs = self.iface_behavior.fs
        self.model.data.all_poke_epoch.fs = self.iface_behavior.fs
        self.model.data.response_ts.fs = self.iface_behavior.fs

        targets1 = [self.model.data.poke_TTL, self.model.data.spout_TTL,
                    self.model.data.reaction_TTL, self.model.data.signal_TTL,
                    self.model.data.response_TTL, self.model.data.reward_TTL, ]

        # If the target is set to None, this means that we aren't interested in
        # capturing the value of that specific bit.  Nothing is stored in the
        # first bit of the TTL_2 data; however, we store the timeout TTL in the
        # second bit.
        targets2 = [None, self.model.data.TO_TTL]

        # deinterleave_bits is the Python complement of the RPvds FromBits
        # component that breaks down the integer into its individual bits.
        # Targets are the destination channel (which map to the underlying HDF5
        # array) for each bit.  e.g. the value of the first bit gets sent to
        # targets1[0] (which is the poke_TTL).  deinterleave_bits is a
        # "pipeline" function that automatically performs its function each time
        # new data arrives and hands the result off to the targets.  The targets
        # recieve this data and store it in the HDF5 array and notify the GUI
        # that new data has arrived and should be plotted.
        self.pipeline_TTL1 = deinterleave_bits(targets1)
        self.pipeline_TTL2 = deinterleave_bits(targets2)

        # Configure the pump
        self.iface_pump.set_trigger(start='rising', stop=None)
        self.iface_pump.set_direction('infuse')