emodelrunner.create_hoc_tools

Creates .hoc from cell.

Functions

create_hoc(mechs, parameters[, ...])

Return a string containing the hoc template.

create_main_protocol_hoc(template_path, ...)

Create main_protocol.hoc file.

create_run_hoc(template_path, main_protocol)

Returns a string containing run.hoc.

create_simul_hoc(template_path, ...[, ...])

Create createsimulation.hoc file.

create_synapse_hoc(syn_mech_args, ...[, ...])

Returns a string containing the synapse hoc.

Classes

HocStimuliCreator(prot_definitions, mtype, ...)

Class to create the stimuli in hoc.

class emodelrunner.create_hoc_tools.HocStimuliCreator(prot_definitions, mtype, add_synapses, apical_point_isec)[source]

Bases: object

Class to create the stimuli in hoc.

apical_point_isec

section index of the apical point Set to -1 if there is no apical point

Type:

int

n_stims

total number of protocols to be run by hoc. Gets incremented during initiation to enumerate the protocols.

Type:

int

max_steps

A StepProtocol can have multiple steps. This attribute counts the maximum steps that the StepProtocol with the most steps has. Stays at 0 if there is no StepProtocol.

Type:

int

reset_step_stimuli

hoc script resetting the step stimuli objects to be put inhoc file.

Type:

str

init_step_stimuli

hoc script initiating the step stimuli objects to be put in hoc file.

Type:

str

stims_hoc

hoc script containing all the protocols to be run by hoc. The Protocols supported by this library to be converted to hoc are:

  • StepProtocol

  • StepThresholdProtocol (only inside Main Protocol)

  • RampProtocol

  • RampThresholdProtocol (only inside Main Protocol)

  • Vecstim

  • Netstim

Type:

str

extra_recs_vars

names of the extra recordings hoc variables Have the form ‘, var1, var2, …, var_n’ to be added to the hoc variable declaration

Type:

str

extra_recs

hoc script to declare the extra recordings

Type:

str

add_extra_recs(extra_recs)[source]

Add extra recordings to the recordings settings.

Parameters:

extra_recs (list) – list of dicts defining the extra recordings

static add_save_recordings_hoc(mtype, prot_name, prot)[source]

Add this to the hoc file to save the recordings.

Parameters:
  • mtype (str) – mtype of the cell. prefix to use in the output files names

  • prot_name (str) – name of the protocol. used in the output files names

  • prot (dict) – dictionary defining the protocol

Returns:

hoc scipt to save the recordings of given protocol.

Return type:

str

get_init_step()[source]

Hoc script initiating all step stimuli needed by all the step protocols.

static get_netstim_hoc(prot)[source]

Get netstim stimulus in hoc format from netstim protocol dict.

Parameters:

prot (dict) – dictionary defining the netstim protocol

Returns:

hoc script declaring the netstim simuli

Return type:

str

static get_ramp_hoc(prot)[source]

Get ramp stimuli in hoc format from ramp protocol dict.

Parameters:

prot (dict) – dictionary defining the ramp protocol

Returns:

hoc script declaring the ramp stimulus

Return type:

str

get_reset_step()[source]

Hoc script reseting all step stimuli needed by all the step protocols.

get_step_hoc(prot)[source]

Get step stimuli in hoc format from step protocol dict.

Parameters:

prot (dict) – dictionary defining the step protocol

Returns:

hoc script declaring one or more step stimuli

Return type:

str

static get_vecstim_hoc(prot)[source]

Get vecstim stimulus in hoc format from vecstim protocol dict.

Parameters:

prot (dict) – dictionary defining the vecstim protocol

Returns:

hoc script declaring the vecstim stimuli

Return type:

str

emodelrunner.create_hoc_tools.create_hoc(mechs, parameters, ignored_globals=(), replace_axon=None, template_name='CCell', template_path='templates/cell_template.jinja2', disable_banner=None, add_synapses=False, synapses_template_name='hoc_synapses', syn_hoc_filename='synapses.hoc', syn_dir='synapses')[source]

Return a string containing the hoc template.

Parameters:
  • mechs (list of bluepyopt.ephys.mechanisms.Mechanisms) – All the mechs for the hoc template

  • parameters (list of bluepyopt.Parameters) – All the parameters in the hoc template

  • ignored_globals (iterable str) – HOC coded is added for each NrnGlobalParameter that exists, to test that it matches the values set in the parameters. This iterable contains parameter names that aren’t checked

  • replace_axon (str) – String replacement for the ‘replace_axon’ command. Must include ‘proc replace_axon(){ … }

  • template_name (str) – name of cell class in hoc

  • template_path (str) – path to the jinja2 template

  • disable_banner (bool) – if not True: a banner is added to the hoc file

  • add_synapses (bool) – if True: synapses are loaded in the hoc

  • synapses_template_name (str) – synapse class name in hoc

  • syn_hoc_filename (str) – file name of synapse hoc file

  • syn_dir (str) – directory where the synapse data /files are

Returns:

hoc script describing the cell model

Return type:

str

emodelrunner.create_hoc_tools.create_main_protocol_hoc(template_path, protocol_definitions, rin_exp_voltage_base, mtype)[source]

Create main_protocol.hoc file.

Parameters:
  • template_path (str) – path to the template to fill in

  • protocol_definitions (dict) – dictionary defining the protocols

  • rin_exp_voltage_base (float) – experimental value for the voltage_base feature for Rin protocol

  • mtype (str) – mtype of the cell. prefix to use in the output files names

Returns:

hoc script containing the main protocol functions

Return type:

str

emodelrunner.create_hoc_tools.create_run_hoc(template_path, main_protocol)[source]

Returns a string containing run.hoc.

Parameters:
  • template_path (str) – path to the template to fill in

  • main_protocol (bool) – whether the Main Protocol is used or not

Returns:

hoc script to run the simulation

Return type:

str

emodelrunner.create_hoc_tools.create_simul_hoc(template_path, add_synapses, hoc_paths, constants_args, protocol_definitions, apical_point_isec=-1)[source]

Create createsimulation.hoc file.

Parameters:
  • template_path (str) – path to the template to fill in

  • add_synapses (bool) – whether to add synapses to the cell

  • hoc_paths (HocPaths) – contains paths of the hoc files to be created

  • constants_args (dict) – contains data about the constants of the simulation

  • protocol_definitions (dict) – dictionary defining the protocols. Should have the structure of the protocol file in example/sscx/config/protocols

  • apical_point_isec (int) – section index of the apical point Set to -1 if there is no apical point

Returns:

hoc script to create the simulation

Return type:

str

emodelrunner.create_hoc_tools.create_synapse_hoc(syn_mech_args, syn_hoc_dir, template_path, gid, dt, synapses_template_name='hoc_synapses')[source]

Returns a string containing the synapse hoc.

Parameters:
  • syn_mech_args (SynMechArgs) – synapse-related configuration

  • syn_hoc_dir (str) – path to directory containing synapse-related data

  • template_path (str) – path to the template to fill in

  • gid (int) – cell ID

  • dt (float) – timestep (ms)

  • synapses_template_name (str) – template name of the synapse class

Returns:

hoc script with the synapse class template

Return type:

str