cleo.ephys module#
Contains probes, convenience functions for generating electrode array coordinates, signals, spiking, and LFP
- class cleo.ephys.MultiUnitSpiking(r_perfect_detection: brian2.units.fundamentalunits.Quantity, r_half_detection: brian2.units.fundamentalunits.Quantity, cutoff_probability: float = 0.01, *, name: str = NOTHING)[source]#
Bases:
cleo.ephys.spiking.Spiking
Detects (unsorted) spikes per channel.
Method generated by attrs for class MultiUnitSpiking.
- connect_to_neuron_group(neuron_group: brian2.groups.neurongroup.NeuronGroup, **kwparams) None [source]#
Configure signal to record from specified neuron group
- Parameters
neuron_group (NeuronGroup) – group to record from
- get_state() tuple[NDArray[Any, ..., UInt[64]], NDArray[Any, ..., Float[64]], NDArray[Any, ..., UInt[64]]] [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() neo.core.group.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: brian2.units.fundamentalunits.Quantity, signals: list[cleo.ephys.probes.Signal] = NOTHING, *, name: str = NOTHING, save_history: bool = True)[source]#
Bases:
cleo.base.Recorder
,cleo.base.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: mpl_toolkits.mplot3d.axes3d.Axes3D, axis_scale_unit: brian2.units.fundamentalunits.Unit, **kwargs) list[matplotlib.artist.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: cleo.ephys.probes.Signal) None [source]#
Add signals to the probe for recording
- Parameters
*signals (Signal) – signals to add
- connect_to_neuron_group(neuron_group: brian2.groups.neurongroup.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
- signals: list[Signal]#
Signals recorded by the probe. Can be added to post-init with
add_signals()
.
- to_neo() neo.core.group.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: brian2.units.fundamentalunits.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: brian2.units.fundamentalunits.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: brian2.units.fundamentalunits.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.Signal(*, name: str = NOTHING)[source]#
Bases:
abc.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: brian2.groups.neurongroup.NeuronGroup, **kwparams)[source]#
Configure signal to record from specified neuron group
- Parameters
neuron_group (NeuronGroup) – group to record from
- init_for_probe(probe: cleo.ephys.probes.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: cleo.ephys.probes.Probe#
The probe the signal is configured to record for.
- class cleo.ephys.SortedSpiking(r_perfect_detection: brian2.units.fundamentalunits.Quantity, r_half_detection: brian2.units.fundamentalunits.Quantity, cutoff_probability: float = 0.01, *, name: str = NOTHING)[source]#
Bases:
cleo.ephys.spiking.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: brian2.groups.neurongroup.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[Any, ..., UInt[64]], NDArray[Any, ..., Float[64]], NDArray[Any, ..., UInt[64]]] [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: brian2.units.fundamentalunits.Quantity, r_half_detection: brian2.units.fundamentalunits.Quantity, cutoff_probability: float = 0.01, *, name: str = NOTHING)[source]#
Bases:
cleo.ephys.probes.Signal
,cleo.base.NeoExportable
Base class for probabilistically detecting spikes
Method generated by attrs for class Spiking.
- connect_to_neuron_group(neuron_group: brian2.groups.neurongroup.NeuronGroup, **kwparams) numpy.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[Any, ..., UInt[64]], NDArray[Any, ..., Float[64]], NDArray[Any, ..., UInt[64]]] [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
onprobe
- 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
- t_ms: NDArray[Any, float]#
Spike times in ms, stored if
save_history
onprobe
- t_samp_ms: NDArray[Any, float]#
Sample times in ms when each spike was recorded, stored if
save_history
onprobe
- to_neo() neo.core.group.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, *, name: str = NOTHING)[source]#
Bases:
cleo.ephys.probes.Signal
,cleo.base.NeoExportable
Records the Teleńczuk kernel LFP approximation.
Requires
tklfp_type='exc'|'inh'
to specify cell type on injection.An
orientation
keyword argument can also be specified on injection, which should be an 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.” As stated elsewhere, Cleo’s convention is that z=0 corresponds to the cortical surface and increasing z values represent increasing depth.TKLFP is computed from spikes using the tklfp package.
Method generated by attrs for class TKLFPSignal.
- connect_to_neuron_group(neuron_group: brian2.groups.neurongroup.NeuronGroup, **kwparams)[source]#
Configure signal to record from specified neuron group
- Parameters
neuron_group (NeuronGroup) – group to record from
- lfp_uV: nptyping.types._ndarray.NDArray[Any, Any, nptyping.types._number.Float]#
Approximated LFP from every call to
get_state()
. Shape is (n_samples, n_channels). Stored ifsave_history
onprobe
- t_ms: nptyping.types._ndarray.NDArray[Any, nptyping.types._number.Float]#
Times at which LFP is recorded, in ms, stored if
save_history
onprobe
- to_neo() neo.AnalogSignal [source]#
Return a Neo signal object with the device’s data
- Returns
Neo object representing exported data
- Return type
neo.core.BaseNeo
- 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: brian2.units.fundamentalunits.Quantity, channel_count: int, start_location: brian2.units.fundamentalunits.Quantity = array([0., 0., 0.]) * metre, direction: Tuple[float, float, float] = (0, 0, 1)) brian2.units.fundamentalunits.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: brian2.units.fundamentalunits.Quantity, channel_count: int, intercol_space: brian2.units.fundamentalunits.Quantity, start_location: brian2.units.fundamentalunits.Quantity = array([0., 0., 0.]) * metre, direction: Tuple[float, float, float] = (0, 0, 1)) brian2.units.fundamentalunits.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: brian2.units.fundamentalunits.Quantity, channel_count: int, intercol_space: brian2.units.fundamentalunits.Quantity, start_location: brian2.units.fundamentalunits.Quantity = array([0., 0., 0.]) * metre, direction: Tuple[float, float, float] = (0, 0, 1)) brian2.units.fundamentalunits.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: brian2.units.fundamentalunits.Quantity, tetrode_count: int, start_location: brian2.units.fundamentalunits.Quantity = array([0., 0., 0.]) * metre, direction: Tuple[float, float, float] = (0, 0, 1), tetrode_width: brian2.units.fundamentalunits.Quantity = 25. * umetre) brian2.units.fundamentalunits.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: brian2.units.fundamentalunits.Quantity, num_tiles: int, tile_vector: brian2.units.fundamentalunits.Quantity) brian2.units.fundamentalunits.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