class RunSimulate(object): _log = logging.getLogger('allensdk.model.biophysical.run_simulate') def __init__(self, input_json, output_json): self.input_json = input_json self.output_json = output_json self.app_config = None self.manifest = None def load_manifest(self): self.app_config = Config().load(self.input_json) self.manifest = self.app_config.manifest fix_sections = ['passive', 'axon_morph,', 'conditions', 'fitting'] self.app_config.fix_unary_sections(fix_sections) def nrnivmodl(self): RunSimulate._log.debug("nrnivmodl") subprocess.call(['nrnivmodl', './modfiles']) def simulate(self): from allensdk.internal.api.queries.biophysical_module_reader \ import BiophysicalModuleReader self.load_manifest() try: stimulus_path = self.manifest.get_path('stimulus_path') RunSimulate._log.info("stimulus path: %s" % (stimulus_path)) except: raise Exception( 'Could not read input stimulus path from input config.') try: out_path = self.manifest.get_path('output_path') RunSimulate._log.info("result NWB file: %s" % (out_path)) except: raise Exception('Could not read output path from input config.') try: morphology_path = self.manifest.get_path('MORPHOLOGY') RunSimulate._log.info("morphology path: %s" % (morphology_path)) except: raise Exception( 'Could not read morphology path from input config.') single_cell.run(self.app_config) lims_upload_config = BiophysicalModuleReader() lims_upload_config.read_json( self.manifest.get_path('neuronal_model_run_data')) lims_upload_config.update_well_known_file(out_path) lims_upload_config.set_workflow_state('passed') lims_upload_config.write_file(self.output_json)
def load_description(manifest_json_path): '''Read configuration file. Parameters ---------- manifest_json_path : string File containing the experiment configuration. Returns ------- Config Object with all information needed to run the experiment. ''' description = Config().load(manifest_json_path) # fix nonstandard description sections fix_sections = ['passive', 'axon_morph,', 'conditions', 'fitting'] description.fix_unary_sections(fix_sections) return description
def load_description(manifest_json_path): '''Read configuration file. Parameters ---------- manifest_json_path : string File containing the experiment configuration. Returns ------- Config Object with all information needed to run the experiment. ''' description = Config().load(manifest_json_path) # fix nonstandard description sections fix_sections = ['passive', 'axon_morph,', 'conditions', 'fitting'] description.fix_unary_sections(fix_sections) return description
def run_nrn(manifest, current, t_start, t_stop): description = Config().load(manifest) description.update_data({'axon_type': 'truncated'}, 'biophys') fix_sections = ['passive', 'axon_morph,', 'conditions', 'fitting'] description.fix_unary_sections(fix_sections) utils = create_utils(description) hoc = utils.h manifest = description.manifest morphology_path = manifest.get_path('MORPHOLOGY').encode( 'ascii', 'ignore').decode("utf-8") stimulus_path = description.manifest.get_path('stimulus_path') utils.generate_morphology(morphology_path) utils.load_cell_parameters() utils.read_stimulus(stimulus_path, sweep=35) # needed for sampling rates stim = hoc.IClamp(hoc.soma[0](0.5)) stim.amp = current stim.delay = t_start stim.dur = t_stop - t_start simulation_dt = 1.0e3 / utils.simulation_sampling_rate hoc.dt = simulation_dt hoc.tstop = t_start + t_stop vec = utils.record_values() hoc.finitialize() hoc.run() recorded_data = utils.get_recorded_data(vec) vs = recorded_data['v'] ts = recorded_data['t'] return ts, vs