Network#
- class Network( )[source]#
Bases:
objectModern neural network builder with intuitive connection API.
Provides a clean, discoverable interface for creating neural network connections while maintaining compatibility with existing NEURON-based infrastructure.
Initialize network with neural populations.
- Parameters:
populations (dict[str, Union[list, Any]]) – Dictionary mapping population names to Pool objects or lists of neuron objects. Pool objects will have .neurons extracted, lists used directly. Example: {“alpha_mn”: alphaMN_pool, “ia”: ia_pool}
spike_recording (dict, optional) – Dictionary containing ‘idvec’ and ‘spkvec’ for spike recording. Example: {“idvec”: {“aMN”: h.Vector()}, “spkvec”: {“aMN”: h.Vector()}}
Methods
Initialize network with neural populations.
Connect two neural populations with specified parameters.
Connect external input source to a neural population.
Connect two neural populations with one-to-one mapping.
Connect a neural population to a muscle with activation callback.
Get list of all connection specifications.
Get NEURON NetCon objects with optional filtering by source and target.
Print a summary of network structure.
Set up spike recording NetCons for all neurons in all populations.
- setup_spike_recording()[source]#
Set up spike recording NetCons for all neurons in all populations.
This creates additional NetCons specifically for recording spikes from neurons that might not have outgoing connections but still need spike recording for analysis.
- connect(
- source: str,
- target: str,
- probability: float = 1.0,
- weight__uS: Quantity__uS = DEFAULT_SYNAPTIC_WEIGHT,
- delay__ms: Quantity__ms = DEFAULT_SYNAPTIC_DELAY,
- threshold__mV: Quantity__mV = DEFAULT_SPIKE_THRESHOLD,
- deterministic: bool = False,
- inhibitory: bool = False,
Connect two neural populations with specified parameters.
- Parameters:
source (str) – Name of source population (must exist in populations dict).
target (str) – Name of target population (must exist in populations dict).
probability (float, optional) – Connection probability between 0.0 and 1.0, by default 1.0. Each source-target neuron pair connects with this probability (if deterministic=False). If deterministic=True, each source connects to exactly int(probability × n_targets) targets.
weight__uS (float, optional) – Synaptic weight in microsiemens, by default 0.6.
delay__ms (float, optional) – Synaptic delay in milliseconds, by default 1.0.
threshold__mV (float, optional) – Spike threshold in millivolts, by default -10.0.
deterministic (bool, optional) – If True, each source neuron connects to exactly int(probability × n_targets) randomly selected target neurons. If False, uses probabilistic sampling. Default False.
inhibitory (bool, optional) – If True, connect to inhibitory synapses on target neurons (reversal < -40 mV). If False, connect to excitatory synapses (reversal >= -40 mV). Default False. Use inhibitory=True for connections from inhibitory interneurons (e.g., gII→aMN, gIb→aMN).
- Returns:
List of created NEURON NetCon objects for this connection group.
- Return type:
list[h.NetCon]
- Raises:
ValueError – If source or target populations don’t exist, or probability out of range.
- connect_to_muscle(
- source: str,
- muscle,
- activation_callback: Callable,
- weight__uS: Quantity__uS = DEFAULT_SYNAPTIC_WEIGHT,
- threshold__mV: Quantity__mV = DEFAULT_SPIKE_THRESHOLD,
Connect a neural population to a muscle with activation callback.
- Parameters:
source (str) – Name of motor neuron population.
muscle (object) – Muscle object for force generation.
activation_callback (Callable) – Function called when motor neurons fire. Expected signature: callback(neuron_id, muscle, delay_time)
weight__uS (float, optional) – Synaptic weight in microsiemens, by default 1.0.
threshold__mV (float, optional) – Spike threshold in millivolts, by default -10.0.
- Returns:
List of motor neuron to muscle NetCon objects.
- Return type:
list[h.NetCon]
- connect_from_external(
- source: str,
- target: str,
- weight__uS: Quantity__uS = DEFAULT_SYNAPTIC_WEIGHT,
- delay__ms: Quantity__ms = DEFAULT_SYNAPTIC_DELAY,
- threshold__mV: Quantity__mV = DEFAULT_SPIKE_THRESHOLD,
Connect external input source to a neural population.
- Parameters:
source (str) – Name/label for external input source (e.g., “spindle”, “cortical_drive”).
target (str) – Name of target neural population.
weight__uS (Quantity__uS, optional) – Synaptic weight in microsiemens, by default 0.8.
delay__ms (float, optional) – Synaptic delay in milliseconds, by default 1.0.
threshold__mV (float, optional) – Spike threshold in millivolts, by default -10.0.
- Returns:
List of external to neural NetCon objects.
- Return type:
list[h.NetCon]
- connect_one_to_one(
- source: str,
- target: str,
- probability: float = 1.0,
- weight__uS: Quantity__uS = DEFAULT_SYNAPTIC_WEIGHT,
- delay__ms: Quantity__ms = DEFAULT_SYNAPTIC_DELAY,
- threshold__mV: Quantity__mV = DEFAULT_SPIKE_THRESHOLD,
- inhibitory: bool = False,
Connect two neural populations with one-to-one mapping.
Creates individual connections between source[i] and target[i] for each neuron pair at matching indices with specified probability. This is particularly useful for modeling independent noise sources (e.g., independent Poisson drives) where each target neuron should receive input from exactly one source neuron.
- Parameters:
source (str) – Name of source population (must exist in populations dict).
target (str) – Name of target population (must exist in populations dict).
probability (float, optional) – Probability that each source[i] -> target[i] connection is made, by default 1.0. Must be between 0.0 and 1.0.
weight__uS (Quantity__uS, optional) – Synaptic weight in microsiemens, by default 0.6.
delay__ms (Quantity__ms, optional) – Synaptic delay in milliseconds, by default 1.0.
threshold__mV (Quantity__mV, optional) – Spike threshold in millivolts, by default -10.0.
inhibitory (bool, optional) – If True, connect to inhibitory synapses on target neurons (reversal < -40 mV). If False, connect to excitatory synapses (reversal >= -40 mV). Default False.
- Returns:
List of created NEURON NetCon objects for connections that were made.
- Return type:
list[h.NetCon]
- Raises:
ValueError – If source or target populations don’t exist, have different sizes, or probability is not in [0.0, 1.0].
Examples
>>> # Create independent noise for each motor neuron >>> noise_pool = DescendingDrive__Pool(n=10, poisson_batch_size=16, timestep__ms=0.05) >>> mn_pool = AlphaMN__Pool(n=10) >>> network = Network({"noise": noise_pool, "mn": mn_pool}) >>> network.connect_one_to_one("noise", "mn", weight__uS=0.5)