## Abstract

This study combines experimental techniques and mathematical modeling to investigate the dynamics of *C. elegans* body-wall muscle cells. Specifically, by conducting voltage clamp and mutant experiments, we identify key ion channels, particularly the L-type voltage-gated calcium channel (EGL-19) and potassium channels (SHK-1, SLO-2), which are crucial for generating action potentials. We develop Hodgkin-Huxley-based models for these channels and integrate them to capture the cells’ electrical activity. To ensure the model accurately reflects cellular responses under depolarizing currents, we develop a parallel simulation-based inference method for determining the model’s free parameters. This method performs rapid parallel sampling across high-dimensional parameter spaces, fitting the model to the responses of muscle cells to specific stimuli and yielding accurate parameter estimates. We validate our model by comparing its predictions against cellular responses to various current stimuli in experiments and show that our approach effectively determines suitable parameters for accurately modeling the dynamics in mutant cases. Additionally, we discover an optimal response frequency in body-wall muscle cells, which corresponds to a burst firing mode rather than regular firing mode. Our work provides the first experimentally constrained and biophysically detailed muscle cell model of *C. elegans*, and our analytical framework combined with robust and efficient parametric estimation method can be extended to model construction in other species.

**Author summary** Despite the availability of many biophysical neuron models of *C. elegans*, a biologically detailed model of its muscle cell remains lacking, which hampers an integrated understanding of the motion control process. We conduct voltage clamp and mutant experiments to identify ion channels that influence the dynamics of body-wall muscle cells. Using these data, we establish Hodgkin-Huxley-based models for these ion channels and integrate them to simulate the electrical activity of the muscle cells. To determine the free parameters of the model, we develop a simulation-based inference method with parallel sampling that aligns the model with the muscle cells’ responses to specific stimuli. Our method allows for swift parallel sampling of parameters in high dimensions, facilitating efficient and accurate parameter estimation. To validate the effectiveness of the determined parameters, we verify the cells’ responses under different current stimuli in wild type and mutant cases. Furthermore, we investigate the optimal response frequency of body-wall muscle cells and find that it exhibits a frequency consistent with burst firing mode rather than regular firing mode. Our research introduces the first experimentally validated and biophysically detailed model of muscle cells in *C. elegans*. Additionally, our modeling and simulation framework for efficient parametric estimation in high-dimensional dynamical systems can be extended to model constructions in other scenarios.

## Introduction

The quest to reverse-engineer biologically intellectual systems remains a pivotal challenge in the domains of neuroscience and artificial intelligence. Achieving an in-depth understanding of the brain and its peripheral systems’ functional mechanisms is crucial for deciphering the fundamental origins of intelligence [1, 2]. Although the field has witnessed substantial advancements, the creation of human-level intelligent systems is still an elusive target. This is largely attributed to the human brain’s vast complexity, encompassing billions of interconnected neurons [3]. In contrast, the nematode *C. elegans* provides a more tractable model due to its comparatively simple neuronal network, consisting of far fewer neurons and synapses [4]. Despite its simplicity, the *C. elegans* brain demonstrates remarkable computational efficiency and versatility. This enables the nematode to execute a diverse array of behaviors, including movement, feeding, sleeping, and mating [5–8]. Moreover, this species is capable of adapting its behavior in response to environmental changes and various stimuli, such as hunger, sex, or stress [6, 9, 10]. Crucially, the connectome of *C. elegans* has been comprehensively mapped at the cellular level [11, 12], providing a valuable and unique resource for neuronal networks modeling.

The long-standing perception in neuroscience posits that nematodes are exceptional in their absence of neuronal action potentials [13]. This has been primarily shaped by early electrophysiological studies conducted on the parasitic nematode *Ascaris suum* [14]. These studies demonstrate that the motor neurons of *Ascaris suum* exhibit only graded electrical properties and synaptic transmission, without any evidence of the typical action potentials observed in many other species [13–16]. Additionally, the *C. elegans* genome lacks voltage-gated sodium channel genes [17], a feature not commonly seen in many species, which is thought to correlate with the absence of action potentials in nematode neurons. However, recent discoveries have challenged this notion by revealing the presence of digital signals within *C. elegans*. Surprisingly, neuroscientists have detected calcium-mediated spikes in *C. elegans*, exhibiting features resembling the hallmark characteristics of action potentials seen in other species [13, 16, 18–27]. Notably, these have been observed in specific interneurons [25], and various sensory and motor neurons [13, 26, 27], with pharyngeal and body-wall muscles also displaying calcium-dependent action potentials at frequencies between 3–10 Hz [18, 24, 28].

Concurrently, the development of computational models has significantly advanced the understanding of *C. elegans* neuronal physiology. One area of focus is macroscopic network modeling, which has yielded several important insights. For example, a forward locomotion modeling has revealed that AVB premotor interneurons can induce bifurcations in B-type motor neuron dynamics [29]. Furthermore, proprioceptive interactions among neighboring B-type motor neurons synchronize the frequency of body movements [8, 29, 30]. Meanwhile, detailed electrophysiological single-neuron models are essential for elucidating neuronal transmission and electrical responses at the molecular level. For instance, an olfactory neuron AWA has been shown to encode natural odor stimuli through regenerative all-or-nothing action potentials [13]. These detailed models are also crucial for investigating the roles of specific ion channels in various cells. Notably, T-type calcium currents facilitated by CCA-1 channels play a critical role in eliciting the depolarization of the motor neuron RMD [26]. Similarly, the electrophysiological model of pharyngeal muscle cells has demonstrated that the strong hyperpolarization after each spike is mediated by potassium channels EXP-2 [27, 31, 32].

Despite the availability of many biophysical neuron models of *C. elegans*, a biologically detailed model of its muscle cell remains lacking, which hampers an integrated understanding of intellectual behaviors of motion control. Therefore, there remains a need for detailed mathematical models that accurately characterize the electrophysiological data of these body-wall muscle cells.

In this study, we perform electrophysiological experiments and develop Hodgkin-Huxley type models to capture the underlying mechanism for action potential generation for body-wall muscle cells [33–36]. Specifically, utilizing voltage clamp techniques, we construct detailed current dynamics for each ion channel based on our experimental data. These ion currents are subsequently used to develop a well-constrained biophysical model of electrical activity in body-wall muscle cells. To determine the free parameters in the model, we develop a parallel simulation-based inference method to fit the responses of body-wall muscle cells under specific current stimuli [37–39]. This method is based on a Bayesian framework and can efficiently explore high-dimensional parameter spaces. It identifies high-probability regions of parameter space that are consistent with experimental data, thereby quantifying parameter uncertainty. We then validate the model’s accuracy by comparing its responses to various current stimuli with corresponding experimental data. Additionally, our approach effectively determines suitable parameters for accurately modeling the dynamics in channel mutants and responses in sodium-ion-free solutions. We also explore the optimal response frequency of body-wall muscle cells, finding that it corresponds to a burst firing mode rather than a regular firing mode. Our modeling approach and framework provide detailed current dynamics for each ion channel and facilitate efficient parametric estimation in high-dimensional dynamical systems, which can be extended to model construction of different cell types in other species.

The structure of this paper is organized as follows: Section 2 details the electrophysiology experimental setup and explains the use of voltage clamp experimental data to establish the corresponding ion channel model. It then introduces an algorithm designed to efficiently search high-dimensional parameter spaces to determine the model’s optimal parameters. The results obtained are analyzed in Section 3 from both numerical and biological perspectives. Section 4 concludes with a summary and discussion, as well as possible future research directions.

## Materials and methods

### Electrophysiology

Recordings from dissected *C. elegans* body-wall muscles were conducted following established protocols [24]. Specifically, adult hermaphrodites aged one day were immobilized on slides with adhesive, and the body-wall muscles were exposed through lateral incisions. We then assessed the integrity of the anterior ventral body muscle and the ventral nerve cord using differential interference contrast (DIC) microscopy. Muscle cells were subsequently patched using fire-polished borosilicate pipettes with a resistance of 4-6 MΩ (World Precision Instruments, USA). We recorded membrane currents and potentials in a whole-cell configuration using a Digidata 1440A and a MultiClamp 700A amplifier, coupled with Clampex 10 software for acquisition and Clampfit 10 for data processing (Axon Instruments, Molecular Devices, USA). The data were digitized at a rate of 10-20 kHz and filtered at 2.6 kHz. Using Clampex, we determined cell resistance and capacitance by administering a 10-mV depolarizing pulse from a holding potential of *−*60mV, enabling the calculation of Ca^{2+} and K^{+} current densities (pA*/*pF). Leak currents were not subtracted in these measurements. For recording membrane potentials and K^{+}currents: The pipette solution contains (in mM): K-gluconate 115; KCl 25; CaCl_{2} 0.1; MgCl_{2} 5; BAPTA 1; HEPES 10; Na_{2}ATP 5; Na_{2}GTP 0.5; cAMP 0.5; cGMP 0.5, pH7.2 with KOH, *∼*320 mOsm. The extracellular Nsolution consists of (in mM): NaCl 150; KCl 5; CaCl_{2} 5; MgCl_{2} 1; glucose 10; sucrose 5; HEPES 15, pH7.3 with NaOH, *∼*330 mOsm. For recording voltage-dependent Ca^{2+} currents: The pipette solution contained (in mM): CsCl 140; TEA-Cl 10; MgCl_{2} 5; EGTA 5; HEPES 10, pH7.2 with CsOH, *∼*320 mOsm. The extracellular solution contained (in mM): TEA-Cl 140; CaCl_{2} 5; MgCl_{2} 1; 4-AP 3; glucose 10; sucrose 5; HEPES 15, pH7.4 with CsOH, *∼*330 mOsm.

### Conductance-based model description

In this section, we present the mathematical formulation of our biophysical model. Our model is based on the Hodgkin-Huxley type formulation, which proves to be a powerful computational approach that accurately reproduces the spiking times and membrane voltage waveform of biological neurons in response to current injections [33–36]. The Hodgkin-Huxley type model we construct encompasses a spectrum of ion channels present in *C. elegans*, including the L-type voltage-gated calcium channel EGL-19, voltage-gated potassium channel SHK-1, and Ca^{2+}-gated potassium channel SLO-2, along with non-specific passive currents (Leak) [40, 41]. According to the conservation of current, the membrane voltage dynamics can be described by:
where *I*_{ext} is the external applied current and *I*_{total} contains all the considered ionic currents
The ionic currents *I*_{EGL-19}, *I*_{SHK-1}, and *I*_{Leak} are governed by a generalized formulation:
where *m*_{ion} and *h*_{ion} are voltage-dependent activation and inactivation gating variables, respectively. Both gates can be in either an open or closed state. The variables *m*_{ion} and *h*_{ion} represent the probability of an activation or inactivation gate being in the open state, respectively. For each ion channel, the parameters *a* and *b* represent the number of activation and inactivation gates, respectively. The parameter *g*_{ion} represents the maximal conductance, while *E*_{ion} denotes the reversal potential of the specific ion channel. The gating variables follow the dynamics described by first-order differential equations:
where *x*_{∞}(*V*) represents the steady state and *τ*_{x}(*V*) represents the voltage-dependent time constant.

Meanwhile, there are also ion channels characterized by ligand and voltage regulated currents, e.g., calcium-regulated channel SLO-2. These models are elucidated by specialized models as follows. We modify the model from previous studies [26, 42, 43] to describe the kinetics of *I*_{SLO-2}, which requires the binding of two calcium ions to open the channel. The ionic current takes the form of
where [Ca^{2+}] is the intracellular calcium concentration, and
Here, *α* = 58 ms^{−1}mM^{−2} and *β* = 0.09 ms^{−1} are rate constants [26, 44, 45]. Additionally, the parameter *z*_{∞} in Eq. 5 is the voltage-dependent equilibrium value.

Due to the dependence of the gating variable *p* on [Ca^{2+}]_{i}, it is imperative to undertake an estimation of differential equation:[Ca^{2+}]_{i}. The calculation is performed using the following differential equation:
where [Ca^{2+}]_{r} is the resting intracellular calcium concentration. The parameter *d* denotes the depth of a proximal shell adjacent to the cell’s surface, which encompasses an area *A*. The Faraday constant *F* indicates the charge per mole and the parameter *γ* represents the recovery rate for calcium ions [46, 47].

We initially establish an estimated range for the model parameters. There are two methods to estimate these parameters. The first method involves fitting experimental voltage clamp data from various ion channels, which helps determine a subset of the model’s parameters. Due to individual cell variability, the model parameters for different cells exhibit a range of values. Since voltage clamp experiments for different ion channels are conducted on different cells, solely fitting the voltage clamp data to determine all parameters does not accurately capture the cells’ voltage responses to current injection, which is the primary focus of our model. Consequently, we consider the maximum conductance of each ion channel and the cell membrane capacitance as free parameters. The initially estimated range of these parameters is then incorporated into a parallel simulation-based inference technique to estimate the probability distributions of parameters, fitting the response of body-wall muscle cells to specific external current stimuli.

### Parallel simulation-based inference

Simulation-based inference (SBI) is a powerful statistical inference approach aimed at estimating parameters of a simulation model based on observed data in experiment [39, 48, 49]. This method has demonstrated considerable efficacy in numerous real-world applications, spanning a diverse array of scientific domains, including population genetics, neuroscience, epidemiology, climate science, astrophysics, and cosmology [39, 48, 50–52]. However, the challenge in our study lies in navigating a high-dimensional parameter space, which renders existing algorithms computationally intensive and time-consuming. To address this, we devise a parallelized version of SBI capable of efficiently exploring high-dimensional parameter spaces through GPU acceleration.

Before introducing the algorithm, we first present the experimental dataset used in our study. We generate four spike trains using four constant current stimuli of 15 pA, 20 pA, 25 pA, and 30 pA. One of them is selected as the training dataset, with the remaining three spike trains serving as the test datasets.

Our algorithm is outlined in Algorithm 1. Based on the experimental data, we provide approximate intervals for the model’s parameter values, choosing a uniform prior distribution *p*(** θ**) within these intervals. We then extract the essential features from the experimental data, as shown in Tab. 1, which we refer to as the observed data

**x**

_{o}. Our objective is to determine a posterior distribution of the parameters

**. This is achieved through the Maximum a Posteriori (MAP) method, which yields the distribution**

*θ**p*(

**|**

*θ***x**). By conditioning on the observed data

**x**=

**x**

_{o}, we ultimately obtain

*p*(

**|**

*θ***x**

_{o}). The algorithm operates over multiple rounds, beginning with the initial round. In this round, with the simulation number

*N*=

*N*

_{1}, we sample

*N*parameter values from the prior distribution

*p*(

**), denoted as**

*θ*

*θ*_{i}

*∼ p*(

**) for**

*θ**i*= 1, 2,

*…, N*. These sampled values are then used to run simulations, a process known to be time-consuming, especially for large

*N*. To mitigate this, we leverage GPU parallel computation to vectorize, parallelize, and utilize just-in-time compilation for the entire simulation process, using the BrainPy software [53, 54]. The outputs of the model simulations, specifically the generated voltage curves, are summarized by key features, denoted as

**x**

_{i}and detailed in Tab. 1. This summarization step is also vectorized and processed on the GPU. The resulting

*N*parameter-data pairs, represented as (

*θ*_{i},

**x**

_{i}) for

*i*= 1, 2,

*… … …, N*, are used to train a neural network posterior estimator

*q*

_{ψ}(

**|**

*θ***x**), where

*ψ*denotes the neural network parameters. The neural network learns the posterior probability based on a masked autoregressive flow method [55]. The network parameters

*ψ*are optimized by minimizing the objective function , where Finally, the trained neural network posterior estimator:

*q*

_{ψ}(

**|**

*θ***x**) is applied to the observation data

**x**

_{o}, yielding the posterior distribution

*q*

_{ψ}(

**|**

*θ***x**

_{o}). This constitutes the initial round of inference. In subsequent rounds, samples from the obtained posterior distribution conditioned on the observed data,

*p*∼

_{r+1}(

**) =**

*θ**q*

_{ψ}(

**|**

*θ***x**

_{o}), are used to simulate a new training set. This new training set is then combined with the previous dataset to retrain the network. This process repeats for a specified number of rounds or until the Kullback-Leibler (KL) divergence [56] between successive posterior distributions falls below a predefined threshold

*ϵ*, indicating convergence. The KL divergence measures how one probability distribution diverges from a second, expected probability distribution, thus a lower value suggests the distributions are more similar. Ultimately, the final posterior distribution is represented as

*p*(

**|**

*θ***x**

_{o}) =

*q*

_{ψ}(

**|**

*θ***x**

_{o}).

Given the high dimensionality of the parameter space in our study, the algorithm requires a substantial number of model simulations to yield satisfactory results. The original SBI algorithm, due to computational time and hardware limitations, could only perform a limited number of model simulations in each round. This necessitated multiple rounds for the algorithm to converge. Our parallel SBI algorithm improves upon previous methodologies by utilizing GPU-based vectorization and parallelization, enabling a significant number of model simulations to be performed concurrently in each round within a brief timeframe. This enhancement accelerates the algorithm’s convergence, thereby reducing the number of rounds required. Consequently, this reduction in rounds decreases the number of neural network training sessions, thereby lowering computational costs and reducing execution time.

## Results

Our experimental observations indicate that body-wall muscle cell spikes exhibit a stereotypical shape characterized by a fast upstroke, followed by a rapid downstroke and afterhyperpolarization, as shown in Fig. 1A. These spikes can display “burst” and “regular” firing modes. In this section, we develop a biologically detailed model of the body-wall muscle cells and investigate the physiological mechanisms underlying our experimental observations. In particular, we analyze the roles of individual ionic currents within the overall cell dynamics.

### Body-wall muscle cells fire all-or-nothing action potentials

To explore the biophysical underlying mechanisms of the *C. elegans* motor circuits, we have conducted an electrophysiological survey of body-wall-muscle cells in *C. elegans*. Classic whole-cell configuration, by using a Digidata 1440A and a MultiClamp 700A amplifier, was made to record the isolated voltage activated K^{+} currents and voltage-gated Ca^{2+} currents from the muscle cells as shown in Fig. 1B.

It is well-established that voltage-dependent potassium channels, triggered by depolarization, play a crucial role in terminating action potentials. Therefore, it is imperative to investigate all potassium channels involved in regulating the electrical activity of body-wall muscle cells. Fig. 1C provides a comprehensive overview of the currents associated with voltage-gated potassium channels expressed in *C. elegans*. Mutant voltage clamp currents exhibit significant findings: a marked decrease in current response in *shk-1(lf)* mutants and a moderate reduction in *slo-2(lf)* mutants, and only nominal alterations in other mutant varieties (Fig. 1(C-D) and S1 Fig). These observations suggest that the SHK-1 channel plays a central role as the primary voltage-gated potassium channel responsible for repolarizing action potentials, while the SLO-2 channel contributes minimally to this repolarization process.

Our previous work [24] established that the action potentials of *C. elegans* body-wall muscle cells are calcium-dependent. To further explore the primary channels influencing the electrophysiological activity of these muscle cells, we conduct voltage clamp experiments. Because *egl-19* null animals are embryonically lethal, two viable, recessive alleles with partial loss-of-function, *n582* and *ad1006*, are examined. Fig. 1E illustrates altered kinetics in *egl-19* mutants, indicating that EGL-19 is responsible for eliciting muscle cell action potentials.

These findings highlight the voltage-dependent Ca^{2+} channel EGL-19, in conjunction with K^{+} channels SHK-1 and SLO-2, collectively contribute to the generation of action potentials in *C. elegans* body-wall muscle cells.

### Modeling channel dynamics based on experimental data

Based on the previous discussion in Sec. Materials and methods, the parameters for the SHK-1 channel model are determined using voltage clamp experimental data. As shown in Fig. 2A, we perform numerical curve fitting for each voltage clamp protocol, where the voltage is held constant. Through this process, we obtain appropriate values for *τ*_{n} and *n*_{∞} at specific voltages, with the results presented in Fig. 2A. Subsequently, these values are further analyzed to establish the voltage-dependent functions *τ*_{n}(*V*) and *n*_{∞}(*V*), as demonstrated in Fig. 2(B-C).

Next, we focus on modeling the calcium channel EGL-19. To address the variability in experimental data for calcium channels across different individuals, we analyze the current-voltage (I-V) relationship of calcium currents from multiple individual cells. We then calculate the mean and standard error, as illustrated in Fig 3B. We determine model parameters based on both voltage clamp experimental data in Fig. 1E and the I-V relationship in Fig. 3B, with the final results presented in Fig 3(A-B). Subsequently, we obtain the parameters *τ*_{m}, *τ*_{h}, *m*_{∞}, and *n*_{∞} at specific voltages. Based on these values, we establish the functional forms for the gating variables *m* and *h*, as illustrated in Fig. 3(C-D).

The calcium-regulated potassium channels SLO-2 are characterized by their intricate dynamics, influenced by both calcium ion concentration levels and voltage amplitude, as modeled previously. Determining numerous parameters solely from voltage clamp data is difficult. Therefore, our methodology predominantly relies on using the parallel SBI method to fit the model to action potential traces observed in body-wall muscle cells subjected to specific electrical stimuli, ensuring precise parameter estimation.

The model of leak current for the *C. elegans* body-wall muscle cells is
where *E*_{Leak} corresponds to the reversal potential of the channel and *g*_{Leak} is the leak conductance that can be estimated in experiment by assuming the cell is a linear integrator [57].

By combining experimental measurements of the four aforementioned ion channels and considering individual cell variability, we can initially estimate the confidence intervals for the corresponding parameters of these ion channels. However, in the case of *C. elegans*, the generation of action potentials may involve additional channels. In the following discussion, we will integrate ion channel candidates mentioned in previous studies on motor neurons and muscle cells, alongside numerical modeling methods, to identify these additional ion channels. Furthermore, we will use our designed parallel algorithm of simulation-based inference method to accurately determine the parameter ranges for all these channels.

### The resulting 7-dimensional HH type model

We note that when the model contains only the four previously mentioned ion channels, the action potentials exhibit premature repolarization compared to experimental data. Additionally, the resting potential deviates from that observed in the experimental data. To address these issues, we introduce a potassium ionic current, denoted as *K*_{r}, which serves as an early-phase inhibitory current, and the NCA sodium leak channel, which has a conserved role in determining the neuronal resting membrane potential in our model [58].

The final 7-dimensional HH type model for body-wall muscle cells is given by the following:
The six ionic currents in our model are shown in the following:
where g_{x}(*x* = SHK-1, EGL-19, SLO-2, Kr, Na, Leak) and *E*_{x}(*x* = K, Ca, Na, Leak) denote the maximal ionic conductance and the reversal potential for each respective current. Additionally, *n, p* and *q* correspond to the activation gating variables for *I*_{SHK-1}, *I*_{SLO-2} and *I*_{Kr}, respectively. The *m* and *h* represent the activation and inactivation gating variables for *I*_{EGL-19}, respectively.

As detailed in Sec. Materials and methods, we determine the free model parameters as illustrated in Fig. 4E. These parameters include maximal conductance values (*g*_{EGL-19}, *g*_{SHK-1}, *g*_{SLO-2}, and *g*_{Leak}), membrane capacitance (*C*_{m}), and voltage shift value (*V*_{th}). For more details on the voltage shift, please refer to S1 Appendix. To measure the differences between the model-generated spike train and the experimental data, we calculate five features of the voltage trace in Fig. 4A (red curve), as listed in Tab. 1. These features provide a comprehensive representation of neuronal activity.

Specifically, the action potential count and latency of the first spike indicate neuronal excitability and response speed, respectively, while the mean and variance of the voltage reflect overall activity. The resting potential serves as a baseline indicator of the neuron’s physiological state. Furthermore, these features are also suitable for GPU parallelization and vectorized computation, thereby enhancing computational efficiency.

Additionally, we utilize our newly-developed SBI method to efficiently explore the high-dimensional parameter space, as described in the Sec. Materials and methods. By leveraging the computational power of A100 GPUs and parallel computing, this approach significantly enhances the speed of parameter sampling in high-dimensional spaces. This method outperforms the original SBI method by two orders of magnitude in terms of runtime and also maintains an accuracy comparable to benchmarks, as demonstrated in Tab. 2. The final results are depicted in S1 Table. The simulated curves now demonstrate consistency in action potential frequency, amplitude, and resting potential when compared to the experimental curves, as shown in Fig. 4(A-D).

As illustrated in Fig. 4(F-G), the potassium channel SLO-2 plays a crucial role in modulating two distinct firing modes in body-wall muscle cells. With an increase in calcium ion concentration, SLO-2 inhibits action potentials. Due to its relatively slow activation time, the channel allows the cell to continue firing, resulting in two distinct firing modes under constant current input: the “burst” and “regular” firing modes. These findings are consistent with experimental observations, as shown in Fig. 1A.

### Prediction of dynamics in mutants and different extracellular solutions

To delve deeper into the dynamical properties of body-wall muscle cells, we investigate how mutants and alterations in extracellular solutions significantly impact the dynamics of our model.

In studying the *egl-19(ad1006,lf)* mutants, a substantial decrease in calcium current amplitudes is observed, as illustrated in Fig. 1C. To replicate these experimental findings, our simulation incorporates a reduction in the maximum conductance for the calcium ion channel EGL-19. This modification results in a notable reduction in action potential amplitudes, a finding that our experiments have confirmed. Specifically, under a 30 pA current injection, the average action potential amplitude in wild-type cells is 61.6 mV, as shown by the red curve in Fig. 4A. In contrast, in the *egl-19(ad1006,lf)* mutants, the amplitude is less than half of this value, as depicted by the red curve in Fig. 5A. Notably, the mutant model agrees with the shape of action potentials under constant current injections, as shown in Fig. 5B.

While the *egl-19(ad1006,lf)* mutants exhibit reduced current amplitudes, another aspect of calcium channel dynamics is revealed in the study of *egl-19(n582,lf)* mutants. Namely, experimental data indicate an increase in the activation time constants of the EGL-19 channel, denoted as *τ*_{m} in these mutant models, as shown in Fig. 1C. Our simulations, illustrated in Fig. 5(C-D), replicate this finding by increasing the *τ*_{m} values 6-fold. As shown in Fig. 5(E), *τ*_{m} becomes closer to *τ*_{n}. This modification significantly reduces the firing rate of the cells compared to wild-type cells. Further increasing *τ*_{m} to 20-fold results in *τ*_{m} exceeding *τ*_{n} throughout most of the firing voltage interval (Fig. 5E), leading to a marked inability of the cells to generate action potentials, as shown in Fig. 5F. Under the current injection conditions presented in Fig. 5C, the average action potential firing rate in wild-type cells is approximately 4 Hz, whereas the *egl-19(n582,lf)* mutants exhibit firing rates below 1 Hz, as illustrated in Fig. 5C. These results indicate that our model accurately reflects the observed phenomena.

When substituting extracellular sodium ions (Na^{+}) with N-methyl-D-glucamine (NMDG), notable changes occur in the resting membrane potential and action potential amplitude of muscle cells. In our quest to pinpoint the channels responsible for these observations, we scrutinize the voltage clamp data pertaining to all ion channels involved in action potential generation. The removal of extracellular sodium ions first leads to a cessation of the NCA sodium leak current. Our investigation further reveals that the SLO-2 channel exhibits an increased steady-state value in the absence of Na^{+} compared to the normal condition. The *slo-2* encodes a subunit of the K^{+} channel that is modulated by calcium and chloride ion concentrations [40]. The absence of extracellular Na^{+} induces a shift in the dynamics of the SLO-2 channel, contributing to the altered action potentials. After calibrating the SLO-2 and NCA channel parameters in our model by modifying the maximum conductance of SLO-2 and setting the NCA current to zero, the simulation results in Fig. 6B closely align with the experimental data shown in Fig. 6A.

Following the calibration of SLO-2 and NCA channel parameters in our model, Fig. 6B showcases simulation results that align with experimental data shown in Fig. 6A.

### Frequency preferences of body-wall muscle model

The behavioral states in animals are often characterized by network oscillations with specific frequencies, as documented in various studies [59–62]. Neuroscientists have extensively explored how different neuronal types within these networks react to oscillatory inputs, meticulously recording responses to sinusoidal stimuli at preferred frequencies [59]. Building on this foundation, we investigate the response of body-wall muscle cells to oscillatory input patterns.

To provide a comprehensive understanding of these responses, we use a ZAP current as our oscillatory input. The ZAP current is particularly useful because it covers a broad range of frequencies, allowing us to systematically examine how the muscle cells respond to different oscillatory inputs. By applying a ZAP current with a linear frequency sweep from 0.01 to 30 Hz to our model [63], we can observe the cells’ behavior across this spectrum.

The ZAP current is governed by
where *f* (*t*) represents the frequency range swept by the ZAP function. For *f* (*t*), we utilize a linear chirp function:
To effectively estimate impedance magnitude, we transform current (*I*) and voltage (*V*) recordings from the time domain into the frequency domain using fast Fourier transforms (FFTs). The impedance (*Z*) is calculated by taking the ratio of the FFT of the voltage to the FFT of the current, as represented by
The impedance magnitude is then expressed as a function of frequency, forming an Impedance–Magnitude (IM) profile, as illustrated in Fig. 7B. Notably, the body-wall muscle cells of *C. elegans* exhibit a distinct preferred frequency at around 4.7 Hz, which could be related to the specific nematode locomotion paradigm. At this frequency, the body-wall muscle cells operate in a burst firing mode, as depicted in Fig. 7C. In this mode, muscle cells exhibit rapid spiking, indicating a state of exertion in *C. elegans* [24]. From this observation, we hypothesize that nematodes exhibit a preference for this specific frequency input to enhance their forceful movements [8, 30].

## Discussion

This study advances the understanding of the neurophysiology of *C. elegans* body-wall muscle cells by integrating detailed computational models with empirical data analysis. Our biophysical model effectively captures the main features of electrical dynamics in wild-type cells. Moreover, it predicts alterations in the dynamic properties of *C. elegans* body-wall muscle cells across various mutants and in sodium-ion-free solutions. Our work also provides a parallel SBI algorithm using GPU vectorization and parallelization, which allows for extensive and efficient exploration of the model’s parameter space. Additionally, by linking model dynamics with physiological functions, we identify a distinct preferred frequency in *C. elegans* body-wall muscle cells. This optimal frequency induces a burst firing mode, which may significantly enhance the force of nmuscle contractions.

In studying the locomotion of *C. elegans*, experimental findings indicate that their movement is regulated by a network of excitatory cholinergic (A-and B-types) and inhibitory GABAergic (D-type) motor neurons along the nerve cord, which innervate the muscle cells lining the worm’s body [30, 64]. Additionally, a series of interneurons indirectly regulate the worm’s movement by modulating motor neurons and proprioception [30, 65]. Current research predominantly focuses on modeling the neurons involved and investigating the underlying physiological mechanisms, with comparatively less emphasis on body-wall muscle cells [66–70]. However, muscle cells play a crucial role in locomotion as they integrate neuronal inputs and deliver all-or-nothing electrical outputs to drive movement. The biophysically detailed model we developed characterizes the physiological mechanisms underlying body-wall muscle cells, providing insights for further exploration of the interactions between motor neurons and muscle cells. On the other hand, our modeling framework can serve as a solid foundation for future explorations in modeling other neurons within *C. elegans*. Previous work on neuron model parameter estimation, such as those conducted on various types of neurons in the mouse visual cortex by the Allen Brain Project [71] and on neuron models in the electric fish *Apteronotus* [72], has employed parameter estimation methods based on several evolutionary algorithms, including Differential Evolution, Simulated Annealing, and Particle Swarm Optimization [73–75]. However, the SBI algorithm generally achieves faster convergence compared to traditional evolutionary algorithms when exploring the model’s high-dimensional parameter space [39, 76]. Moreover, our parallel SBI algorithm further accelerates this exploration through GPU acceleration, making neuron modeling more efficient.

In conclusion, our biophysical model presented here may shed light on the underlying mechanisms for electrical activities in *C. elegans* body-wall muscle cells and offer a generalized framework for detailed modeling in the study of the *C. elegans* locomotion system. Future directions may include utilizing this modeling framework to develop detailed biophysical models for various motor neurons within the *C. elegans* motor circuits. This will enable a more thorough investigation into the interactions between motor neurons and muscle cells during locomotion, enhancing our understanding of the system’s complexity.

## Supporting information

### S1 Appendix. Equations used in the model simulations. Voltage-gated Calcium channel: *I*_{EGL-19}

**Voltage-gated Potassium current:** *I*_{SHK-1}
**Voltage-gated Potassium current:** *I*_{Kr}
**Calcium dependent potassium current:** *I*_{SLO-2}
**Calcium concentration**
**S1 Table. Model parameters**.

**S1 Dataset. The relevant experimental data in the paper**.

## Data Availability Statement

All code used for model fitting and plotting is available on a GitHub repository at https://github.com/XuexingDu/C.elegans-Muscle. All data used in the paper are included as Supporting information files.

## Acknowledgements

We thank Gregor Kovačič for his invaluable insights throughout the project. This work was supported by Science and Technology Innovation 2030 - Brain Science and Brain-Inspired Intelligence Project with Grant No. 2021ZD0200204 (S.L., D.Z.);National Natural Science Foundation of China with Grant No. 12225109, 12071287 (D.Z.); National Natural Science Foundation of China Grant 12271361, 12250710674 (S.L.); Lingang Laboratory Grant No. LG-QS-202202-01, and the Student Innovation Center at Shanghai Jiao Tong University (X.D., S.L., and D.Z.). National Natural Science Foundation of China with Grant No. 32371189 (S.G.), the Major International (Regional) Joint Research Project (32020103007 to S.G.). The funders had no role in study design, data collection and analysis, decision to publish, or preparation of the manuscript.

## Footnotes

↵* Songting Li, songting{at}sjtu.edu.cn; Shangbang Gao, sgao{at}hust.edu.cn; Douglas Zhou, zdz{at}sjtu.edu.cn