IntramuscularEMG#
- class IntramuscularEMG(
- muscle_model,
- electrode_array,
- sampling_frequency__Hz=10240.0,
- spatial_resolution__mm=0.01,
- endplate_center__percent=50,
- nmj_jitter__s=35e-6,
- branch_cvs__m_per_s=(5.0, 2.0),
- MUs_to_simulate=None,
Bases:
object
Intramuscular Electromyography (iEMG) Simulation.
This class provides a comprehensive simulation framework for generating intramuscular EMG signals detected by needle electrodes.
- Parameters:
muscle_model (
Muscle
) – Pre-computed muscle model (seemyogen.simulator.Muscle
).electrode_array (
IntramuscularElectrodeArray
) – Intramuscular electrode array configuration to use for simulation (seemyogen.simulator.IntramuscularElectrodeArray
).sampling_frequency__Hz (
float
, default10240.0
) – Sampling frequency in Hz for EMG simulation. Default is set to 10240 Hz as used by the Quattrocento (OT Bioelettronica, Turin, Italy) system.spatial_resolution__mm (
float
, default0.01
) – Spatial resolution for fiber action potential calculation in mm. Default is set to 0.01 mm.endplate_center__percent (
float
, default50
) – Percentage of muscle length where the endplate is located. By default, the endplate is located at the center of the muscle (50% of the muscle length).nmj_jitter__s (
float
, default35e-6
) – Standard deviation of neuromuscular junction jitter in seconds. Default is set to 35e-6 s as determined by Konstantin et al. 2020 [1].branch_cvs__m_per_s (
tuple[float
,float]
, default(5.0
,2.0)
) –Conduction velocities for the two-layer model of the neuromuscular junction in m/s. Default is set to (5.0, 2.0) m/s as determined by Konstantin et al. 2020 [1].
Note
The two-layer model is a simplification of the actual arborization pattern, but it is a good approximation for the purposes of this simulation. Follows the implementation of Kontos et al. 2020 [1].
MUs_to_simulate (
list
[int
], optional) – Indices of motor units to simulate. If None, all motor units are simulated. Default is None. For computational efficiency, consider simulating subsets for initial analysis. Indices correspond to the recruitment order (0 is recruited first).
- muaps#
Intramuscular MUAP shapes for all electrode arrays. Available after simulate_muaps().
- intramuscular_emg__tensor#
Intramuscular EMG signals for all electrode arrays. Available after simulate_intramuscular_emg().
- noisy_intramuscular_emg__tensor#
Noisy intramuscular EMG signals for all electrode arrays. Available after add_noise().
- motor_neuron_pool#
Motor neuron pool used for EMG generation. Available after simulate_intramuscular_emg().
- Type:
References
Methods
Add noise to all electrode arrays.
Generate intramuscular EMG signals for all electrode arrays using the provided motor neuron pool.
Simulate MUAPs for all electrode arrays using the provided muscle model.
Attributes
Intramuscular EMG signals for all electrode arrays.
Motor neuron pool used for EMG generation.
Intramuscular MUAP shapes for all electrode arrays.
Noisy intramuscular EMG signals for all electrode arrays.
- simulate_muaps()[source]#
Simulate MUAPs for all electrode arrays using the provided muscle model.
This method generates intramuscular Motor Unit Action Potential (MUAP) templates by simulating individual motor units with realistic neuromuscular junction distributions and fiber action potential propagation.
- Returns:
Intramuscular MUAP shapes for all electrode arrays. Results are stored in the muaps property after execution.
- Return type:
Notes
This method must be called before simulate_intramuscular_emg(). The process includes: (1) motor unit initialization, (2) neuromuscular junction simulation, and (3) MUAP calculation with spatial filtering.
- simulate_intramuscular_emg(motor_neuron_pool)[source]#
Generate intramuscular EMG signals for all electrode arrays using the provided motor neuron pool.
This method convolves the pre-computed MUAP templates with motor neuron spike trains to synthesize realistic intramuscular EMG signals. The process includes temporal resampling and supports both CPU and GPU acceleration for efficient computation.
- Parameters:
motor_neuron_pool (
MotorNeuronPool
) – Motor neuron pool with spike trains computed (seemyogen.simulator.MotorNeuronPool
).- Returns:
Intramuscular EMG signals for all electrode arrays. Results are stored in the intramuscular_emg__tensor property after execution.
- Return type:
- Raises:
ValueError – If MUAP templates have not been generated. Call simulate_muaps() first.
- add_noise(snr_db, noise_type='gaussian')[source]#
Add noise to all electrode arrays.
This method adds realistic noise to the simulated intramuscular EMG signals based on a specified signal-to-noise ratio. The noise characteristics can be customized to match different recording conditions.
- Parameters:
- Returns:
Noisy intramuscular EMG signals for all electrode arrays. Results are stored in the noisy_intramuscular_emg__tensor property after execution.
- Return type:
- Raises:
ValueError – If intramuscular EMG has not been simulated. Call simulate_intramuscular_emg() first.
- property muaps: ndim == 3]]#
Intramuscular MUAP shapes for all electrode arrays.
- Returns:
Intramuscular MUAP templates for the electrode array.
- Return type:
- Raises:
ValueError – If MUAP templates have not been computed yet.
- property intramuscular_emg__tensor: ndim == 3]]#
Intramuscular EMG signals for all electrode arrays.
- Returns:
Intramuscular EMG signals for the electrode array.
- Return type:
- Raises:
ValueError – If intramuscular EMG has not been computed yet.
- property noisy_intramuscular_emg__tensor: ndim == 3]]#
Noisy intramuscular EMG signals for all electrode arrays.
- Returns:
Noisy intramuscular EMG signals for the electrode array.
- Return type:
- Raises:
ValueError – If noisy intramuscular EMG has not been computed yet.
- property motor_neuron_pool: MotorNeuronPool#
Motor neuron pool used for EMG generation.
- Returns:
The motor neuron pool used in the simulation.
- Return type:
- Raises:
ValueError – If motor neuron pool has not been set yet.