cleo.ephys module#

Contains probes, convenience functions for generating electrode array coordinates, signals, spiking, and LFP

class cleo.ephys.LFPSignalBase(*, name: str = _Nothing.NOTHING)[source]#

Bases: Signal, NeoExportable

Base class for LFP Signals.

Injection kwargs:

orientation (np.ndarray, optional) – Array of shape (n_neurons, 3) representing which way is “up,” that is, towards the surface of the cortex, for each neuron. If a single vector is given, it is taken to be the orientation for all neurons in the group. [0, 0, -1] is the default, meaning the negative z axis is “up.”

Method generated by attrs for class Signal.

brian_objects: set#

All Brian objects created by the signal. Must be kept up-to-date for automatic injection into the network

lfp: NDArray[Any, Any, Quantity] = _CountingAttr(counter=155, _default=NOTHING, repr=False, eq=True, order=True, hash=None, init=False, on_setattr=None, alias=None, metadata={})#

Approximated LFP from every call to get_state(). Shape is (n_samples, n_channels). Stored if save_history on probe

name: str#

Unique identifier used to organize probe output. Name of the class by default.

probe: Probe#

The probe the signal is configured to record for.

t_ms: NDArray[Any, float] = _CountingAttr(counter=154, _default=NOTHING, repr=False, eq=True, order=True, hash=None, init=False, on_setattr=None, alias=None, metadata={})#

Times at which LFP is recorded, in ms, stored if save_history on probe

to_neo() AnalogSignal[source]#

Return a Neo signal object with the device’s data

Returns:

Neo object representing exported data

Return type:

neo.core.BaseNeo

class cleo.ephys.MultiUnitSpiking(r_perfect_detection: Quantity, r_half_detection: Quantity, cutoff_probability: float = 0.01, *, name: str = _Nothing.NOTHING)[source]#

Bases: Spiking

Detects (unsorted) spikes per channel.

Method generated by attrs for class MultiUnitSpiking.

connect_to_neuron_group(neuron_group: NeuronGroup, **kwparams) None[source]#

Configure signal to record from specified neuron group

Parameters:

neuron_group (NeuronGroup) – group to record from

get_state() tuple[NDArray[None, UInt], NDArray[None, Float], NDArray[None, UInt]][source]#

Return spikes since method was last called (i, t_ms, y)

Returns:

(i, t_ms, y) where i is channel (for multi-unit) or neuron (for sorted) spike indices, t_ms is spike times, and y is a spike count vector suitable for control- theoretic uses—i.e., a 0 for every channel/neuron that hasn’t spiked and a 1 for a single spike.

Return type:

tuple[NDArray[np.uint], NDArray[float], NDArray[np.uint]]

to_neo() Group[source]#

Return a Neo signal object with the device’s data

Returns:

Neo object representing exported data

Return type:

neo.core.BaseNeo

class cleo.ephys.Probe(coords: Quantity, signals: list[Signal] = _Nothing.NOTHING, *, name: str = _Nothing.NOTHING, save_history: bool = True)[source]#

Bases: Recorder, NeoExportable

Picks up specified signals across an array of electrodes.

Visualization kwargs:
  • marker (str, optional) – The marker used to represent each contact. “x” by default.

  • size (float, optional) – The size of each contact marker. 40 by default.

  • color (Any, optional) – The color of contact markers. “xkcd:dark gray” by default.

Method generated by attrs for class Probe.

add_self_to_plot(ax: Axes3D, axis_scale_unit: Unit, **kwargs) list[Artist][source]#

Add device to an existing plot

Should only be called by plot().

Parameters:
  • ax (Axes3D) – The existing matplotlib Axes object

  • axis_scale_unit (Unit) – The unit used to label axes and define chart limits

  • **kwargs (optional) –

Returns:

A list of artists used to render the device. Needed for use in conjunction with VideoVisualizer.

Return type:

list[Artist]

add_signals(*signals: Signal) None[source]#

Add signals to the probe for recording

Parameters:

*signals (Signal) – signals to add

connect_to_neuron_group(neuron_group: NeuronGroup, **kwparams: Any) None[source]#

Configure probe to record from given neuron group

Will call Signal.connect_to_neuron_group() for each signal

Parameters:
  • neuron_group (NeuronGroup) – neuron group to connect to, i.e., record from

  • **kwparams (Any) – Passed in to signals’ connect functions, needed for some signals

coords: Quantity#

Coordinates of n electrodes. Must be an n x 3 array (with unit) where columns represent x, y, and z

get_state() dict[source]#

Get current state from probe, i.e., all signals

Returns:

{‘signal_name’: value} dict with signal states

Return type:

dict

property n#

Number of electrode contacts in the probe

probe: Probe#
reset(**kwargs)[source]#

Reset the probe to a neutral state

Calls reset() on each signal

signals: list[Signal]#

Signals recorded by the probe. Can be added to post-init with add_signals().

to_neo() Group[source]#

Return a Neo signal object with the device’s data

Returns:

Neo object representing exported data

Return type:

neo.core.BaseNeo

property xs: Quantity#

x coordinates of recording contacts

Returns:

x coordinates represented as a Brian quantity, that is, including units. Should be like a 1D array.

Return type:

Quantity

property ys: Quantity#

y coordinates of recording contacts

Returns:

y coordinates represented as a Brian quantity, that is, including units. Should be like a 1D array.

Return type:

Quantity

property zs: Quantity#

z coordinates of recording contacts

Returns:

z coordinates represented as a Brian quantity, that is, including units. Should be like a 1D array.

Return type:

Quantity

class cleo.ephys.RWSLFPSignalBase(amp_func: callable = <function mazzoni15_nrn>, pop_aggregate: bool = False, wslfp_kwargs: dict = _Nothing.NOTHING, lfp_unit: ~brian2.units.fundamentalunits.Unit = 1, *, name: str = _Nothing.NOTHING)[source]#

Bases: LFPSignalBase

Base class for RWSLFPSignalFromSpikes and RWSLFPSignalFromPSCs.

These signals should only be injected into neurons representing pyramidal cells with standard synaptic structure (see Mazzoni, Lindén et al., 2015).

RWSLFP is computed using the wslfp package.

amp_func and pop_aggregate can be overridden on injection.

Method generated by attrs for class RWSLFPSignalBase.

amp_func: callable#

Function to calculate LFP amplitudes, by default wslfp.mazzoni15_nrn.

See wslfp documentation for more info.

get_state() ndarray[source]#

Get the signal’s current value

pop_aggregate: bool#

Whether to aggregate currents across the population (as opposed to neurons having differential contributions to LFP depending on their location). False by default.

reset(**kwargs) None[source]#

Reset signal to a neutral state

to_neo() AnalogSignal[source]#

Return a Neo signal object with the device’s data

Returns:

Neo object representing exported data

Return type:

neo.core.BaseNeo

wslfp_kwargs: dict#

Keyword arguments to pass to the WSLFP calculator, e.g., alpha, tau_ampa_ms, tau_gaba_ms````source_coords_are_somata, source_dendrite_length_um, amp_kwargs, strict_boundaries.

class cleo.ephys.RWSLFPSignalFromPSCs(amp_func: callable = <function mazzoni15_nrn>, pop_aggregate: bool = False, wslfp_kwargs: dict = _Nothing.NOTHING, lfp_unit: ~brian2.units.fundamentalunits.Unit = 1, *, name: str = _Nothing.NOTHING)[source]#

Bases: RWSLFPSignalBase

Computes RWSLFP from the currents onto pyramidal cells.

Use this if your model already simulates synaptic current dynamics. Iampa_var_names and Igaba_var_names are lists of variable names to include and must be passed in as kwargs on injection or else the target neuron group will not contribute to this signal (desirable for interneurons).

RWSLFP refers to the Reference Weighted Sum of synaptic currents LFP proxy from Mazzoni, Lindén et al., 2015.

Injection kwargs:
  • Iampa_var_names (list[str]) – List of variable names in the neuron group representing AMPA currents.

  • Igaba_var_names (list[str]) – List of variable names in the neuron group representing GABA currents.

Method generated by attrs for class RWSLFPSignalFromPSCs.

connect_to_neuron_group(neuron_group: NeuronGroup, **kwparams)[source]#

Configure signal to record from specified neuron group

Parameters:

neuron_group (NeuronGroup) – group to record from

reset(**kwargs) None[source]#

Reset signal to a neutral state

class cleo.ephys.RWSLFPSignalFromSpikes(amp_func: callable = <function mazzoni15_nrn>, pop_aggregate: bool = False, wslfp_kwargs: dict = _Nothing.NOTHING, lfp_unit: ~brian2.units.fundamentalunits.Unit = 1, tau1_ampa: ~brian2.units.fundamentalunits.Quantity = 2. * msecond, tau2_ampa: ~brian2.units.fundamentalunits.Quantity = 0.4 * msecond, tau1_gaba: ~brian2.units.fundamentalunits.Quantity = 5. * msecond, tau2_gaba: ~brian2.units.fundamentalunits.Quantity = 250. * usecond, syn_delay: ~brian2.units.fundamentalunits.Quantity = 1. * msecond, I_threshold: float = 0.001, weight: str = 'w', *, name: str = _Nothing.NOTHING)[source]#

Bases: RWSLFPSignalBase

Computes RWSLFP from the spikes onto pyramidal cell.

Use this if your model does not simulate synaptic current dynamics directly. The parameters of this class are used to synthesize biexponential synaptic currents using wslfp.spikes_to_biexp_currents(). ampa_syns and gaba_syns are lists of Synapses or SynapticSubgroup objects and must be passed as kwargs on injection, or else this signal will not be recorded for the target neurons (useful for ignoring interneurons). Attributes set on the signal object serve as the default, but can be overridden on injection. Also, in the case that parameters (e.g., tau1_ampa or weight) vary by synapse, these can be overridden by passing a tuple of the Synapses or SynapticSubgroup object and a dictionary of the parameters to override.

RWSLFP refers to the Reference Weighted Sum of synaptic currents LFP proxy from Mazzoni, Lindén et al., 2015.

Injection kwargs:
  • ampa_syns (list[Synapses | SynapticSubgroup | tuple[Synapses|SynapticSubgroup, dict]]) – Synapses or SynapticSubgroup objects representing AMPA synapses (delivering excitatory currents). Or a tuple of the Synapses or SynapticSubgroup object and a dictionary of parameters to override.

  • gaba_syns (list[Synapses | SynapticSubgroup | tuple[Synapses|SynapticSubgroup, dict]]) – Synapses or SynapticSubgroup objects representing GABA synapses (delivering inhibitory currents). Or a tuple of the Synapses or SynapticSubgroup object and a dictionary of parameters to override.

  • weight (str | float, optional) – Name of the weight variable or parameter in the Synapses or SynapticSubgroup objects, or a float in the case of a single weight for all synapses. Default is ‘w’.

Method generated by attrs for class RWSLFPSignalFromSpikes.

I_threshold: float#

Threshold, as a proportion of the peak current, below which spikes’ contribution to synaptic currents (and thus LFP) is ignored, by default 1e-3.

connect_to_neuron_group(neuron_group: NeuronGroup, **kwparams)[source]#

Configure signal to record from specified neuron group

Parameters:

neuron_group (NeuronGroup) – group to record from

syn_delay: Quantity#

The synaptic transmission delay, i.e., between a spike and the onset of the postsynaptic current. 1 ms by default.

tau1_ampa: Quantity#

The fall time constant of the biexponential current kernel for AMPA synapses. 2 ms by default.

tau1_gaba: Quantity#

The fall time constant of the biexponential current kernel for GABA synapses. 5 ms by default.

tau2_ampa: Quantity#

The time constant of subtracted part of the biexponential current kernel for AMPA synapses. 0.4 ms by default.

tau2_gaba: Quantity#

The time constant of subtracted part of the biexponential current kernel for GABA synapses. 0.25 ms by default.

weight: str#

Name of the weight variable or parameter in the Synapses or SynapticSubgroup objects. Default is ‘w’.

class cleo.ephys.Signal(*, name: str = _Nothing.NOTHING)[source]#

Bases: ABC

Base class representing something an electrode can record

Method generated by attrs for class Signal.

brian_objects: set#

All Brian objects created by the signal. Must be kept up-to-date for automatic injection into the network

abstract connect_to_neuron_group(neuron_group: NeuronGroup, **kwparams)[source]#

Configure signal to record from specified neuron group

Parameters:

neuron_group (NeuronGroup) – group to record from

abstract get_state() Any[source]#

Get the signal’s current value

init_for_probe(probe: Probe) None[source]#

Called when attached to a probe.

Ensures signal can access probe and is only attached to one

Parameters:

probe (Probe) – Probe to attach to

Raises:

ValueError – When signal already attached to another probe

name: str#

Unique identifier used to organize probe output. Name of the class by default.

probe: Probe#

The probe the signal is configured to record for.

reset(**kwargs) None[source]#

Reset signal to a neutral state

class cleo.ephys.SortedSpiking(r_perfect_detection: Quantity, r_half_detection: Quantity, cutoff_probability: float = 0.01, *, name: str = _Nothing.NOTHING)[source]#

Bases: Spiking

Detect spikes identified by neuron indices.

The indices used by the probe do not correspond to those coming from neuron groups, since the probe must consider multiple potential groups and within a group ignores those neurons that are too far away to be easily detected.

Method generated by attrs for class SortedSpiking.

connect_to_neuron_group(neuron_group: NeuronGroup, **kwparams) None[source]#

Configure sorted spiking signal to record from given neuron group

Parameters:

neuron_group (NeuronGroup) – group to record from

get_state() tuple[NDArray[None, UInt], NDArray[None, Float], NDArray[None, UInt]][source]#

Return spikes since method was last called (i, t_ms, y)

Returns:

(i, t_ms, y) where i is channel (for multi-unit) or neuron (for sorted) spike indices, t_ms is spike times, and y is a spike count vector suitable for control- theoretic uses—i.e., a 0 for every channel/neuron that hasn’t spiked and a 1 for a single spike.

Return type:

tuple[NDArray[np.uint], NDArray[float], NDArray[np.uint]]

class cleo.ephys.Spiking(r_perfect_detection: Quantity, r_half_detection: Quantity, cutoff_probability: float = 0.01, *, name: str = _Nothing.NOTHING)[source]#

Bases: Signal, NeoExportable

Base class for probabilistically detecting spikes

Method generated by attrs for class Spiking.

connect_to_neuron_group(neuron_group: NeuronGroup, **kwparams) ndarray[source]#

Configure signal to record from specified neuron group

Parameters:

neuron_group (NeuronGroup) – Neuron group to record from

Returns:

num_neurons_to_consider x num_channels array of spike detection probabilities, for use in subclasses

Return type:

np.ndarray

cutoff_probability: float#

Spike detection probability below which neurons will not be considered. For computational efficiency.

abstract get_state() tuple[NDArray[None, UInt], NDArray[None, Float], NDArray[None, UInt]][source]#

Return spikes since method was last called (i, t_ms, y)

Returns:

(i, t_ms, y) where i is channel (for multi-unit) or neuron (for sorted) spike indices, t_ms is spike times, and y is a spike count vector suitable for control- theoretic uses—i.e., a 0 for every channel/neuron that hasn’t spiked and a 1 for a single spike.

Return type:

tuple[NDArray[np.uint], NDArray[float], NDArray[np.uint]]

i: NDArray[Any, np.uint]#

Channel (for multi-unit) or neuron (for sorted) indices of spikes, stored if save_history on probe

i_probe_by_i_ng: bidict#

(neuron_group, i_ng) keys, i_probe values. bidict for converting between neuron group indices and the indices the probe uses

r_half_detection: Quantity#

Radius (with Brian unit) within which half of all spikes are detected

r_perfect_detection: Quantity#

Radius (with Brian unit) within which all spikes are detected

reset(**kwargs) None[source]#

Reset signal to a neutral state

t_ms: NDArray[Any, float]#

Spike times in ms, stored if save_history on probe

t_samp_ms: NDArray[Any, float]#

Sample times in ms when each spike was recorded, stored if save_history on probe

to_neo() Group[source]#

Return a Neo signal object with the device’s data

Returns:

Neo object representing exported data

Return type:

neo.core.BaseNeo

class cleo.ephys.TKLFPSignal(uLFP_threshold_uV: float = 0.001, lfp_unit: Unit = uvolt, *, name: str = _Nothing.NOTHING)[source]#

Bases: LFPSignalBase

Records the Teleńczuk kernel LFP approximation.

Requires tklfp_type='exc'|'inh' to specify cell type on injection.

TKLFP is computed from spikes using the tklfp package.

Injection kwargs:

tklfp_type (str) – Either ‘exc’ or ‘inh’ to specify the cell type.

Method generated by attrs for class TKLFPSignal.

connect_to_neuron_group(neuron_group: NeuronGroup, **kwparams)[source]#

Configure signal to record from specified neuron group

Parameters:

neuron_group (NeuronGroup) – group to record from

get_state() ndarray[source]#

Get the signal’s current value

reset(**kwargs) None[source]#

Reset signal to a neutral state

uLFP_threshold_uV: float#

Threshold, in microvolts, above which the uLFP for a single spike is guaranteed to be considered, by default 1e-3. This determines the buffer length of past spikes, since the uLFP from a long-past spike becomes negligible and is ignored.

cleo.ephys.linear_shank_coords(array_length: Quantity, channel_count: int, start_location: Quantity = array([0., 0., 0.]) * metre, direction: Tuple[float, float, float] = (0, 0, 1)) Quantity[source]#

Generate coordinates in a linear pattern

Parameters:
  • array_length (Quantity) – Distance from the first to the last contact (with a Brian unit)

  • channel_count (int) – Number of coordinates to generate, i.e. electrode contacts

  • start_location (Quantity, optional) – x, y, z coordinate (with unit) for the start of the electrode array, by default (0, 0, 0)*mm

  • direction (Tuple[float, float, float], optional) – x, y, z vector indicating the direction in which the array extends, by default (0, 0, 1), meaning pointing straight down

Returns:

channel_count x 3 array of coordinates, where the 3 columns represent x, y, and z

Return type:

Quantity

cleo.ephys.poly2_shank_coords(array_length: Quantity, channel_count: int, intercol_space: Quantity, start_location: Quantity = array([0., 0., 0.]) * metre, direction: Tuple[float, float, float] = (0, 0, 1)) Quantity[source]#

Generate NeuroNexus-style Poly2 array coordinates

Poly2 refers to 2 parallel columns with staggered contacts. See https://www.neuronexus.com/products/electrode-arrays/up-to-15-mm-depth for more detail.

Parameters:
  • array_length (Quantity) – Length from the beginning to the end of the two-column array, as measured in the center

  • channel_count (int) – Total (not per-column) number of coordinates (recording contacts) desired

  • intercol_space (Quantity) – Distance between columns (with Brian unit)

  • start_location (Quantity, optional) – Where to place the beginning of the array, by default (0, 0, 0)*mm

  • direction (Tuple[float, float, float], optional) – x, y, z vector indicating the direction in which the two columns extend; by default (0, 0, 1), meaning straight down.

Returns:

channel_count x 3 array of coordinates, where the 3 columns represent x, y, and z

Return type:

Quantity

cleo.ephys.poly3_shank_coords(array_length: Quantity, channel_count: int, intercol_space: Quantity, start_location: Quantity = array([0., 0., 0.]) * metre, direction: Tuple[float, float, float] = (0, 0, 1)) Quantity[source]#

Generate NeuroNexus Poly3-style array coordinates

Poly3 refers to three parallel columns of electrodes. The middle column will be longest if the channel count isn’t divisible by three and the side columns will be centered vertically with respect to the middle.

Parameters:
  • array_length (Quantity) – Length from beginning to end of the array as measured along the center column

  • channel_count (int) – Total (not per-column) number of coordinates to generate (i.e., electrode contacts)

  • intercol_space (Quantity) – Spacing between columns, with Brian unit

  • start_location (Quantity, optional) – Location of beginning of the array, that is, the first contact in the center column, by default (0, 0, 0)*mm

  • direction (Tuple[float, float, float], optional) – x, y, z vector indicating the direction along which the array extends, by default (0, 0, 1), meaning straight down

Returns:

channel_count x 3 array of coordinates, where the 3 columns represent x, y, and z

Return type:

Quantity

cleo.ephys.tetrode_shank_coords(array_length: Quantity, tetrode_count: int, start_location: Quantity = array([0., 0., 0.]) * metre, direction: Tuple[float, float, float] = (0, 0, 1), tetrode_width: Quantity = 25. * umetre) Quantity[source]#

Generate coordinates for a linear array of tetrodes

See https://www.neuronexus.com/products/electrode-arrays/up-to-15-mm-depth to visualize NeuroNexus-style arrays.

Parameters:
  • array_length (Quantity) – Distance from the center of the first tetrode to the last (with a Brian unit)

  • tetrode_count (int) – Number of tetrodes desired

  • start_location (Quantity, optional) – Center location of the first tetrode in the array, by default (0, 0, 0)*mm

  • direction (Tuple[float, float, float], optional) – x, y, z vector determining the direction in which the linear array extends, by default (0, 0, 1), meaning straight down.

  • tetrode_width (Quantity, optional) – Distance between contacts in a single tetrode. Not the diagonal distance, but the length of one side of the square. By default 25*umeter, as in NeuroNexus probes.

Returns:

(tetrode_count*4) x 3 array of coordinates, where 3 columns represent x, y, and z

Return type:

Quantity

cleo.ephys.tile_coords(coords: Quantity, num_tiles: int, tile_vector: Quantity) Quantity[source]#

Tile (repeat) coordinates to produce multi-shank/matrix arrays

Parameters:
  • coords (Quantity) – The n x 3 coordinates array to tile

  • num_tiles (int) – Number of times to tile (repeat) the coordinates. For example, if you are tiling linear shank coordinates to produce multi-shank coordinates, this would be the desired number of shanks

  • tile_vector (Quantity) – x, y, z array with Brian unit determining both the length and direction of the tiling

Returns:

(n * num_tiles) x 3 array of coordinates, where the 3 columns represent x, y, and z

Return type:

Quantity