From b60493a8ceeafe828ee3919399173b02b60cb094 Mon Sep 17 00:00:00 2001 From: HanjiaJiang Date: Mon, 5 Feb 2024 21:56:06 +0100 Subject: [PATCH 1/2] Rename the variable name "Ca" to "Ca_astro" in astrocyte_lr_1994 --- .../astrocyte_model_implementation.ipynb | 30 +++++++++---------- models/astrocyte_lr_1994.cpp | 18 +++++------ models/astrocyte_lr_1994.h | 20 ++++++------- nestkernel/nest_names.cpp | 1 + nestkernel/nest_names.h | 1 + .../examples/astrocytes/astrocyte_brunel.py | 4 +-- .../astrocytes/astrocyte_interaction.py | 4 +-- .../examples/astrocytes/astrocyte_single.py | 4 +-- .../astrocytes/astrocyte_small_network.py | 4 +-- testsuite/pytests/test_astrocyte.dat | 2 +- testsuite/pytests/test_astrocyte.py | 6 ++-- testsuite/pytests/test_sic_connection.py | 6 ++-- 12 files changed, 51 insertions(+), 49 deletions(-) diff --git a/doc/htmldoc/model_details/astrocyte_model_implementation.ipynb b/doc/htmldoc/model_details/astrocyte_model_implementation.ipynb index f75876799f..fa73230bee 100644 --- a/doc/htmldoc/model_details/astrocyte_model_implementation.ipynb +++ b/doc/htmldoc/model_details/astrocyte_model_implementation.ipynb @@ -84,39 +84,39 @@ " Parameters\n", " ----------\n", " y : list\n", - " Vector containing the state variables [IP3, Ca, h_IP3R]\n", + " Vector containing the state variables [IP3, Ca_astro, h_IP3R]\n", " _ : unused var\n", " p : Params instance\n", " Object containing the astrocyte parameters.\n", "\n", " Returns\n", " -------\n", - " dCa : double\n", - " Derivative of Ca\n", + " dCa_astro : double\n", + " Derivative of Ca_astro\n", " dIP3 : double\n", " Derivative of IP3\n", " dh_IP3R : double\n", " Derivative of h_IP3R\n", " \"\"\"\n", " IP3 = y[0]\n", - " Ca = y[1]\n", + " Ca_astro = y[1]\n", " h_IP3R = y[2]\n", "\n", - " Ca = max(0, min(Ca, p.Ca_tot * (1 + p.ratio_ER_cyt)))\n", + " Ca_astro = max(0, min(Ca_astro, p.Ca_tot * (1 + p.ratio_ER_cyt)))\n", " alpha = p.k_IP3R * p.Kd_inh * (IP3 + p.Kd_IP3_1) / (IP3 + p.Kd_IP3_2)\n", - " beta = p.k_IP3R * Ca\n", - " Ca_ER = (p.Ca_tot - Ca) / p.ratio_ER_cyt\n", + " beta = p.k_IP3R * Ca_astro\n", + " Ca_ER = (p.Ca_tot - Ca_astro) / p.ratio_ER_cyt\n", " m_inf = IP3 / (IP3 + p.Kd_IP3_1)\n", - " n_inf = Ca / (Ca + p.Kd_act)\n", - " J_ch = p.ratio_ER_cyt * p.rate_IP3R * ((m_inf * n_inf * h_IP3R) ** 3) * (Ca_ER - Ca)\n", - " J_pump = p.rate_SERCA * (Ca**2) / (p.Km_SERCA**2 + Ca**2)\n", - " J_leak = p.ratio_ER_cyt * p.rate_L * (Ca_ER - Ca)\n", + " n_inf = Ca_astro / (Ca_astro + p.Kd_act)\n", + " J_ch = p.ratio_ER_cyt * p.rate_IP3R * ((m_inf * n_inf * h_IP3R) ** 3) * (Ca_ER - Ca_astro)\n", + " J_pump = p.rate_SERCA * (Ca_astro**2) / (p.Km_SERCA**2 + Ca_astro**2)\n", + " J_leak = p.ratio_ER_cyt * p.rate_L * (Ca_ER - Ca_astro)\n", "\n", - " dCa = J_ch - J_pump + J_leak\n", + " dCa_astro = J_ch - J_pump + J_leak\n", " dIP3 = (p.IP3_0 - IP3) / p.tau_IP3\n", " dh_IP3R = alpha * (1 - h_IP3R) - beta * h_IP3R\n", "\n", - " return dIP3, dCa, dh_IP3R" + " return dIP3, dCa_astro, dh_IP3R" ] }, { @@ -164,7 +164,7 @@ " \"\"\"\n", " t = np.arange(0, simtime, dt) # time axis\n", " n = len(t)\n", - " y = np.zeros((n, 3)) # state variables: IP3, Ca, h_IP3R\n", + " y = np.zeros((n, 3)) # state variables: IP3, Ca_astro, h_IP3R\n", " # for the state variables, assign the same initial values as in test_astrocyte.py\n", " y[0, 0] = 1.0\n", " y[0, 1] = 1.0\n", @@ -282,7 +282,7 @@ "implementation detailed in\n", "``doc/htmldoc/model_details/astrocyte_model_implementation.ipynb``.\n", "This data is used as reference for the tests in ``test_astrocyte.py``.\\n\n", - " Times IP3 Ca h_IP3R \"\"\",\n", + " Times IP3 Ca_astro h_IP3R\"\"\",\n", ")" ] }, diff --git a/models/astrocyte_lr_1994.cpp b/models/astrocyte_lr_1994.cpp index 139647106a..4278bd7a3f 100644 --- a/models/astrocyte_lr_1994.cpp +++ b/models/astrocyte_lr_1994.cpp @@ -61,7 +61,7 @@ RecordablesMap< astrocyte_lr_1994 >::create() { // use standard names whereever you can for consistency! insert_( names::IP3, &astrocyte_lr_1994::get_y_elem_< astrocyte_lr_1994::State_::IP3 > ); - insert_( names::Ca, &astrocyte_lr_1994::get_y_elem_< astrocyte_lr_1994::State_::Ca > ); + insert_( names::Ca_astro, &astrocyte_lr_1994::get_y_elem_< astrocyte_lr_1994::State_::Ca_astro > ); insert_( names::h_IP3R, &astrocyte_lr_1994::get_y_elem_< astrocyte_lr_1994::State_::h_IP3R > ); } @@ -85,7 +85,7 @@ astrocyte_lr_1994_dynamics( double time, const double y[], double f[], void* pno const double& ip3 = y[ S::IP3 ]; // Ca_tot_ corresponds to the c_0 (total [Ca++] in terms of cytosolic vol) // in De Young & Keizer (1992) and Li & Rinzel (1994) - const double& calc = std::max( 0.0, std::min( y[ S::Ca ], node.P_.Ca_tot_ ) ); // keep calcium within limits + const double& calc = std::max( 0.0, std::min( y[ S::Ca_astro ], node.P_.Ca_tot_ ) ); // keep calcium within limits const double& h_ip3r = y[ S::h_IP3R ]; const double alpha_h_ip3r = @@ -101,7 +101,7 @@ astrocyte_lr_1994_dynamics( double time, const double y[], double f[], void* pno * std::pow( h_ip3r, 3 ) * ( calc_ER - calc ); f[ S::IP3 ] = ( node.P_.IP3_0_ - ip3 ) / node.P_.tau_IP3_; - f[ S::Ca ] = J_channel - J_pump + J_leak + node.B_.J_noise_; + f[ S::Ca_astro ] = J_channel - J_pump + J_leak + node.B_.J_noise_; f[ S::h_IP3R ] = alpha_h_ip3r * ( 1.0 - h_ip3r ) - beta_h_ip3r * h_ip3r; return GSL_SUCCESS; @@ -137,7 +137,7 @@ nest::astrocyte_lr_1994::State_::State_( const Parameters_& p ) { // initial values based on Li & Rinzel (1994) and Nadkarni & Jung (2003) y_[ IP3 ] = p.IP3_0_; - y_[ Ca ] = 0.073; + y_[ Ca_astro ] = 0.073; y_[ h_IP3R ] = 0.793; } @@ -278,7 +278,7 @@ void nest::astrocyte_lr_1994::State_::get( DictionaryDatum& d ) const { def< double >( d, names::IP3, y_[ IP3 ] ); - def< double >( d, names::Ca, y_[ Ca ] ); + def< double >( d, names::Ca_astro, y_[ Ca_astro ] ); def< double >( d, names::h_IP3R, y_[ h_IP3R ] ); } @@ -286,14 +286,14 @@ void nest::astrocyte_lr_1994::State_::set( const DictionaryDatum& d, const Parameters_&, Node* node ) { updateValueParam< double >( d, names::IP3, y_[ IP3 ], node ); - updateValueParam< double >( d, names::Ca, y_[ Ca ], node ); + updateValueParam< double >( d, names::Ca_astro, y_[ Ca_astro ], node ); updateValueParam< double >( d, names::h_IP3R, y_[ h_IP3R ], node ); if ( y_[ IP3 ] < 0 ) { throw BadProperty( "IP3 concentration must be non-negative." ); } - if ( y_[ Ca ] < 0 ) + if ( y_[ Ca_astro ] < 0 ) { throw BadProperty( "Calcium concentration must be non-negative." ); } @@ -465,7 +465,7 @@ nest::astrocyte_lr_1994::update( Time const& origin, const long from, const long } // keep calcium within limits - S_.y_[ State_::Ca ] = std::max( 0.0, std::min( S_.y_[ State_::Ca ], P_.Ca_tot_ ) ); + S_.y_[ State_::Ca_astro ] = std::max( 0.0, std::min( S_.y_[ State_::Ca_astro ], P_.Ca_tot_ ) ); // this is to add the incoming spikes to IP3 S_.y_[ State_::IP3 ] += P_.delta_IP3_ * B_.spike_exc_.get_value( lag ); @@ -473,7 +473,7 @@ nest::astrocyte_lr_1994::update( Time const& origin, const long from, const long // SIC generation according to Nadkarni & Jung, 2003 // Suprathreshold log of calcium concentration determines SIC generation // 1000.0: change unit to nM as in the original paper - const double calc_thr = ( S_.y_[ State_::Ca ] - P_.SIC_th_ ) * 1000.0; + const double calc_thr = ( S_.y_[ State_::Ca_astro ] - P_.SIC_th_ ) * 1000.0; const double sic_value = calc_thr > 1.0 ? std::log( calc_thr ) * P_.SIC_scale_ : 0.0; B_.sic_values[ lag ] = sic_value; diff --git a/models/astrocyte_lr_1994.h b/models/astrocyte_lr_1994.h index bc918e1f1e..640714e33c 100644 --- a/models/astrocyte_lr_1994.h +++ b/models/astrocyte_lr_1994.h @@ -164,15 +164,15 @@ Parameters The following parameters can be set in the status dictionary. -====== ========= ============================================================= +======== ========= ============================================================= **Dynamic state variables** -------------------------------------------------------------------------------- -IP3 µM Inositol 1,4,5-trisphosphate concentration in the astrocytic - cytosol -Ca µM Calcium concentration in the astrocytic cytosol -h_IP3R unitless Fraction of IP3 receptors on the astrocytic ER that are not - yet inactivated by calcium -====== ========= ============================================================= +-------------------------------------------------------------------------------- +IP3 µM Inositol 1,4,5-trisphosphate concentration in the astrocytic + cytosol +Ca_astro µM Calcium concentration in the astrocytic cytosol +h_IP3R unitless Fraction of IP3 receptors on the astrocytic ER that are not + yet inactivated by calcium +======== ========= ============================================================= =============== ========= ===================================================== **Parameters** @@ -354,8 +354,8 @@ class astrocyte_lr_1994 : public StructuralPlasticityNode enum StateVecElems { IP3 = 0, - Ca, // 1 - h_IP3R, // 2 + Ca_astro, // 1 + h_IP3R, // 2 STATE_VEC_SIZE }; diff --git a/nestkernel/nest_names.cpp b/nestkernel/nest_names.cpp index 47bfbfba05..b821cf5d58 100644 --- a/nestkernel/nest_names.cpp +++ b/nestkernel/nest_names.cpp @@ -84,6 +84,7 @@ const Name buffer_size_target_data( "buffer_size_target_data" ); const Name C_m( "C_m" ); const Name Ca( "Ca" ); +const Name Ca_astro( "Ca_astro" ); const Name Ca_tot( "Ca_tot" ); const Name c( "c" ); const Name c_1( "c_1" ); diff --git a/nestkernel/nest_names.h b/nestkernel/nest_names.h index b0ef0734c0..b34745b2b1 100644 --- a/nestkernel/nest_names.h +++ b/nestkernel/nest_names.h @@ -110,6 +110,7 @@ extern const Name buffer_size_target_data; extern const Name C_m; extern const Name Ca; +extern const Name Ca_astro; extern const Name Ca_tot; extern const Name c; extern const Name c_1; diff --git a/pynest/examples/astrocytes/astrocyte_brunel.py b/pynest/examples/astrocytes/astrocyte_brunel.py index ec8c46097c..78669886cc 100644 --- a/pynest/examples/astrocytes/astrocyte_brunel.py +++ b/pynest/examples/astrocytes/astrocyte_brunel.py @@ -256,7 +256,7 @@ def plot_dynamics(astro_data, neuron_data, start): # astrocyte data astro_mask = astro_data["times"] > start astro_ip3 = astro_data["IP3"][astro_mask] - astro_cal = astro_data["Ca"][astro_mask] + astro_cal = astro_data["Ca_astro"][astro_mask] astro_times = astro_data["times"][astro_mask] astro_times_set = list(set(astro_times)) ip3_means = np.array([np.mean(astro_ip3[astro_times == t]) for t in astro_times_set]) @@ -329,7 +329,7 @@ def run_simulation(): # create and connect recorders (multimeter default resolution = 1 ms) sr_neuron = nest.Create("spike_recorder") mm_neuron = nest.Create("multimeter", params={"record_from": ["I_SIC"]}) - mm_astro = nest.Create("multimeter", params={"record_from": ["IP3", "Ca"]}) + mm_astro = nest.Create("multimeter", params={"record_from": ["IP3", "Ca_astro"]}) # select nodes randomly and connect them with recorders print("Connecting recorders ...") diff --git a/pynest/examples/astrocytes/astrocyte_interaction.py b/pynest/examples/astrocytes/astrocyte_interaction.py index ce91b0e56d..4be19b1371 100644 --- a/pynest/examples/astrocytes/astrocyte_interaction.py +++ b/pynest/examples/astrocytes/astrocyte_interaction.py @@ -95,7 +95,7 @@ # Create and connect the astrocyte and its devices. astrocyte = nest.Create("astrocyte_lr_1994", params=params_astro) -mm_astro = nest.Create("multimeter", params={"record_from": ["IP3", "Ca"]}) +mm_astro = nest.Create("multimeter", params={"record_from": ["IP3", "Ca_astro"]}) nest.Connect(mm_astro, astrocyte) ############################################################################### @@ -133,7 +133,7 @@ axes[0].plot(data_pre["times"], data_pre["V_m"]) axes[1].plot(data_astro["times"], data_astro["IP3"]) axes[2].plot(data_post["times"], data_post["I_SIC"]) -axes[3].plot(data_astro["times"], data_astro["Ca"]) +axes[3].plot(data_astro["times"], data_astro["Ca_astro"]) axes[0].set_title(f"Presynaptic neuron\n(Poisson rate = {poisson_rate_neuro} Hz)") axes[0].set_ylabel("Membrane potential (mV)") axes[2].set_title("Postsynaptic neuron") diff --git a/pynest/examples/astrocytes/astrocyte_single.py b/pynest/examples/astrocytes/astrocyte_single.py index 7de0865210..e3ef58a130 100644 --- a/pynest/examples/astrocytes/astrocyte_single.py +++ b/pynest/examples/astrocytes/astrocyte_single.py @@ -78,7 +78,7 @@ astrocyte = nest.Create("astrocyte_lr_1994", params=params_astro) ps_astro = nest.Create("poisson_generator", params={"rate": poisson_rate}) -mm_astro = nest.Create("multimeter", params={"record_from": ["IP3", "Ca"]}) +mm_astro = nest.Create("multimeter", params={"record_from": ["IP3", "Ca_astro"]}) nest.Connect(ps_astro, astrocyte, syn_spec={"weight": poisson_weight}) nest.Connect(mm_astro, astrocyte) @@ -93,7 +93,7 @@ fig, axes = plt.subplots(2, 1, sharex=True, figsize=(6.4, 4.8), dpi=100) axes[0].plot(data["times"], data["IP3"]) -axes[1].plot(data["times"], data["Ca"]) +axes[1].plot(data["times"], data["Ca_astro"]) axes[0].set_ylabel(r"[IP$_{3}$] ($\mu$M)") axes[1].set_ylabel(r"[Ca$^{2+}$] ($\mu$M)") axes[1].set_xlabel("Time (ms)") diff --git a/pynest/examples/astrocytes/astrocyte_small_network.py b/pynest/examples/astrocytes/astrocyte_small_network.py index 52b42a3443..9411b78d07 100644 --- a/pynest/examples/astrocytes/astrocyte_small_network.py +++ b/pynest/examples/astrocytes/astrocyte_small_network.py @@ -342,7 +342,7 @@ def plot_dynamics(astro_data, neuron_data, start): print("Plotting dynamics ...") # get astrocyte data astro_times, astro_ip3_mean, astro_ip3_sd = get_plot_data(astro_data, "IP3") - astro_times, astro_ca_mean, astro_ca_sd = get_plot_data(astro_data, "Ca") + astro_times, astro_ca_mean, astro_ca_sd = get_plot_data(astro_data, "Ca_astro") # get neuron data neuron_times, neuron_sic_mean, neuron_sic_sd = get_plot_data(neuron_data, "I_SIC") # set plots @@ -413,7 +413,7 @@ def plot_dynamics(astro_data, neuron_data, start): ) mm_pre_neurons = nest.Create("multimeter", params={"record_from": ["V_m"]}) mm_post_neurons = nest.Create("multimeter", params={"record_from": ["V_m", "I_SIC"]}) -mm_astrocytes = nest.Create("multimeter", params={"record_from": ["IP3", "Ca"]}) +mm_astrocytes = nest.Create("multimeter", params={"record_from": ["IP3", "Ca_astro"]}) nest.Connect(mm_pre_neurons, pre_neurons) nest.Connect(mm_post_neurons, post_neurons) nest.Connect(mm_astrocytes, astrocytes) diff --git a/testsuite/pytests/test_astrocyte.dat b/testsuite/pytests/test_astrocyte.dat index c3da10673c..5646c90265 100644 --- a/testsuite/pytests/test_astrocyte.dat +++ b/testsuite/pytests/test_astrocyte.dat @@ -9,7 +9,7 @@ # ``doc/htmldoc/model_details/astrocyte_model_implementation.ipynb``. # This data is used as reference for the tests in ``test_astrocyte.py``. # -# Times IP3 Ca h_IP3R +# Times IP3 Ca_astro h_IP3R 1.000000000000000056e-01 9.999882386709698645e-01 1.000187105302611235e+00 9.999799984511013040e-01 2.000000000000000111e-01 9.999764775066160016e-01 1.000374129429669079e+00 9.999599938057039950e-01 3.000000000000000444e-01 9.999647165069364130e-01 1.000561072405474095e+00 9.999399860656773553e-01 diff --git a/testsuite/pytests/test_astrocyte.py b/testsuite/pytests/test_astrocyte.py index 3b0cacc44b..db73bd6a27 100644 --- a/testsuite/pytests/test_astrocyte.py +++ b/testsuite/pytests/test_astrocyte.py @@ -58,10 +58,10 @@ def test_closeness_nest_odeint(): # create astrocyte and devices # initial values of the state variables as in the reference solution - astrocyte = nest.Create("astrocyte_lr_1994", params={"IP3": 1.0, "Ca": 1.0, "h_IP3R": 1.0}) + astrocyte = nest.Create("astrocyte_lr_1994", params={"IP3": 1.0, "Ca_astro": 1.0, "h_IP3R": 1.0}) mm = nest.Create( "multimeter", - {"interval": nest.resolution, "record_from": ["IP3", "Ca", "h_IP3R"]}, + {"interval": nest.resolution, "record_from": ["IP3", "Ca_astro", "h_IP3R"]}, ) spk_ge = nest.Create("spike_generator", {"spike_times": spike_times, "spike_weights": spike_weights}) @@ -74,5 +74,5 @@ def test_closeness_nest_odeint(): # compare results with reference data assert mm.events["IP3"] == pytest.approx(ref_ip3) - assert mm.events["Ca"] == pytest.approx(ref_ca) + assert mm.events["Ca_astro"] == pytest.approx(ref_ca) assert mm.events["h_IP3R"] == pytest.approx(ref_h_ip3r) diff --git a/testsuite/pytests/test_sic_connection.py b/testsuite/pytests/test_sic_connection.py index 1e6d69b7dc..ed21a55064 100644 --- a/testsuite/pytests/test_sic_connection.py +++ b/testsuite/pytests/test_sic_connection.py @@ -63,11 +63,11 @@ def test_SynapseFunctionWithAeifModel(): resol = nest.resolution # Create neurons and devices - astrocyte = nest.Create("astrocyte_lr_1994", {"Ca": 0.2}) # a calcium value which produces SIC + astrocyte = nest.Create("astrocyte_lr_1994", {"Ca_astro": 0.2}) # a calcium value which produces SIC neuron = nest.Create("aeif_cond_alpha_astro") mm_neuron = nest.Create("multimeter", params={"record_from": ["I_SIC"], "interval": resol}) - mm_astro = nest.Create("multimeter", params={"record_from": ["Ca"], "interval": resol}) + mm_astro = nest.Create("multimeter", params={"record_from": ["Ca_astro"], "interval": resol}) nest.Connect(astrocyte, neuron, syn_spec={"synapse_model": "sic_connection"}) nest.Connect(mm_neuron, neuron) @@ -80,7 +80,7 @@ def test_SynapseFunctionWithAeifModel(): # The expected SIC values are calculated based on the astrocyte dynamics # implemented in astrocyte_lr_1994.cpp. actual_sic_values = mm_neuron.events["I_SIC"] - Ca = mm_astro.events["Ca"] + Ca = mm_astro.events["Ca_astro"] f_v = np.vectorize(lambda x: np.log(x * 1000.0 - 196.69) if x * 1000.0 - 196.69 > 1.0 else 0.0) expected_sic_values = f_v(Ca) From 677bbd07201d91e52cbc549efef04e1f0d79efcc Mon Sep 17 00:00:00 2001 From: HanjiaJiang Date: Tue, 6 Feb 2024 09:35:31 +0100 Subject: [PATCH 2/2] Fix clang format --- models/astrocyte_lr_1994.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/models/astrocyte_lr_1994.h b/models/astrocyte_lr_1994.h index 640714e33c..9360985b78 100644 --- a/models/astrocyte_lr_1994.h +++ b/models/astrocyte_lr_1994.h @@ -354,8 +354,8 @@ class astrocyte_lr_1994 : public StructuralPlasticityNode enum StateVecElems { IP3 = 0, - Ca_astro, // 1 - h_IP3R, // 2 + Ca_astro, // 1 + h_IP3R, // 2 STATE_VEC_SIZE };