Source code for allensdk.internal.model.biophysical.passive_fitting.neuron_utils

# in place of global from neuron import h

[docs]def get_h(): if get_h.h == None: from neuron import h get_h.h = h return get_h.h
get_h.h = None import sys, os from .output_grabber import OutputGrabber
[docs]def load_morphology(filename): h = get_h() swc = h.Import3d_SWC_read() swc.input(str(filename)) imprt = h.Import3d_GUI(swc, 0) h("objref this") imprt.instantiate(h.this)
[docs]def parse_neuron_output(output_str): printed_fields = {} for line in output_str.split('\n'): if line.startswith('nquad'): continue toks = line.split() if len(toks) == 2: v = toks[1].strip() try: v = float(v) except: pass printed_fields[toks[0].strip()] = v return printed_fields
[docs]def read_neuron_fit_stdout(func): def call(*args, **kwargs): g = OutputGrabber() g.start() data = func(*args, **kwargs) g.stop() printed_fields = parse_neuron_output(g.capturedtext) data.update(printed_fields) return data return call