cleo.imaging module#
Contains Scope and sensors for two-photon microscopy
- class cleo.imaging.CalBindingActivationModel(model: str)[source]#
Bases:
object
Base class for modeling calcium binding/activation
Method generated by attrs for class CalBindingActivationModel.
- model: str#
- class cleo.imaging.CalciumModel(model: str)[source]#
Bases:
object
Base class for how GECI computes calcium concentration
Must provide variable Ca (molar) in model.
Method generated by attrs for class CalciumModel.
- model: str#
- on_pre: str#
- class cleo.imaging.DoubExpCalBindingActivation(*, A: float, tau_on: Quantity, tau_off: Quantity, Ca_rest: Quantity)[source]#
Bases:
CalBindingActivationModel
Double exponential kernel convolution representing CaB binding/activation.
Convolution is implemented via ODEs; see
notebooks/double_exp_conv_as_ode.ipynb
for derivation.A
,tau_on
, andtau_off
are the versions with proper scale and units of NAOMi’sca_amp
,t_on
, andt_off
.Some parameters found here. Fitting code here.
Method generated by attrs for class DoubExpCalBindingActivation.
- A: float#
amplitude of double exponential kernel
- model: str#
- class cleo.imaging.DynamicCalcium(*, Ca_rest: Quantity, gamma: Quantity, B_T: Quantity, kappa_S: float, dCa_T: Quantity)[source]#
Bases:
CalciumModel
Simulates intracellular calcium dynamics from spikes. Pieced together from Lütke et al., 2013; Helmchen and Tank, 2015; and Song et al., 2021. (code)
Method generated by attrs for class DynamicCalcium.
- kappa_S: float#
Ca2+ binding ratio of the endogenous buffer
- model: str#
from eq 8 in Lütke et al., 2013
- on_pre: str#
from eq 9 in Lütke et al., 2013
- class cleo.imaging.ExcitationModel(model: str)[source]#
Bases:
object
Defines
exc_factor
Method generated by attrs for class ExcitationModel.
- model: str#
- class cleo.imaging.GECI(extra_namespace: dict = _Nothing.NOTHING, *, name: str = _Nothing.NOTHING, save_history: bool = True, sigma_noise: float, dFF_1AP: float, cal_model: CalciumModel, bind_act_model: CalBindingActivationModel, exc_model: ExcitationModel, K_d: Quantity, n_H: float, dFF_max: float)[source]#
Bases:
Sensor
GECI model based on Song et al., 2021, with interchangeable components.
See
geci()
for a convenience function for creating GECI models.As a potentially simpler alternative for future work, see the phenomological S2F model from Zhang et al., 2023. While parameter count looks similar, at least they have parameters fit already, and directly to data, rather than to biophysical processes before the data.
Method generated by attrs for class GECI.
- K_d: Quantity#
indicator dissociation constant (binding affinity) (molar)
- bind_act_model: CalBindingActivationModel#
- cal_model: CalciumModel#
- dFF_max: float#
amplitude of Hill equation for conversion from Ca2+ to ΔF/F, Fmax/F0. May be approximated from ‘dynamic range’ in literature Fmax/Fmin
- exc_model: ExcitationModel#
- fluor_model: str#
Uses a Hill equation to convert from Ca2+ to ΔF/F, as in Song et al., 2021
- get_state() dict[NeuronGroup, ndarray] [source]#
Returns a {neuron_group: fluorescence} dict of dFF values.
- init_syn_vars(syn: Synapses) None [source]#
Initializes appropriate variables in Synapses implementing the model
Also called on
reset()
.- Parameters:
syn (Synapses) – The synapses object implementing this model
- location: str#
cytoplasm or membrane
- Type:
where sensor is expressed
- n_H: float#
Hill coefficient for conversion from Ca2+ to ΔF/F
- property params: dict#
Returns a dictionary of all parameters from model/submodels
- class cleo.imaging.LightExcitation[source]#
Bases:
ExcitationModel
Models light-dependent excitation (not implemented yet)
Method generated by attrs for class LightExcitation.
- model: str#
- class cleo.imaging.NullBindingActivation[source]#
Bases:
CalBindingActivationModel
Doesn’t model binding/activation; i.e., goes straight from [Ca2+] to ΔF/F
Method generated by attrs for class NullBindingActivation.
- model: str#
- class cleo.imaging.NullExcitation[source]#
Bases:
ExcitationModel
Models excitation as a constant factor
Method generated by attrs for class NullExcitation.
- model: str#
- class cleo.imaging.PreexistingCalcium[source]#
Bases:
CalciumModel
Calcium concentration is pre-existing in neuron model
Method generated by attrs for class PreexistingCalcium.
- model: str#
- class cleo.imaging.Scope(sensor: Sensor, img_width: Quantity, focus_depth: Quantity = None, location: Quantity = array([0., 0., 0.]) * metre, direction: Quantity = (0, 0, 1), soma_radius: Quantity = 10. * umetre, snr_cutoff: float = 1, rand_seed: int = None, *, name: str = _Nothing.NOTHING, save_history: bool = True)[source]#
Bases:
Recorder
Two-photon microscope.
- Injection kwargs:
rho_rel_generator (Callable[[int], NDArray[(Any,), float]], optional) – A function assigning expression levels. Takes n as an arg, outputs float array.
lambda n: np.ones(n)
by default.focus_depth (Quantity, optional) – The depth of the focal plane, by default that of the scope.
soma_radius (Quantity, optional) – The radius of the soma of the neuron, by default that of the scope. Used to compute noise focus factor, since smaller ROIs will have a noisier distribution of fluorescence, averaged over fewer pixels.
Method generated by attrs for class Scope.
- 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]
- connect_to_neuron_group(neuron_group: NeuronGroup, **kwparams) None [source]#
Connect device to given neuron_group.
If your device introduces any objects which Brian must keep track of, such as a NeuronGroup, Synapses, or Monitor, make sure to add these to
brian_objects
.- Parameters:
neuron_group (NeuronGroup) –
**kwparams (optional) – Passed from inject
- dFF: list[NDArray[Any, float]]#
ΔF/F from every call to
get_state()
. Shape is (n_samples, n_ROIs). Stored ifsave_history
- property dFF_1AP: NDArray[Any, Float]#
dFF_1AP for all targets, in order injected. Varies with expression levels.
- direction: NDArray[3, float]#
Direction in which the microscope is pointing. By default straight down (+z direction)
- focus_coords_per_injct: list[NDArray[Any, float]]#
coordinates on the focal plane of neurons selected from each injection
- focus_depth: Quantity#
The depth of the focal plane, with distance units
- get_state() NDArray[Any, Float] [source]#
Returns a 1D array of ΔF/F values for all targets, in order injected.
- Returns:
Fluorescence values for all targets
- Return type:
NDArray[(Any,), float]
- i_targets_per_injct: list[NDArray[Any, int]]#
targets of neurons selected from each injection
- img_width: Quantity#
The width (diameter) of the (circular) image captured by the microscope. Specified in distance units.
- location: Quantity#
Location of the objective lens.
- property n: int#
Number of imaged ROIs
- neuron_groups: list[NeuronGroup]#
neuron groups the scope has been injected into, in order of injection
- rand_seed: int#
- rho_rel_per_injct: list[NDArray[Any, float]]#
relative expression levels of neurons selected from each injection
- property sigma_noise: NDArray[Any, Float]#
noise std dev (in terms of ΔF/F) for all targets, in order injected.
- sigma_per_injct: list[NDArray[Any, float]]#
sigma_noise of neurons selected from each injection
- snr_cutoff: float#
SNR below which neurons are discarded. Applied only when not focus_depth is not None
- soma_radius: Quantity#
Assumed radius of neurons, used to compute noise focus factor. Smaller neurons have noisier signals.
- t_ms: list[float]#
Times at which sensor traces are recorded, in ms, stored if
save_history
- target_neurons_in_plane(ng, focus_depth: Quantity = None, soma_radius: Quantity = None) tuple[NDArray[Any, Int], NDArray[Any, Float], NDArray[Any, 3, Float]] [source]#
calls
target_neurons_in_plane()
with scope parameter defaults. focus_depth and soma_radius can be overridden here.- Parameters:
ng (NeuronGroup) – The neuron group to target.
focus_depth (Quantity) – The depth of the focal plane, by default that of the microscope.
soma_radius (Quantity, optional) – The radius of the soma of the neuron, by default that of the microscope. Used to compute noise focus factor, since smaller ROIs will have a noisier distribution of fluorescence, averaged over fewer pixels.
- Returns:
A tuple of (i_targets, noise_focus_factor, coords_on_plane)
- Return type:
Tuple[NDArray[(Any,), int], NDArray[(Any,), float], NDArray[(Any, 3), float]]
- class cleo.imaging.Sensor(extra_namespace: dict = _Nothing.NOTHING, *, name: str = _Nothing.NOTHING, save_history: bool = True, sigma_noise: float, dFF_1AP: float, location: str)[source]#
Bases:
SynapseDevice
Base class for sensors
Method generated by attrs for class Sensor.
- dFF_1AP: float#
ΔF/F for 1 AP, only used for scope SNR cutoff
- property exc_spectrum: list[tuple[float, float]]#
Excitation spectrum, alias for
spectrum
- get_state() dict[NeuronGroup, ndarray] [source]#
Returns a {neuron_group: fluorescence} dict of dFF values.
- location: str#
cytoplasm or membrane
- Type:
where sensor is expressed
- sigma_noise: float#
standard deviation of Gaussian noise in ΔF/F measurement
- property snr: float#
Signal-to-noise ratio for 1 AP
- cleo.imaging.gcamp3(light_dependent=False, doub_exp_conv=True, pre_existing_cal=False, K_d=287. * nmolar, n_H=2.52, dFF_max=12, sigma_noise=0.018571428571428572, dFF_1AP=0.039, ca_amp=0.05, t_on=1, t_off=1, Ca_rest=50. * nmolar, kappa_S=110, gamma=292.3 * hertz, B_T=200. * umolar, dCa_T=7.6 * umolar, name='gcamp3', **kwparams) GECI #
Returns a (light-dependent) GECI model with specified submodel choices. Default parameters are taken from NAOMi’s code (Song et al., 2021) as well as Dana et al., 2019 and Zhang et al., 2023.
Only those parameters used in chosen model components apply. If the default is
None
, then we don’t have it fit yet.ca_amp
,t_on
, andt_off
are given as in NAOMi, but are converted to the proper scale and units for the double exponential convolution model. Namely,A = ca_amp / (second / 100)
andtau_[on|off] = second / t_[on|off]
.
- cleo.imaging.gcamp6f(light_dependent=False, doub_exp_conv=True, pre_existing_cal=False, K_d=290. * nmolar, n_H=2.7, dFF_max=25.2, sigma_noise=0.03748181818181818, dFF_1AP=0.09775500000000001, ca_amp=76.1251, t_on=0.8535, t_off=98.6173, Ca_rest=50. * nmolar, kappa_S=110, gamma=292.3 * hertz, B_T=200. * umolar, dCa_T=7.6 * umolar, name='gcamp6f', **kwparams) GECI #
Returns a (light-dependent) GECI model with specified submodel choices. Default parameters are taken from NAOMi’s code (Song et al., 2021) as well as Dana et al., 2019 and Zhang et al., 2023.
Only those parameters used in chosen model components apply. If the default is
None
, then we don’t have it fit yet.ca_amp
,t_on
, andt_off
are given as in NAOMi, but are converted to the proper scale and units for the double exponential convolution model. Namely,A = ca_amp / (second / 100)
andtau_[on|off] = second / t_[on|off]
.
- cleo.imaging.gcamp6rs06(light_dependent=False, doub_exp_conv=True, pre_existing_cal=False, K_d=0.32 * umolar, n_H=3, dFF_max=15, sigma_noise=0.030227272727272728, dFF_1AP=None, ca_amp=None, t_on=None, t_off=None, Ca_rest=50. * nmolar, kappa_S=110, gamma=292.3 * hertz, B_T=200. * umolar, dCa_T=7.6 * umolar, name='gcamp6rs06', **kwparams) GECI #
Returns a (light-dependent) GECI model with specified submodel choices. Default parameters are taken from NAOMi’s code (Song et al., 2021) as well as Dana et al., 2019 and Zhang et al., 2023.
Only those parameters used in chosen model components apply. If the default is
None
, then we don’t have it fit yet.ca_amp
,t_on
, andt_off
are given as in NAOMi, but are converted to the proper scale and units for the double exponential convolution model. Namely,A = ca_amp / (second / 100)
andtau_[on|off] = second / t_[on|off]
.Don’t know sigma_noise. Default is the GCaMP6s value.
- cleo.imaging.gcamp6rs09(light_dependent=False, doub_exp_conv=True, pre_existing_cal=False, K_d=0.52 * umolar, n_H=3.2, dFF_max=25, sigma_noise=0.030227272727272728, dFF_1AP=None, ca_amp=None, t_on=None, t_off=None, Ca_rest=50. * nmolar, kappa_S=110, gamma=292.3 * hertz, B_T=200. * umolar, dCa_T=7.6 * umolar, name='gcamp6rs09', **kwparams) GECI #
Returns a (light-dependent) GECI model with specified submodel choices. Default parameters are taken from NAOMi’s code (Song et al., 2021) as well as Dana et al., 2019 and Zhang et al., 2023.
Only those parameters used in chosen model components apply. If the default is
None
, then we don’t have it fit yet.ca_amp
,t_on
, andt_off
are given as in NAOMi, but are converted to the proper scale and units for the double exponential convolution model. Namely,A = ca_amp / (second / 100)
andtau_[on|off] = second / t_[on|off]
.Don’t know sigma_noise. Default is the GCaMP6s value.
- cleo.imaging.gcamp6s(light_dependent=False, doub_exp_conv=True, pre_existing_cal=False, K_d=147. * nmolar, n_H=2.45, dFF_max=27.2, sigma_noise=0.030227272727272728, dFF_1AP=0.133, ca_amp=54.6943, t_on=0.4526, t_off=68.5461, Ca_rest=50. * nmolar, kappa_S=110, gamma=292.3 * hertz, B_T=200. * umolar, dCa_T=7.6 * umolar, name='gcamp6s', **kwparams) GECI #
Returns a (light-dependent) GECI model with specified submodel choices. Default parameters are taken from NAOMi’s code (Song et al., 2021) as well as Dana et al., 2019 and Zhang et al., 2023.
Only those parameters used in chosen model components apply. If the default is
None
, then we don’t have it fit yet.ca_amp
,t_on
, andt_off
are given as in NAOMi, but are converted to the proper scale and units for the double exponential convolution model. Namely,A = ca_amp / (second / 100)
andtau_[on|off] = second / t_[on|off]
.
- cleo.imaging.geci(light_dependent: bool, doub_exp_conv: bool, pre_existing_cal: bool, **kwparams) GECI [source]#
Initializes a
GECI
model with given parameters.- Parameters:
light_dependent (bool) – Whether the indicator is light-dependent.
doub_exp_conv (bool) – Whether to use double exponential convolution for binding/activation.
pre_existing_cal (bool) – Whether to use calcium concentrations already simulated in the neuron model.
**kwparams – Keyword parameters for
GECI
and sub-models.
- Returns:
A (LightDependent)GECI model specified submodels and parameters.
- Return type:
- cleo.imaging.jgcamp7b(light_dependent=False, doub_exp_conv=True, pre_existing_cal=False, K_d=82. * nmolar, n_H=3.06, dFF_max=22.1, sigma_noise=0.007556818181818182, dFF_1AP=0.61712, ca_amp=None, t_on=None, t_off=None, Ca_rest=50. * nmolar, kappa_S=110, gamma=292.3 * hertz, B_T=200. * umolar, dCa_T=7.6 * umolar, name='jgcamp7b', **kwparams) GECI #
Returns a (light-dependent) GECI model with specified submodel choices. Default parameters are taken from NAOMi’s code (Song et al., 2021) as well as Dana et al., 2019 and Zhang et al., 2023.
Only those parameters used in chosen model components apply. If the default is
None
, then we don’t have it fit yet.ca_amp
,t_on
, andt_off
are given as in NAOMi, but are converted to the proper scale and units for the double exponential convolution model. Namely,A = ca_amp / (second / 100)
andtau_[on|off] = second / t_[on|off]
.
- cleo.imaging.jgcamp7c(light_dependent=False, doub_exp_conv=True, pre_existing_cal=False, K_d=298. * nmolar, n_H=2.44, dFF_max=145.6, sigma_noise=0.011788636363636364, dFF_1AP=0.24605000000000002, ca_amp=None, t_on=None, t_off=None, Ca_rest=50. * nmolar, kappa_S=110, gamma=292.3 * hertz, B_T=200. * umolar, dCa_T=7.6 * umolar, name='jgcamp7c', **kwparams) GECI #
Returns a (light-dependent) GECI model with specified submodel choices. Default parameters are taken from NAOMi’s code (Song et al., 2021) as well as Dana et al., 2019 and Zhang et al., 2023.
Only those parameters used in chosen model components apply. If the default is
None
, then we don’t have it fit yet.ca_amp
,t_on
, andt_off
are given as in NAOMi, but are converted to the proper scale and units for the double exponential convolution model. Namely,A = ca_amp / (second / 100)
andtau_[on|off] = second / t_[on|off]
.
- cleo.imaging.jgcamp7f(light_dependent=False, doub_exp_conv=True, pre_existing_cal=False, K_d=174. * nmolar, n_H=2.3, dFF_max=30.2, sigma_noise=0.021763636363636363, dFF_1AP=0.22743000000000002, ca_amp=None, t_on=None, t_off=None, Ca_rest=50. * nmolar, kappa_S=110, gamma=292.3 * hertz, B_T=200. * umolar, dCa_T=7.6 * umolar, name='jgcamp7f', **kwparams) GECI #
Returns a (light-dependent) GECI model with specified submodel choices. Default parameters are taken from NAOMi’s code (Song et al., 2021) as well as Dana et al., 2019 and Zhang et al., 2023.
Only those parameters used in chosen model components apply. If the default is
None
, then we don’t have it fit yet.ca_amp
,t_on
, andt_off
are given as in NAOMi, but are converted to the proper scale and units for the double exponential convolution model. Namely,A = ca_amp / (second / 100)
andtau_[on|off] = second / t_[on|off]
.
- cleo.imaging.jgcamp7s(light_dependent=False, doub_exp_conv=True, pre_existing_cal=False, K_d=68. * nmolar, n_H=2.49, dFF_max=40.4, sigma_noise=0.009975000000000001, dFF_1AP=0.65968, ca_amp=None, t_on=None, t_off=None, Ca_rest=50. * nmolar, kappa_S=110, gamma=292.3 * hertz, B_T=200. * umolar, dCa_T=7.6 * umolar, name='jgcamp7s', **kwparams) GECI #
Returns a (light-dependent) GECI model with specified submodel choices. Default parameters are taken from NAOMi’s code (Song et al., 2021) as well as Dana et al., 2019 and Zhang et al., 2023.
Only those parameters used in chosen model components apply. If the default is
None
, then we don’t have it fit yet.ca_amp
,t_on
, andt_off
are given as in NAOMi, but are converted to the proper scale and units for the double exponential convolution model. Namely,A = ca_amp / (second / 100)
andtau_[on|off] = second / t_[on|off]
.
- cleo.imaging.ogb1(light_dependent=False, doub_exp_conv=True, pre_existing_cal=False, K_d=250. * nmolar, n_H=1, dFF_max=14, sigma_noise=0.030227272727272728, dFF_1AP=None, ca_amp=None, t_on=None, t_off=None, Ca_rest=50. * nmolar, kappa_S=110, gamma=292.3 * hertz, B_T=200. * umolar, dCa_T=7.6 * umolar, name='ogb1', **kwparams) GECI #
Returns a (light-dependent) GECI model with specified submodel choices. Default parameters are taken from NAOMi’s code (Song et al., 2021) as well as Dana et al., 2019 and Zhang et al., 2023.
Only those parameters used in chosen model components apply. If the default is
None
, then we don’t have it fit yet.ca_amp
,t_on
, andt_off
are given as in NAOMi, but are converted to the proper scale and units for the double exponential convolution model. Namely,A = ca_amp / (second / 100)
andtau_[on|off] = second / t_[on|off]
.Don’t know sigma_noise. Default is the GCaMP6s value.
- cleo.imaging.target_neurons_in_plane(ng: NeuronGroup, scope_focus_depth: Quantity, scope_img_width: Quantity, scope_location: Quantity = array([0., 0., 0.]) * metre, scope_direction: tuple = (0, 0, 1), soma_radius: Quantity = 10. * umetre, sensor_location: str = 'cytoplasm') tuple[NDArray[Any, Int], NDArray[Any, Float], NDArray[Any, 3, Float]] [source]#
Returns a tuple of (i_targets, noise_focus_factor, coords_on_plane)
- Parameters:
ng (NeuronGroup) – The neuron group to target.
scope_focus_depth (Quantity) – The depth of the focal plane of the microscope.
scope_img_width (Quantity) – The width of the image captured by the microscope.
scope_location (Quantity, optional) – The location of the microscope, by default (0, 0, 0) * mm.
scope_direction (tuple, optional) – The direction of the microscope, by default (0, 0, 1).
soma_radius (Quantity, optional) – The radius of the soma of the neuron, by default 10 * um. Used to compute noise focus factor, since smaller ROIs will have a noisier distribution of fluorescence, averaged over fewer pixels.
sensor_location (str, optional) – The location of the sensor, by default “cytoplasm”.
- Returns:
A tuple of (i_targets, noise_focus_factor, coords_on_plane)
- Return type:
Tuple[NDArray[(Any,), int], NDArray[(Any,), float], NDArray[(Any, 3), float]]