sc_neurocore_engine/bindings/
fitzhugh_rinzel.rs1use numpy::{IntoPyArray, PyArray1};
12use pyo3::prelude::*;
13use pyo3::types::PyDict;
14
15use crate::neurons::FitzHughRinzelNeuron;
16
17py_neuron_default!("FitzHughRinzelNeuron", PyFitzHughRinzelNeuron, FitzHughRinzelNeuron, state v, state w, state y);
18
19pub(super) fn register(module: &Bound<'_, PyModule>) -> PyResult<()> {
21 module.add_class::<PyFitzHughRinzelNeuron>()?;
22 module.add_function(wrap_pyfunction!(py_fitzhugh_rinzel_simulate, module)?)?;
23 Ok(())
24}
25
26#[pyfunction]
33#[pyo3(signature = (v0, w0, y0, a, b, c, d, delta, mu, dt, v_threshold, n_steps, current))]
34#[allow(clippy::too_many_arguments)]
35fn py_fitzhugh_rinzel_simulate<'py>(
36 py: Python<'py>,
37 v0: f64,
38 w0: f64,
39 y0: f64,
40 a: f64,
41 b: f64,
42 c: f64,
43 d: f64,
44 delta: f64,
45 mu: f64,
46 dt: f64,
47 v_threshold: f64,
48 n_steps: usize,
49 current: f64,
50) -> (Bound<'py, PyArray1<f64>>, i64, f64, f64, f64) {
51 let mut neuron = FitzHughRinzelNeuron {
52 v: v0,
53 w: w0,
54 y: y0,
55 a,
56 b,
57 c,
58 d,
59 delta,
60 mu,
61 dt,
62 v_threshold,
63 };
64 let (trace, spikes) = neuron.simulate(n_steps, current);
65 (trace.into_pyarray(py), spikes, neuron.v, neuron.w, neuron.y)
66}