How to use the neuron.h.load_file function in NEURON

To help you get started, we’ve selected a few NEURON examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github JustasB / BlenderNEURON / tests / test_client.py View on Github external
def test():
            from blenderneuron.quick import bn

            with Blender():
                from neuron import h
                h.load_file(test_hoc_file)
                tc1 = h.TestCell()
                tc2 = h.TestCell()

                ic = h.IClamp(0.5, sec=tc1.soma)
                ic.delay = 1
                ic.dur = 3
                ic.amp = 0.5

                bn.prepare_for_collection()
                bn.groups["all"]["3d_data"]["interaction_level"] = "Group"
                bn.groups["all"]["3d_data"]["color_level"] = "Group"

                h.run()

                bn.to_blender()
github Neurosim-lab / netpyne / netpyne / analysis.py View on Github external
import os
            
    root = os.path.dirname(netpyne.__file__)
    
    if 'nte' not in dir(h): 
        try: 
            print ' Warning: support/nte.mod not compiled; attempting to compile from %s via "nrnivmodl support"'%(root)
            os.system('cd ' + root + '; nrnivmodl support')
            from neuron import load_mechanisms
            load_mechanisms(root)
            print ' Compilation of support folder mod files successful'
        except:
            print ' Error compiling support folder mod files'
            return

    h.load_file(root+'/support/nte.hoc') # nTE code (also requires support/net.mod)
    
    if not spks1:  # if doesnt contain a list of spk times, obtain from cells specified
        cells, cellGids, netStimPops = getCellsInclude(cells1)
        numNetStims = 0

        # Select cells to include
        if len(cellGids) > 0:
            try:
                spkts = [spkt for spkgid,spkt in zip(sim.allSimData['spkid'],sim.allSimData['spkt']) if spkgid in cellGids]
            except:
                spkts = []
        else: 
            spkts = []

        # Add NetStim spikes
        spkts = list(spkts)
github MetaCell / NetPyNE-UI / netpyne_ui / models / CA3_pyramidal.py View on Github external
def __init__(self):
        logging.debug('Loading CA3 Pyramidal')

        neuron_utils.createProject(name='CA3 Pyramidal Neuron')

        resource_package = "neuron_ui"
        resource_path = '/'.join(('models', 'geo-cell1zr.hoc'))
        filepath = pkg_resources.resource_filename(resource_package, resource_path)

        h.load_file(filepath)

        neuron_geometries_utils.extractGeometries()

        logging.debug('CA3 Pyramidal loaded')
github MetaCell / NetPyNE-UI / netpyne_ui / neuron_geometries_utils.py View on Github external
"""
utils.py 
Useful functions
Contributors: 
"""
import os
import sys
from neuron import h
from math import sqrt, pow, ceil
from jupyter_geppetto.geppetto_comm import GeppettoCoreAPI as G
import logging
h.load_file("stdrun.hoc")
from jupyter_geppetto.geppetto_comm import GeppettoJupyterModelSync

def calculate_distance_to_cylinder_location(geometry, seg_loc):
    distance_to_seg_loc = 0
    proximal = []
    distal = []
    for point_index in range(len(geometry.python_variable["section_points"]) - 1):
        proximal = geometry.python_variable["section_points"][point_index]
        distal = geometry.python_variable["section_points"][point_index + 1]
        geometry_length = sqrt(pow(distal[0] - proximal[0], 2) + pow(
            distal[1] - proximal[1], 2) + pow(distal[2] - proximal[2], 2))
        if seg_loc < geometry_length + distance_to_seg_loc:
            break
        distance_to_seg_loc += geometry_length
    return distal, proximal, distance_to_seg_loc
github Neurosim-lab / netpyne / sim / init.py View on Github external
# header
import sys
from neuron import h
from time import time
import datetime
h.load_file('stdrun.hoc')
import params as p
import shared as s

def runSeq():
    if s.rank==0: verystart=time()  # store initial time
    s.sim.readArgs()  # set parameters based on commandline arguments
    s.network.createPops()  # instantiate network populations
    s.network.createCells()  # instantiate network cells based on defined populations
    s.network.connectCells()  
    s.network.addBackground()
    s.sim.setupRecording()
    s.sim.runSim()
    s.sim.gatherData()
    s.sim.saveData()
    s.analysis.plotData()
github ahwillia / PyNeuron-Toolbox / PyNeuronToolbox / channel_analysis.py View on Github external
rs = resistance of voltage clamp in MOhm
        vinit = initialization voltage

    Returns:
        i = iterable of peak currents (in mA/cm^2)
        v = iterable of corresponding test voltages

    Note:
        The initialization potential (vinit) may affect the result. For example, consider
        the Hodgkin-Huxley sodium channel; a large fraction are inactivated at rest. Using a
        strongly hyperpolarizing vinit will uninactivate many channels, leading to more
        current.
    """
    from neuron import h
    import numpy
    h.load_file('stdrun.hoc')
    sec = h.Section()
    sec.insert(mechanism_name)
    sec.L = 1
    sec.diam = 1
    seclamp = h.SEClamp(sec(0.5))
    seclamp.amp1 = vinit
    seclamp.dur1 = transient_time
    seclamp.dur2 = test_time 
    seclamp.rs = rs
    i_record = h.Vector()
    i_record.record(sec(0.5).__getattribute__('_ref_' + i_type))
    result_i = []
    result_v = numpy.arange(vmin, vmax, deltav)
    for test_v in result_v:
        seclamp.amp2 = test_v
        h.finitialize(vinit)
github AllenInstitute / biophys_optimize / biophys_optimize / passive_fitting / neuron_passive_fit2.py View on Github external
def main(input_file, output_file):
    with open(input_file, "r") as f:
        input = json.load(f)

    swc_path = input["paths"]["swc"].encode('ascii', 'ignore')
    up_data = np.loadtxt(input["paths"]["up"])
    down_data = np.loadtxt(input["paths"]["down"])
    with open(input["paths"]["passive_info"], "r") as f:
        info = json.load(f)

    h.load_file("stdgui.hoc")
    h.load_file("import3d.hoc")
    load_morphology(swc_path)

    for sec in h.allsec():
        if sec.name().startswith("axon"):
            h.delete_section(sec=sec)
    axon = h.Section()
    axon.L = 60
    axon.diam = 1
    axon.connect(h.soma[0], 0.5, 0)

    h.define_shape()

    for sec in h.allsec():
        sec.insert('pas')
        for seg in sec:
github AllenInstitute / biophys_optimize / biophys_optimize / passive_fitting / neuron_passive_fit_elec.py View on Github external
def main(input_file, output_file):
    with open(input_file, "r") as f:
        input = json.load(f)

    swc_path = input["paths"]["swc"].encode('ascii', 'ignore')
    up_data = np.loadtxt(input["paths"]["up"])
    down_data = np.loadtxt(input["paths"]["down"])
    with open(input["paths"]["passive_info"], "r") as f:
        info = json.load(f)

    h.load_file("stdgui.hoc")
    h.load_file("import3d.hoc")
    load_morphology(swc_path)

    for sec in h.allsec():
        if sec.name().startswith("axon"):
            h.delete_section(sec=sec)
    axon = h.Section()
    axon.L = 60
    axon.diam = 1
    axon.connect(h.soma[0], 0.5, 0)

    h.define_shape()

    for sec in h.allsec():
        sec.insert('pas')
        for seg in sec:
            seg.pas.e = 0
github AllenInstitute / biophys_optimize / biophys_optimize / neuron_passive_fit.py View on Github external
def initialize_neuron(swc_path, file_paths):
    """ Initialize neuron with morphology and load hoc files

    Parameters
    ----------
    swc_path : str
        Path to SWC file
    file_paths : list
        List of str file paths of files for NEURON to load

    """
    h.load_file("stdgui.hoc")
    h.load_file("import3d.hoc")

    swc = h.Import3d_SWC_read()
    swc.input(swc_path)
    imprt = h.Import3d_GUI(swc, 0)
    h("objref this")
    imprt.instantiate(h.this)

    for sec in h.allsec():
        if sec.name().startswith("axon"):
            h.delete_section(sec=sec)

    axon = h.Section()
    axon.L = 60
    axon.diam = 1
    axon.connect(h.soma[0], 0.5, 0)
github BlueBrain / eFEL / examples / deap / deap_efel_eval1.py View on Github external
"""Neuron / DEAP optimisation example evaluation function"""

import neuron
neuron.h.load_file('stdrun.hoc')

import efel

# pylint: disable=W0212


def evaluate(individual, target_voltage1=-80, target_voltage2=-60):
    """
    Evaluate a neuron model with parameters e_pas and g_pas, extracts
    features from resulting traces and returns a tuple with
    abs(voltage_base-target_voltage1) and 
    abs(steady_state_voltage-target_voltage2)
    """

    neuron.h.v_init = target_voltage1