示例#1
0
 def next_trial(self):
     # First trial exception
     if self.trial_num == 0:
         self.trial_num += 1
         # Send next trial info to Bonsai
         bonsai.send_current_trial_info(self)
         return
     self.data_file = str(self.data_file)
     # Increment trial number
     self.trial_num += 1
     # Update contrast
     self.contrast = random.choice(self.contrast_set)
     # Update stimulus phase
     self.stim_phase = random.uniform(0, 2 * math.pi)
     # Update position
     self.position = random.choice(self.position_set)
     # Update delay to stimulus center
     self.delay_to_stim_center = np.random.normal(
         self.delay_to_stim_center_mean, 2)
     # Update water delivered
     self.water_delivered += self.reward_amount
     # Open the data file to append the next trial
     self.data_file = open(self.data_file_path, "a")
     # Send next trial info to Bonsai
     bonsai.send_current_trial_info(self)
    def next_trial(self):
        # First trial exception
        if self.trial_num == 0:
            self.trial_num += 1
            # Send next trial info to Bonsai
            bonsai.send_current_trial_info(self)
            return
        self.data_file = str(self.data_file)
        # update + next contrast: update buffers/counters + get next contrast
        # This has to happen before self.contrast is pointing to next trials
        self.contrast.next_trial(self.position)  # still prev_position

        # Increment trial number
        self.trial_num += 1
        # Update quiescent period
        self.quiescent_period = self.quiescent_period_base + misc.texp()
        # Update stimulus phase
        self.stim_phase = random.uniform(0, math.pi)
        # Update contrast
        self._next_contrast()
        # Update position
        self.position, self.stim_probability_left = self._next_position()
        # Update signed_contrast and buffer (AFTER position update)
        self.signed_contrast = self.contrast.value * np.sign(self.position)
        self.signed_contrast_buffer.append(self.signed_contrast)
        # Update state machine events
        self.event_error = self.threshold_events_dict[self.position]
        self.event_reward = self.threshold_events_dict[-self.position]
        # Reset outcome variables for next trial
        self.trial_correct = None
        # Open the data file to append the next trial
        self.data_file = open(self.data_file_path, 'a')
        # Send next trial info to Bonsai
        bonsai.send_current_trial_info(self)
 def next_trial(self):
     # First trial exception
     if self.trial_num == 0:
         self.trial_num += 1
         # Send next trial info to Bonsai
         bonsai.send_current_trial_info(self)
         return
     self.data_file = str(self.data_file)
     # Increment trial number
     self.trial_num += 1
     # Open the data file to append the next trial
     self.data_file = open(self.data_file_path, 'a')
     # Send next trial info to Bonsai
     bonsai.send_current_trial_info(self)
示例#4
0
 def next_trial(self):
     # First trial exception
     if self.trial_num == 0:
         self.trial_num += 1
         self.block_num += 1
         self.block_trial_num += 1
         # Send next trial info to Bonsai
         bonsai.send_current_trial_info(self)
         return
     self.data_file = str(self.data_file)
     # Increment trial number
     self.trial_num += 1
     # Update quiescent period
     self.quiescent_period = self.quiescent_period_base + misc.texp()
     # Update stimulus phase
     self.stim_phase = random.uniform(0, 2 * math.pi)
     # Update block
     self = update_block_params(self)
     # Update stim probability left + buffer
     self.stim_probability_left = update_probability_left(self)
     self.stim_probability_left_buffer.append(self.stim_probability_left)
     # Update position + buffer
     self.position = draw_position(self.position_set,
                                   self.stim_probability_left)
     self.position_buffer.append(self.position)
     # Update reward
     self.left_reward, self.right_reward = draw_reward(
         self.stim_probability_left)
     # Update contrast + buffer
     self.contrast = misc.draw_contrast(
         self.contrast_set, prob_type=self.contrast_set_probability_type)
     self.contrast_buffer.append(self.contrast)
     # Update signed_contrast + buffer (AFTER position update)
     self.signed_contrast = self.contrast * np.sign(self.position)
     self.signed_contrast_buffer.append(self.signed_contrast)
     # Update state machine events
     self.event_error = self.threshold_events_dict[self.position]
     self.event_reward = self.threshold_events_dict[-self.position]
     # Reset outcome variables for next trial
     self.trial_correct = None
     # Open the data file to append the next trial
     self.data_file = open(self.data_file_path, "a")
     # Send next trial info to Bonsai
     bonsai.send_current_trial_info(self)
示例#5
0
 def next_trial(self):
     # First trial exception
     if self.trial_num == 0:
         self.trial_num += 1
         self.block_num += 1
         self.block_trial_num += 1
         # Send next trial info to Bonsai
         bonsai.send_current_trial_info(self)
         return
     self.data_file = str(self.data_file)
     # Increment trial number
     self.trial_num += 1
     # Update quiescent period
     self.quiescent_period = self.quiescent_period_buffer[self.trial_num -
                                                          1]
     # Update stimulus phase
     self.stim_phase = self.stim_phase_buffer[self.trial_num - 1]
     # Update block
     self.block_trial_num += 1
     if self.block_trial_num > self.block_len:
         self.block_num += 1
         self.block_trial_num = 1
         self.block_len = self.len_blocks_buffer[self.block_num - 1]
     # Update stim probability left + buffer
     self.stim_probability_left = blocks.calc_probability_left(self)
     self.stim_probability_left_buffer.append(self.stim_probability_left)
     # Update position + buffer
     self.position = int(self.position_buffer[self.trial_num - 1])
     # Update contrast + buffer
     self.contrast = self.contrast_buffer[self.trial_num - 1]
     # Update signed_contrast + buffer (AFTER position update)
     self.signed_contrast = self.contrast * np.sign(self.position)
     self.signed_contrast_buffer.append(self.signed_contrast)
     # Update state machine events
     self.event_error = self.threshold_events_dict[self.position]
     self.event_reward = self.threshold_events_dict[-self.position]
     # Reset outcome variables for next trial
     self.trial_correct = None
     # Open the data file to append the next trial
     self.data_file = open(self.data_file_path, "a")
     # Send next trial info to Bonsai
     bonsai.send_current_trial_info(self)