IntramuscularEMG#
- class IntramuscularEMG(
- muscle_model: Muscle,
- electrode_array: IntramuscularElectrodeArray,
- sampling_frequency__Hz: Quantity__Hz = 10240.0 * pq.Hz,
- spatial_resolution__mm: Quantity__mm = 0.01 * pq.mm,
- endplate_center__percent: float = 50,
- nmj_jitter__s: Quantity__s = 35e-6 * pq.s,
- branch_cvs__m_per_s: tuple[Quantity__m_per_s, Quantity__m_per_s] = (5.0 * pq.m / pq.s, 2.0 * pq.m / pq.s),
- MUs_to_simulate: list[int] | None = None,
Bases:
objectIntramuscular 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 (see
myogen.simulator.Muscle).electrode_array (IntramuscularElectrodeArray) – Intramuscular electrode array configuration to use for simulation (see
myogen.simulator.IntramuscularElectrodeArray).sampling_frequency__Hz (Quantity__Hz, default=10240.0 * pq.Hz) – 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 (Quantity__mm, default=0.01 * pq.mm) – Spatial resolution for fiber action potential calculation in mm. Default is set to 0.01 mm.
endplate_center__percent (float, default=50) – 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 (Quantity__s, default=35e-6 * pq.s) – 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[Quantity__m_per_s, Quantity__m_per_s], default=(5.0 * pq.m / pq.s, 2.0 * pq.m / pq.s)) –
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__Block#
Intramuscular MUAP shapes for the electrode array as a neo.Block. Available after simulate_muaps().
- intramuscular_emg__Block#
Intramuscular EMG signals for the electrode array as a neo.Block. Available after simulate_intramuscular_emg().
- Type:
- noisy_intramuscular_emg__Block#
Noisy intramuscular EMG signals for the electrode array as a neo.Block. Available after add_noise().
- Type:
- spike_train__Block#
Spike train block used for EMG generation. Available after simulate_intramuscular_emg().
- Type:
References
Methods
Add noise to the electrode array.
Generate intramuscular EMG signals using the provided spike train block.
Simulate MUAPs for all electrode arrays using the provided muscle model.
Attributes
Intramuscular EMG signals for the electrode array.
Intramuscular MUAP shapes for the electrode array.
Noisy intramuscular EMG signals for the electrode array.
Spike train block used for EMG generation.
- simulate_muaps(
- n_jobs: int = -2,
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.
- Parameters:
n_jobs (int, optional) – Number of parallel workers for motor unit processing. Default is -2. - n_jobs=-1: Use all CPU cores - n_jobs=-2: Use all cores except one (recommended, keeps system responsive) - n_jobs=-3: Use all cores except two - n_jobs=1: No parallelization - n_jobs=N: Use exactly N cores
- Returns:
Intramuscular MUAP shapes for all electrode arrays. Results are stored in the muaps property after execution.
- Return type:
INTRAMUSCULAR_MUAP_SHAPE__TENSOR
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(
- spike_train__Block: SPIKE_TRAIN__Block,
Generate intramuscular EMG signals using the provided spike train block.
This method convolves the pre-computed MUAP templates with spike trains to synthesize realistic intramuscular EMG signals. The process includes temporal resampling and supports both CPU and GPU acceleration for efficient computation.
- Parameters:
spike_train__Block (
SPIKE_TRAIN__Block) – Block containing spike trains organized as segments (pools) with spiketrains.- Returns:
Intramuscular EMG signals for the electrode array stored in a neo.Block. Results are stored in the intramuscular_emg__Block property after execution.
- Return type:
- Raises:
ValueError – If MUAP templates have not been generated. Call simulate_muaps() first.
- add_noise( ) INTRAMUSCULAR_EMG__Block[source]#
Add noise to the electrode array.
This method adds realistic noise to the simulated intramuscular EMG signals based on a specified signal-to-noise ratio. The noise is calculated and applied independently for each electrode channel to ensure that channels with different signal amplitudes maintain the specified SNR.
- Parameters:
snr__dB (float) – Signal-to-noise ratio in dB. Higher values result in cleaner signals. Typical intramuscular EMG has SNR ranging from 15-50 dB. The SNR is applied independently to each electrode channel.
noise_type (str, default="gaussian") – Type of noise to add. Currently supports “gaussian” for white noise.
- Returns:
Noisy intramuscular EMG signals for the electrode array as a neo.Block. Results are stored in the noisy_intramuscular_emg__Block property after execution.
- Return type:
- Raises:
ValueError – If intramuscular EMG has not been simulated. Call simulate_intramuscular_emg() first.
Notes
The noise is computed per-channel (per electrode) to maintain the specified SNR independently across all channels. This ensures that electrodes with different signal amplitudes receive appropriately scaled noise.
- property muaps__Block: segments))]]#
Intramuscular MUAP shapes for the electrode array.
- Returns:
Intramuscular MUAP templates for the electrode array as a neo.Block.
- Return type:
- Raises:
ValueError – If MUAP templates have not been computed yet.
- property intramuscular_emg__Block: segments))]]#
Intramuscular EMG signals for the electrode array.
- Returns:
Intramuscular EMG signals for the electrode array as a neo.Block.
- Return type:
- Raises:
ValueError – If intramuscular EMG has not been computed yet.
- property noisy_intramuscular_emg__Block: segments))]]#
Noisy intramuscular EMG signals for the electrode array.
- Returns:
Noisy intramuscular EMG signals for the electrode array as a neo.Block.
- Return type:
- Raises:
ValueError – If noisy intramuscular EMG has not been computed yet.
- property spike_train__Block: segments))]]#
Spike train block used for EMG generation.
- Returns:
The spike train block used in the simulation.
- Return type:
- Raises:
ValueError – If spike train block has not been set yet.