Classes for NEURON

class blenderneuron.nrn.neuronnode.NeuronNode(server_end=None, *args, **kwargs)[source]
static add_spine_pt3d(sec, xyz, diam)[source]
assign_gid_to_source_seg(pre_sec, pre_sec_x, threshold, gid)[source]
static clamp_section_x(x_in)[source]

When placing synapses, avoid using 0 and 1 section locations, esp. if extracellular potentials will be computed. See the warning comment in:

https://www.neuron.yale.edu/neuron/static/py_doc/modelspec/programmatic/

mechanisms/mech.html?highlight=i_membrane#mech-extracellular

Parameters:

x_in – 0-1 section location

Returns:

section location constrained to 0.001-0.999

create_netcon_syn(syn_class_name, syn_sec, syn_sec_x, syn_params, source_sec, source_x, threshold, delay, weight, source_on_rank, syn_on_rank, source_gid)[source]
create_synapses(syn_set)[source]
gather_group_dicts(local_groups)[source]

Gather local group dictionaries on rank zero and merge their roots.

ParallelContext.py_alltoall is used rather than an external MPI dependency. Each rank sends its local fragment only to rank zero, so large activity traces are not replicated on every worker.

get_group_dicts(compressed=True)[source]

Return the selected groups, gathering rank-local roots under MPI.

When MPI is enabled this is a collective operation: every rank must call it in the same order. Only rank zero receives the complete result; non-root ranks return None. Keeping the collective boundary here means a caller can send precisely one complete payload to Blender.

get_roots()[source]
get_sim_params()[source]
init_mpi(parallel_ctx, mpimap=None)[source]
initialize_groups(blender_groups, send_back=True)[source]
merge_mpi_group_fragments(fragments)[source]

Merge rank fragments deterministically, restoring Blender names.

rank_section_name(single_rank_name)[source]
run_simulation()[source]

Initialize and run, dispatching to every rank under the coordinator.

Without the coordinator, MPI callers must call this on every rank.

section_rx = re.compile('(.+?])\\.?(.*)')
segment_gid(sec_name, seg_id, has_spine)[source]

Only one gid can be associated with a segment. If more than one gid is assigned to a seg, only the last gid will send events to the post- synapse.

However, if the segment index can be computed from section.x location, locations that refer to the same segment e.g. section(0.49) and section(0.51) when nseg=3, can be identified.

This method generates a unique gid for each segment based on the section name and segment index. Where section(0) -> seg_id=0 and section(1) -> seg_id=nseg-1

If a spine was added, its assumed that the pre-syn location is at the head of the spine.

Parameters:
  • sec_name –

  • seg_id –

  • has_spine –

Returns:

set_sim_params(params)[source]
start_mpi_coordinator()[source]

Start rank-zero Blender coordination after MPI model setup.

Call this on every rank after init_mpi. It returns immediately on rank zero, which remains available to Blender; worker ranks enter the request loop and return only after stop_mpi_coordinator is called on rank zero.

stop_mpi_coordinator()[source]

Stop worker request loops. This must be called from rank zero.

update_groups(blender_groups)[source]

Apply group dictionaries, serialized groups, or flat group-file tables.

A file loaded with json.load() can be passed as one item in the list. Call deserialize() first if application code needs to inspect its roots.

update_section_index()[source]
class blenderneuron.nrn.neuronrootgroup.NeuronRootGroup[source]
clear_activity(queue_cleared=False)[source]
close()[source]

Detach owned recordings and initialization callbacks.

collect()[source]

Based on the group’s color level, gathers the values of the group’s collect_variable. This method is called at regular times during the simulation.

Returns:

None

create_collector()[source]

Install weak initialization hooks; rebuild native vectors each run.

from_skeletal_blender_group(blender_group, node)[source]
from_updated_blender_group(blender_group)[source]
prepare_activity(queue_cleared=False)[source]

Clear traces and refresh geometry before the first sample of a run.

Rebuilding also captures direct NEURON pt3d edits between runs. Direct pt3d edits during collection require an explicit cache rebuild; Blender coordinate updates invalidate the affected sections automatically.

save_recording_params(blender_group)[source]
class blenderneuron.nrn.neuronsection.NeuronSection[source]
collect(recursive=True)[source]

Recursively collects the section midpoint values of a group’s collect_variable (e.g. ‘v’)

Parameters:

recursive – Whether to collect child section values (otherwise stop at root/soma)

Returns:

None

collect_segments_recursive()[source]

Recursively collects the values of segments of a root section. Segments are given sequential 0-based names similar to NEURON cells and sections. For example, TestCell[0].dend[3][4] refers to first TestCell, 4th dendrite, 5th segment. Segment order is determined by the order in which they appear in NEURON’s xyz3d() function.

Returns:

None

from_nrn_section(nrn_section, group)[source]

Iteratively initializes the NeuronSection instances from NEURON sections, maintaining the original structure.

Parameters:
  • nrn_section – The NEURON section to initialize from

  • group – The group to which the sections belong

Returns:

None

from_skeletal_blender_root(source_section, group)[source]
from_updated_blender_root(blender_section)[source]

Update the coordinates and radii from the updated blender_section, iteratively for all child sections.

Parameters:

blender_section – The updated blender section data

Returns:

None

get_coords_and_radii()[source]
rebuild_segment_midpoints_recursive()[source]

Refresh local geometry once per initialization, without recursion.

update_coords_and_radii(blender_section)[source]