bluecellulab.cell.core

Cell class.

Classes

Cell(**kwargs)

Represents a Cell object.

class bluecellulab.cell.core.Cell(**kwargs)[source]

Represents a Cell object.

addAxialCurrentRecordings(section)[source]

Record all the axial current flowing in and out of the section.

add_ais_recording(dt=None)[source]

Adds recording to AIS.

Parameters:

dt (Optional[float])

Return type:

None

add_allsections_voltagerecordings()[source]

Add a voltage recording to every section of the cell.

add_currents_recordings(section, segx=0.5, *, include_nonspecific=True, include_point_processes=False, dt=None)[source]

Record all available currents (ionic + optionally nonspecific) at (section, segx).

Parameters:
  • segx (float)

  • include_nonspecific (bool)

  • include_point_processes (bool)

  • dt (float | None)

Return type:

list[str]

add_recording(var_name, dt=None)[source]

Add a recording to the cell.

Parameters:
  • var_name (str) – Variable to be recorded.

  • dt (Optional[float]) – Recording time step. If not provided, the recording step will

  • step. (default to the simulator's time)

Return type:

None

add_recordings(var_names, dt=None)[source]

Add a list of recordings to the cell.

Parameters:
  • var_names (list[str]) – Variables to be recorded.

  • dt (Optional[float]) – Recording time step. If not provided, the recording step will

  • step. (default to the simulator's time)

Return type:

None

add_replay_delayed_weight(sid, delay, weight)[source]

Add a synaptic weight for sid that will be set with a time delay.

Parameters:
  • sid (tuple[str, int])

  • delay (float)

  • weight (float)

Return type:

None

add_replay_minis(synapse_id, syn_description, connection_modifiers, popids, mini_frequencies)[source]

Add minis from the replay.

Parameters:
  • synapse_id (SynapseID)

  • syn_description (Series)

  • connection_modifiers (dict)

  • popids (tuple[int, int])

  • mini_frequencies (tuple[float | None, float | None])

Return type:

None

add_replay_synapse(synapse_id, syn_description, connection_modifiers, condition_parameters, popids, extracellular_calcium)[source]

Add synapse based on the syn_description to the cell.

Parameters:
  • synapse_id (SynapseID)

  • syn_description (Series)

  • connection_modifiers (dict)

  • condition_parameters (Conditions)

  • popids (tuple[int, int])

  • extracellular_calcium (float | None)

Return type:

None

add_synapse_replay(stimulus, spike_threshold, spike_location)[source]

Adds the synapse spike replay to the cell if the synapse is connected to that cell.

Parameters:
  • stimulus (SynapseReplay)

  • spike_threshold (float)

  • spike_location (str)

Return type:

None

add_variable_recording(variable, section=None, segx=0.5, dt=None)[source]

Add a recording of any NEURON RANGE variable (e.g., gna, gk, ina) from a given section and segment.

Parameters:
  • variable (str) – The NEURON variable name to record (e.g., “gna”).

  • section (Optional[HocObject]) – The section to record from (defaults to soma).

  • segx (float) – Segment position between 0 and 1.

  • dt (Optional[float]) – Optional recording time step.

Return type:

None

add_voltage_recording(section=None, segx=0.5, dt=None)[source]

Add a voltage recording to a certain section at a given segment (segx).

Parameters:
  • section (Optional[HocObject]) – Section to record from (Neuron section pointer).

  • segx (float) – Segment x coordinate. Specify a value between 0 and 1. 0 is typically the end closest to the soma, 1 is the distal end.

  • dt (Optional[float]) – Recording time step. If not provided, the recording step will default to the simulator’s time step.

Return type:

None

apical_trunk()[source]

Return the apical trunk of the cell.

area()[source]

The total surface area of the cell.

Return type:

float

configure_recording(recording_sites, variable_name, report_name)[source]

Attach NEURON recordings for a variable at the given sites and return the recording names created.

Parameters:
  • recording_sites (iterable) – (section, section_name, segx) tuples describing recording locations.

  • variable_name (str) – Variable to record (e.g. “v”, “ina”, “kca.gkca”).

  • report_name (str) – Report identifier (for logging).

Returns:

(site, rec_name) pairs for successfully configured recordings.

Return type:

list[tuple[ReportSite, str]]

connect_to_circuit(sonata_proxy)[source]

Connect this cell to a circuit via sonata proxy.

Parameters:

sonata_proxy (SonataProxy)

Return type:

None

create_netcon_spikedetector(target, location, threshold=-30.0)[source]

Add and return a spikedetector.

This function creates a NetCon object that detects spikes at a specific location in the current cell and connects to the provided target point process. The location can be specified as a predefined site (‘soma’ or ‘AIS’) or as a custom location in the format section[index](position). Custom locations allow fine-grained control of the spike detection site within the cell’s sections.

Parameters:
  • target (HocObject) – A NEURON point process object (e.g., synapse) that the NetCon connects to.

  • location (str) –

    The spike detection location. Acceptable formats include:

    • ”soma”: Detect spikes in the soma section at the distal end.

    • ”AIS”: Detect spikes in the axon initial segment at the midpoint.

    • ”section[index](position)”: Custom location specifying:

      • section: The name of the section (e.g., ‘soma’, ‘axon’).

      • [index] (optional): Segment index within a section array (e.g., ‘soma[0]’).

      • (position) (optional): Normalized position along the section length (0 to 1). Defaults to 0.5 if not provided.

  • threshold (float) – The voltage threshold for spike detection (default: -30.0 mV).

Return type:

HocObject

Returns:

A NEURON NetCon object configured for spike detection at the specified location.

Raises:

ValueError – If: - The location is not ‘soma’, ‘AIS’, or a valid custom format. - The specified section or segment index does not exist. - The position is out of bounds (e.g., negative or greater than 1.0).

delete()[source]

Delete the cell.

disable_ttx()[source]

Remove TTX from the environment (i.e. unblock the Na channels).

Disable TTX by inserting TTXDynamicsSwitch and setting ttxo to 1e-14

Return type:

None

enable_ttx()[source]

Add TTX to the environment (i.e. block the Na channels).

Enable TTX by inserting TTXDynamicsSwitch and setting ttxo to 1.0

Return type:

None

static euclid_section_distance(hsection1=None, hsection2=None, location1=None, location2=None, projection=None)[source]

Calculate euclidian distance between positions on two sections Uses bluecellulab.cell.section_distance.EuclideanSectionDistance.

Parameters:
  • hsection1 (hoc section) – First section

  • hsection2 (hoc section) – Second section

  • location1 (float) – range x along hsection1

  • location2 (float) – range x along hsection2

  • projection (string) – planes to project on, e.g. ‘xy’

classmethod from_template_parameters(template_params, cell_id=None, record_dt=None)[source]

Create a cell from a TemplateParams object.

Useful in isolating runs.

Parameters:
Return type:

Cell

getAxialCurrentRecording(section)[source]

Return the axial current recording.

get_ais_voltage()[source]

Get a vector of AIS voltage.

Return type:

ndarray

get_allsections_voltagerecordings()[source]

Get all the voltage recordings from all the sections.

Return type:

dict[str, ndarray]

get_childrensections(parentsection)[source]

Get the children section of a neuron section.

Parameters:

parentsection (HocObject)

Return type:

list[HocObject]

static get_parentsection(childsection)[source]

Get the parent section of a neuron section.

Parameters:

childsection (HocObject)

Return type:

HocObject

static get_precise_record_dt(dt)[source]

Get a more precise record_dt to make time points faill on dts.

Parameters:

dt (float)

Return type:

float

get_psection(section_id)[source]

Return a python section with the specified section id.

Parameters:

section_id (int | str)

Return type:

PSection

get_recorded_spikes(location, threshold=-30)[source]

Get recorded spikes in the current cell.

Parameters:
  • location (str) – the spike detection location

  • threshold (float) – spike detection threshold

Return type:

list[float]

Returns: recorded spikes

get_recording(var_name)[source]

Get recorded values.

Parameters:

var_name (str)

Return type:

ndarray

get_section(section_name)[source]

Return a single, fully specified NEURON section (e.g., ‘soma[0]’, ‘dend[3]’).

Raises:

ValueError or TypeError if the section is not found or invalid.

Parameters:

section_name (str)

Return type:

HocObject

get_section_by_id(section_id)[source]

Return NEURON section by global section index (LibSONATA ordering).

Parameters:

section_id (int)

Return type:

HocObject

get_sections(section_name)[source]

Return a list of NEURON sections.

If the section name is a fully specified one (e.g., ‘dend[3]’), return it as a list of one. If the section name is a base name (e.g., ‘dend’), return all matching sections like ‘dend[0]’, ‘dend[1]’, etc.

Raises:

ValueError if no valid sections are found.

Parameters:

section_name (str)

Return type:

List[HocObject]

get_soma_voltage()[source]

Get a vector of the soma voltage.

Return type:

ndarray

get_time()[source]

Get the time vector.

Return type:

ndarray

get_variable_recording(variable, section, segx)[source]

Get a recording of any variable recorded from a section and segment.

Parameters:
  • variable (str) – The name of the recorded variable (e.g., ‘v’, ‘gna’).

  • section (Optional[HocObject]) – The NEURON section object.

  • segx (float) – Segment location from 0 to 1.

Return type:

ndarray

Returns:

NumPy array of recorded values.

Raises:

ValueError – If the recording is not found.

get_voltage_recording(section=None, segx=0.5)[source]

Get a voltage recording for a certain section at a given segment (segx).

Parameters:
  • section (Optional[HocObject]) – Section to record from (Neuron section pointer).

  • segx (float) – Segment x coordinate. Specify a value between 0 and 1. 0 is typically the end closest to the soma, 1 is the distal end.

Return type:

ndarray

Returns:

A NumPy array containing the voltage recording values.

Raises:

BluecellulabError – If voltage recording was not added previously using add_voltage_recording.

property info_dict

Return a dictionary with all the information of this cell.

make_passive()[source]

Make the cell passive by deactivating all the active channels.

Return type:

None

property n_segments: int

Get the number of segments in the cell.

pre_gid_synapse_ids(pre_gid)[source]

List of synapse_ids of synapses a cell uses to connect to this cell.

Parameters:

pre_gid (int) – gid of the presynaptic cell.

Return type:

list[SynapseID]

Returns:

synapse_id’s that connect the presynaptic cell with this cell.

pre_gids()[source]

Get the list of unique gids of cells that connect to this cell.

Return type:

list[int]

Returns:

A list of gids of cells that connect to this cell.

re_init_rng()[source]

Reinitialize the random number generator for stochastic channels.

Return type:

None

resolve_segments_from_compartment_set(node_id, compartment_nodes)[source]

Resolve segments for a cell using a predefined compartment node list.

Supports both LibSONATA format ([node_id, section_id, seg]) and name-based format ([node_id, section_name, seg]).

Return type:

List[Tuple[HocObject, str, float]]

resolve_segments_from_config(report_cfg)[source]

Resolve segments from NEURON sections based on config.

Return type:

List[Tuple[HocObject, str, float]]

somatic_branches()[source]

Show the index numbers.

Return type:

None

start_recording_spikes(target, location, threshold=-30)[source]

Start recording spikes in the current cell.

Parameters:
  • target (HocObject) – target point process

  • location (str) – the spike detection location

  • threshold (float) – spike detection threshold

Return type:

None