Ejemplo n.º 1
0
        def temp():
            self.recent_state = block_num
            self.log.warning('Starting %s'%(self.block_name(block_num)))
            if 'free_food_schedule' in self.parameters:
                if utils.check_time(self.parameters['free_food_schedule']):
                    return 'free_food_block'
            utils.run_state_machine(    start_in='init',
                                        error_state='wait',
                                        error_callback=self.error_callback,
                                        init=self._block_init('wait'),
                                        wait=self._wait_block(10, 40,'check'),
                                        check=self._check_block('flash_mid', 1, float('inf')),
                                        flash_mid=self._flash_poll(self.panel.center, 5, 'reward', 'pre_reward'),
                                        pre_reward=self._pre_reward('reward'),
                                        reward=self.reward(5, 'check2'),
                                        check2=self._check_block('wait', 1, float('inf')))


            # check if its time for free food
            if 'free_food_schedule' in self.parameters:
                if utils.check_time(self.parameters['free_food_schedule']):
                    return 'free_food_block'

            if not utils.check_time(self.parameters['light_schedule']):
                return 'sleep_block'
            return self.block_name(block_num + 1)
Ejemplo n.º 2
0
 def temp():
     self.recent_state = block_num
     self.log.info('Starting %s'%(self.block_name(block_num)))
     utils.run_state_machine(    start_in='init',
                                 error_state='check',
                                 error_callback=self.error_callback,
                                 init=self._block_init('check'),
                                 check=self._check_block('poll_mid', reps, revert_timeout),
                                 poll_mid=self._poll(self.panel.center, 10, 'check', 'coin_flip'),
                                 coin_flip=self._rand_state(('check_right', 'check_center', 'check_left')),
                                 check_right=self._check_block('audio_right', reps, revert_timeout),
                                 audio_right=self._play_audio('poll_right', 'R'),
                                 poll_right=self._flash_poll(self.panel.right, 10, 'check_right', 'close_audio'),
                                 check_center=self._check_block('audio_center', reps, revert_timeout),
                                 audio_center=self._play_audio('poll_center', 'C'),
                                 poll_center=self._flash_poll(self.panel.center, 10, 'check_center', 'close_audio'),
                                 check_left=self._check_block('audio_left', reps, revert_timeout),
                                 audio_left=self._play_audio('poll_left', 'L'),
                                 poll_left=self._flash_poll(self.panel.left, 10, 'check_left', 'close_audio'),
                                 close_audio=self._close_audio('pre_reward'),
                                 pre_reward=self._pre_reward('reward'),
                                 reward=self.reward(2.5, 'check'))
     if not utils.check_time(self.parameters['light_schedule']):
         return 'sleep_block'
     if self.responded_block:
         return self.block_name(block_num + 1)
     else:
         return self.block_name(block_num - 1)
Ejemplo n.º 3
0
 def temp():
     self.recent_state = block_num
     self.log.warning('Starting %s' % (self.block_name(block_num)))
     utils.run_state_machine(
         start_in='init',
         error_state='check',
         error_callback=self.error_callback,
         init=self._block_init('check'),
         check=self._check_block('poll_mid', reps, revert_timeout),
         poll_mid=self._poll(self.panel.center, 10, 'check',
                             'coin_flip'),
         coin_flip=self._rand_state(
             ('check_right', 'check_center', 'check_left')),
         check_right=self._check_block('poll_right', reps,
                                       revert_timeout),
         poll_right=self._flash_poll(self.panel.right, 10,
                                     'check_right', 'pre_reward'),
         check_center=self._check_block('poll_center', reps,
                                        revert_timeout),
         poll_center=self._flash_poll(self.panel.center, 10,
                                      'check_center', 'pre_reward'),
         check_left=self._check_block('poll_left', reps,
                                      revert_timeout),
         poll_left=self._flash_poll(self.panel.left, 10, 'check_left',
                                    'pre_reward'),
         pre_reward=self._pre_reward('reward'),
         reward=self.reward(2.5, 'check'))
     if not utils.check_time(self.parameters['light_schedule']):
         return 'sleep_block'
     if self._check_free_food_block(): return 'free_food_block'
     if self.responded_block:
         return self.block_name(block_num + 1)
     else:
         return self.block_name(block_num - 1)
Ejemplo n.º 4
0
 def temp():
     self.recent_state = block_num
     self.log.info("Starting %s" % (self.block_name(block_num)))
     utils.run_state_machine(
         start_in="init",
         error_state="check",
         error_callback=self.error_callback,
         init=self._block_init("check"),
         check=self._check_block("poll_mid", reps, revert_timeout),
         poll_mid=self._poll(self.panel.center, 10, "check", "coin_flip"),
         coin_flip=self._rand_state(("check_right", "check_center", "check_left")),
         check_right=self._check_block("audio_right", reps, revert_timeout),
         audio_right=self._play_audio("poll_right", "R"),
         poll_right=self._flash_poll(self.panel.right, 10, "check_right", "close_audio"),
         check_center=self._check_block("audio_center", reps, revert_timeout),
         audio_center=self._play_audio("poll_center", "C"),
         poll_center=self._flash_poll(self.panel.center, 10, "check_center", "close_audio"),
         check_left=self._check_block("audio_left", reps, revert_timeout),
         audio_left=self._play_audio("poll_left", "L"),
         poll_left=self._flash_poll(self.panel.left, 10, "check_left", "close_audio"),
         close_audio=self._close_audio("pre_reward"),
         pre_reward=self._pre_reward("reward"),
         reward=self.reward(2.5, "check"),
     )
     if not utils.check_time(self.parameters["light_schedule"]):
         return "sleep_block"
     if self.responded_block:
         return self.block_name(block_num + 1)
     else:
         return self.block_name(block_num - 1)
Ejemplo n.º 5
0
        def temp():
            self.recent_state = block_num
            self.log.warning('Starting %s'%(self.block_name(block_num)))
            utils.run_state_machine(    start_in='init',
                                        error_state='check',
                                        error_callback=self.error_callback,
                                        init=self._block_init('check'),
                                        check=self._check_block('poll_mid', reps, revert_timeout),
                                        poll_mid=self._flash_poll(self.panel.center, 10, 'check', 'coin_flip'),
                                        coin_flip=self._rand_state(('check_right', 'check_left')),
                                        check_right=self._check_block('poll_right', reps, revert_timeout),
                                        poll_right=self._flash_poll(self.panel.right, 10, 'check_right', 'pre_reward'),
                                        check_left=self._check_block('poll_left', reps, revert_timeout),
                                        poll_left=self._flash_poll(self.panel.left, 10, 'check_left', 'pre_reward'),
                                        pre_reward=self._pre_reward('reward'),
                                        reward=self.reward(3, 'check'))
            if not utils.check_time(self.parameters['light_schedule']):
                return 'sleep_block'
            if 'free_food_schedule' in self.parameters:
                if utils.check_time(self.parameters['free_food_schedule']):
                    return 'free_food_block'

            if self.responded_block:
                return self.block_name(block_num + 1)
            else:
                return self.block_name(block_num - 1)
Ejemplo n.º 6
0
        def temp():
            self.recent_state = block_num
            self.log.warning('Starting %s' % (self.block_name(block_num)))
            if 'free_food_schedule' in self.parameters:
                if utils.check_time(self.parameters['free_food_schedule']):
                    return 'free_food_block'
            utils.run_state_machine(
                start_in='init',
                error_state='wait',
                error_callback=self.error_callback,
                init=self._block_init('wait'),
                wait=self._wait_block(10, 40, 'check'),
                check=self._check_block('flash_mid', 1, float('inf')),
                flash_mid=self._flash_poll(self.panel.center, 5, 'reward',
                                           'pre_reward'),
                pre_reward=self._pre_reward('reward'),
                reward=self.reward(5, 'check2'),
                check2=self._check_block('wait', 1, float('inf')))

            # check if its time for free food
            if 'free_food_schedule' in self.parameters:
                if utils.check_time(self.parameters['free_food_schedule']):
                    return 'free_food_block'

            if not utils.check_time(self.parameters['light_schedule']):
                return 'sleep_block'
            return self.block_name(block_num + 1)
Ejemplo n.º 7
0
 def _run_session(self):
     utils.run_state_machine(start_in='pre',
                             error_state='post',
                             error_callback=self.log_error_callback,
                             pre=self.session_pre,
                             main=self.session_main,
                             post=self.session_post)
     return 'idle'
Ejemplo n.º 8
0
 def _run_session(self):
     utils.run_state_machine(start_in='pre',
                             error_state='post',
                             error_callback=self.log_error_callback,
                             pre=self.session_pre,
                             main=self.session_main,
                             post=self.session_post)
     return 'idle'
Ejemplo n.º 9
0
 def temp():
     utils.run_state_machine(start_in='init',
                             init=self._polling_init('main'),
                             main=poll_state(component, duration))
     if self.responded_poll:
         return reward_state
     else:
         return next_state
Ejemplo n.º 10
0
 def _run_sleep(self):
     utils.run_state_machine(start_in='pre',
                             error_state='post',
                             error_callback=self.error_callback,
                             pre=self.sleep_pre,
                             main=self.sleep_main,
                             post=self.sleep_post)
     return self.block_name(self.recent_state)
Ejemplo n.º 11
0
 def temp():
     utils.run_state_machine(
         start_in="init", init=self._polling_init("main"), main=poll_state(component, duration)
     )
     if self.responded_poll:
         return reward_state
     else:
         return next_state
Ejemplo n.º 12
0
 def _free_food(self):
     utils.run_state_machine(start_in='pre',
                             error_state='post',
                             error_callback=self.error_callback,
                             pre=self.free_food_pre,
                             main=self.free_food_main,
                             post=self.free_food_post)
     return self.block_name(self.recent_state)
Ejemplo n.º 13
0
 def _run_trial(self):
     self.log.debug('running trial')
     self.log.debug("number of open file descriptors: %d" %(utils.get_num_open_fds()))
     utils.run_state_machine(start_in='pre',
                             error_state='post',
                             error_callback=self.log_error_callback,
                             pre=self.trial_pre,
                             main=self.trial_main,
                             post=self.trial_post)
Ejemplo n.º 14
0
 def _free_food(self):
     self.log.debug('Starting _free_food')
     utils.run_state_machine(start_in='pre',
                             error_state='post',
                             error_callback=self.log_error_callback,
                             pre=self.free_food_pre,
                             main=self.free_food_main,
                             post=self.free_food_post)
     return 'idle'
Ejemplo n.º 15
0
 def _free_food(self):
     self.log.debug('Starting _free_food')
     utils.run_state_machine(start_in='pre',
                             error_state='post',
                             error_callback=self.log_error_callback,
                             pre=self.free_food_pre,
                             main=self.free_food_main,
                             post=self.free_food_post)
     return 'idle'
Ejemplo n.º 16
0
 def run_shape(self, start_state='block1'):
     self.log.info('Starting shaping procedure')
     utils.run_state_machine(    start_in=start_state,
                                 error_state='block1',
                                 error_callback=self.error_callback,
                                 block1=self.block1,
                                 block2=self.block2,
                                 block3=self.block3,
                                 block4=self.block4,
                                 block5=self.block5,
                                 sleep_block=self._run_sleep)
     self.log.warning('Shaping procedure complete.  Remember to disable shaping in your config file')
Ejemplo n.º 17
0
 def run_shape(self, start_state='block1'):
     self.log.info('Starting shaping procedure')
     utils.run_state_machine(    start_in=start_state,
                                 error_state='block1',
                                 error_callback=self.error_callback,
                                 block1=self.block1,
                                 block2=self.block2,
                                 block3=self.block3,
                                 block4=self.block4,
                                 block5=self.block5,
                                 sleep_block=self._run_sleep)
     self.log.info('Shaping procedure complete')
Ejemplo n.º 18
0
 def run_shape(self, start_state='block1'):
     self.log.warning('Starting shaping procedure')
     utils.run_state_machine(    start_in=start_state,
                                 error_state='block1',
                                 error_callback=self.error_callback,
                                 block1=self.block1,
                                 block2=self.block2,
                                 block3=self.block3,
                                 block4=self.block4,
                                 block5=self.block5,
                                 sleep_block=self._run_sleep)
     self.log.warning('Shaping procedure complete.  Remember to disable shaping in your config file')
Ejemplo n.º 19
0
    def free_food_main(self):
        """ reset expal parameters for the next day """
        self.log.debug('Starting Free Food main.')
        utils.run_state_machine(start_in='wait',
                                error_state='wait',
                                error_callback=self.log_error_callback,
                                wait=self._wait_block(5, 5, 'food'),
                                food=self.deliver_free_food(10, 'checker'),
                                checker=self.food_checker('wait'))

        if not utils.check_time(self.parameters['free_food_schedule']):
            return 'post'
        else:
            return 'main'
Ejemplo n.º 20
0
    def free_food_main(self):
        """ reset expal parameters for the next day """
        self.log.debug('Starting Free Food main.')
        utils.run_state_machine(start_in='wait',
                                error_state='wait',
                                error_callback=self.log_error_callback,
                                wait=self._wait_block(5, 5, 'food'),
                                food=self.deliver_free_food(10, 'checker'),
                                checker=self.food_checker('wait')
                                )

        if not utils.check_time(self.parameters['free_food_schedule']):
            return 'post'
        else:
            return 'main'
Ejemplo n.º 21
0
 def temp():
     self.recent_state = block_num
     self.log.info('Starting %s'%(self.block_name(block_num)))
     utils.run_state_machine(    start_in='init',
                                 error_state='check',
                                 error_callback=self.error_callback,
                                 init=self._block_init('check'),
                                 check=self._check_block('poll_mid', reps, revert_timeout),
                                 poll_mid=self._flash_poll(self.panel.center, 10, 'check', 'pre_reward'),
                                 pre_reward=self._pre_reward('reward'),
                                 reward=self.reward(4, 'check'))
     if not utils.check_time(self.parameters['light_schedule']):
         return 'sleep_block'
     if self.responded_block:
         return self.block_name(block_num + 1)
     else:
         return self.block_name(block_num - 1)
Ejemplo n.º 22
0
 def temp():
     self.recent_state = block_num
     self.log.warning("Starting %s" % (self.block_name(block_num)))
     utils.run_state_machine(
         start_in="init",
         error_state="wait",
         error_callback=self.error_callback,
         init=self._block_init("wait"),
         wait=self._wait_block(10, 40, "check"),
         check=self._check_block("flash_mid", 1, float("inf")),
         flash_mid=self._flash_poll(self.panel.center, 5, "reward", "pre_reward"),
         pre_reward=self._pre_reward("reward"),
         reward=self.reward(5, "check2"),
         check2=self._check_block("wait", 1, float("inf")),
     )
     if not utils.check_time(self.parameters["light_schedule"]):
         return "sleep_block"
     return self.block_name(block_num + 1)
Ejemplo n.º 23
0
 def temp():
     self.recent_state = block_num
     self.log.warning("Starting %s" % (self.block_name(block_num)))
     utils.run_state_machine(
         start_in="init",
         error_state="check",
         error_callback=self.error_callback,
         init=self._block_init("check"),
         check=self._check_block("poll_mid", reps, revert_timeout),
         poll_mid=self._flash_poll(self.panel.center, 10, "check", "pre_reward"),
         pre_reward=self._pre_reward("reward"),
         reward=self.reward(4, "check"),
     )
     if not utils.check_time(self.parameters["light_schedule"]):
         return "sleep_block"
     if self.responded_block:
         return self.block_name(block_num + 1)
     else:
         return self.block_name(block_num - 1)
Ejemplo n.º 24
0
    def run(self):

        for attr in self.req_panel_attr:
            assert hasattr(self.panel,attr)
        self.panel_reset()
        self.save()
        self.init_summary()

        self.log.info('%s: running %s with parameters in %s' % (self.name,
                                                                self.__class__.__name__,
                                                                self.snapshot_f,
                                                                )
                      )
        if self.parameters['shape']:
                self.shaper.run_shape(self.parameters['shape'])
        while True: #is this while necessary
            utils.run_state_machine(start_in='idle',
                                    error_state='idle',
                                    error_callback=self.log_error_callback,
                                    idle=self._run_idle,
                                    sleep=self._run_sleep,
                                    session=self._run_session)
Ejemplo n.º 25
0
 def _run_stimulus(self):
     utils.run_state_machine(start_in='pre',
                             error_callback=self.log_error_callback,
                             pre=self.stimulus_pre,
                             main=self.stimulus_main,
                             post=self.stimulus_post)
Ejemplo n.º 26
0
 def _run_consequence(self):
     utils.run_state_machine(start_in='pre',
                             error_callback=self.log_error_callback,
                             pre=self.consequence_pre,
                             main=self.consequence_main,
                             post=self.consequence_post)
Ejemplo n.º 27
0
 def _run_punish(self):
     utils.run_state_machine(start_in='pre',
                             error_callback=self.log_error_callback,
                             pre=self.punish_pre,
                             main=self.punish_main,
                             post=self.punish_post)
Ejemplo n.º 28
0
 def _run_correction_reward(self):
     utils.run_state_machine(start_in='pre',
                             error_callback=self.log_error_callback,
                             pre=self.correction_reward_pre,
                             main=self.correction_reward_main,
                             post=self.correction_reward_post)
Ejemplo n.º 29
0
 def _run_correction_reward(self):
     utils.run_state_machine(start_in='pre',
                             error_callback=self.log_error_callback,
                             pre=self.correction_reward_pre,
                             main=self.correction_reward_main,
                             post=self.correction_reward_post)