Exemplo n.º 1
0
 def __init__(self):
     self.stimulus = StimCommand(
         server_hostname=ExperimentConfig.STIM_SERVER_HOST)
     self.exp_name = None
     self.post_fix = None
     self.stim_source = None
     self.logger = logging.getLogger('Experimenter.Experiments')
Exemplo n.º 2
0
class Experiment(object):
    def __init__(self):
        self.stimulus = StimCommand(
            server_hostname=ExperimentConfig.STIM_SERVER_HOST)
        self.exp_name = None
        self.post_fix = None
        self.stim_source = None
        self.logger = logging.getLogger('Experimenter.Experiments')

    def get_stimulus_params(self, eye):
        return self.stimulus.get_params(eye)

    def run(self):
        # sleep for 5 seconds
        time.sleep(5.0)
        self.logger.info('=' * 18)

    def run_stimulus(self,
                     left_params=None,
                     right_params=None,
                     assignments=[]):
        exp_file = os.path.dirname(
            __file__) + os.path.sep + 'script' + os.path.sep + self.stim_source
        self.logger.info('Running script: ' + exp_file)
        self.logger.info('Experiment name is: ' + self.exp_name)
        self.logger.info('Experiment time is: ' +
                         time.strftime('%Y/%m/%d %H:%M:%S', time.localtime()))
        # make sure that experiment timestamp is at least 1 sec earlier than PLX file timestamp
        time.sleep(1.0)
        try:
            with open(exp_file) as source_file:
                source = source_file.read()
        except IOError:
            self.logger.error('Cannot read stimulation source code.')
            return
        self.stimulus.run(self.exp_name, source, left_params, right_params,
                          assignments)

    def wait_for_stim(self):
        self.logger.info('Waiting for stimulus...')
        while self.stimulus.is_running():
            time.sleep(1.0)
        self.logger.info('Writing stimulus log...')

        log_file = ExperimentConfig.CELLDIR + os.path.sep + self.exp_name + '.log'
        with open(log_file, 'w') as log:
            loglines = self.stimulus.get_stimulus_log(self.exp_name)
            log.writelines(loglines)
Exemplo n.º 3
0
class Experiment(object):
    def __init__(self):
        self.stimulus = StimCommand(server_hostname=ExperimentConfig.STIM_SERVER_HOST)
        self.exp_name = None
        self.post_fix = None
        self.stim_source = None
        self.logger = logging.getLogger('Experimenter.Experiments')
        
    def get_stimulus_params(self,eye):
        return self.stimulus.get_params(eye)
    
    def run(self):
        # sleep for 5 seconds
        time.sleep(5.0)
        self.logger.info('='*18)
        
    def run_stimulus(self, left_params=None, right_params=None, assignments=[]):
        exp_file = os.path.dirname(__file__) + os.path.sep + 'script' + os.path.sep + self.stim_source
        self.logger.info('Running script: ' + exp_file)
        self.logger.info('Experiment name is: ' + self.exp_name)
        self.logger.info('Experiment time is: ' + time.strftime('%Y/%m/%d %H:%M:%S', time.localtime()))
        # make sure that experiment timestamp is at least 1 sec earlier than PLX file timestamp
        time.sleep(1.0)
        try:
            with open(exp_file) as source_file:
                source = source_file.read()
        except IOError:
            self.logger.error('Cannot read stimulation source code.')
            return
        self.stimulus.run(self.exp_name,source,left_params,right_params,assignments)
        
    def wait_for_stim(self):
        self.logger.info('Waiting for stimulus...')
        while self.stimulus.is_running():
            time.sleep(1.0)
        self.logger.info('Writing stimulus log...')
        
        log_file = ExperimentConfig.CELLDIR + os.path.sep + self.exp_name + '.log'
        with open(log_file, 'w') as log:
            loglines = self.stimulus.get_stimulus_log(self.exp_name)
            log.writelines(loglines)
Exemplo n.º 4
0
#!/usr/bin/python
# QuitServer script
#
# Copyright (C) 2010-2012 Huang Xin
# 
# See LICENSE.TXT that came with this file.

if __name__ == '__main__':
    from StimControl.ControlCmd import StimCommand
    cmd = StimCommand('192.168.1.105', 7766)
    cmd.quit_server()
Exemplo n.º 5
0
#!/usr/bin/python
# QuitServer script
#
# Copyright (C) 2010-2012 Huang Xin
#
# See LICENSE.TXT that came with this file.

if __name__ == '__main__':
    from StimControl.ControlCmd import StimCommand
    cmd = StimCommand('192.168.1.105', 7766)
    cmd.quit_server()
Exemplo n.º 6
0
 def __init__(self):
     self.stimulus = StimCommand(server_hostname=ExperimentConfig.STIM_SERVER_HOST)
     self.exp_name = None
     self.post_fix = None
     self.stim_source = None
     self.logger = logging.getLogger('Experimenter.Experiments')
Exemplo n.º 7
0
# QuitServer script
#
# Copyright (C) 2010-2012 Huang Xin
#
# See LICENSE.TXT that came with this file.

if __name__ == '__main__':
    from StimControl.ControlCmd import StimCommand
    cmd = StimCommand('localhost', 7766)
    cmd.quit_server()