Exemple #1
0
    def __init__(self, model, parameters):
        Experiment.__init__(self, model, parameters)
        from mozaik.sheets.direct_stimulator import Kick

        d = OrderedDict()
        for i, sheet in enumerate(self.parameters.sheet_list):
            p = MozaikExtendedParameterSet({
                'exc_firing_rate':
                self.parameters.lambda_list[i],
                'exc_weight':
                self.parameters.weight_list[i],
                'drive_period':
                self.parameters.drive_period,
                'population_selector':
                self.parameters.stimulation_configuration
            })

            d[sheet] = [Kick(model.sheets[sheet], p)]

        self.direct_stimulation = [d]
        self.stimuli.append(
            InternalStimulus(frame_duration=self.parameters.duration,
                             duration=self.parameters.duration,
                             trial=0,
                             direct_stimulation_name='Kick',
                             direct_stimulation_parameters=p))
def add_per_stimulus_current_injection(exp, stimulation_configuration,
                                       stimulation_sheet, stimulation_current):
    """
    To experiment *exp*, add an injection of current of magnitude *stimulation_current* to neurons from sheet *stimulation_sheet*
    selected based on population selector *stimulation_configuration*.
    """
    # this will work correctly only if no direct stimulators were already added.
    assert exp.direct_stimulation == None
    exp.direct_stimulation = []
    for s in exp.stimuli:
        d = {}
        p = MozaikExtendedParameterSet({
            'population_selector': stimulation_configuration,
            'current': stimulation_current
        })

        d[stimulation_sheet] = [
            Depolarization(exp.model.sheets[stimulation_sheet], p)
        ]

        exp.direct_stimulation.append(d)

        p['sheet'] = stimulation_sheet
        s.direct_stimulation_name = 'Injection'
        s.direct_stimulation_parameters = p

    return exp
Exemple #3
0
    def __init__(self, model, parameters):
        Experiment.__init__(self, model, parameters)
        from mozaik.sheets.direct_stimulator import Depolarization

        d = OrderedDict()
        for i, sheet in enumerate(self.parameters.sheet_list):
            p = MozaikExtendedParameterSet({
                'current':
                self.parameters.current,
                'population_selector':
                self.parameters.stimulation_configuration
            })

            d[sheet] = [Depolarization(model.sheets[sheet], p)]

        self.direct_stimulation = [d]
        self.stimuli.append(
            InternalStimulus(frame_duration=self.parameters.duration,
                             duration=self.parameters.duration,
                             trial=0,
                             direct_stimulation_name='Injection',
                             direct_stimulation_parameters=p))
Exemple #4
0
def run_experiments(model, experiment_list, parameters, load_from=None):
    """
    This is function called by :func:.run_workflow that executes the experiments in the `experiment_list` over the model. 
    Alternatively, if load_from is specified it will load an existing simulation from the path specified in load_from.
    
    Parameters
    ----------
    
    model : Model
          The model to execute experiments on.
    
    experiment_list : list
          The list of experiments to execute.
    
    parameters : ParameterSet
               The parameters given to the simulation run.
          
    load_from : str
              If not None it will load the simulation from the specified directory.
              
    Returns
    -------
    
    data_store : DataStore
               The data store containing the recordings.
    """

    # first lets run all the measurements required by the experiments
    logger.info('Starting Experiemnts')
    if load_from == None:
        data_store = PickledDataStore(load=False,
                                      parameters=MozaikExtendedParameterSet({
                                          'root_directory':
                                          Global.root_directory,
                                          'store_stimuli':
                                          parameters.store_stimuli
                                      }))
    else:
        data_store = PickledDataStore(load=True,
                                      parameters=MozaikExtendedParameterSet({
                                          'root_directory':
                                          load_from,
                                          'store_stimuli':
                                          parameters.store_stimuli
                                      }))

    data_store.set_neuron_ids(model.neuron_ids())
    data_store.set_neuron_positions(model.neuron_positions())
    data_store.set_neuron_annotations(model.neuron_annotations())
    data_store.set_model_parameters(str(parameters))
    data_store.set_sheet_parameters(str(model.sheet_parameters()))
    data_store.set_experiment_parametrization_list([
        (str(exp.__class__), str(exp.parameters)) for exp in experiment_list
    ])

    t0 = time.time()
    simulation_run_time = 0
    for i, experiment in enumerate(experiment_list):
        logger.info('Starting experiment: ' + experiment.__class__.__name__)
        stimuli = experiment.return_stimuli()
        unpresented_stimuli_indexes = data_store.identify_unpresented_stimuli(
            stimuli)
        logger.info('Running model')
        simulation_run_time += experiment.run(data_store,
                                              unpresented_stimuli_indexes)
        logger.info('Experiment %d/%d finished' %
                    (i + 1, len(experiment_list)))

    total_run_time = time.time() - t0
    mozaik_run_time = total_run_time - simulation_run_time

    logger.info('Total simulation run time: %.0fs' % total_run_time)
    logger.info(
        'Simulator run time: %.0fs (%d%%)' %
        (simulation_run_time, int(simulation_run_time / total_run_time * 100)))
    logger.info('Mozaik run time: %.0fs (%d%%)' %
                (mozaik_run_time, int(mozaik_run_time / total_run_time * 100)))

    return data_store