<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://pc5271.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Wang+Jingyi</id>
	<title>pc5271AY2526wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://pc5271.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Wang+Jingyi"/>
	<link rel="alternate" type="text/html" href="https://pc5271.org/index.php/Special:Contributions/Wang_Jingyi"/>
	<updated>2026-10-20T01:41:26Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.11</generator>
	<entry>
		<id>https://pc5271.org/index.php?title=Surface_EMG_Sensor_for_Muscle_Activity_Measurement:_AFE_Design_and_Signal_Processing&amp;diff=1379</id>
		<title>Surface EMG Sensor for Muscle Activity Measurement: AFE Design and Signal Processing</title>
		<link rel="alternate" type="text/html" href="https://pc5271.org/index.php?title=Surface_EMG_Sensor_for_Muscle_Activity_Measurement:_AFE_Design_and_Signal_Processing&amp;diff=1379"/>
		<updated>2026-04-23T08:39:31Z</updated>

		<summary type="html">&lt;p&gt;Wang Jingyi: /* Appendix */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Background and Theory==&lt;br /&gt;
&lt;br /&gt;
=== Surface EMG Signals ===&lt;br /&gt;
Surface electromyography (sEMG) refers to the bioelectrical signals detected on the skin surface during muscle contraction. These signals originate from the electrical activity of muscle fibers and provide a non-invasive way to monitor muscle activation. Compared with invasive EMG methods, sEMG is easier to apply, safer for repeated measurements, and more suitable for real-time monitoring. Therefore, it has been widely used in areas such as rehabilitation, motion analysis, human–machine interaction, and physiological monitoring.&lt;br /&gt;
&lt;br /&gt;
=== Characteristics of EMG Signals ===&lt;br /&gt;
EMG signals are generally weak, time-varying, and stochastic in nature. Their waveforms are typically bipolar, fluctuating around zero with both positive and negative components. The amplitude and frequency content of EMG signals depend on factors such as muscle contraction level, electrode placement, skin condition, and individual physiological differences. In practice, the useful frequency components of sEMG are mainly concentrated in a limited low-to-mid frequency range. Because of their low amplitude and variability, EMG signals usually require further conditioning before reliable interpretation and feature extraction can be performed.&lt;br /&gt;
&lt;br /&gt;
=== Bioelectrical Signal Acquisition Principles ===&lt;br /&gt;
The acquisition of bioelectrical signals is based on measuring the small potential difference on the skin surface using electrodes, then converting it into a processable electrical signal through amplification and digitization. For sEMG measurement, electrode placement and skin–electrode contact quality are especially important, since they directly affect signal amplitude and stability. In addition, the front-end acquisition circuit must provide sufficient sensitivity and good interference rejection, so that the recorded signal reflects actual muscle activity rather than environmental disturbance or poor contact conditions.&lt;br /&gt;
&lt;br /&gt;
=== Noise Sources in EMG (50 Hz, motion artifacts) ===&lt;br /&gt;
In practical EMG recording, the measured signal is easily contaminated by different types of noise. Two of the most common sources are power-line interference and motion artifacts. Power-line interference usually appears as a narrow-band component at 50 Hz in the local electrical environment, while motion artifacts are mainly caused by electrode movement, cable disturbance, or variations in the electrode–skin impedance, and are often concentrated in the low-frequency range. In addition, electronic noise from the acquisition hardware may also affect the recording quality. These unwanted components can reduce signal clarity and make muscle activity analysis less reliable, so they must be considered in the design of the signal processing pipeline.&lt;br /&gt;
[[File:background_theory_figure1.1_emg_noise_sources.png|center|thumb|700px|&#039;&#039;&#039;Figure 1.1.&#039;&#039;&#039; Principle of surface EMG acquisition.]]&lt;br /&gt;
&lt;br /&gt;
==System Architecture==&lt;br /&gt;
=== Total Structure Design ===&lt;br /&gt;
&lt;br /&gt;
For clarity，the proposed physiological signal acquisition system mainly consists of two core parts：the analog front－end （AFE）and the ADC board．The AFE is responsible for the preliminary conditioning of weak bioelectrical signals，including amplification，filtering，interference suppression，and level shifting，so that the analog waveform can be converted into a stable and measurable form．The ADC board then performs high－resolution digitization of the conditioned signal and transfers the sampled data to the host computer for subsequent display，storage，and analysis．Therefore，the overall system forms a complete signal－acquisition chain from weak physiological input to digital output．&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_1.jpg|thumb|center|800px|Figure 2.1. Overall system architecture of the proposed physiological signal acquisition platform，including the AFE and ADC modules．]]&lt;br /&gt;
&lt;br /&gt;
=== sEMG AFE Design ===&lt;br /&gt;
&lt;br /&gt;
To collect the weak bioelectric potential signals of the human body，an analog front－end（AFE）suitable sEMG measurements was designed．The module is powered by an external 5 V supply，and the complete circuit includes a first－ stage instrumentation amplifier based on INA128（Texas Instruments，Dallas，TX，USA），a band－pass filter，a 50 Hz notch filter，a second－order amplification and level shifting stage，a driver electrode circuit，a precise 1.5 V reference source，and a -5 V voltage generation module for powering the operational amplifiers．&lt;br /&gt;
&lt;br /&gt;
==== First－order Amplifier ====&lt;br /&gt;
&lt;br /&gt;
The input bioelectric signal is first acquired in differential form and applied to the INA128 instrumentation amplifier，which provides high input impedance，high common－mode rejection，and moderate initial gain for sEMG acquisition．This stage enlarges the weak physiological signal before filtering while reducing the risk of premature saturation caused by electrode offset or motion－induced disturbance，thereby preparing a more stable signal for the subsequent conditioning stages．&lt;br /&gt;
&lt;br /&gt;
==== Bandpass Filter ====&lt;br /&gt;
&lt;br /&gt;
After the instrumentation amplifier，the signal passes through a second－order active band－pass filter，as shown in Figure 2．2． This stage suppresses baseline drift and high－frequency noise outside the useful sEMG range，so that the low－frequency envelope information of sEMG can be preserved before further amplification．&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_2.jpg|thumb|center|800px|Figure 2.2. Schematic diagram of the active band-pass filter used in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the band-pass stage used to retain the main physiological signal band while suppressing unwanted lowand high-frequency components.&lt;br /&gt;
&lt;br /&gt;
==== Notch Filter ====&lt;br /&gt;
&lt;br /&gt;
To reduce power-line interference, a dedicated 50 Hz notch filter is introduced after the band-pass stage, as shown in Figure 2.3. This filter attenuates the mains-frequency component that commonly contaminates weak bioelectric measurements, thereby improving the signal-to-noise ratio of sEMG signals before the final amplification stage.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_3.jpg|thumb|center|800px|Figure 2.3. Schematic diagram of the 50 Hz notch filter used in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the circuit used to attenuate 50 Hz mains interference in the analog front end.&lt;br /&gt;
&lt;br /&gt;
==== Second-order Amplifier &amp;amp; Level Shifter ====&lt;br /&gt;
&lt;br /&gt;
After filtering, the signal enters the second-stage amplification and level-shifting circuit shown in Figure 2.4. In this stage, the filtered signal is further amplified to improve amplitude utilization and then shifted by a 1.5 V reference so that the output becomes a stable unipolar signal suitable for ADC sampling, while preserving linear operation and providing sufficient output swing margin.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_4.jpg|thumb|center|800px|Figure 2.4. Schematic diagram of the second-stage amplifier and level-shifting circuit in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows how the conditioned signal is further amplified and shifted to a suitable DC level before digitization.&lt;br /&gt;
&lt;br /&gt;
==== Power Module and Drive-electrode Circuit ====&lt;br /&gt;
&lt;br /&gt;
The AFE is powered by a 5 V supply and also integrates a 1.5 V precision reference, a -5 V generation circuit, and a driveelectrode circuit. These supporting modules provide the required supply rails and reference level for analog signal conditioning, while the drive-electrode circuit feeds back common-mode voltage to the body to suppress interference at the source. As a result, the complete AFE can support sEMG acquisition with adequate gain, filtering, and noise-reduction performance in a compact hardware structure.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_5.jpg|thumb|center|800px|Figure 2.5. Physical picture of the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the fabricated sEMG analog front-end hardware used in the system.&lt;br /&gt;
&lt;br /&gt;
Figure 2.5 presents the practical hardware implementation of the proposed sEMG AFE. It integrates amplification, filtering, level shifting, and driven-reference functions in a compact circuit for weak bioelectrical signal acquisition.&lt;br /&gt;
&lt;br /&gt;
=== ADS1256-based ADC Board ===&lt;br /&gt;
&lt;br /&gt;
To digitize the conditioned weak physiological signals with sufficient resolution and low noise, this project developed a dedicated ADC board based on the ADS1256 analog-to-digital converter (Texas Instruments, Dallas, TX, USA) and the STM32F103C8T6 microcontroller (STMicroelectronics, Geneva, Switzerland). The overall design objective of this board was not merely to realize analog-to-digital conversion, but to provide a complete hardware interface between the analog front-end and the digital processing unit, including precision reference generation, clocking, input protection and filtering, serial communication, power regulation, and MCU-based acquisition control. The ADS1256 was selected because it is a&lt;br /&gt;
&lt;br /&gt;
very low-noise 24-bit delta-sigma converter with a programmable gain amplifier (PGA), flexible input multiplexer, programmable digital filter, and SPI-compatible serial interface, which makes it well suited for weak low-frequency physiological signals after analog conditioning. The STM32F103C8T6 was used as the local controller because it provides a 32-bit Cortex-M3 core, up to 72 MHz system clock, SPI, USART, USB, and standard SWD debugging support in a compact and low-cost platform.&lt;br /&gt;
&lt;br /&gt;
==== ADC Core Architecture and Design Rationale ====&lt;br /&gt;
&lt;br /&gt;
The ADS1256 was selected as the core ADC because it provides high-resolution, low-noise delta-sigma conversion with an input multiplexer, programmable gain amplifier, and digital filter, which are suitable for weak and low-frequency physiological signals. As shown in Figure 2.6, this architecture emphasizes resolution and noise performance rather than high conversion bandwidth, making it appropriate for sEMG signal digitization after analog conditioning.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_6.jpg|thumb|center|800px|Figure 2.6. Internal functional structure of the ADS1256 analog-to-digital converter.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the main internal blocks of the ADS1256, including the multiplexer, PGA, modulator, and digital filter.&lt;br /&gt;
&lt;br /&gt;
==== Analog Front-End Interface, Reference, and Clocking ====&lt;br /&gt;
&lt;br /&gt;
The ADS1256 analog inputs are connected to the external header through a passive input-conditioning network that helps suppress high-frequency interference and improve input stability. In addition, the board includes a dedicated precision reference and clocking circuits so that the ADC can perform stable and accurate conversion. Together, these circuits provide a reliable analog interface and timing basis for high-resolution digitization of weak physiological signals.&lt;br /&gt;
&lt;br /&gt;
==== SPI Interface between ADS1256 and STM32F103C8T6 ====&lt;br /&gt;
&lt;br /&gt;
Communication between the ADS1256 and the STM32F103C8T6 is implemented through an SPI-compatible interface, with dedicated lines for chip select, serial clock, input/output data, data-ready notification, and hardware reset. This connection allows the MCU to configure the ADC, read conversion results in synchrony with DRDY, and maintain efficient and reliable acquisition control for multi-channel physiological measurements.&lt;br /&gt;
&lt;br /&gt;
==== Power Supply and On-board Regulation ====&lt;br /&gt;
&lt;br /&gt;
The ADC board uses a USB Type-B connector as the main power input and includes protection, voltage regulation, and local decoupling circuits to provide a stable supply for both the MCU and ADC-related hardware. In addition, analog ground and digital ground are separated in the PCB layout to reduce digital noise coupling into the analog path, which is particularly important for weak physiological signal acquisition.&lt;br /&gt;
&lt;br /&gt;
==== Basic Peripheral Circuits of the STM32F103C8T6 ====&lt;br /&gt;
&lt;br /&gt;
The STM32F103C8T6 serves as the local controller of the ADC board and is supported by several basic peripheral circuits, including an external crystal oscillator, reset network, BOOT0 configuration, SWD programming/debugging header, and a CH340N USB-to-UART bridge. These circuits ensure stable MCU operation, convenient firmware downloading and debugging, and reliable data transmission from the board to the host computer for real-time display and storage.&lt;br /&gt;
&lt;br /&gt;
==== Hardware-level Working Principle of the ADC Board ====&lt;br /&gt;
&lt;br /&gt;
In operation, the conditioned analog signal from the AFE enters the ADS1256 through the input header, is digitized with high resolution under the control of the local precision reference and clock, and is then read by the STM32 through the SPI interface. The MCU subsequently forwards the sampled data to the host computer through the serial communication link, so that the entire board functions as a compact digital acquisition backend connecting weak physiological analog signals to later software processing, display, and storage.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_7.jpg|thumb|center|800px|Figure 2.7. Photograph of the fabricated ADS1256-based ADC board developed in this project and the definitions of some key pins.]]&lt;br /&gt;
&lt;br /&gt;
Figure 2.7 shows the ADC board fabricated for this project. It integrates the ADS1256 conversion core, STM32 control circuit, power-conditioning circuits, and communication interfaces on a compact PCB for physiological signal digitization.&lt;br /&gt;
&lt;br /&gt;
== Signal Conditioning and Filtering ==&lt;br /&gt;
Although the AFE already performs preliminary band-pass filtering and 50 Hz interference suppression in the analog domain, the digitized sEMG signal may still contain residual noise due to component tolerances, electrode-contact variation, and environmental interference. Therefore, an additional digital filtering stage is implemented in software as a complementary post-processing step to improve signal quality and to provide a more stable input for rectification, envelope extraction, and subsequent analysis. In this sense, the software filtering is not a simple repetition of the analog filtering, but a refinement and compensation for non-ideal front-end behavior.&lt;br /&gt;
&lt;br /&gt;
Surface electromyographic (sEMG) signals are highly susceptible to several sources of contamination during acquisition. In practical measurements, the dominant disturbances usually include low-frequency motion artifacts caused by electrode movement and electrode–skin impedance variation, narrow-band power-line interference centered at 50 Hz, and broadband high-frequency electronic noise introduced by the acquisition hardware. These unwanted components degrade the quality of the recorded signal and may significantly affect the reliability of subsequent feature extraction, parameter estimation, and muscle activity interpretation. For this reason, an effective signal-conditioning procedure is necessary before any higher-level analysis is performed.&lt;br /&gt;
&lt;br /&gt;
In the present implementation, the filtering strategy follows the principle of restricting the signal bandwidth first and then removing the remaining narrow-band interference in a targeted manner. Accordingly, the raw sEMG signal is first processed by a fourth-order Butterworth IIR band-pass filter and then by a 50 Hz notch filter. This processing sequence is illustrated in the flowchart below, where the signal passes through band-pass filtering, notch filtering, full-wave rectification, and envelope extraction before producing the final processed output.&lt;br /&gt;
&lt;br /&gt;
[[File:flowchart.png|thumb|center|500px|Flowchart of the real-time sEMG signal conditioning pipeline.]]&lt;br /&gt;
&lt;br /&gt;
The rationale of this order is that the &#039;&#039;&#039;band-pass stage&#039;&#039;&#039; first confines the signal to the main spectral region of interest for sEMG, thereby attenuating motion artifacts at very low frequencies and suppressing high-frequency noise components outside the physiological band. After this spectral preconditioning, the notch stage can more effectively suppress the residual 50 Hz power-line interference that lies inside the useful sEMG band. In transfer-function form, the band-pass filter may be written as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;H_{BP}(z)=\frac{B_{BP}(z)}{A_{BP}(z)}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where the effective passband is selected as &amp;lt;math&amp;gt;20 \leq f \leq 160 \text{ Hz}&amp;lt;/math&amp;gt;. This frequency interval is consistent with the dominant spectral content of surface EMG: the lower cutoff near 20 Hz reduces motion artifacts and unstable low-frequency fluctuations, whereas the upper cutoff near 160 Hz removes high-frequency electronic noise while preserving the main energy-bearing components of the muscle signal. The use of a Butterworth structure is appropriate here because it provides a smooth monotonic passband response without ripple, which helps preserve signal morphology in real-time applications.&lt;br /&gt;
&lt;br /&gt;
After band limitation, a &#039;&#039;&#039;notch filter&#039;&#039;&#039; centered at the power-line frequency is applied to suppress interference that cannot be removed by the band-pass stage alone. The notch filter is designed around &amp;lt;math&amp;gt;f_0 = 50 \text{ Hz}&amp;lt;/math&amp;gt;, and its bandwidth is controlled by the quality factor &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;, which is expressed as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;Q = \frac{f_0}{\Delta f}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In transfer-function form, the notch stage is written as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;H_{N}(z)=\frac{B_{N}(z)}{A_{N}(z)}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the implemented program, a large quality factor is chosen so that the notch remains narrow, allowing effective rejection of the 50 Hz interference while minimizing distortion of neighboring useful spectral components. This is particularly important for sEMG because the interference frequency lies directly inside the physiological band of interest.&lt;br /&gt;
&lt;br /&gt;
Following the filtering stages, further signal conditioning is performed to obtain a representation that is more directly related to muscle activation intensity. The filtered sEMG waveform is first &#039;&#039;&#039;full-wave rectified&#039;&#039;&#039;, which converts the bipolar oscillatory signal into a unipolar signal by taking its absolute value.  Rectification does not remove noise by itself; instead, it transforms the signal into a form that is more suitable for amplitude-based analysis because both positive and negative deflections contribute positively to the activation measure.&lt;br /&gt;
&lt;br /&gt;
After rectification, the signal envelope is extracted to provide a smooth estimate of muscle activation level over time. In a general formulation, the envelope can be described as the &#039;&#039;&#039;low-pass filtered&#039;&#039;&#039; version of the rectified signal, namely &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y_{\mathrm{env}}[n] = \mathrm{LPF}\bigl(y_{\mathrm{rect}}[n]\bigr)&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the present code implementation, this operation is realized by short-time averaging over a finite window, which is equivalent to a moving-average low-pass smoothing of the rectified waveform. The corresponding expression is &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y_{\mathrm{env}}[n] = \frac{1}{N}\sum_{k=0}^{N-1} |x[n-k]|&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; is the window length in samples. With a window duration of approximately 200 ms, this envelope extraction method provides a stable and physiologically meaningful representation of muscle activation intensity, making it suitable for tasks such as force estimation, fatigue analysis, and motor-control studies.&lt;br /&gt;
&lt;br /&gt;
An important feature of the present &#039;&#039;&#039;implementation&#039;&#039;&#039; is that the entire filtering process is performed &#039;&#039;&#039;in real time&#039;&#039;&#039;, sample by sample, rather than by offline block processing. For this reason, IIR filters are preferred over FIR filters, since they can achieve comparable filtering performance with lower order, lower computational cost, and shorter delay. These properties are especially valuable in embedded systems, serial data streaming, and other low-latency experimental applications. However, unlike memoryless operations, an IIR filter depends not only on the current input but also on previous inputs and previous outputs. Its discrete-time behavior can therefore be represented by the recursive difference equation &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y[n] = \sum_{k=0}^{M} b_k x[n-k] - \sum_{k=1}^{N} a_k y[n-k]&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This equation makes clear that internal filter states must be preserved continuously during streaming operation. If the state variables were reinitialized for every incoming sample or data segment, artificial transients would appear and the output would no longer remain continuous.&lt;br /&gt;
&lt;br /&gt;
In the Python implementation, this state continuity is maintained using the internal initial-condition mechanism provided by SciPy, such as &amp;lt;code&amp;gt;lfilter_zi&amp;lt;/code&amp;gt;, together with recursive state updates during each filtering call. As a result, each newly acquired sample is passed first through the band-pass filter and then through the notch filter, while the internal states of both filters are updated after every step. This state-preserving sample-by-sample design ensures that the processing chain remains causal, continuous, and suitable for real-time display or downstream analysis without requiring storage of the entire signal segment.&lt;br /&gt;
&lt;br /&gt;
Overall, this signal-conditioning scheme provides an experimentally practical solution for real-time sEMG processing. The fourth-order Butterworth band-pass filter confines the signal to the main physiological band of interest, the 50 Hz notch filter removes narrow-band power-line contamination, and the subsequent rectification and envelope extraction generate a smooth amplitude descriptor of muscle activity. Combined with state-preserved streaming IIR implementation, this approach achieves a good balance between signal fidelity, computational efficiency, and real-time applicability in biomedical and physical experiment settings.&lt;br /&gt;
&lt;br /&gt;
== Experimental Setup ==&lt;br /&gt;
&lt;br /&gt;
=== Experimental Demonstration ===&lt;br /&gt;
&lt;br /&gt;
The experimental setup and data acquisition process are demonstrated in the video below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;text-align:center;&amp;quot;&amp;gt;&lt;br /&gt;
[[File:EMG_Experiment.mp4|center|800px]]&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The video illustrates the complete measurement procedure, including electrode placement, muscle activation, and real-time EMG signal visualization.&lt;br /&gt;
&lt;br /&gt;
=== Experimental Procedure ===&lt;br /&gt;
&lt;br /&gt;
Surface EMG signals were acquired using disposable electrodes placed on the forearm muscles responsible for wrist extension. &lt;br /&gt;
&lt;br /&gt;
Three electrodes were used in the measurement setup:&lt;br /&gt;
&lt;br /&gt;
* One electrode placed on the back of the hand serves as the reference electrode  &lt;br /&gt;
* The other two electrodes placed along the forearm muscle act as the differential input electrodes (positive and negative)  &lt;br /&gt;
&lt;br /&gt;
This configuration enables differential measurement of EMG signals while suppressing common-mode noise.&lt;br /&gt;
&lt;br /&gt;
The experimental movement consists of making a fist while extending the wrist backward. This action activates the forearm extensor muscles beneath the electrodes, producing measurable EMG signals.&lt;br /&gt;
&lt;br /&gt;
=== Data Acquisition Protocol ===&lt;br /&gt;
&lt;br /&gt;
Each subject performed repeated contraction–relaxation cycles under controlled conditions:&lt;br /&gt;
&lt;br /&gt;
* Number of subjects: 3  &lt;br /&gt;
* Number of trials per subject: 3  &lt;br /&gt;
* Duration of each trial: 30 seconds  &lt;br /&gt;
&lt;br /&gt;
During each trial, subjects were instructed to periodically contract and relax the muscle to generate clear dynamic EMG signals, while maintaining a stable resting state between contractions.&lt;br /&gt;
&lt;br /&gt;
=== System and Measurement Conditions ===&lt;br /&gt;
&lt;br /&gt;
The EMG signals were recorded and visualized in real time using a data acquisition system connected to a computer. The sampling rate was set to 400 Hz.&lt;br /&gt;
&lt;br /&gt;
To ensure consistency across measurements:&lt;br /&gt;
&lt;br /&gt;
* Electrode placement was kept consistent for all subjects  &lt;br /&gt;
* The same movement protocol was followed  &lt;br /&gt;
* Measurements were conducted under similar environmental conditions  &lt;br /&gt;
&lt;br /&gt;
=== Summary ===&lt;br /&gt;
&lt;br /&gt;
This experimental setup enables reliable acquisition of both resting and dynamic EMG signals, providing a consistent dataset for subsequent signal processing and performance evaluation.&lt;br /&gt;
&lt;br /&gt;
== Data Processing ==&lt;br /&gt;
&lt;br /&gt;
The objective of data processing is to convert raw surface electromyography (sEMG) recordings into stable, quantitative, and comparable indicators of muscle activity. Since EMG signals are low in amplitude, highly variable over time, and easily contaminated by noise, a dedicated processing pipeline is necessary before any experimental interpretation can be performed.&lt;br /&gt;
&lt;br /&gt;
In this project, the data processing workflow includes time normalization, signal pre-processing, sliding-window feature extraction, noise-floor estimation, and automatic contraction detection. The processed outputs are then used for subsequent experimental evaluation, including rest-versus-contraction discrimination, signal-to-noise ratio analysis, and repeatability assessment.&lt;br /&gt;
&lt;br /&gt;
=== Input Data and Time Normalization ===&lt;br /&gt;
&lt;br /&gt;
The acquired EMG data are read from CSV files containing two columns: time and filtered sEMG amplitude. In the MATLAB implementation, the time vector is normalized so that each recording starts from zero:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t = t_{all} - t_{all}(1)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This normalization is important because it removes the influence of absolute recording timestamps and makes different trials directly comparable on the same time axis.&lt;br /&gt;
&lt;br /&gt;
In addition, the signal type is automatically identified from the filename as either dynamic or rest. This design allows the same program to process both contraction recordings and resting recordings with different downstream analysis logic.&lt;br /&gt;
&lt;br /&gt;
=== Signal Pre-processing ===&lt;br /&gt;
&lt;br /&gt;
Raw EMG signals cannot be analyzed directly because they usually contain DC offset, low-frequency drift, motion artifacts, and residual high-frequency interference. Therefore, several pre-processing steps are applied before feature extraction.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(1) Baseline Removal&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The first step is DC offset removal:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
x_{dc}(t) = x(t) - \frac{1}{N}\sum_{i=1}^{N}x(i)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This operation centers the signal around zero. It is necessary because an uncorrected baseline would bias amplitude-based metrics and reduce the reliability of later envelope and feature calculations.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(2) Band-pass Filtering &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
After baseline correction, a fourth-order Butterworth band-pass filter is applied with a passband of 20–150 Hz.&lt;br /&gt;
&lt;br /&gt;
This step is introduced for two reasons:&lt;br /&gt;
&lt;br /&gt;
* The low-frequency cutoff at 20 Hz suppresses baseline drift and motion artifacts.&lt;br /&gt;
* The high-frequency cutoff at 150 Hz reduces unwanted high-frequency noise while preserving the main energy band of the recorded sEMG in this project.&lt;br /&gt;
&lt;br /&gt;
Compared with processing the raw waveform directly, band-pass filtering makes the subsequent time-domain features more stable and more physiologically meaningful.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(3) Full-wave Rectification&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The filtered EMG signal is bipolar, meaning that positive and negative phases coexist due to motor unit action potentials. If these positive and negative components are averaged directly, they may cancel each other out. To avoid this, full-wave rectification is performed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
x_{rect}(t) = |x_{filt}(t)|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This transforms the signal into a unipolar representation, so that all muscle activity contributes positively to the extracted features.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(4) Envelope Extraction &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Although the rectified signal reflects signal magnitude, it still fluctuates rapidly. To obtain a smoother representation of muscle activation level, an envelope is extracted using a moving average with a 100 ms window.&lt;br /&gt;
&lt;br /&gt;
Envelope extraction is important because contraction detection should reflect the overall activation trend rather than instantaneous spikes. A smoothed envelope is therefore more robust for identifying active and inactive muscle states.&lt;br /&gt;
&lt;br /&gt;
=== Sliding Window Design ===&lt;br /&gt;
&lt;br /&gt;
To quantify how muscle activity changes with time, the filtered signal is divided into overlapping short-time segments using a sliding window method.&lt;br /&gt;
&lt;br /&gt;
The window parameters are:&lt;br /&gt;
&lt;br /&gt;
* Window length: 250 ms&lt;br /&gt;
* Step size: 50 ms&lt;br /&gt;
&lt;br /&gt;
These values are chosen as a trade-off between temporal resolution and feature stability.&lt;br /&gt;
&lt;br /&gt;
A longer window improves statistical robustness because more samples are included in each calculation. However, if the window is too long, short contractions or rapid changes may be blurred. A smaller step size increases temporal continuity between adjacent feature points and makes the feature curves smoother in time. Therefore, the 250 ms / 50 ms design provides a practical balance between smoothing and time localization.&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt;-th segment, the feature time is defined as the mean time of that segment:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t_k = \frac{1}{N}\sum_{i=s_k}^{e_k} t(i)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;s_k&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;e_k&amp;lt;/math&amp;gt; denote the start and end indices of the window.&lt;br /&gt;
&lt;br /&gt;
=== Feature Extraction ===&lt;br /&gt;
&lt;br /&gt;
Within each sliding window, three time-domain features are extracted: RMS, iEMG, and MAV. These features are widely used in EMG analysis because they are simple, computationally efficient, and directly related to muscle activation intensity.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(1) Root Mean Square (RMS)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
RMS = \sqrt{\frac{1}{N}\sum_{i=1}^{N}x_i^2}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
RMS reflects the effective power of the EMG signal and is one of the most common indicators of contraction strength. It is sensitive to both amplitude and energy, making it especially useful for comparing rest and active states.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(2) Integrated EMG (iEMG)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
iEMG = \sum_{i=1}^{N}|x_i|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
iEMG describes the cumulative electrical activity within a window. It is often interpreted as a measure of total muscle effort over that time segment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(3) Mean Absolute Value (MAV)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
MAV = \frac{1}{N}\sum_{i=1}^{N}|x_i|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
MAV is an amplitude descriptor similar to iEMG, but normalized by the number of samples. It provides an efficient estimate of average signal level and is less computationally intensive than some other features.&lt;br /&gt;
&lt;br /&gt;
These three features are used together because they provide complementary descriptions of EMG intensity. RMS emphasizes signal energy, iEMG emphasizes cumulative activation, and MAV reflects average amplitude.&lt;br /&gt;
&lt;br /&gt;
=== Peak-value Extraction ===&lt;br /&gt;
&lt;br /&gt;
In addition to continuous feature curves, several key peak values are extracted from the processed signal:&lt;br /&gt;
&lt;br /&gt;
* maximum and minimum of the filtered EMG waveform&lt;br /&gt;
* peak of the envelope&lt;br /&gt;
* peak RMS&lt;br /&gt;
* peak iEMG&lt;br /&gt;
* peak MAV&lt;br /&gt;
&lt;br /&gt;
These peak values provide concise descriptors of the strongest activity observed in each recording. They are useful for quick comparison across trials and subjects.&lt;br /&gt;
&lt;br /&gt;
=== Noise Floor Estimation ===&lt;br /&gt;
&lt;br /&gt;
To evaluate signal quality, the noise floor is estimated from a reference resting interval. In the present implementation, the first 3 seconds of the recording are used as the default rest reference:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t \in [0,\min(3,t_{end})]&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this segment, three noise descriptors are computed:&lt;br /&gt;
&lt;br /&gt;
* Noise RMS&lt;br /&gt;
* Noise standard deviation&lt;br /&gt;
* Noise peak-to-peak amplitude&lt;br /&gt;
&lt;br /&gt;
Noise-floor estimation is important because EMG amplitude alone is not sufficient to judge recording quality. A large signal is only meaningful if it is sufficiently higher than the baseline noise level. Therefore, the noise floor serves as the reference for later SNR calculation and for designing contraction thresholds.&lt;br /&gt;
&lt;br /&gt;
=== Global Signal Metrics ===&lt;br /&gt;
&lt;br /&gt;
For each recording, three global metrics are also computed over the entire filtered signal:&lt;br /&gt;
&lt;br /&gt;
* Global RMS&lt;br /&gt;
* Global MAV&lt;br /&gt;
* Global iEMG&lt;br /&gt;
&lt;br /&gt;
These global descriptors summarize the overall signal level of the full recording and are later used in group-level comparisons.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Contraction Detection ===&lt;br /&gt;
&lt;br /&gt;
For dynamic recordings, an automatic contraction detection algorithm is used to identify repeated active segments. This is one of the key parts of the data processing pipeline, because it transforms a continuous EMG trace into discrete contraction events that can be counted and compared.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(1) Threshold Design&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The detection threshold is designed adaptively rather than using a fixed value. Two candidate thresholds are first calculated:&lt;br /&gt;
&lt;br /&gt;
* an envelope-based threshold derived from the global envelope mean and standard deviation&lt;br /&gt;
* a rest-reference threshold derived from the mean and standard deviation of the resting reference amplitude&lt;br /&gt;
&lt;br /&gt;
The final threshold is taken as the larger of the two after additional scaling. This strategy improves robustness because it combines the global activation level of the signal with the baseline noise characteristics of the individual recording.&lt;br /&gt;
&lt;br /&gt;
This adaptive threshold design is preferable to a manually fixed threshold because EMG amplitude can vary strongly between subjects, muscles, and recording sessions.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(2) Initial Segmentation&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
After thresholding the envelope, the signal is classified into active and inactive regions:&lt;br /&gt;
&lt;br /&gt;
* active: envelope above threshold&lt;br /&gt;
* inactive: envelope below threshold&lt;br /&gt;
&lt;br /&gt;
The rising and falling edges of the binary activity vector are then used to determine the start and end points of each candidate contraction segment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(3) Removal of Short Segments&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Very short active regions are often caused by noise fluctuations rather than true muscle contractions. Therefore, segments shorter than 0.20 s are discarded.&lt;br /&gt;
&lt;br /&gt;
This step prevents false positive detections and increases the physiological relevance of the segmentation results.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(4) Merging of Adjacent Segments &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If two neighboring active segments are separated by a very short gap, they are merged when the gap is less than 0.15 s.&lt;br /&gt;
&lt;br /&gt;
This operation is necessary because a single real contraction may be temporarily interrupted by a brief drop in the envelope caused by local fluctuation. Without merging, one contraction could be incorrectly counted as multiple repetitions.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(5) Repetition-level Metrics &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
For each detected contraction segment, two repetition-level metrics are extracted:&lt;br /&gt;
&lt;br /&gt;
* peak RMS of that contraction&lt;br /&gt;
* mean RMS of that contraction&lt;br /&gt;
&lt;br /&gt;
These metrics quantify both the strongest activation within each repetition and the average activation level over the repetition duration.&lt;br /&gt;
&lt;br /&gt;
=== Repeatability Analysis ===&lt;br /&gt;
&lt;br /&gt;
When multiple valid contractions are detected, repeatability is evaluated using the coefficient of variation (CV):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
CV = \frac{\sigma}{\mu}\times 100\%&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt; is the standard deviation and &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is the mean value across repetitions.&lt;br /&gt;
&lt;br /&gt;
Two CV values are computed:&lt;br /&gt;
&lt;br /&gt;
* CV of repetition peak RMS&lt;br /&gt;
* CV of repetition mean RMS&lt;br /&gt;
&lt;br /&gt;
A lower CV indicates better repeatability, meaning that repeated contractions produce more consistent EMG responses.&lt;br /&gt;
&lt;br /&gt;
=== Signal-to-Noise Ratio (SNR) ===&lt;br /&gt;
&lt;br /&gt;
In this project, the signal-to-noise ratio (SNR) is defined based on the ratio between contraction and rest activity:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
SNR_{dB} = 20\log_{10}\left(\frac{RMS_{contraction}}{RMS_{rest}}\right)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This definition is adopted because it directly reflects the system’s ability to distinguish active muscle contraction from baseline noise.&lt;br /&gt;
&lt;br /&gt;
Compared with global SNR definitions, this formulation is more relevant for practical EMG applications such as activity detection and classification.&lt;br /&gt;
&lt;br /&gt;
=== Rest-versus-Contraction Window Comparison ===&lt;br /&gt;
&lt;br /&gt;
To further distinguish inactive and active states, all sliding windows are divided into two groups:&lt;br /&gt;
&lt;br /&gt;
* rest windows: windows with envelope clearly below the threshold&lt;br /&gt;
* contraction windows: windows with envelope above the threshold&lt;br /&gt;
&lt;br /&gt;
The RMS values of these two groups are then compared statistically.&lt;br /&gt;
&lt;br /&gt;
This comparison is important because a practical EMG system should not only detect signal presence, but also clearly separate rest from contraction in a quantitative way. If the two RMS distributions are well separated, it indicates that the system has good discriminative capability.&lt;br /&gt;
&lt;br /&gt;
=== Output Data Structure ===&lt;br /&gt;
&lt;br /&gt;
The processed outputs are organized into structured data for experimental analysis:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(1) Time-series outputs&#039;&#039;&#039;&lt;br /&gt;
* Filtered EMG signal  &lt;br /&gt;
* Rectified signal  &lt;br /&gt;
* Envelope  &lt;br /&gt;
* RMS(t), iEMG(t), MAV(t)  &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(2) Recording-level outputs&#039;&#039;&#039; &lt;br /&gt;
* RMS (rest)  &lt;br /&gt;
* RMS (contraction)  &lt;br /&gt;
* iEMG  &lt;br /&gt;
* Noise metrics  &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(3) Dynamic-signal outputs &#039;&#039;&#039;&lt;br /&gt;
* Detected contractions  &lt;br /&gt;
* Repetition count  &lt;br /&gt;
* Peak RMS per repetition  &lt;br /&gt;
* Mean RMS per repetition  &lt;br /&gt;
* Coefficient of variation (CV)  &lt;br /&gt;
* Signal-to-noise ratio (SNR)  &lt;br /&gt;
&lt;br /&gt;
All extracted features are designed to directly support the evaluation of noise level, signal quality, activity discrimination, and repeatability in the subsequent experimental analysis.&lt;br /&gt;
&lt;br /&gt;
== Experimental Results ==&lt;br /&gt;
&lt;br /&gt;
This section presents representative results of the EMG acquisition and data processing pipeline under both dynamic (muscle contraction) and resting conditions.&lt;br /&gt;
&lt;br /&gt;
=== Representative Dynamic Signal Analysis ===&lt;br /&gt;
&lt;br /&gt;
[[File:Dynamic_Figure1.png|thumb|800px|center|Figure 5.1: Processed EMG signal under dynamic contraction, including filtered signal, rectified signal with envelope, and extracted features (RMS, iEMG, MAV).]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.1 shows the processed EMG signal during repeated muscle contractions.&lt;br /&gt;
&lt;br /&gt;
The filtered EMG waveform exhibits clear burst-like patterns corresponding to periodic contractions. The signal amplitude reaches a maximum of approximately 0.45, while the baseline remains centered around zero, indicating effective baseline removal and filtering.&lt;br /&gt;
&lt;br /&gt;
After rectification and envelope extraction, the contraction periods become clearly distinguishable. The envelope provides a smooth representation of muscle activation, with a peak value of approximately 0.145.&lt;br /&gt;
&lt;br /&gt;
The extracted time-domain features (RMS, iEMG, MAV) further quantify the signal. Among these, iEMG shows the strongest dynamic variation, indicating high sensitivity to contraction intensity.&lt;br /&gt;
&lt;br /&gt;
=== Noise Floor and Rest Reference ===&lt;br /&gt;
&lt;br /&gt;
[[File:Dynamic_Figure2.png|thumb|800px|center|Figure 5.2: Noise estimation, rest vs contraction comparison, automatic contraction detection, and repetition analysis.]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (top-left) shows the resting reference segment used for noise estimation.&lt;br /&gt;
&lt;br /&gt;
The signal remains centered around zero with small fluctuations. The noise characteristics are:&lt;br /&gt;
&lt;br /&gt;
* Noise RMS ≈ 0.0046  &lt;br /&gt;
* Standard deviation ≈ 0.0046  &lt;br /&gt;
* Peak-to-peak amplitude ≈ 0.071  &lt;br /&gt;
&lt;br /&gt;
This indicates a low noise floor and stable measurement conditions.&lt;br /&gt;
&lt;br /&gt;
=== Rest vs Contraction Discrimination ===&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (top-right) compares RMS values between rest and contraction states.&lt;br /&gt;
&lt;br /&gt;
The two distributions are clearly separated:&lt;br /&gt;
&lt;br /&gt;
* Rest mean RMS ≈ 0.0053  &lt;br /&gt;
* Contraction mean RMS ≈ 0.1064  &lt;br /&gt;
&lt;br /&gt;
This corresponds to an approximate 20× increase, demonstrating strong discriminability between inactive and active muscle states.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Contraction Detection ===&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (bottom-left) illustrates automatic detection based on the envelope signal.&lt;br /&gt;
&lt;br /&gt;
A threshold of approximately 0.040 is applied, resulting in stable segmentation of contraction periods.&lt;br /&gt;
&lt;br /&gt;
A total of 12 repetitions are detected, with good alignment to visible signal peaks.&lt;br /&gt;
&lt;br /&gt;
=== Repeatability Analysis ===&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (bottom-right) shows the peak RMS value of each detected contraction.&lt;br /&gt;
&lt;br /&gt;
The results indicate:&lt;br /&gt;
&lt;br /&gt;
* Mean peak RMS ≈ 0.1355  &lt;br /&gt;
* Standard deviation ≈ 0.0173  &lt;br /&gt;
* CV ≈ 12.77%  &lt;br /&gt;
* SNR ≈ 21.26 dB  &lt;br /&gt;
&lt;br /&gt;
This indicates acceptable repeatability and good signal quality.&lt;br /&gt;
&lt;br /&gt;
=== Representative Rest Signal Analysis ===&lt;br /&gt;
&lt;br /&gt;
[[File:Rest_Figure1.png|thumb|800px|center|Figure 5.3: Processed EMG signal under rest condition, showing low amplitude and absence of contraction patterns.]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.3 shows the EMG signal under resting conditions.&lt;br /&gt;
&lt;br /&gt;
The signal remains within a narrow amplitude range (approximately ±0.04) and shows no burst-like structures. The envelope remains close to zero, confirming the absence of muscle activity.&lt;br /&gt;
&lt;br /&gt;
The extracted features remain low:&lt;br /&gt;
&lt;br /&gt;
* RMS ≈ 0.007  &lt;br /&gt;
* MAV ≈ 0.005  &lt;br /&gt;
* iEMG remains stable  &lt;br /&gt;
&lt;br /&gt;
This confirms that no false activation is detected.&lt;br /&gt;
&lt;br /&gt;
=== Frequency-domain Characteristics ===&lt;br /&gt;
&lt;br /&gt;
[[File:Rest_Figure2.png|thumb|800px|center|Figure 5.4: Frequency-domain analysis and statistical characteristics of rest signal.]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.4 shows the frequency-domain characteristics of the resting signal.&lt;br /&gt;
&lt;br /&gt;
The power spectral density (PSD) indicates low overall signal energy without dominant peaks, confirming that the signal mainly consists of noise.&lt;br /&gt;
&lt;br /&gt;
=== Summary of Single-recording Performance ===&lt;br /&gt;
&lt;br /&gt;
From the representative results:&lt;br /&gt;
&lt;br /&gt;
* EMG signals are effectively extracted and denoised  &lt;br /&gt;
* Contraction events are clearly identifiable  &lt;br /&gt;
* Rest and contraction states are well separated  &lt;br /&gt;
* Automatic detection is stable and accurate  &lt;br /&gt;
* Repeatability is acceptable  &lt;br /&gt;
* No false activation occurs under rest conditions  &lt;br /&gt;
&lt;br /&gt;
=== Consistency Across Multiple Recordings ===&lt;br /&gt;
&lt;br /&gt;
The same data processing pipeline was applied to multiple recordings from different subjects and trials.&lt;br /&gt;
&lt;br /&gt;
Across all datasets, consistent patterns were observed:&lt;br /&gt;
&lt;br /&gt;
* Dynamic signals exhibit clear burst-like structures corresponding to repeated muscle contractions  &lt;br /&gt;
* Rest signals remain low in amplitude without distinct activation patterns  &lt;br /&gt;
* RMS values under contraction are consistently higher than those under rest  &lt;br /&gt;
* The automatic detection algorithm reliably identifies contraction segments  &lt;br /&gt;
&lt;br /&gt;
Although quantitative values (e.g., RMS, SNR, CV) vary across recordings due to differences in electrode contact, muscle activation strength, and individual conditions, the overall trends remain consistent.&lt;br /&gt;
&lt;br /&gt;
These results demonstrate the robustness and general applicability of the proposed signal processing method.&lt;br /&gt;
&lt;br /&gt;
== Multi-subject Analysis ==&lt;br /&gt;
=== System Evaluation ===&lt;br /&gt;
&lt;br /&gt;
This section evaluates the performance of the EMG acquisition system in terms of noise level, signal quality, activity discrimination, and repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Noise Floor Analysis ====&lt;br /&gt;
&lt;br /&gt;
The noise floor was evaluated using rest-state recordings, characterized by RMS noise, standard deviation, and peak-to-peak amplitude.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039; shows the lowest noise level (RMS ≈ 0.0046), indicating stable electrode contact and minimal interference.  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039; exhibits moderate noise (RMS ≈ 0.0080), likely influenced by motion artifacts or electrode–skin impedance variation.  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039; shows relatively higher noise (RMS ≈ 0.0126), suggesting increased baseline fluctuation.  &lt;br /&gt;
&lt;br /&gt;
Overall, the system maintains a low noise floor across subjects, although the quality depends on experimental conditions such as electrode contact and environmental interference.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Signal-to-Noise Ratio (SNR) ====&lt;br /&gt;
&lt;br /&gt;
The signal-to-noise ratio (SNR) is defined as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{SNR (dB)} = 20 \log_{10} \left( \frac{\mathrm{RMS}_{\mathrm{contraction}}}{\mathrm{RMS}_{\mathrm{rest}}} \right)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The measured SNR values are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: 21.26 dB → good signal quality  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: 13.52 dB → moderate and usable  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: 6.66 dB → low signal clarity  &lt;br /&gt;
&lt;br /&gt;
General interpretation:&lt;br /&gt;
&lt;br /&gt;
* &amp;gt;20 dB → good  &lt;br /&gt;
* 10–20 dB → usable  &lt;br /&gt;
* &amp;lt;10 dB → poor  &lt;br /&gt;
&lt;br /&gt;
These results show that the system can achieve reliable signal acquisition, although performance varies across subjects.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
====  Rest vs Contraction Discrimination ====&lt;br /&gt;
&lt;br /&gt;
A clear distinction between rest and contraction states is observed based on RMS values.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: 0.0053 → 0.1064 (≈20× increase)  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: 0.0079 → 0.0283 (≈3.6× increase)  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: 0.0141 → 0.0646 (≈4.6× increase)  &lt;br /&gt;
&lt;br /&gt;
This demonstrates that the system is capable of separating muscle activity from baseline noise.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Conclusion:&#039;&#039;  &lt;br /&gt;
The system can be used for basic muscle activity detection and simple classification tasks based on RMS features.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Repeatability of Repeated Contractions ====&lt;br /&gt;
&lt;br /&gt;
Repeatability is evaluated using the coefficient of variation (CV) of peak RMS values across repetitions.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! CV Range !! Evaluation&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt; 10% || Excellent&lt;br /&gt;
|-&lt;br /&gt;
| 10–20% || Acceptable&lt;br /&gt;
|-&lt;br /&gt;
| &amp;gt; 20% || Poor&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Results:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: CV = 12.77% → Acceptable  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: CV = 24.77% → Poor  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: CV = 10.60% → Acceptable  &lt;br /&gt;
&lt;br /&gt;
Although WANG&#039;s signal is detectable, its contraction amplitude varies significantly across repetitions, resulting in poor repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
=== Overall System Performance ===&lt;br /&gt;
&lt;br /&gt;
The system demonstrates the following performance characteristics:&lt;br /&gt;
&lt;br /&gt;
* Reliable detection of muscle activity across all subjects  &lt;br /&gt;
* Clear separation between rest and contraction states  &lt;br /&gt;
* Moderate to high signal quality depending on subject conditions  &lt;br /&gt;
* Repeatability ranging from acceptable to poor due to user-dependent factors  &lt;br /&gt;
&lt;br /&gt;
Overall, the designed EMG acquisition system is capable of stable signal acquisition and feature extraction, with performance primarily influenced by electrode contact quality, skin impedance, and motion consistency.&lt;br /&gt;
&lt;br /&gt;
===== Summary of Quantitative Metrics =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Subject !! RMS (Rest) !! RMS (Contraction) !! Separation Ratio !! iEMG (max) !! Noise RMS !! SNR (dB) !! CV (%) !! Evaluation&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;LIU&#039;&#039;&#039; || 0.0053 || 0.1064 || &#039;&#039;&#039;20.1×&#039;&#039;&#039; || 12.72 || 0.0046 || &#039;&#039;&#039;21.26&#039;&#039;&#039; || 12.77 || Strong signal, good quality&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;WANG&#039;&#039;&#039; || 0.0079 || 0.0283 || 3.57× || 11.10 || 0.0080 || 13.52 || &#039;&#039;&#039;24.77&#039;&#039;&#039; || Usable signal, poor repeatability&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ZHONG&#039;&#039;&#039; || 0.0141 || 0.0646 || 4.58× || 6.70 || 0.0126 || 6.66 || 10.60 || Acceptable performance&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Summary:&#039;&#039; Subject LIU shows the best overall performance, WANG provides usable but less stable signals, and ZHONG demonstrates moderate signal quality with good repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Activation Intensity =====&lt;br /&gt;
&lt;br /&gt;
Among the three subjects, &#039;&#039;&#039;LIU exhibits the strongest muscle activation&#039;&#039;&#039;, as indicated by the highest contraction RMS and iEMG values. ZHONG shows moderate activation, while WANG demonstrates comparable iEMG but lower RMS consistency.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Signal Quality =====&lt;br /&gt;
&lt;br /&gt;
Signal quality is evaluated based on SNR and noise level:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039; achieves the highest SNR and lowest noise → best signal quality  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039; shows moderate SNR → usable but less robust  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039; has the lowest SNR → weakest signal clarity  &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Repeatability =====&lt;br /&gt;
&lt;br /&gt;
Repeatability is evaluated using the coefficient of variation (CV):&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;ZHONG (10.60%)&#039;&#039;&#039; → most stable  &lt;br /&gt;
* &#039;&#039;&#039;LIU (12.77%)&#039;&#039;&#039; → acceptable  &lt;br /&gt;
* &#039;&#039;&#039;WANG (24.77%)&#039;&#039;&#039; → poor  &lt;br /&gt;
&lt;br /&gt;
This indicates that WANG’s contraction strength varies significantly between repetitions.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Engineering Interpretation of Inter-subject Differences =====&lt;br /&gt;
&lt;br /&gt;
The observed differences are mainly attributed to engineering and experimental factors rather than physiological differences.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Electrode contact quality&#039;&#039;&#039;  &lt;br /&gt;
  Variations in electrode placement, pressure, and gel contact affect signal amplitude and stability.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Skin impedance&#039;&#039;&#039;  &lt;br /&gt;
  Differences in skin condition (hydration, oil, hair) influence electrode–skin impedance, affecting noise level and signal coupling.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Muscle control consistency&#039;&#039;&#039;  &lt;br /&gt;
  Variations in contraction strength and timing affect repeatability and CV.&lt;br /&gt;
&lt;br /&gt;
Therefore, the variation across subjects reflects practical acquisition conditions rather than intrinsic system limitations.&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&lt;br /&gt;
This project presents a complete surface EMG (sEMG) acquisition and analysis system, integrating hardware design, signal conditioning, data processing, and experimental validation.&lt;br /&gt;
&lt;br /&gt;
From the hardware perspective, a dedicated analog front-end and data acquisition system were developed to capture low-amplitude bioelectrical signals with sufficient resolution and stability. The experimental setup, including electrode placement and measurement protocol, enables consistent and repeatable signal acquisition across different subjects.&lt;br /&gt;
&lt;br /&gt;
From the signal processing perspective, a structured pipeline was implemented, including filtering, rectification, envelope extraction, sliding-window segmentation, and feature extraction. Key features such as RMS, iEMG, and MAV were used to quantitatively characterize muscle activity.&lt;br /&gt;
&lt;br /&gt;
Experimental results demonstrate that:&lt;br /&gt;
&lt;br /&gt;
* EMG signals can be effectively extracted and denoised  &lt;br /&gt;
* Muscle contraction produces clear and repeatable signal patterns  &lt;br /&gt;
* Rest and contraction states can be reliably distinguished  &lt;br /&gt;
* Automatic detection accurately identifies contraction segments  &lt;br /&gt;
* The system achieves acceptable repeatability and signal quality  &lt;br /&gt;
&lt;br /&gt;
Overall, the proposed system provides a reliable framework for basic EMG signal acquisition and analysis. It is capable of capturing meaningful muscle activity and generating quantitative features that support further evaluation and interpretation.&lt;br /&gt;
&lt;br /&gt;
These results establish a solid foundation for subsequent multi-subject analysis and demonstrate the practical feasibility of the system for EMG-based monitoring applications.&lt;br /&gt;
&lt;br /&gt;
== Appendix ==&lt;br /&gt;
&lt;br /&gt;
=== EMG Signal Processing Code ===&lt;br /&gt;
&lt;br /&gt;
The following MATLAB code summarizes the core implementation of the EMG signal processing pipeline.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
% =========================&lt;br /&gt;
% EMG Analysis (Simplified)&lt;br /&gt;
% =========================&lt;br /&gt;
&lt;br /&gt;
clear; clc; close all;&lt;br /&gt;
&lt;br /&gt;
%% 1. Read data&lt;br /&gt;
filename = &#039;your_file.csv&#039;;&lt;br /&gt;
T = readtable(filename, &#039;VariableNamingRule&#039;,&#039;preserve&#039;);&lt;br /&gt;
&lt;br /&gt;
t_all = T.(&amp;quot;Time (s)&amp;quot;);&lt;br /&gt;
x_all = T.(&amp;quot;Filtered sEMG&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
t_all = t_all(:);&lt;br /&gt;
x_all = x_all(:);&lt;br /&gt;
&lt;br /&gt;
fs = 400;&lt;br /&gt;
&lt;br /&gt;
%% 2. Time normalization&lt;br /&gt;
t = t_all - t_all(1);&lt;br /&gt;
x = x_all;&lt;br /&gt;
&lt;br /&gt;
%% 3. Preprocessing&lt;br /&gt;
x = x - mean(x);   % Remove DC&lt;br /&gt;
&lt;br /&gt;
[b_bp, a_bp] = butter(4, [20 150]/(fs/2), &#039;bandpass&#039;);&lt;br /&gt;
x_filt = filtfilt(b_bp, a_bp, x);   % Band-pass filter&lt;br /&gt;
&lt;br /&gt;
x_rect = abs(x_filt);               % Rectification&lt;br /&gt;
env = movmean(x_rect, round(0.10*fs));  % Envelope&lt;br /&gt;
&lt;br /&gt;
%% 4. Sliding window feature extraction&lt;br /&gt;
win = round(0.25*fs);&lt;br /&gt;
step = round(0.05*fs);&lt;br /&gt;
&lt;br /&gt;
idx_start = 1:step:(length(x_filt)-win+1);&lt;br /&gt;
&lt;br /&gt;
for k = 1:length(idx_start)&lt;br /&gt;
    s = idx_start(k);&lt;br /&gt;
    e = s + win - 1;&lt;br /&gt;
    seg = x_filt(s:e);&lt;br /&gt;
&lt;br /&gt;
    RMS(k)  = sqrt(mean(seg.^2));&lt;br /&gt;
    iEMG(k) = sum(abs(seg));&lt;br /&gt;
    MAV(k)  = mean(abs(seg));&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
%% 5. Noise floor estimation&lt;br /&gt;
noise_floor_rms = sqrt(mean(x_filt(1:fs*3).^2));&lt;br /&gt;
&lt;br /&gt;
%% 6. Envelope-based detection&lt;br /&gt;
th = mean(env) + 0.5 * std(env);&lt;br /&gt;
is_active = env &amp;gt; th;&lt;br /&gt;
&lt;br /&gt;
%% 7. Signal-to-noise ratio&lt;br /&gt;
snr_db = 20 * log10(rms(x_filt) / noise_floor_rms);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The full MATLAB implementation is available upon request.&lt;/div&gt;</summary>
		<author><name>Wang Jingyi</name></author>
	</entry>
	<entry>
		<id>https://pc5271.org/index.php?title=Surface_EMG_Sensor_for_Muscle_Activity_Measurement:_AFE_Design_and_Signal_Processing&amp;diff=1378</id>
		<title>Surface EMG Sensor for Muscle Activity Measurement: AFE Design and Signal Processing</title>
		<link rel="alternate" type="text/html" href="https://pc5271.org/index.php?title=Surface_EMG_Sensor_for_Muscle_Activity_Measurement:_AFE_Design_and_Signal_Processing&amp;diff=1378"/>
		<updated>2026-04-23T08:36:45Z</updated>

		<summary type="html">&lt;p&gt;Wang Jingyi: /* Appendix */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Background and Theory==&lt;br /&gt;
&lt;br /&gt;
=== Surface EMG Signals ===&lt;br /&gt;
Surface electromyography (sEMG) refers to the bioelectrical signals detected on the skin surface during muscle contraction. These signals originate from the electrical activity of muscle fibers and provide a non-invasive way to monitor muscle activation. Compared with invasive EMG methods, sEMG is easier to apply, safer for repeated measurements, and more suitable for real-time monitoring. Therefore, it has been widely used in areas such as rehabilitation, motion analysis, human–machine interaction, and physiological monitoring.&lt;br /&gt;
&lt;br /&gt;
=== Characteristics of EMG Signals ===&lt;br /&gt;
EMG signals are generally weak, time-varying, and stochastic in nature. Their waveforms are typically bipolar, fluctuating around zero with both positive and negative components. The amplitude and frequency content of EMG signals depend on factors such as muscle contraction level, electrode placement, skin condition, and individual physiological differences. In practice, the useful frequency components of sEMG are mainly concentrated in a limited low-to-mid frequency range. Because of their low amplitude and variability, EMG signals usually require further conditioning before reliable interpretation and feature extraction can be performed.&lt;br /&gt;
&lt;br /&gt;
=== Bioelectrical Signal Acquisition Principles ===&lt;br /&gt;
The acquisition of bioelectrical signals is based on measuring the small potential difference on the skin surface using electrodes, then converting it into a processable electrical signal through amplification and digitization. For sEMG measurement, electrode placement and skin–electrode contact quality are especially important, since they directly affect signal amplitude and stability. In addition, the front-end acquisition circuit must provide sufficient sensitivity and good interference rejection, so that the recorded signal reflects actual muscle activity rather than environmental disturbance or poor contact conditions.&lt;br /&gt;
&lt;br /&gt;
=== Noise Sources in EMG (50 Hz, motion artifacts) ===&lt;br /&gt;
In practical EMG recording, the measured signal is easily contaminated by different types of noise. Two of the most common sources are power-line interference and motion artifacts. Power-line interference usually appears as a narrow-band component at 50 Hz in the local electrical environment, while motion artifacts are mainly caused by electrode movement, cable disturbance, or variations in the electrode–skin impedance, and are often concentrated in the low-frequency range. In addition, electronic noise from the acquisition hardware may also affect the recording quality. These unwanted components can reduce signal clarity and make muscle activity analysis less reliable, so they must be considered in the design of the signal processing pipeline.&lt;br /&gt;
[[File:background_theory_figure1.1_emg_noise_sources.png|center|thumb|700px|&#039;&#039;&#039;Figure 1.1.&#039;&#039;&#039; Principle of surface EMG acquisition.]]&lt;br /&gt;
&lt;br /&gt;
==System Architecture==&lt;br /&gt;
=== Total Structure Design ===&lt;br /&gt;
&lt;br /&gt;
For clarity，the proposed physiological signal acquisition system mainly consists of two core parts：the analog front－end （AFE）and the ADC board．The AFE is responsible for the preliminary conditioning of weak bioelectrical signals，including amplification，filtering，interference suppression，and level shifting，so that the analog waveform can be converted into a stable and measurable form．The ADC board then performs high－resolution digitization of the conditioned signal and transfers the sampled data to the host computer for subsequent display，storage，and analysis．Therefore，the overall system forms a complete signal－acquisition chain from weak physiological input to digital output．&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_1.jpg|thumb|center|800px|Figure 2.1. Overall system architecture of the proposed physiological signal acquisition platform，including the AFE and ADC modules．]]&lt;br /&gt;
&lt;br /&gt;
=== sEMG AFE Design ===&lt;br /&gt;
&lt;br /&gt;
To collect the weak bioelectric potential signals of the human body，an analog front－end（AFE）suitable sEMG measurements was designed．The module is powered by an external 5 V supply，and the complete circuit includes a first－ stage instrumentation amplifier based on INA128（Texas Instruments，Dallas，TX，USA），a band－pass filter，a 50 Hz notch filter，a second－order amplification and level shifting stage，a driver electrode circuit，a precise 1.5 V reference source，and a -5 V voltage generation module for powering the operational amplifiers．&lt;br /&gt;
&lt;br /&gt;
==== First－order Amplifier ====&lt;br /&gt;
&lt;br /&gt;
The input bioelectric signal is first acquired in differential form and applied to the INA128 instrumentation amplifier，which provides high input impedance，high common－mode rejection，and moderate initial gain for sEMG acquisition．This stage enlarges the weak physiological signal before filtering while reducing the risk of premature saturation caused by electrode offset or motion－induced disturbance，thereby preparing a more stable signal for the subsequent conditioning stages．&lt;br /&gt;
&lt;br /&gt;
==== Bandpass Filter ====&lt;br /&gt;
&lt;br /&gt;
After the instrumentation amplifier，the signal passes through a second－order active band－pass filter，as shown in Figure 2．2． This stage suppresses baseline drift and high－frequency noise outside the useful sEMG range，so that the low－frequency envelope information of sEMG can be preserved before further amplification．&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_2.jpg|thumb|center|800px|Figure 2.2. Schematic diagram of the active band-pass filter used in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the band-pass stage used to retain the main physiological signal band while suppressing unwanted lowand high-frequency components.&lt;br /&gt;
&lt;br /&gt;
==== Notch Filter ====&lt;br /&gt;
&lt;br /&gt;
To reduce power-line interference, a dedicated 50 Hz notch filter is introduced after the band-pass stage, as shown in Figure 2.3. This filter attenuates the mains-frequency component that commonly contaminates weak bioelectric measurements, thereby improving the signal-to-noise ratio of sEMG signals before the final amplification stage.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_3.jpg|thumb|center|800px|Figure 2.3. Schematic diagram of the 50 Hz notch filter used in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the circuit used to attenuate 50 Hz mains interference in the analog front end.&lt;br /&gt;
&lt;br /&gt;
==== Second-order Amplifier &amp;amp; Level Shifter ====&lt;br /&gt;
&lt;br /&gt;
After filtering, the signal enters the second-stage amplification and level-shifting circuit shown in Figure 2.4. In this stage, the filtered signal is further amplified to improve amplitude utilization and then shifted by a 1.5 V reference so that the output becomes a stable unipolar signal suitable for ADC sampling, while preserving linear operation and providing sufficient output swing margin.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_4.jpg|thumb|center|800px|Figure 2.4. Schematic diagram of the second-stage amplifier and level-shifting circuit in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows how the conditioned signal is further amplified and shifted to a suitable DC level before digitization.&lt;br /&gt;
&lt;br /&gt;
==== Power Module and Drive-electrode Circuit ====&lt;br /&gt;
&lt;br /&gt;
The AFE is powered by a 5 V supply and also integrates a 1.5 V precision reference, a -5 V generation circuit, and a driveelectrode circuit. These supporting modules provide the required supply rails and reference level for analog signal conditioning, while the drive-electrode circuit feeds back common-mode voltage to the body to suppress interference at the source. As a result, the complete AFE can support sEMG acquisition with adequate gain, filtering, and noise-reduction performance in a compact hardware structure.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_5.jpg|thumb|center|800px|Figure 2.5. Physical picture of the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the fabricated sEMG analog front-end hardware used in the system.&lt;br /&gt;
&lt;br /&gt;
Figure 2.5 presents the practical hardware implementation of the proposed sEMG AFE. It integrates amplification, filtering, level shifting, and driven-reference functions in a compact circuit for weak bioelectrical signal acquisition.&lt;br /&gt;
&lt;br /&gt;
=== ADS1256-based ADC Board ===&lt;br /&gt;
&lt;br /&gt;
To digitize the conditioned weak physiological signals with sufficient resolution and low noise, this project developed a dedicated ADC board based on the ADS1256 analog-to-digital converter (Texas Instruments, Dallas, TX, USA) and the STM32F103C8T6 microcontroller (STMicroelectronics, Geneva, Switzerland). The overall design objective of this board was not merely to realize analog-to-digital conversion, but to provide a complete hardware interface between the analog front-end and the digital processing unit, including precision reference generation, clocking, input protection and filtering, serial communication, power regulation, and MCU-based acquisition control. The ADS1256 was selected because it is a&lt;br /&gt;
&lt;br /&gt;
very low-noise 24-bit delta-sigma converter with a programmable gain amplifier (PGA), flexible input multiplexer, programmable digital filter, and SPI-compatible serial interface, which makes it well suited for weak low-frequency physiological signals after analog conditioning. The STM32F103C8T6 was used as the local controller because it provides a 32-bit Cortex-M3 core, up to 72 MHz system clock, SPI, USART, USB, and standard SWD debugging support in a compact and low-cost platform.&lt;br /&gt;
&lt;br /&gt;
==== ADC Core Architecture and Design Rationale ====&lt;br /&gt;
&lt;br /&gt;
The ADS1256 was selected as the core ADC because it provides high-resolution, low-noise delta-sigma conversion with an input multiplexer, programmable gain amplifier, and digital filter, which are suitable for weak and low-frequency physiological signals. As shown in Figure 2.6, this architecture emphasizes resolution and noise performance rather than high conversion bandwidth, making it appropriate for sEMG signal digitization after analog conditioning.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_6.jpg|thumb|center|800px|Figure 2.6. Internal functional structure of the ADS1256 analog-to-digital converter.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the main internal blocks of the ADS1256, including the multiplexer, PGA, modulator, and digital filter.&lt;br /&gt;
&lt;br /&gt;
==== Analog Front-End Interface, Reference, and Clocking ====&lt;br /&gt;
&lt;br /&gt;
The ADS1256 analog inputs are connected to the external header through a passive input-conditioning network that helps suppress high-frequency interference and improve input stability. In addition, the board includes a dedicated precision reference and clocking circuits so that the ADC can perform stable and accurate conversion. Together, these circuits provide a reliable analog interface and timing basis for high-resolution digitization of weak physiological signals.&lt;br /&gt;
&lt;br /&gt;
==== SPI Interface between ADS1256 and STM32F103C8T6 ====&lt;br /&gt;
&lt;br /&gt;
Communication between the ADS1256 and the STM32F103C8T6 is implemented through an SPI-compatible interface, with dedicated lines for chip select, serial clock, input/output data, data-ready notification, and hardware reset. This connection allows the MCU to configure the ADC, read conversion results in synchrony with DRDY, and maintain efficient and reliable acquisition control for multi-channel physiological measurements.&lt;br /&gt;
&lt;br /&gt;
==== Power Supply and On-board Regulation ====&lt;br /&gt;
&lt;br /&gt;
The ADC board uses a USB Type-B connector as the main power input and includes protection, voltage regulation, and local decoupling circuits to provide a stable supply for both the MCU and ADC-related hardware. In addition, analog ground and digital ground are separated in the PCB layout to reduce digital noise coupling into the analog path, which is particularly important for weak physiological signal acquisition.&lt;br /&gt;
&lt;br /&gt;
==== Basic Peripheral Circuits of the STM32F103C8T6 ====&lt;br /&gt;
&lt;br /&gt;
The STM32F103C8T6 serves as the local controller of the ADC board and is supported by several basic peripheral circuits, including an external crystal oscillator, reset network, BOOT0 configuration, SWD programming/debugging header, and a CH340N USB-to-UART bridge. These circuits ensure stable MCU operation, convenient firmware downloading and debugging, and reliable data transmission from the board to the host computer for real-time display and storage.&lt;br /&gt;
&lt;br /&gt;
==== Hardware-level Working Principle of the ADC Board ====&lt;br /&gt;
&lt;br /&gt;
In operation, the conditioned analog signal from the AFE enters the ADS1256 through the input header, is digitized with high resolution under the control of the local precision reference and clock, and is then read by the STM32 through the SPI interface. The MCU subsequently forwards the sampled data to the host computer through the serial communication link, so that the entire board functions as a compact digital acquisition backend connecting weak physiological analog signals to later software processing, display, and storage.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_7.jpg|thumb|center|800px|Figure 2.7. Photograph of the fabricated ADS1256-based ADC board developed in this project and the definitions of some key pins.]]&lt;br /&gt;
&lt;br /&gt;
Figure 2.7 shows the ADC board fabricated for this project. It integrates the ADS1256 conversion core, STM32 control circuit, power-conditioning circuits, and communication interfaces on a compact PCB for physiological signal digitization.&lt;br /&gt;
&lt;br /&gt;
== Signal Conditioning and Filtering ==&lt;br /&gt;
Although the AFE already performs preliminary band-pass filtering and 50 Hz interference suppression in the analog domain, the digitized sEMG signal may still contain residual noise due to component tolerances, electrode-contact variation, and environmental interference. Therefore, an additional digital filtering stage is implemented in software as a complementary post-processing step to improve signal quality and to provide a more stable input for rectification, envelope extraction, and subsequent analysis. In this sense, the software filtering is not a simple repetition of the analog filtering, but a refinement and compensation for non-ideal front-end behavior.&lt;br /&gt;
&lt;br /&gt;
Surface electromyographic (sEMG) signals are highly susceptible to several sources of contamination during acquisition. In practical measurements, the dominant disturbances usually include low-frequency motion artifacts caused by electrode movement and electrode–skin impedance variation, narrow-band power-line interference centered at 50 Hz, and broadband high-frequency electronic noise introduced by the acquisition hardware. These unwanted components degrade the quality of the recorded signal and may significantly affect the reliability of subsequent feature extraction, parameter estimation, and muscle activity interpretation. For this reason, an effective signal-conditioning procedure is necessary before any higher-level analysis is performed.&lt;br /&gt;
&lt;br /&gt;
In the present implementation, the filtering strategy follows the principle of restricting the signal bandwidth first and then removing the remaining narrow-band interference in a targeted manner. Accordingly, the raw sEMG signal is first processed by a fourth-order Butterworth IIR band-pass filter and then by a 50 Hz notch filter. This processing sequence is illustrated in the flowchart below, where the signal passes through band-pass filtering, notch filtering, full-wave rectification, and envelope extraction before producing the final processed output.&lt;br /&gt;
&lt;br /&gt;
[[File:flowchart.png|thumb|center|500px|Flowchart of the real-time sEMG signal conditioning pipeline.]]&lt;br /&gt;
&lt;br /&gt;
The rationale of this order is that the &#039;&#039;&#039;band-pass stage&#039;&#039;&#039; first confines the signal to the main spectral region of interest for sEMG, thereby attenuating motion artifacts at very low frequencies and suppressing high-frequency noise components outside the physiological band. After this spectral preconditioning, the notch stage can more effectively suppress the residual 50 Hz power-line interference that lies inside the useful sEMG band. In transfer-function form, the band-pass filter may be written as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;H_{BP}(z)=\frac{B_{BP}(z)}{A_{BP}(z)}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where the effective passband is selected as &amp;lt;math&amp;gt;20 \leq f \leq 160 \text{ Hz}&amp;lt;/math&amp;gt;. This frequency interval is consistent with the dominant spectral content of surface EMG: the lower cutoff near 20 Hz reduces motion artifacts and unstable low-frequency fluctuations, whereas the upper cutoff near 160 Hz removes high-frequency electronic noise while preserving the main energy-bearing components of the muscle signal. The use of a Butterworth structure is appropriate here because it provides a smooth monotonic passband response without ripple, which helps preserve signal morphology in real-time applications.&lt;br /&gt;
&lt;br /&gt;
After band limitation, a &#039;&#039;&#039;notch filter&#039;&#039;&#039; centered at the power-line frequency is applied to suppress interference that cannot be removed by the band-pass stage alone. The notch filter is designed around &amp;lt;math&amp;gt;f_0 = 50 \text{ Hz}&amp;lt;/math&amp;gt;, and its bandwidth is controlled by the quality factor &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;, which is expressed as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;Q = \frac{f_0}{\Delta f}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In transfer-function form, the notch stage is written as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;H_{N}(z)=\frac{B_{N}(z)}{A_{N}(z)}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the implemented program, a large quality factor is chosen so that the notch remains narrow, allowing effective rejection of the 50 Hz interference while minimizing distortion of neighboring useful spectral components. This is particularly important for sEMG because the interference frequency lies directly inside the physiological band of interest.&lt;br /&gt;
&lt;br /&gt;
Following the filtering stages, further signal conditioning is performed to obtain a representation that is more directly related to muscle activation intensity. The filtered sEMG waveform is first &#039;&#039;&#039;full-wave rectified&#039;&#039;&#039;, which converts the bipolar oscillatory signal into a unipolar signal by taking its absolute value.  Rectification does not remove noise by itself; instead, it transforms the signal into a form that is more suitable for amplitude-based analysis because both positive and negative deflections contribute positively to the activation measure.&lt;br /&gt;
&lt;br /&gt;
After rectification, the signal envelope is extracted to provide a smooth estimate of muscle activation level over time. In a general formulation, the envelope can be described as the &#039;&#039;&#039;low-pass filtered&#039;&#039;&#039; version of the rectified signal, namely &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y_{\mathrm{env}}[n] = \mathrm{LPF}\bigl(y_{\mathrm{rect}}[n]\bigr)&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the present code implementation, this operation is realized by short-time averaging over a finite window, which is equivalent to a moving-average low-pass smoothing of the rectified waveform. The corresponding expression is &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y_{\mathrm{env}}[n] = \frac{1}{N}\sum_{k=0}^{N-1} |x[n-k]|&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; is the window length in samples. With a window duration of approximately 200 ms, this envelope extraction method provides a stable and physiologically meaningful representation of muscle activation intensity, making it suitable for tasks such as force estimation, fatigue analysis, and motor-control studies.&lt;br /&gt;
&lt;br /&gt;
An important feature of the present &#039;&#039;&#039;implementation&#039;&#039;&#039; is that the entire filtering process is performed &#039;&#039;&#039;in real time&#039;&#039;&#039;, sample by sample, rather than by offline block processing. For this reason, IIR filters are preferred over FIR filters, since they can achieve comparable filtering performance with lower order, lower computational cost, and shorter delay. These properties are especially valuable in embedded systems, serial data streaming, and other low-latency experimental applications. However, unlike memoryless operations, an IIR filter depends not only on the current input but also on previous inputs and previous outputs. Its discrete-time behavior can therefore be represented by the recursive difference equation &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y[n] = \sum_{k=0}^{M} b_k x[n-k] - \sum_{k=1}^{N} a_k y[n-k]&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This equation makes clear that internal filter states must be preserved continuously during streaming operation. If the state variables were reinitialized for every incoming sample or data segment, artificial transients would appear and the output would no longer remain continuous.&lt;br /&gt;
&lt;br /&gt;
In the Python implementation, this state continuity is maintained using the internal initial-condition mechanism provided by SciPy, such as &amp;lt;code&amp;gt;lfilter_zi&amp;lt;/code&amp;gt;, together with recursive state updates during each filtering call. As a result, each newly acquired sample is passed first through the band-pass filter and then through the notch filter, while the internal states of both filters are updated after every step. This state-preserving sample-by-sample design ensures that the processing chain remains causal, continuous, and suitable for real-time display or downstream analysis without requiring storage of the entire signal segment.&lt;br /&gt;
&lt;br /&gt;
Overall, this signal-conditioning scheme provides an experimentally practical solution for real-time sEMG processing. The fourth-order Butterworth band-pass filter confines the signal to the main physiological band of interest, the 50 Hz notch filter removes narrow-band power-line contamination, and the subsequent rectification and envelope extraction generate a smooth amplitude descriptor of muscle activity. Combined with state-preserved streaming IIR implementation, this approach achieves a good balance between signal fidelity, computational efficiency, and real-time applicability in biomedical and physical experiment settings.&lt;br /&gt;
&lt;br /&gt;
== Experimental Setup ==&lt;br /&gt;
&lt;br /&gt;
=== Experimental Demonstration ===&lt;br /&gt;
&lt;br /&gt;
The experimental setup and data acquisition process are demonstrated in the video below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;text-align:center;&amp;quot;&amp;gt;&lt;br /&gt;
[[File:EMG_Experiment.mp4|center|800px]]&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The video illustrates the complete measurement procedure, including electrode placement, muscle activation, and real-time EMG signal visualization.&lt;br /&gt;
&lt;br /&gt;
=== Experimental Procedure ===&lt;br /&gt;
&lt;br /&gt;
Surface EMG signals were acquired using disposable electrodes placed on the forearm muscles responsible for wrist extension. &lt;br /&gt;
&lt;br /&gt;
Three electrodes were used in the measurement setup:&lt;br /&gt;
&lt;br /&gt;
* One electrode placed on the back of the hand serves as the reference electrode  &lt;br /&gt;
* The other two electrodes placed along the forearm muscle act as the differential input electrodes (positive and negative)  &lt;br /&gt;
&lt;br /&gt;
This configuration enables differential measurement of EMG signals while suppressing common-mode noise.&lt;br /&gt;
&lt;br /&gt;
The experimental movement consists of making a fist while extending the wrist backward. This action activates the forearm extensor muscles beneath the electrodes, producing measurable EMG signals.&lt;br /&gt;
&lt;br /&gt;
=== Data Acquisition Protocol ===&lt;br /&gt;
&lt;br /&gt;
Each subject performed repeated contraction–relaxation cycles under controlled conditions:&lt;br /&gt;
&lt;br /&gt;
* Number of subjects: 3  &lt;br /&gt;
* Number of trials per subject: 3  &lt;br /&gt;
* Duration of each trial: 30 seconds  &lt;br /&gt;
&lt;br /&gt;
During each trial, subjects were instructed to periodically contract and relax the muscle to generate clear dynamic EMG signals, while maintaining a stable resting state between contractions.&lt;br /&gt;
&lt;br /&gt;
=== System and Measurement Conditions ===&lt;br /&gt;
&lt;br /&gt;
The EMG signals were recorded and visualized in real time using a data acquisition system connected to a computer. The sampling rate was set to 400 Hz.&lt;br /&gt;
&lt;br /&gt;
To ensure consistency across measurements:&lt;br /&gt;
&lt;br /&gt;
* Electrode placement was kept consistent for all subjects  &lt;br /&gt;
* The same movement protocol was followed  &lt;br /&gt;
* Measurements were conducted under similar environmental conditions  &lt;br /&gt;
&lt;br /&gt;
=== Summary ===&lt;br /&gt;
&lt;br /&gt;
This experimental setup enables reliable acquisition of both resting and dynamic EMG signals, providing a consistent dataset for subsequent signal processing and performance evaluation.&lt;br /&gt;
&lt;br /&gt;
== Data Processing ==&lt;br /&gt;
&lt;br /&gt;
The objective of data processing is to convert raw surface electromyography (sEMG) recordings into stable, quantitative, and comparable indicators of muscle activity. Since EMG signals are low in amplitude, highly variable over time, and easily contaminated by noise, a dedicated processing pipeline is necessary before any experimental interpretation can be performed.&lt;br /&gt;
&lt;br /&gt;
In this project, the data processing workflow includes time normalization, signal pre-processing, sliding-window feature extraction, noise-floor estimation, and automatic contraction detection. The processed outputs are then used for subsequent experimental evaluation, including rest-versus-contraction discrimination, signal-to-noise ratio analysis, and repeatability assessment.&lt;br /&gt;
&lt;br /&gt;
=== Input Data and Time Normalization ===&lt;br /&gt;
&lt;br /&gt;
The acquired EMG data are read from CSV files containing two columns: time and filtered sEMG amplitude. In the MATLAB implementation, the time vector is normalized so that each recording starts from zero:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t = t_{all} - t_{all}(1)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This normalization is important because it removes the influence of absolute recording timestamps and makes different trials directly comparable on the same time axis.&lt;br /&gt;
&lt;br /&gt;
In addition, the signal type is automatically identified from the filename as either dynamic or rest. This design allows the same program to process both contraction recordings and resting recordings with different downstream analysis logic.&lt;br /&gt;
&lt;br /&gt;
=== Signal Pre-processing ===&lt;br /&gt;
&lt;br /&gt;
Raw EMG signals cannot be analyzed directly because they usually contain DC offset, low-frequency drift, motion artifacts, and residual high-frequency interference. Therefore, several pre-processing steps are applied before feature extraction.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(1) Baseline Removal&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The first step is DC offset removal:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
x_{dc}(t) = x(t) - \frac{1}{N}\sum_{i=1}^{N}x(i)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This operation centers the signal around zero. It is necessary because an uncorrected baseline would bias amplitude-based metrics and reduce the reliability of later envelope and feature calculations.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(2) Band-pass Filtering &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
After baseline correction, a fourth-order Butterworth band-pass filter is applied with a passband of 20–150 Hz.&lt;br /&gt;
&lt;br /&gt;
This step is introduced for two reasons:&lt;br /&gt;
&lt;br /&gt;
* The low-frequency cutoff at 20 Hz suppresses baseline drift and motion artifacts.&lt;br /&gt;
* The high-frequency cutoff at 150 Hz reduces unwanted high-frequency noise while preserving the main energy band of the recorded sEMG in this project.&lt;br /&gt;
&lt;br /&gt;
Compared with processing the raw waveform directly, band-pass filtering makes the subsequent time-domain features more stable and more physiologically meaningful.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(3) Full-wave Rectification&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The filtered EMG signal is bipolar, meaning that positive and negative phases coexist due to motor unit action potentials. If these positive and negative components are averaged directly, they may cancel each other out. To avoid this, full-wave rectification is performed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
x_{rect}(t) = |x_{filt}(t)|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This transforms the signal into a unipolar representation, so that all muscle activity contributes positively to the extracted features.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(4) Envelope Extraction &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Although the rectified signal reflects signal magnitude, it still fluctuates rapidly. To obtain a smoother representation of muscle activation level, an envelope is extracted using a moving average with a 100 ms window.&lt;br /&gt;
&lt;br /&gt;
Envelope extraction is important because contraction detection should reflect the overall activation trend rather than instantaneous spikes. A smoothed envelope is therefore more robust for identifying active and inactive muscle states.&lt;br /&gt;
&lt;br /&gt;
=== Sliding Window Design ===&lt;br /&gt;
&lt;br /&gt;
To quantify how muscle activity changes with time, the filtered signal is divided into overlapping short-time segments using a sliding window method.&lt;br /&gt;
&lt;br /&gt;
The window parameters are:&lt;br /&gt;
&lt;br /&gt;
* Window length: 250 ms&lt;br /&gt;
* Step size: 50 ms&lt;br /&gt;
&lt;br /&gt;
These values are chosen as a trade-off between temporal resolution and feature stability.&lt;br /&gt;
&lt;br /&gt;
A longer window improves statistical robustness because more samples are included in each calculation. However, if the window is too long, short contractions or rapid changes may be blurred. A smaller step size increases temporal continuity between adjacent feature points and makes the feature curves smoother in time. Therefore, the 250 ms / 50 ms design provides a practical balance between smoothing and time localization.&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt;-th segment, the feature time is defined as the mean time of that segment:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t_k = \frac{1}{N}\sum_{i=s_k}^{e_k} t(i)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;s_k&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;e_k&amp;lt;/math&amp;gt; denote the start and end indices of the window.&lt;br /&gt;
&lt;br /&gt;
=== Feature Extraction ===&lt;br /&gt;
&lt;br /&gt;
Within each sliding window, three time-domain features are extracted: RMS, iEMG, and MAV. These features are widely used in EMG analysis because they are simple, computationally efficient, and directly related to muscle activation intensity.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(1) Root Mean Square (RMS)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
RMS = \sqrt{\frac{1}{N}\sum_{i=1}^{N}x_i^2}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
RMS reflects the effective power of the EMG signal and is one of the most common indicators of contraction strength. It is sensitive to both amplitude and energy, making it especially useful for comparing rest and active states.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(2) Integrated EMG (iEMG)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
iEMG = \sum_{i=1}^{N}|x_i|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
iEMG describes the cumulative electrical activity within a window. It is often interpreted as a measure of total muscle effort over that time segment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(3) Mean Absolute Value (MAV)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
MAV = \frac{1}{N}\sum_{i=1}^{N}|x_i|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
MAV is an amplitude descriptor similar to iEMG, but normalized by the number of samples. It provides an efficient estimate of average signal level and is less computationally intensive than some other features.&lt;br /&gt;
&lt;br /&gt;
These three features are used together because they provide complementary descriptions of EMG intensity. RMS emphasizes signal energy, iEMG emphasizes cumulative activation, and MAV reflects average amplitude.&lt;br /&gt;
&lt;br /&gt;
=== Peak-value Extraction ===&lt;br /&gt;
&lt;br /&gt;
In addition to continuous feature curves, several key peak values are extracted from the processed signal:&lt;br /&gt;
&lt;br /&gt;
* maximum and minimum of the filtered EMG waveform&lt;br /&gt;
* peak of the envelope&lt;br /&gt;
* peak RMS&lt;br /&gt;
* peak iEMG&lt;br /&gt;
* peak MAV&lt;br /&gt;
&lt;br /&gt;
These peak values provide concise descriptors of the strongest activity observed in each recording. They are useful for quick comparison across trials and subjects.&lt;br /&gt;
&lt;br /&gt;
=== Noise Floor Estimation ===&lt;br /&gt;
&lt;br /&gt;
To evaluate signal quality, the noise floor is estimated from a reference resting interval. In the present implementation, the first 3 seconds of the recording are used as the default rest reference:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t \in [0,\min(3,t_{end})]&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this segment, three noise descriptors are computed:&lt;br /&gt;
&lt;br /&gt;
* Noise RMS&lt;br /&gt;
* Noise standard deviation&lt;br /&gt;
* Noise peak-to-peak amplitude&lt;br /&gt;
&lt;br /&gt;
Noise-floor estimation is important because EMG amplitude alone is not sufficient to judge recording quality. A large signal is only meaningful if it is sufficiently higher than the baseline noise level. Therefore, the noise floor serves as the reference for later SNR calculation and for designing contraction thresholds.&lt;br /&gt;
&lt;br /&gt;
=== Global Signal Metrics ===&lt;br /&gt;
&lt;br /&gt;
For each recording, three global metrics are also computed over the entire filtered signal:&lt;br /&gt;
&lt;br /&gt;
* Global RMS&lt;br /&gt;
* Global MAV&lt;br /&gt;
* Global iEMG&lt;br /&gt;
&lt;br /&gt;
These global descriptors summarize the overall signal level of the full recording and are later used in group-level comparisons.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Contraction Detection ===&lt;br /&gt;
&lt;br /&gt;
For dynamic recordings, an automatic contraction detection algorithm is used to identify repeated active segments. This is one of the key parts of the data processing pipeline, because it transforms a continuous EMG trace into discrete contraction events that can be counted and compared.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(1) Threshold Design&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The detection threshold is designed adaptively rather than using a fixed value. Two candidate thresholds are first calculated:&lt;br /&gt;
&lt;br /&gt;
* an envelope-based threshold derived from the global envelope mean and standard deviation&lt;br /&gt;
* a rest-reference threshold derived from the mean and standard deviation of the resting reference amplitude&lt;br /&gt;
&lt;br /&gt;
The final threshold is taken as the larger of the two after additional scaling. This strategy improves robustness because it combines the global activation level of the signal with the baseline noise characteristics of the individual recording.&lt;br /&gt;
&lt;br /&gt;
This adaptive threshold design is preferable to a manually fixed threshold because EMG amplitude can vary strongly between subjects, muscles, and recording sessions.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(2) Initial Segmentation&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
After thresholding the envelope, the signal is classified into active and inactive regions:&lt;br /&gt;
&lt;br /&gt;
* active: envelope above threshold&lt;br /&gt;
* inactive: envelope below threshold&lt;br /&gt;
&lt;br /&gt;
The rising and falling edges of the binary activity vector are then used to determine the start and end points of each candidate contraction segment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(3) Removal of Short Segments&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Very short active regions are often caused by noise fluctuations rather than true muscle contractions. Therefore, segments shorter than 0.20 s are discarded.&lt;br /&gt;
&lt;br /&gt;
This step prevents false positive detections and increases the physiological relevance of the segmentation results.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(4) Merging of Adjacent Segments &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If two neighboring active segments are separated by a very short gap, they are merged when the gap is less than 0.15 s.&lt;br /&gt;
&lt;br /&gt;
This operation is necessary because a single real contraction may be temporarily interrupted by a brief drop in the envelope caused by local fluctuation. Without merging, one contraction could be incorrectly counted as multiple repetitions.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(5) Repetition-level Metrics &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
For each detected contraction segment, two repetition-level metrics are extracted:&lt;br /&gt;
&lt;br /&gt;
* peak RMS of that contraction&lt;br /&gt;
* mean RMS of that contraction&lt;br /&gt;
&lt;br /&gt;
These metrics quantify both the strongest activation within each repetition and the average activation level over the repetition duration.&lt;br /&gt;
&lt;br /&gt;
=== Repeatability Analysis ===&lt;br /&gt;
&lt;br /&gt;
When multiple valid contractions are detected, repeatability is evaluated using the coefficient of variation (CV):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
CV = \frac{\sigma}{\mu}\times 100\%&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt; is the standard deviation and &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is the mean value across repetitions.&lt;br /&gt;
&lt;br /&gt;
Two CV values are computed:&lt;br /&gt;
&lt;br /&gt;
* CV of repetition peak RMS&lt;br /&gt;
* CV of repetition mean RMS&lt;br /&gt;
&lt;br /&gt;
A lower CV indicates better repeatability, meaning that repeated contractions produce more consistent EMG responses.&lt;br /&gt;
&lt;br /&gt;
=== Signal-to-Noise Ratio (SNR) ===&lt;br /&gt;
&lt;br /&gt;
In this project, the signal-to-noise ratio (SNR) is defined based on the ratio between contraction and rest activity:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
SNR_{dB} = 20\log_{10}\left(\frac{RMS_{contraction}}{RMS_{rest}}\right)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This definition is adopted because it directly reflects the system’s ability to distinguish active muscle contraction from baseline noise.&lt;br /&gt;
&lt;br /&gt;
Compared with global SNR definitions, this formulation is more relevant for practical EMG applications such as activity detection and classification.&lt;br /&gt;
&lt;br /&gt;
=== Rest-versus-Contraction Window Comparison ===&lt;br /&gt;
&lt;br /&gt;
To further distinguish inactive and active states, all sliding windows are divided into two groups:&lt;br /&gt;
&lt;br /&gt;
* rest windows: windows with envelope clearly below the threshold&lt;br /&gt;
* contraction windows: windows with envelope above the threshold&lt;br /&gt;
&lt;br /&gt;
The RMS values of these two groups are then compared statistically.&lt;br /&gt;
&lt;br /&gt;
This comparison is important because a practical EMG system should not only detect signal presence, but also clearly separate rest from contraction in a quantitative way. If the two RMS distributions are well separated, it indicates that the system has good discriminative capability.&lt;br /&gt;
&lt;br /&gt;
=== Output Data Structure ===&lt;br /&gt;
&lt;br /&gt;
The processed outputs are organized into structured data for experimental analysis:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(1) Time-series outputs&#039;&#039;&#039;&lt;br /&gt;
* Filtered EMG signal  &lt;br /&gt;
* Rectified signal  &lt;br /&gt;
* Envelope  &lt;br /&gt;
* RMS(t), iEMG(t), MAV(t)  &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(2) Recording-level outputs&#039;&#039;&#039; &lt;br /&gt;
* RMS (rest)  &lt;br /&gt;
* RMS (contraction)  &lt;br /&gt;
* iEMG  &lt;br /&gt;
* Noise metrics  &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(3) Dynamic-signal outputs &#039;&#039;&#039;&lt;br /&gt;
* Detected contractions  &lt;br /&gt;
* Repetition count  &lt;br /&gt;
* Peak RMS per repetition  &lt;br /&gt;
* Mean RMS per repetition  &lt;br /&gt;
* Coefficient of variation (CV)  &lt;br /&gt;
* Signal-to-noise ratio (SNR)  &lt;br /&gt;
&lt;br /&gt;
All extracted features are designed to directly support the evaluation of noise level, signal quality, activity discrimination, and repeatability in the subsequent experimental analysis.&lt;br /&gt;
&lt;br /&gt;
== Experimental Results ==&lt;br /&gt;
&lt;br /&gt;
This section presents representative results of the EMG acquisition and data processing pipeline under both dynamic (muscle contraction) and resting conditions.&lt;br /&gt;
&lt;br /&gt;
=== Representative Dynamic Signal Analysis ===&lt;br /&gt;
&lt;br /&gt;
[[File:Dynamic_Figure1.png|thumb|800px|center|Figure 5.1: Processed EMG signal under dynamic contraction, including filtered signal, rectified signal with envelope, and extracted features (RMS, iEMG, MAV).]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.1 shows the processed EMG signal during repeated muscle contractions.&lt;br /&gt;
&lt;br /&gt;
The filtered EMG waveform exhibits clear burst-like patterns corresponding to periodic contractions. The signal amplitude reaches a maximum of approximately 0.45, while the baseline remains centered around zero, indicating effective baseline removal and filtering.&lt;br /&gt;
&lt;br /&gt;
After rectification and envelope extraction, the contraction periods become clearly distinguishable. The envelope provides a smooth representation of muscle activation, with a peak value of approximately 0.145.&lt;br /&gt;
&lt;br /&gt;
The extracted time-domain features (RMS, iEMG, MAV) further quantify the signal. Among these, iEMG shows the strongest dynamic variation, indicating high sensitivity to contraction intensity.&lt;br /&gt;
&lt;br /&gt;
=== Noise Floor and Rest Reference ===&lt;br /&gt;
&lt;br /&gt;
[[File:Dynamic_Figure2.png|thumb|800px|center|Figure 5.2: Noise estimation, rest vs contraction comparison, automatic contraction detection, and repetition analysis.]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (top-left) shows the resting reference segment used for noise estimation.&lt;br /&gt;
&lt;br /&gt;
The signal remains centered around zero with small fluctuations. The noise characteristics are:&lt;br /&gt;
&lt;br /&gt;
* Noise RMS ≈ 0.0046  &lt;br /&gt;
* Standard deviation ≈ 0.0046  &lt;br /&gt;
* Peak-to-peak amplitude ≈ 0.071  &lt;br /&gt;
&lt;br /&gt;
This indicates a low noise floor and stable measurement conditions.&lt;br /&gt;
&lt;br /&gt;
=== Rest vs Contraction Discrimination ===&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (top-right) compares RMS values between rest and contraction states.&lt;br /&gt;
&lt;br /&gt;
The two distributions are clearly separated:&lt;br /&gt;
&lt;br /&gt;
* Rest mean RMS ≈ 0.0053  &lt;br /&gt;
* Contraction mean RMS ≈ 0.1064  &lt;br /&gt;
&lt;br /&gt;
This corresponds to an approximate 20× increase, demonstrating strong discriminability between inactive and active muscle states.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Contraction Detection ===&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (bottom-left) illustrates automatic detection based on the envelope signal.&lt;br /&gt;
&lt;br /&gt;
A threshold of approximately 0.040 is applied, resulting in stable segmentation of contraction periods.&lt;br /&gt;
&lt;br /&gt;
A total of 12 repetitions are detected, with good alignment to visible signal peaks.&lt;br /&gt;
&lt;br /&gt;
=== Repeatability Analysis ===&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (bottom-right) shows the peak RMS value of each detected contraction.&lt;br /&gt;
&lt;br /&gt;
The results indicate:&lt;br /&gt;
&lt;br /&gt;
* Mean peak RMS ≈ 0.1355  &lt;br /&gt;
* Standard deviation ≈ 0.0173  &lt;br /&gt;
* CV ≈ 12.77%  &lt;br /&gt;
* SNR ≈ 21.26 dB  &lt;br /&gt;
&lt;br /&gt;
This indicates acceptable repeatability and good signal quality.&lt;br /&gt;
&lt;br /&gt;
=== Representative Rest Signal Analysis ===&lt;br /&gt;
&lt;br /&gt;
[[File:Rest_Figure1.png|thumb|800px|center|Figure 5.3: Processed EMG signal under rest condition, showing low amplitude and absence of contraction patterns.]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.3 shows the EMG signal under resting conditions.&lt;br /&gt;
&lt;br /&gt;
The signal remains within a narrow amplitude range (approximately ±0.04) and shows no burst-like structures. The envelope remains close to zero, confirming the absence of muscle activity.&lt;br /&gt;
&lt;br /&gt;
The extracted features remain low:&lt;br /&gt;
&lt;br /&gt;
* RMS ≈ 0.007  &lt;br /&gt;
* MAV ≈ 0.005  &lt;br /&gt;
* iEMG remains stable  &lt;br /&gt;
&lt;br /&gt;
This confirms that no false activation is detected.&lt;br /&gt;
&lt;br /&gt;
=== Frequency-domain Characteristics ===&lt;br /&gt;
&lt;br /&gt;
[[File:Rest_Figure2.png|thumb|800px|center|Figure 5.4: Frequency-domain analysis and statistical characteristics of rest signal.]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.4 shows the frequency-domain characteristics of the resting signal.&lt;br /&gt;
&lt;br /&gt;
The power spectral density (PSD) indicates low overall signal energy without dominant peaks, confirming that the signal mainly consists of noise.&lt;br /&gt;
&lt;br /&gt;
=== Summary of Single-recording Performance ===&lt;br /&gt;
&lt;br /&gt;
From the representative results:&lt;br /&gt;
&lt;br /&gt;
* EMG signals are effectively extracted and denoised  &lt;br /&gt;
* Contraction events are clearly identifiable  &lt;br /&gt;
* Rest and contraction states are well separated  &lt;br /&gt;
* Automatic detection is stable and accurate  &lt;br /&gt;
* Repeatability is acceptable  &lt;br /&gt;
* No false activation occurs under rest conditions  &lt;br /&gt;
&lt;br /&gt;
=== Consistency Across Multiple Recordings ===&lt;br /&gt;
&lt;br /&gt;
The same data processing pipeline was applied to multiple recordings from different subjects and trials.&lt;br /&gt;
&lt;br /&gt;
Across all datasets, consistent patterns were observed:&lt;br /&gt;
&lt;br /&gt;
* Dynamic signals exhibit clear burst-like structures corresponding to repeated muscle contractions  &lt;br /&gt;
* Rest signals remain low in amplitude without distinct activation patterns  &lt;br /&gt;
* RMS values under contraction are consistently higher than those under rest  &lt;br /&gt;
* The automatic detection algorithm reliably identifies contraction segments  &lt;br /&gt;
&lt;br /&gt;
Although quantitative values (e.g., RMS, SNR, CV) vary across recordings due to differences in electrode contact, muscle activation strength, and individual conditions, the overall trends remain consistent.&lt;br /&gt;
&lt;br /&gt;
These results demonstrate the robustness and general applicability of the proposed signal processing method.&lt;br /&gt;
&lt;br /&gt;
== Multi-subject Analysis ==&lt;br /&gt;
=== System Evaluation ===&lt;br /&gt;
&lt;br /&gt;
This section evaluates the performance of the EMG acquisition system in terms of noise level, signal quality, activity discrimination, and repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Noise Floor Analysis ====&lt;br /&gt;
&lt;br /&gt;
The noise floor was evaluated using rest-state recordings, characterized by RMS noise, standard deviation, and peak-to-peak amplitude.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039; shows the lowest noise level (RMS ≈ 0.0046), indicating stable electrode contact and minimal interference.  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039; exhibits moderate noise (RMS ≈ 0.0080), likely influenced by motion artifacts or electrode–skin impedance variation.  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039; shows relatively higher noise (RMS ≈ 0.0126), suggesting increased baseline fluctuation.  &lt;br /&gt;
&lt;br /&gt;
Overall, the system maintains a low noise floor across subjects, although the quality depends on experimental conditions such as electrode contact and environmental interference.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Signal-to-Noise Ratio (SNR) ====&lt;br /&gt;
&lt;br /&gt;
The signal-to-noise ratio (SNR) is defined as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{SNR (dB)} = 20 \log_{10} \left( \frac{\mathrm{RMS}_{\mathrm{contraction}}}{\mathrm{RMS}_{\mathrm{rest}}} \right)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The measured SNR values are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: 21.26 dB → good signal quality  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: 13.52 dB → moderate and usable  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: 6.66 dB → low signal clarity  &lt;br /&gt;
&lt;br /&gt;
General interpretation:&lt;br /&gt;
&lt;br /&gt;
* &amp;gt;20 dB → good  &lt;br /&gt;
* 10–20 dB → usable  &lt;br /&gt;
* &amp;lt;10 dB → poor  &lt;br /&gt;
&lt;br /&gt;
These results show that the system can achieve reliable signal acquisition, although performance varies across subjects.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
====  Rest vs Contraction Discrimination ====&lt;br /&gt;
&lt;br /&gt;
A clear distinction between rest and contraction states is observed based on RMS values.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: 0.0053 → 0.1064 (≈20× increase)  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: 0.0079 → 0.0283 (≈3.6× increase)  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: 0.0141 → 0.0646 (≈4.6× increase)  &lt;br /&gt;
&lt;br /&gt;
This demonstrates that the system is capable of separating muscle activity from baseline noise.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Conclusion:&#039;&#039;  &lt;br /&gt;
The system can be used for basic muscle activity detection and simple classification tasks based on RMS features.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Repeatability of Repeated Contractions ====&lt;br /&gt;
&lt;br /&gt;
Repeatability is evaluated using the coefficient of variation (CV) of peak RMS values across repetitions.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! CV Range !! Evaluation&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt; 10% || Excellent&lt;br /&gt;
|-&lt;br /&gt;
| 10–20% || Acceptable&lt;br /&gt;
|-&lt;br /&gt;
| &amp;gt; 20% || Poor&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Results:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: CV = 12.77% → Acceptable  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: CV = 24.77% → Poor  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: CV = 10.60% → Acceptable  &lt;br /&gt;
&lt;br /&gt;
Although WANG&#039;s signal is detectable, its contraction amplitude varies significantly across repetitions, resulting in poor repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
=== Overall System Performance ===&lt;br /&gt;
&lt;br /&gt;
The system demonstrates the following performance characteristics:&lt;br /&gt;
&lt;br /&gt;
* Reliable detection of muscle activity across all subjects  &lt;br /&gt;
* Clear separation between rest and contraction states  &lt;br /&gt;
* Moderate to high signal quality depending on subject conditions  &lt;br /&gt;
* Repeatability ranging from acceptable to poor due to user-dependent factors  &lt;br /&gt;
&lt;br /&gt;
Overall, the designed EMG acquisition system is capable of stable signal acquisition and feature extraction, with performance primarily influenced by electrode contact quality, skin impedance, and motion consistency.&lt;br /&gt;
&lt;br /&gt;
===== Summary of Quantitative Metrics =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Subject !! RMS (Rest) !! RMS (Contraction) !! Separation Ratio !! iEMG (max) !! Noise RMS !! SNR (dB) !! CV (%) !! Evaluation&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;LIU&#039;&#039;&#039; || 0.0053 || 0.1064 || &#039;&#039;&#039;20.1×&#039;&#039;&#039; || 12.72 || 0.0046 || &#039;&#039;&#039;21.26&#039;&#039;&#039; || 12.77 || Strong signal, good quality&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;WANG&#039;&#039;&#039; || 0.0079 || 0.0283 || 3.57× || 11.10 || 0.0080 || 13.52 || &#039;&#039;&#039;24.77&#039;&#039;&#039; || Usable signal, poor repeatability&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ZHONG&#039;&#039;&#039; || 0.0141 || 0.0646 || 4.58× || 6.70 || 0.0126 || 6.66 || 10.60 || Acceptable performance&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Summary:&#039;&#039; Subject LIU shows the best overall performance, WANG provides usable but less stable signals, and ZHONG demonstrates moderate signal quality with good repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Activation Intensity =====&lt;br /&gt;
&lt;br /&gt;
Among the three subjects, &#039;&#039;&#039;LIU exhibits the strongest muscle activation&#039;&#039;&#039;, as indicated by the highest contraction RMS and iEMG values. ZHONG shows moderate activation, while WANG demonstrates comparable iEMG but lower RMS consistency.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Signal Quality =====&lt;br /&gt;
&lt;br /&gt;
Signal quality is evaluated based on SNR and noise level:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039; achieves the highest SNR and lowest noise → best signal quality  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039; shows moderate SNR → usable but less robust  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039; has the lowest SNR → weakest signal clarity  &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Repeatability =====&lt;br /&gt;
&lt;br /&gt;
Repeatability is evaluated using the coefficient of variation (CV):&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;ZHONG (10.60%)&#039;&#039;&#039; → most stable  &lt;br /&gt;
* &#039;&#039;&#039;LIU (12.77%)&#039;&#039;&#039; → acceptable  &lt;br /&gt;
* &#039;&#039;&#039;WANG (24.77%)&#039;&#039;&#039; → poor  &lt;br /&gt;
&lt;br /&gt;
This indicates that WANG’s contraction strength varies significantly between repetitions.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Engineering Interpretation of Inter-subject Differences =====&lt;br /&gt;
&lt;br /&gt;
The observed differences are mainly attributed to engineering and experimental factors rather than physiological differences.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Electrode contact quality&#039;&#039;&#039;  &lt;br /&gt;
  Variations in electrode placement, pressure, and gel contact affect signal amplitude and stability.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Skin impedance&#039;&#039;&#039;  &lt;br /&gt;
  Differences in skin condition (hydration, oil, hair) influence electrode–skin impedance, affecting noise level and signal coupling.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Muscle control consistency&#039;&#039;&#039;  &lt;br /&gt;
  Variations in contraction strength and timing affect repeatability and CV.&lt;br /&gt;
&lt;br /&gt;
Therefore, the variation across subjects reflects practical acquisition conditions rather than intrinsic system limitations.&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&lt;br /&gt;
This project presents a complete surface EMG (sEMG) acquisition and analysis system, integrating hardware design, signal conditioning, data processing, and experimental validation.&lt;br /&gt;
&lt;br /&gt;
From the hardware perspective, a dedicated analog front-end and data acquisition system were developed to capture low-amplitude bioelectrical signals with sufficient resolution and stability. The experimental setup, including electrode placement and measurement protocol, enables consistent and repeatable signal acquisition across different subjects.&lt;br /&gt;
&lt;br /&gt;
From the signal processing perspective, a structured pipeline was implemented, including filtering, rectification, envelope extraction, sliding-window segmentation, and feature extraction. Key features such as RMS, iEMG, and MAV were used to quantitatively characterize muscle activity.&lt;br /&gt;
&lt;br /&gt;
Experimental results demonstrate that:&lt;br /&gt;
&lt;br /&gt;
* EMG signals can be effectively extracted and denoised  &lt;br /&gt;
* Muscle contraction produces clear and repeatable signal patterns  &lt;br /&gt;
* Rest and contraction states can be reliably distinguished  &lt;br /&gt;
* Automatic detection accurately identifies contraction segments  &lt;br /&gt;
* The system achieves acceptable repeatability and signal quality  &lt;br /&gt;
&lt;br /&gt;
Overall, the proposed system provides a reliable framework for basic EMG signal acquisition and analysis. It is capable of capturing meaningful muscle activity and generating quantitative features that support further evaluation and interpretation.&lt;br /&gt;
&lt;br /&gt;
These results establish a solid foundation for subsequent multi-subject analysis and demonstrate the practical feasibility of the system for EMG-based monitoring applications.&lt;br /&gt;
&lt;br /&gt;
= Appendix =&lt;br /&gt;
&lt;br /&gt;
== EMG Signal Processing Code ==&lt;br /&gt;
&lt;br /&gt;
The following MATLAB code summarizes the core implementation of the EMG signal processing pipeline.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
% =========================&lt;br /&gt;
% EMG Analysis (Simplified)&lt;br /&gt;
% =========================&lt;br /&gt;
&lt;br /&gt;
clear; clc; close all;&lt;br /&gt;
&lt;br /&gt;
%% 1. Read data&lt;br /&gt;
filename = &#039;your_file.csv&#039;;&lt;br /&gt;
T = readtable(filename, &#039;VariableNamingRule&#039;,&#039;preserve&#039;);&lt;br /&gt;
&lt;br /&gt;
t_all = T.(&amp;quot;Time (s)&amp;quot;);&lt;br /&gt;
x_all = T.(&amp;quot;Filtered sEMG&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
t_all = t_all(:);&lt;br /&gt;
x_all = x_all(:);&lt;br /&gt;
&lt;br /&gt;
fs = 400;&lt;br /&gt;
&lt;br /&gt;
%% 2. Time normalization&lt;br /&gt;
t = t_all - t_all(1);&lt;br /&gt;
x = x_all;&lt;br /&gt;
&lt;br /&gt;
%% 3. Preprocessing&lt;br /&gt;
x = x - mean(x);   % Remove DC&lt;br /&gt;
&lt;br /&gt;
[b_bp, a_bp] = butter(4, [20 150]/(fs/2), &#039;bandpass&#039;);&lt;br /&gt;
x_filt = filtfilt(b_bp, a_bp, x);   % Band-pass filter&lt;br /&gt;
&lt;br /&gt;
x_rect = abs(x_filt);               % Rectification&lt;br /&gt;
env = movmean(x_rect, round(0.10*fs));  % Envelope&lt;br /&gt;
&lt;br /&gt;
%% 4. Sliding window feature extraction&lt;br /&gt;
win = round(0.25*fs);&lt;br /&gt;
step = round(0.05*fs);&lt;br /&gt;
&lt;br /&gt;
idx_start = 1:step:(length(x_filt)-win+1);&lt;br /&gt;
&lt;br /&gt;
for k = 1:length(idx_start)&lt;br /&gt;
    s = idx_start(k);&lt;br /&gt;
    e = s + win - 1;&lt;br /&gt;
    seg = x_filt(s:e);&lt;br /&gt;
&lt;br /&gt;
    RMS(k)  = sqrt(mean(seg.^2));&lt;br /&gt;
    iEMG(k) = sum(abs(seg));&lt;br /&gt;
    MAV(k)  = mean(abs(seg));&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
%% 5. Noise floor estimation&lt;br /&gt;
noise_floor_rms = sqrt(mean(x_filt(1:fs*3).^2));&lt;br /&gt;
&lt;br /&gt;
%% 6. Envelope-based detection&lt;br /&gt;
th = mean(env) + 0.5 * std(env);&lt;br /&gt;
is_active = env &amp;gt; th;&lt;br /&gt;
&lt;br /&gt;
%% 7. Signal-to-noise ratio&lt;br /&gt;
snr_db = 20 * log10(rms(x_filt) / noise_floor_rms);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
&lt;br /&gt;
* Sampling rate: 400 Hz&lt;br /&gt;
* Band-pass filter: 20–150 Hz&lt;br /&gt;
* Sliding window: 250 ms, step 50 ms&lt;br /&gt;
* Envelope window: 100 ms&lt;br /&gt;
&lt;br /&gt;
The full implementation is available upon request.&lt;/div&gt;</summary>
		<author><name>Wang Jingyi</name></author>
	</entry>
	<entry>
		<id>https://pc5271.org/index.php?title=Surface_EMG_Sensor_for_Muscle_Activity_Measurement:_AFE_Design_and_Signal_Processing&amp;diff=1377</id>
		<title>Surface EMG Sensor for Muscle Activity Measurement: AFE Design and Signal Processing</title>
		<link rel="alternate" type="text/html" href="https://pc5271.org/index.php?title=Surface_EMG_Sensor_for_Muscle_Activity_Measurement:_AFE_Design_and_Signal_Processing&amp;diff=1377"/>
		<updated>2026-04-23T08:35:27Z</updated>

		<summary type="html">&lt;p&gt;Wang Jingyi: /* Conclusion */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Background and Theory==&lt;br /&gt;
&lt;br /&gt;
=== Surface EMG Signals ===&lt;br /&gt;
Surface electromyography (sEMG) refers to the bioelectrical signals detected on the skin surface during muscle contraction. These signals originate from the electrical activity of muscle fibers and provide a non-invasive way to monitor muscle activation. Compared with invasive EMG methods, sEMG is easier to apply, safer for repeated measurements, and more suitable for real-time monitoring. Therefore, it has been widely used in areas such as rehabilitation, motion analysis, human–machine interaction, and physiological monitoring.&lt;br /&gt;
&lt;br /&gt;
=== Characteristics of EMG Signals ===&lt;br /&gt;
EMG signals are generally weak, time-varying, and stochastic in nature. Their waveforms are typically bipolar, fluctuating around zero with both positive and negative components. The amplitude and frequency content of EMG signals depend on factors such as muscle contraction level, electrode placement, skin condition, and individual physiological differences. In practice, the useful frequency components of sEMG are mainly concentrated in a limited low-to-mid frequency range. Because of their low amplitude and variability, EMG signals usually require further conditioning before reliable interpretation and feature extraction can be performed.&lt;br /&gt;
&lt;br /&gt;
=== Bioelectrical Signal Acquisition Principles ===&lt;br /&gt;
The acquisition of bioelectrical signals is based on measuring the small potential difference on the skin surface using electrodes, then converting it into a processable electrical signal through amplification and digitization. For sEMG measurement, electrode placement and skin–electrode contact quality are especially important, since they directly affect signal amplitude and stability. In addition, the front-end acquisition circuit must provide sufficient sensitivity and good interference rejection, so that the recorded signal reflects actual muscle activity rather than environmental disturbance or poor contact conditions.&lt;br /&gt;
&lt;br /&gt;
=== Noise Sources in EMG (50 Hz, motion artifacts) ===&lt;br /&gt;
In practical EMG recording, the measured signal is easily contaminated by different types of noise. Two of the most common sources are power-line interference and motion artifacts. Power-line interference usually appears as a narrow-band component at 50 Hz in the local electrical environment, while motion artifacts are mainly caused by electrode movement, cable disturbance, or variations in the electrode–skin impedance, and are often concentrated in the low-frequency range. In addition, electronic noise from the acquisition hardware may also affect the recording quality. These unwanted components can reduce signal clarity and make muscle activity analysis less reliable, so they must be considered in the design of the signal processing pipeline.&lt;br /&gt;
[[File:background_theory_figure1.1_emg_noise_sources.png|center|thumb|700px|&#039;&#039;&#039;Figure 1.1.&#039;&#039;&#039; Principle of surface EMG acquisition.]]&lt;br /&gt;
&lt;br /&gt;
==System Architecture==&lt;br /&gt;
=== Total Structure Design ===&lt;br /&gt;
&lt;br /&gt;
For clarity，the proposed physiological signal acquisition system mainly consists of two core parts：the analog front－end （AFE）and the ADC board．The AFE is responsible for the preliminary conditioning of weak bioelectrical signals，including amplification，filtering，interference suppression，and level shifting，so that the analog waveform can be converted into a stable and measurable form．The ADC board then performs high－resolution digitization of the conditioned signal and transfers the sampled data to the host computer for subsequent display，storage，and analysis．Therefore，the overall system forms a complete signal－acquisition chain from weak physiological input to digital output．&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_1.jpg|thumb|center|800px|Figure 2.1. Overall system architecture of the proposed physiological signal acquisition platform，including the AFE and ADC modules．]]&lt;br /&gt;
&lt;br /&gt;
=== sEMG AFE Design ===&lt;br /&gt;
&lt;br /&gt;
To collect the weak bioelectric potential signals of the human body，an analog front－end（AFE）suitable sEMG measurements was designed．The module is powered by an external 5 V supply，and the complete circuit includes a first－ stage instrumentation amplifier based on INA128（Texas Instruments，Dallas，TX，USA），a band－pass filter，a 50 Hz notch filter，a second－order amplification and level shifting stage，a driver electrode circuit，a precise 1.5 V reference source，and a -5 V voltage generation module for powering the operational amplifiers．&lt;br /&gt;
&lt;br /&gt;
==== First－order Amplifier ====&lt;br /&gt;
&lt;br /&gt;
The input bioelectric signal is first acquired in differential form and applied to the INA128 instrumentation amplifier，which provides high input impedance，high common－mode rejection，and moderate initial gain for sEMG acquisition．This stage enlarges the weak physiological signal before filtering while reducing the risk of premature saturation caused by electrode offset or motion－induced disturbance，thereby preparing a more stable signal for the subsequent conditioning stages．&lt;br /&gt;
&lt;br /&gt;
==== Bandpass Filter ====&lt;br /&gt;
&lt;br /&gt;
After the instrumentation amplifier，the signal passes through a second－order active band－pass filter，as shown in Figure 2．2． This stage suppresses baseline drift and high－frequency noise outside the useful sEMG range，so that the low－frequency envelope information of sEMG can be preserved before further amplification．&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_2.jpg|thumb|center|800px|Figure 2.2. Schematic diagram of the active band-pass filter used in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the band-pass stage used to retain the main physiological signal band while suppressing unwanted lowand high-frequency components.&lt;br /&gt;
&lt;br /&gt;
==== Notch Filter ====&lt;br /&gt;
&lt;br /&gt;
To reduce power-line interference, a dedicated 50 Hz notch filter is introduced after the band-pass stage, as shown in Figure 2.3. This filter attenuates the mains-frequency component that commonly contaminates weak bioelectric measurements, thereby improving the signal-to-noise ratio of sEMG signals before the final amplification stage.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_3.jpg|thumb|center|800px|Figure 2.3. Schematic diagram of the 50 Hz notch filter used in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the circuit used to attenuate 50 Hz mains interference in the analog front end.&lt;br /&gt;
&lt;br /&gt;
==== Second-order Amplifier &amp;amp; Level Shifter ====&lt;br /&gt;
&lt;br /&gt;
After filtering, the signal enters the second-stage amplification and level-shifting circuit shown in Figure 2.4. In this stage, the filtered signal is further amplified to improve amplitude utilization and then shifted by a 1.5 V reference so that the output becomes a stable unipolar signal suitable for ADC sampling, while preserving linear operation and providing sufficient output swing margin.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_4.jpg|thumb|center|800px|Figure 2.4. Schematic diagram of the second-stage amplifier and level-shifting circuit in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows how the conditioned signal is further amplified and shifted to a suitable DC level before digitization.&lt;br /&gt;
&lt;br /&gt;
==== Power Module and Drive-electrode Circuit ====&lt;br /&gt;
&lt;br /&gt;
The AFE is powered by a 5 V supply and also integrates a 1.5 V precision reference, a -5 V generation circuit, and a driveelectrode circuit. These supporting modules provide the required supply rails and reference level for analog signal conditioning, while the drive-electrode circuit feeds back common-mode voltage to the body to suppress interference at the source. As a result, the complete AFE can support sEMG acquisition with adequate gain, filtering, and noise-reduction performance in a compact hardware structure.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_5.jpg|thumb|center|800px|Figure 2.5. Physical picture of the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the fabricated sEMG analog front-end hardware used in the system.&lt;br /&gt;
&lt;br /&gt;
Figure 2.5 presents the practical hardware implementation of the proposed sEMG AFE. It integrates amplification, filtering, level shifting, and driven-reference functions in a compact circuit for weak bioelectrical signal acquisition.&lt;br /&gt;
&lt;br /&gt;
=== ADS1256-based ADC Board ===&lt;br /&gt;
&lt;br /&gt;
To digitize the conditioned weak physiological signals with sufficient resolution and low noise, this project developed a dedicated ADC board based on the ADS1256 analog-to-digital converter (Texas Instruments, Dallas, TX, USA) and the STM32F103C8T6 microcontroller (STMicroelectronics, Geneva, Switzerland). The overall design objective of this board was not merely to realize analog-to-digital conversion, but to provide a complete hardware interface between the analog front-end and the digital processing unit, including precision reference generation, clocking, input protection and filtering, serial communication, power regulation, and MCU-based acquisition control. The ADS1256 was selected because it is a&lt;br /&gt;
&lt;br /&gt;
very low-noise 24-bit delta-sigma converter with a programmable gain amplifier (PGA), flexible input multiplexer, programmable digital filter, and SPI-compatible serial interface, which makes it well suited for weak low-frequency physiological signals after analog conditioning. The STM32F103C8T6 was used as the local controller because it provides a 32-bit Cortex-M3 core, up to 72 MHz system clock, SPI, USART, USB, and standard SWD debugging support in a compact and low-cost platform.&lt;br /&gt;
&lt;br /&gt;
==== ADC Core Architecture and Design Rationale ====&lt;br /&gt;
&lt;br /&gt;
The ADS1256 was selected as the core ADC because it provides high-resolution, low-noise delta-sigma conversion with an input multiplexer, programmable gain amplifier, and digital filter, which are suitable for weak and low-frequency physiological signals. As shown in Figure 2.6, this architecture emphasizes resolution and noise performance rather than high conversion bandwidth, making it appropriate for sEMG signal digitization after analog conditioning.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_6.jpg|thumb|center|800px|Figure 2.6. Internal functional structure of the ADS1256 analog-to-digital converter.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the main internal blocks of the ADS1256, including the multiplexer, PGA, modulator, and digital filter.&lt;br /&gt;
&lt;br /&gt;
==== Analog Front-End Interface, Reference, and Clocking ====&lt;br /&gt;
&lt;br /&gt;
The ADS1256 analog inputs are connected to the external header through a passive input-conditioning network that helps suppress high-frequency interference and improve input stability. In addition, the board includes a dedicated precision reference and clocking circuits so that the ADC can perform stable and accurate conversion. Together, these circuits provide a reliable analog interface and timing basis for high-resolution digitization of weak physiological signals.&lt;br /&gt;
&lt;br /&gt;
==== SPI Interface between ADS1256 and STM32F103C8T6 ====&lt;br /&gt;
&lt;br /&gt;
Communication between the ADS1256 and the STM32F103C8T6 is implemented through an SPI-compatible interface, with dedicated lines for chip select, serial clock, input/output data, data-ready notification, and hardware reset. This connection allows the MCU to configure the ADC, read conversion results in synchrony with DRDY, and maintain efficient and reliable acquisition control for multi-channel physiological measurements.&lt;br /&gt;
&lt;br /&gt;
==== Power Supply and On-board Regulation ====&lt;br /&gt;
&lt;br /&gt;
The ADC board uses a USB Type-B connector as the main power input and includes protection, voltage regulation, and local decoupling circuits to provide a stable supply for both the MCU and ADC-related hardware. In addition, analog ground and digital ground are separated in the PCB layout to reduce digital noise coupling into the analog path, which is particularly important for weak physiological signal acquisition.&lt;br /&gt;
&lt;br /&gt;
==== Basic Peripheral Circuits of the STM32F103C8T6 ====&lt;br /&gt;
&lt;br /&gt;
The STM32F103C8T6 serves as the local controller of the ADC board and is supported by several basic peripheral circuits, including an external crystal oscillator, reset network, BOOT0 configuration, SWD programming/debugging header, and a CH340N USB-to-UART bridge. These circuits ensure stable MCU operation, convenient firmware downloading and debugging, and reliable data transmission from the board to the host computer for real-time display and storage.&lt;br /&gt;
&lt;br /&gt;
==== Hardware-level Working Principle of the ADC Board ====&lt;br /&gt;
&lt;br /&gt;
In operation, the conditioned analog signal from the AFE enters the ADS1256 through the input header, is digitized with high resolution under the control of the local precision reference and clock, and is then read by the STM32 through the SPI interface. The MCU subsequently forwards the sampled data to the host computer through the serial communication link, so that the entire board functions as a compact digital acquisition backend connecting weak physiological analog signals to later software processing, display, and storage.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_7.jpg|thumb|center|800px|Figure 2.7. Photograph of the fabricated ADS1256-based ADC board developed in this project and the definitions of some key pins.]]&lt;br /&gt;
&lt;br /&gt;
Figure 2.7 shows the ADC board fabricated for this project. It integrates the ADS1256 conversion core, STM32 control circuit, power-conditioning circuits, and communication interfaces on a compact PCB for physiological signal digitization.&lt;br /&gt;
&lt;br /&gt;
== Signal Conditioning and Filtering ==&lt;br /&gt;
Although the AFE already performs preliminary band-pass filtering and 50 Hz interference suppression in the analog domain, the digitized sEMG signal may still contain residual noise due to component tolerances, electrode-contact variation, and environmental interference. Therefore, an additional digital filtering stage is implemented in software as a complementary post-processing step to improve signal quality and to provide a more stable input for rectification, envelope extraction, and subsequent analysis. In this sense, the software filtering is not a simple repetition of the analog filtering, but a refinement and compensation for non-ideal front-end behavior.&lt;br /&gt;
&lt;br /&gt;
Surface electromyographic (sEMG) signals are highly susceptible to several sources of contamination during acquisition. In practical measurements, the dominant disturbances usually include low-frequency motion artifacts caused by electrode movement and electrode–skin impedance variation, narrow-band power-line interference centered at 50 Hz, and broadband high-frequency electronic noise introduced by the acquisition hardware. These unwanted components degrade the quality of the recorded signal and may significantly affect the reliability of subsequent feature extraction, parameter estimation, and muscle activity interpretation. For this reason, an effective signal-conditioning procedure is necessary before any higher-level analysis is performed.&lt;br /&gt;
&lt;br /&gt;
In the present implementation, the filtering strategy follows the principle of restricting the signal bandwidth first and then removing the remaining narrow-band interference in a targeted manner. Accordingly, the raw sEMG signal is first processed by a fourth-order Butterworth IIR band-pass filter and then by a 50 Hz notch filter. This processing sequence is illustrated in the flowchart below, where the signal passes through band-pass filtering, notch filtering, full-wave rectification, and envelope extraction before producing the final processed output.&lt;br /&gt;
&lt;br /&gt;
[[File:flowchart.png|thumb|center|500px|Flowchart of the real-time sEMG signal conditioning pipeline.]]&lt;br /&gt;
&lt;br /&gt;
The rationale of this order is that the &#039;&#039;&#039;band-pass stage&#039;&#039;&#039; first confines the signal to the main spectral region of interest for sEMG, thereby attenuating motion artifacts at very low frequencies and suppressing high-frequency noise components outside the physiological band. After this spectral preconditioning, the notch stage can more effectively suppress the residual 50 Hz power-line interference that lies inside the useful sEMG band. In transfer-function form, the band-pass filter may be written as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;H_{BP}(z)=\frac{B_{BP}(z)}{A_{BP}(z)}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where the effective passband is selected as &amp;lt;math&amp;gt;20 \leq f \leq 160 \text{ Hz}&amp;lt;/math&amp;gt;. This frequency interval is consistent with the dominant spectral content of surface EMG: the lower cutoff near 20 Hz reduces motion artifacts and unstable low-frequency fluctuations, whereas the upper cutoff near 160 Hz removes high-frequency electronic noise while preserving the main energy-bearing components of the muscle signal. The use of a Butterworth structure is appropriate here because it provides a smooth monotonic passband response without ripple, which helps preserve signal morphology in real-time applications.&lt;br /&gt;
&lt;br /&gt;
After band limitation, a &#039;&#039;&#039;notch filter&#039;&#039;&#039; centered at the power-line frequency is applied to suppress interference that cannot be removed by the band-pass stage alone. The notch filter is designed around &amp;lt;math&amp;gt;f_0 = 50 \text{ Hz}&amp;lt;/math&amp;gt;, and its bandwidth is controlled by the quality factor &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;, which is expressed as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;Q = \frac{f_0}{\Delta f}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In transfer-function form, the notch stage is written as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;H_{N}(z)=\frac{B_{N}(z)}{A_{N}(z)}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the implemented program, a large quality factor is chosen so that the notch remains narrow, allowing effective rejection of the 50 Hz interference while minimizing distortion of neighboring useful spectral components. This is particularly important for sEMG because the interference frequency lies directly inside the physiological band of interest.&lt;br /&gt;
&lt;br /&gt;
Following the filtering stages, further signal conditioning is performed to obtain a representation that is more directly related to muscle activation intensity. The filtered sEMG waveform is first &#039;&#039;&#039;full-wave rectified&#039;&#039;&#039;, which converts the bipolar oscillatory signal into a unipolar signal by taking its absolute value.  Rectification does not remove noise by itself; instead, it transforms the signal into a form that is more suitable for amplitude-based analysis because both positive and negative deflections contribute positively to the activation measure.&lt;br /&gt;
&lt;br /&gt;
After rectification, the signal envelope is extracted to provide a smooth estimate of muscle activation level over time. In a general formulation, the envelope can be described as the &#039;&#039;&#039;low-pass filtered&#039;&#039;&#039; version of the rectified signal, namely &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y_{\mathrm{env}}[n] = \mathrm{LPF}\bigl(y_{\mathrm{rect}}[n]\bigr)&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the present code implementation, this operation is realized by short-time averaging over a finite window, which is equivalent to a moving-average low-pass smoothing of the rectified waveform. The corresponding expression is &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y_{\mathrm{env}}[n] = \frac{1}{N}\sum_{k=0}^{N-1} |x[n-k]|&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; is the window length in samples. With a window duration of approximately 200 ms, this envelope extraction method provides a stable and physiologically meaningful representation of muscle activation intensity, making it suitable for tasks such as force estimation, fatigue analysis, and motor-control studies.&lt;br /&gt;
&lt;br /&gt;
An important feature of the present &#039;&#039;&#039;implementation&#039;&#039;&#039; is that the entire filtering process is performed &#039;&#039;&#039;in real time&#039;&#039;&#039;, sample by sample, rather than by offline block processing. For this reason, IIR filters are preferred over FIR filters, since they can achieve comparable filtering performance with lower order, lower computational cost, and shorter delay. These properties are especially valuable in embedded systems, serial data streaming, and other low-latency experimental applications. However, unlike memoryless operations, an IIR filter depends not only on the current input but also on previous inputs and previous outputs. Its discrete-time behavior can therefore be represented by the recursive difference equation &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y[n] = \sum_{k=0}^{M} b_k x[n-k] - \sum_{k=1}^{N} a_k y[n-k]&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This equation makes clear that internal filter states must be preserved continuously during streaming operation. If the state variables were reinitialized for every incoming sample or data segment, artificial transients would appear and the output would no longer remain continuous.&lt;br /&gt;
&lt;br /&gt;
In the Python implementation, this state continuity is maintained using the internal initial-condition mechanism provided by SciPy, such as &amp;lt;code&amp;gt;lfilter_zi&amp;lt;/code&amp;gt;, together with recursive state updates during each filtering call. As a result, each newly acquired sample is passed first through the band-pass filter and then through the notch filter, while the internal states of both filters are updated after every step. This state-preserving sample-by-sample design ensures that the processing chain remains causal, continuous, and suitable for real-time display or downstream analysis without requiring storage of the entire signal segment.&lt;br /&gt;
&lt;br /&gt;
Overall, this signal-conditioning scheme provides an experimentally practical solution for real-time sEMG processing. The fourth-order Butterworth band-pass filter confines the signal to the main physiological band of interest, the 50 Hz notch filter removes narrow-band power-line contamination, and the subsequent rectification and envelope extraction generate a smooth amplitude descriptor of muscle activity. Combined with state-preserved streaming IIR implementation, this approach achieves a good balance between signal fidelity, computational efficiency, and real-time applicability in biomedical and physical experiment settings.&lt;br /&gt;
&lt;br /&gt;
== Experimental Setup ==&lt;br /&gt;
&lt;br /&gt;
=== Experimental Demonstration ===&lt;br /&gt;
&lt;br /&gt;
The experimental setup and data acquisition process are demonstrated in the video below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;text-align:center;&amp;quot;&amp;gt;&lt;br /&gt;
[[File:EMG_Experiment.mp4|center|800px]]&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The video illustrates the complete measurement procedure, including electrode placement, muscle activation, and real-time EMG signal visualization.&lt;br /&gt;
&lt;br /&gt;
=== Experimental Procedure ===&lt;br /&gt;
&lt;br /&gt;
Surface EMG signals were acquired using disposable electrodes placed on the forearm muscles responsible for wrist extension. &lt;br /&gt;
&lt;br /&gt;
Three electrodes were used in the measurement setup:&lt;br /&gt;
&lt;br /&gt;
* One electrode placed on the back of the hand serves as the reference electrode  &lt;br /&gt;
* The other two electrodes placed along the forearm muscle act as the differential input electrodes (positive and negative)  &lt;br /&gt;
&lt;br /&gt;
This configuration enables differential measurement of EMG signals while suppressing common-mode noise.&lt;br /&gt;
&lt;br /&gt;
The experimental movement consists of making a fist while extending the wrist backward. This action activates the forearm extensor muscles beneath the electrodes, producing measurable EMG signals.&lt;br /&gt;
&lt;br /&gt;
=== Data Acquisition Protocol ===&lt;br /&gt;
&lt;br /&gt;
Each subject performed repeated contraction–relaxation cycles under controlled conditions:&lt;br /&gt;
&lt;br /&gt;
* Number of subjects: 3  &lt;br /&gt;
* Number of trials per subject: 3  &lt;br /&gt;
* Duration of each trial: 30 seconds  &lt;br /&gt;
&lt;br /&gt;
During each trial, subjects were instructed to periodically contract and relax the muscle to generate clear dynamic EMG signals, while maintaining a stable resting state between contractions.&lt;br /&gt;
&lt;br /&gt;
=== System and Measurement Conditions ===&lt;br /&gt;
&lt;br /&gt;
The EMG signals were recorded and visualized in real time using a data acquisition system connected to a computer. The sampling rate was set to 400 Hz.&lt;br /&gt;
&lt;br /&gt;
To ensure consistency across measurements:&lt;br /&gt;
&lt;br /&gt;
* Electrode placement was kept consistent for all subjects  &lt;br /&gt;
* The same movement protocol was followed  &lt;br /&gt;
* Measurements were conducted under similar environmental conditions  &lt;br /&gt;
&lt;br /&gt;
=== Summary ===&lt;br /&gt;
&lt;br /&gt;
This experimental setup enables reliable acquisition of both resting and dynamic EMG signals, providing a consistent dataset for subsequent signal processing and performance evaluation.&lt;br /&gt;
&lt;br /&gt;
== Data Processing ==&lt;br /&gt;
&lt;br /&gt;
The objective of data processing is to convert raw surface electromyography (sEMG) recordings into stable, quantitative, and comparable indicators of muscle activity. Since EMG signals are low in amplitude, highly variable over time, and easily contaminated by noise, a dedicated processing pipeline is necessary before any experimental interpretation can be performed.&lt;br /&gt;
&lt;br /&gt;
In this project, the data processing workflow includes time normalization, signal pre-processing, sliding-window feature extraction, noise-floor estimation, and automatic contraction detection. The processed outputs are then used for subsequent experimental evaluation, including rest-versus-contraction discrimination, signal-to-noise ratio analysis, and repeatability assessment.&lt;br /&gt;
&lt;br /&gt;
=== Input Data and Time Normalization ===&lt;br /&gt;
&lt;br /&gt;
The acquired EMG data are read from CSV files containing two columns: time and filtered sEMG amplitude. In the MATLAB implementation, the time vector is normalized so that each recording starts from zero:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t = t_{all} - t_{all}(1)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This normalization is important because it removes the influence of absolute recording timestamps and makes different trials directly comparable on the same time axis.&lt;br /&gt;
&lt;br /&gt;
In addition, the signal type is automatically identified from the filename as either dynamic or rest. This design allows the same program to process both contraction recordings and resting recordings with different downstream analysis logic.&lt;br /&gt;
&lt;br /&gt;
=== Signal Pre-processing ===&lt;br /&gt;
&lt;br /&gt;
Raw EMG signals cannot be analyzed directly because they usually contain DC offset, low-frequency drift, motion artifacts, and residual high-frequency interference. Therefore, several pre-processing steps are applied before feature extraction.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(1) Baseline Removal&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The first step is DC offset removal:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
x_{dc}(t) = x(t) - \frac{1}{N}\sum_{i=1}^{N}x(i)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This operation centers the signal around zero. It is necessary because an uncorrected baseline would bias amplitude-based metrics and reduce the reliability of later envelope and feature calculations.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(2) Band-pass Filtering &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
After baseline correction, a fourth-order Butterworth band-pass filter is applied with a passband of 20–150 Hz.&lt;br /&gt;
&lt;br /&gt;
This step is introduced for two reasons:&lt;br /&gt;
&lt;br /&gt;
* The low-frequency cutoff at 20 Hz suppresses baseline drift and motion artifacts.&lt;br /&gt;
* The high-frequency cutoff at 150 Hz reduces unwanted high-frequency noise while preserving the main energy band of the recorded sEMG in this project.&lt;br /&gt;
&lt;br /&gt;
Compared with processing the raw waveform directly, band-pass filtering makes the subsequent time-domain features more stable and more physiologically meaningful.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(3) Full-wave Rectification&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The filtered EMG signal is bipolar, meaning that positive and negative phases coexist due to motor unit action potentials. If these positive and negative components are averaged directly, they may cancel each other out. To avoid this, full-wave rectification is performed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
x_{rect}(t) = |x_{filt}(t)|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This transforms the signal into a unipolar representation, so that all muscle activity contributes positively to the extracted features.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(4) Envelope Extraction &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Although the rectified signal reflects signal magnitude, it still fluctuates rapidly. To obtain a smoother representation of muscle activation level, an envelope is extracted using a moving average with a 100 ms window.&lt;br /&gt;
&lt;br /&gt;
Envelope extraction is important because contraction detection should reflect the overall activation trend rather than instantaneous spikes. A smoothed envelope is therefore more robust for identifying active and inactive muscle states.&lt;br /&gt;
&lt;br /&gt;
=== Sliding Window Design ===&lt;br /&gt;
&lt;br /&gt;
To quantify how muscle activity changes with time, the filtered signal is divided into overlapping short-time segments using a sliding window method.&lt;br /&gt;
&lt;br /&gt;
The window parameters are:&lt;br /&gt;
&lt;br /&gt;
* Window length: 250 ms&lt;br /&gt;
* Step size: 50 ms&lt;br /&gt;
&lt;br /&gt;
These values are chosen as a trade-off between temporal resolution and feature stability.&lt;br /&gt;
&lt;br /&gt;
A longer window improves statistical robustness because more samples are included in each calculation. However, if the window is too long, short contractions or rapid changes may be blurred. A smaller step size increases temporal continuity between adjacent feature points and makes the feature curves smoother in time. Therefore, the 250 ms / 50 ms design provides a practical balance between smoothing and time localization.&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt;-th segment, the feature time is defined as the mean time of that segment:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t_k = \frac{1}{N}\sum_{i=s_k}^{e_k} t(i)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;s_k&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;e_k&amp;lt;/math&amp;gt; denote the start and end indices of the window.&lt;br /&gt;
&lt;br /&gt;
=== Feature Extraction ===&lt;br /&gt;
&lt;br /&gt;
Within each sliding window, three time-domain features are extracted: RMS, iEMG, and MAV. These features are widely used in EMG analysis because they are simple, computationally efficient, and directly related to muscle activation intensity.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(1) Root Mean Square (RMS)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
RMS = \sqrt{\frac{1}{N}\sum_{i=1}^{N}x_i^2}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
RMS reflects the effective power of the EMG signal and is one of the most common indicators of contraction strength. It is sensitive to both amplitude and energy, making it especially useful for comparing rest and active states.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(2) Integrated EMG (iEMG)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
iEMG = \sum_{i=1}^{N}|x_i|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
iEMG describes the cumulative electrical activity within a window. It is often interpreted as a measure of total muscle effort over that time segment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(3) Mean Absolute Value (MAV)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
MAV = \frac{1}{N}\sum_{i=1}^{N}|x_i|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
MAV is an amplitude descriptor similar to iEMG, but normalized by the number of samples. It provides an efficient estimate of average signal level and is less computationally intensive than some other features.&lt;br /&gt;
&lt;br /&gt;
These three features are used together because they provide complementary descriptions of EMG intensity. RMS emphasizes signal energy, iEMG emphasizes cumulative activation, and MAV reflects average amplitude.&lt;br /&gt;
&lt;br /&gt;
=== Peak-value Extraction ===&lt;br /&gt;
&lt;br /&gt;
In addition to continuous feature curves, several key peak values are extracted from the processed signal:&lt;br /&gt;
&lt;br /&gt;
* maximum and minimum of the filtered EMG waveform&lt;br /&gt;
* peak of the envelope&lt;br /&gt;
* peak RMS&lt;br /&gt;
* peak iEMG&lt;br /&gt;
* peak MAV&lt;br /&gt;
&lt;br /&gt;
These peak values provide concise descriptors of the strongest activity observed in each recording. They are useful for quick comparison across trials and subjects.&lt;br /&gt;
&lt;br /&gt;
=== Noise Floor Estimation ===&lt;br /&gt;
&lt;br /&gt;
To evaluate signal quality, the noise floor is estimated from a reference resting interval. In the present implementation, the first 3 seconds of the recording are used as the default rest reference:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t \in [0,\min(3,t_{end})]&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this segment, three noise descriptors are computed:&lt;br /&gt;
&lt;br /&gt;
* Noise RMS&lt;br /&gt;
* Noise standard deviation&lt;br /&gt;
* Noise peak-to-peak amplitude&lt;br /&gt;
&lt;br /&gt;
Noise-floor estimation is important because EMG amplitude alone is not sufficient to judge recording quality. A large signal is only meaningful if it is sufficiently higher than the baseline noise level. Therefore, the noise floor serves as the reference for later SNR calculation and for designing contraction thresholds.&lt;br /&gt;
&lt;br /&gt;
=== Global Signal Metrics ===&lt;br /&gt;
&lt;br /&gt;
For each recording, three global metrics are also computed over the entire filtered signal:&lt;br /&gt;
&lt;br /&gt;
* Global RMS&lt;br /&gt;
* Global MAV&lt;br /&gt;
* Global iEMG&lt;br /&gt;
&lt;br /&gt;
These global descriptors summarize the overall signal level of the full recording and are later used in group-level comparisons.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Contraction Detection ===&lt;br /&gt;
&lt;br /&gt;
For dynamic recordings, an automatic contraction detection algorithm is used to identify repeated active segments. This is one of the key parts of the data processing pipeline, because it transforms a continuous EMG trace into discrete contraction events that can be counted and compared.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(1) Threshold Design&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The detection threshold is designed adaptively rather than using a fixed value. Two candidate thresholds are first calculated:&lt;br /&gt;
&lt;br /&gt;
* an envelope-based threshold derived from the global envelope mean and standard deviation&lt;br /&gt;
* a rest-reference threshold derived from the mean and standard deviation of the resting reference amplitude&lt;br /&gt;
&lt;br /&gt;
The final threshold is taken as the larger of the two after additional scaling. This strategy improves robustness because it combines the global activation level of the signal with the baseline noise characteristics of the individual recording.&lt;br /&gt;
&lt;br /&gt;
This adaptive threshold design is preferable to a manually fixed threshold because EMG amplitude can vary strongly between subjects, muscles, and recording sessions.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(2) Initial Segmentation&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
After thresholding the envelope, the signal is classified into active and inactive regions:&lt;br /&gt;
&lt;br /&gt;
* active: envelope above threshold&lt;br /&gt;
* inactive: envelope below threshold&lt;br /&gt;
&lt;br /&gt;
The rising and falling edges of the binary activity vector are then used to determine the start and end points of each candidate contraction segment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(3) Removal of Short Segments&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Very short active regions are often caused by noise fluctuations rather than true muscle contractions. Therefore, segments shorter than 0.20 s are discarded.&lt;br /&gt;
&lt;br /&gt;
This step prevents false positive detections and increases the physiological relevance of the segmentation results.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(4) Merging of Adjacent Segments &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If two neighboring active segments are separated by a very short gap, they are merged when the gap is less than 0.15 s.&lt;br /&gt;
&lt;br /&gt;
This operation is necessary because a single real contraction may be temporarily interrupted by a brief drop in the envelope caused by local fluctuation. Without merging, one contraction could be incorrectly counted as multiple repetitions.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(5) Repetition-level Metrics &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
For each detected contraction segment, two repetition-level metrics are extracted:&lt;br /&gt;
&lt;br /&gt;
* peak RMS of that contraction&lt;br /&gt;
* mean RMS of that contraction&lt;br /&gt;
&lt;br /&gt;
These metrics quantify both the strongest activation within each repetition and the average activation level over the repetition duration.&lt;br /&gt;
&lt;br /&gt;
=== Repeatability Analysis ===&lt;br /&gt;
&lt;br /&gt;
When multiple valid contractions are detected, repeatability is evaluated using the coefficient of variation (CV):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
CV = \frac{\sigma}{\mu}\times 100\%&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt; is the standard deviation and &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is the mean value across repetitions.&lt;br /&gt;
&lt;br /&gt;
Two CV values are computed:&lt;br /&gt;
&lt;br /&gt;
* CV of repetition peak RMS&lt;br /&gt;
* CV of repetition mean RMS&lt;br /&gt;
&lt;br /&gt;
A lower CV indicates better repeatability, meaning that repeated contractions produce more consistent EMG responses.&lt;br /&gt;
&lt;br /&gt;
=== Signal-to-Noise Ratio (SNR) ===&lt;br /&gt;
&lt;br /&gt;
In this project, the signal-to-noise ratio (SNR) is defined based on the ratio between contraction and rest activity:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
SNR_{dB} = 20\log_{10}\left(\frac{RMS_{contraction}}{RMS_{rest}}\right)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This definition is adopted because it directly reflects the system’s ability to distinguish active muscle contraction from baseline noise.&lt;br /&gt;
&lt;br /&gt;
Compared with global SNR definitions, this formulation is more relevant for practical EMG applications such as activity detection and classification.&lt;br /&gt;
&lt;br /&gt;
=== Rest-versus-Contraction Window Comparison ===&lt;br /&gt;
&lt;br /&gt;
To further distinguish inactive and active states, all sliding windows are divided into two groups:&lt;br /&gt;
&lt;br /&gt;
* rest windows: windows with envelope clearly below the threshold&lt;br /&gt;
* contraction windows: windows with envelope above the threshold&lt;br /&gt;
&lt;br /&gt;
The RMS values of these two groups are then compared statistically.&lt;br /&gt;
&lt;br /&gt;
This comparison is important because a practical EMG system should not only detect signal presence, but also clearly separate rest from contraction in a quantitative way. If the two RMS distributions are well separated, it indicates that the system has good discriminative capability.&lt;br /&gt;
&lt;br /&gt;
=== Output Data Structure ===&lt;br /&gt;
&lt;br /&gt;
The processed outputs are organized into structured data for experimental analysis:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(1) Time-series outputs&#039;&#039;&#039;&lt;br /&gt;
* Filtered EMG signal  &lt;br /&gt;
* Rectified signal  &lt;br /&gt;
* Envelope  &lt;br /&gt;
* RMS(t), iEMG(t), MAV(t)  &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(2) Recording-level outputs&#039;&#039;&#039; &lt;br /&gt;
* RMS (rest)  &lt;br /&gt;
* RMS (contraction)  &lt;br /&gt;
* iEMG  &lt;br /&gt;
* Noise metrics  &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(3) Dynamic-signal outputs &#039;&#039;&#039;&lt;br /&gt;
* Detected contractions  &lt;br /&gt;
* Repetition count  &lt;br /&gt;
* Peak RMS per repetition  &lt;br /&gt;
* Mean RMS per repetition  &lt;br /&gt;
* Coefficient of variation (CV)  &lt;br /&gt;
* Signal-to-noise ratio (SNR)  &lt;br /&gt;
&lt;br /&gt;
All extracted features are designed to directly support the evaluation of noise level, signal quality, activity discrimination, and repeatability in the subsequent experimental analysis.&lt;br /&gt;
&lt;br /&gt;
== Experimental Results ==&lt;br /&gt;
&lt;br /&gt;
This section presents representative results of the EMG acquisition and data processing pipeline under both dynamic (muscle contraction) and resting conditions.&lt;br /&gt;
&lt;br /&gt;
=== Representative Dynamic Signal Analysis ===&lt;br /&gt;
&lt;br /&gt;
[[File:Dynamic_Figure1.png|thumb|800px|center|Figure 5.1: Processed EMG signal under dynamic contraction, including filtered signal, rectified signal with envelope, and extracted features (RMS, iEMG, MAV).]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.1 shows the processed EMG signal during repeated muscle contractions.&lt;br /&gt;
&lt;br /&gt;
The filtered EMG waveform exhibits clear burst-like patterns corresponding to periodic contractions. The signal amplitude reaches a maximum of approximately 0.45, while the baseline remains centered around zero, indicating effective baseline removal and filtering.&lt;br /&gt;
&lt;br /&gt;
After rectification and envelope extraction, the contraction periods become clearly distinguishable. The envelope provides a smooth representation of muscle activation, with a peak value of approximately 0.145.&lt;br /&gt;
&lt;br /&gt;
The extracted time-domain features (RMS, iEMG, MAV) further quantify the signal. Among these, iEMG shows the strongest dynamic variation, indicating high sensitivity to contraction intensity.&lt;br /&gt;
&lt;br /&gt;
=== Noise Floor and Rest Reference ===&lt;br /&gt;
&lt;br /&gt;
[[File:Dynamic_Figure2.png|thumb|800px|center|Figure 5.2: Noise estimation, rest vs contraction comparison, automatic contraction detection, and repetition analysis.]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (top-left) shows the resting reference segment used for noise estimation.&lt;br /&gt;
&lt;br /&gt;
The signal remains centered around zero with small fluctuations. The noise characteristics are:&lt;br /&gt;
&lt;br /&gt;
* Noise RMS ≈ 0.0046  &lt;br /&gt;
* Standard deviation ≈ 0.0046  &lt;br /&gt;
* Peak-to-peak amplitude ≈ 0.071  &lt;br /&gt;
&lt;br /&gt;
This indicates a low noise floor and stable measurement conditions.&lt;br /&gt;
&lt;br /&gt;
=== Rest vs Contraction Discrimination ===&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (top-right) compares RMS values between rest and contraction states.&lt;br /&gt;
&lt;br /&gt;
The two distributions are clearly separated:&lt;br /&gt;
&lt;br /&gt;
* Rest mean RMS ≈ 0.0053  &lt;br /&gt;
* Contraction mean RMS ≈ 0.1064  &lt;br /&gt;
&lt;br /&gt;
This corresponds to an approximate 20× increase, demonstrating strong discriminability between inactive and active muscle states.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Contraction Detection ===&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (bottom-left) illustrates automatic detection based on the envelope signal.&lt;br /&gt;
&lt;br /&gt;
A threshold of approximately 0.040 is applied, resulting in stable segmentation of contraction periods.&lt;br /&gt;
&lt;br /&gt;
A total of 12 repetitions are detected, with good alignment to visible signal peaks.&lt;br /&gt;
&lt;br /&gt;
=== Repeatability Analysis ===&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (bottom-right) shows the peak RMS value of each detected contraction.&lt;br /&gt;
&lt;br /&gt;
The results indicate:&lt;br /&gt;
&lt;br /&gt;
* Mean peak RMS ≈ 0.1355  &lt;br /&gt;
* Standard deviation ≈ 0.0173  &lt;br /&gt;
* CV ≈ 12.77%  &lt;br /&gt;
* SNR ≈ 21.26 dB  &lt;br /&gt;
&lt;br /&gt;
This indicates acceptable repeatability and good signal quality.&lt;br /&gt;
&lt;br /&gt;
=== Representative Rest Signal Analysis ===&lt;br /&gt;
&lt;br /&gt;
[[File:Rest_Figure1.png|thumb|800px|center|Figure 5.3: Processed EMG signal under rest condition, showing low amplitude and absence of contraction patterns.]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.3 shows the EMG signal under resting conditions.&lt;br /&gt;
&lt;br /&gt;
The signal remains within a narrow amplitude range (approximately ±0.04) and shows no burst-like structures. The envelope remains close to zero, confirming the absence of muscle activity.&lt;br /&gt;
&lt;br /&gt;
The extracted features remain low:&lt;br /&gt;
&lt;br /&gt;
* RMS ≈ 0.007  &lt;br /&gt;
* MAV ≈ 0.005  &lt;br /&gt;
* iEMG remains stable  &lt;br /&gt;
&lt;br /&gt;
This confirms that no false activation is detected.&lt;br /&gt;
&lt;br /&gt;
=== Frequency-domain Characteristics ===&lt;br /&gt;
&lt;br /&gt;
[[File:Rest_Figure2.png|thumb|800px|center|Figure 5.4: Frequency-domain analysis and statistical characteristics of rest signal.]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.4 shows the frequency-domain characteristics of the resting signal.&lt;br /&gt;
&lt;br /&gt;
The power spectral density (PSD) indicates low overall signal energy without dominant peaks, confirming that the signal mainly consists of noise.&lt;br /&gt;
&lt;br /&gt;
=== Summary of Single-recording Performance ===&lt;br /&gt;
&lt;br /&gt;
From the representative results:&lt;br /&gt;
&lt;br /&gt;
* EMG signals are effectively extracted and denoised  &lt;br /&gt;
* Contraction events are clearly identifiable  &lt;br /&gt;
* Rest and contraction states are well separated  &lt;br /&gt;
* Automatic detection is stable and accurate  &lt;br /&gt;
* Repeatability is acceptable  &lt;br /&gt;
* No false activation occurs under rest conditions  &lt;br /&gt;
&lt;br /&gt;
=== Consistency Across Multiple Recordings ===&lt;br /&gt;
&lt;br /&gt;
The same data processing pipeline was applied to multiple recordings from different subjects and trials.&lt;br /&gt;
&lt;br /&gt;
Across all datasets, consistent patterns were observed:&lt;br /&gt;
&lt;br /&gt;
* Dynamic signals exhibit clear burst-like structures corresponding to repeated muscle contractions  &lt;br /&gt;
* Rest signals remain low in amplitude without distinct activation patterns  &lt;br /&gt;
* RMS values under contraction are consistently higher than those under rest  &lt;br /&gt;
* The automatic detection algorithm reliably identifies contraction segments  &lt;br /&gt;
&lt;br /&gt;
Although quantitative values (e.g., RMS, SNR, CV) vary across recordings due to differences in electrode contact, muscle activation strength, and individual conditions, the overall trends remain consistent.&lt;br /&gt;
&lt;br /&gt;
These results demonstrate the robustness and general applicability of the proposed signal processing method.&lt;br /&gt;
&lt;br /&gt;
== Multi-subject Analysis ==&lt;br /&gt;
=== System Evaluation ===&lt;br /&gt;
&lt;br /&gt;
This section evaluates the performance of the EMG acquisition system in terms of noise level, signal quality, activity discrimination, and repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Noise Floor Analysis ====&lt;br /&gt;
&lt;br /&gt;
The noise floor was evaluated using rest-state recordings, characterized by RMS noise, standard deviation, and peak-to-peak amplitude.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039; shows the lowest noise level (RMS ≈ 0.0046), indicating stable electrode contact and minimal interference.  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039; exhibits moderate noise (RMS ≈ 0.0080), likely influenced by motion artifacts or electrode–skin impedance variation.  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039; shows relatively higher noise (RMS ≈ 0.0126), suggesting increased baseline fluctuation.  &lt;br /&gt;
&lt;br /&gt;
Overall, the system maintains a low noise floor across subjects, although the quality depends on experimental conditions such as electrode contact and environmental interference.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Signal-to-Noise Ratio (SNR) ====&lt;br /&gt;
&lt;br /&gt;
The signal-to-noise ratio (SNR) is defined as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{SNR (dB)} = 20 \log_{10} \left( \frac{\mathrm{RMS}_{\mathrm{contraction}}}{\mathrm{RMS}_{\mathrm{rest}}} \right)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The measured SNR values are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: 21.26 dB → good signal quality  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: 13.52 dB → moderate and usable  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: 6.66 dB → low signal clarity  &lt;br /&gt;
&lt;br /&gt;
General interpretation:&lt;br /&gt;
&lt;br /&gt;
* &amp;gt;20 dB → good  &lt;br /&gt;
* 10–20 dB → usable  &lt;br /&gt;
* &amp;lt;10 dB → poor  &lt;br /&gt;
&lt;br /&gt;
These results show that the system can achieve reliable signal acquisition, although performance varies across subjects.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
====  Rest vs Contraction Discrimination ====&lt;br /&gt;
&lt;br /&gt;
A clear distinction between rest and contraction states is observed based on RMS values.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: 0.0053 → 0.1064 (≈20× increase)  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: 0.0079 → 0.0283 (≈3.6× increase)  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: 0.0141 → 0.0646 (≈4.6× increase)  &lt;br /&gt;
&lt;br /&gt;
This demonstrates that the system is capable of separating muscle activity from baseline noise.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Conclusion:&#039;&#039;  &lt;br /&gt;
The system can be used for basic muscle activity detection and simple classification tasks based on RMS features.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Repeatability of Repeated Contractions ====&lt;br /&gt;
&lt;br /&gt;
Repeatability is evaluated using the coefficient of variation (CV) of peak RMS values across repetitions.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! CV Range !! Evaluation&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt; 10% || Excellent&lt;br /&gt;
|-&lt;br /&gt;
| 10–20% || Acceptable&lt;br /&gt;
|-&lt;br /&gt;
| &amp;gt; 20% || Poor&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Results:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: CV = 12.77% → Acceptable  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: CV = 24.77% → Poor  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: CV = 10.60% → Acceptable  &lt;br /&gt;
&lt;br /&gt;
Although WANG&#039;s signal is detectable, its contraction amplitude varies significantly across repetitions, resulting in poor repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
=== Overall System Performance ===&lt;br /&gt;
&lt;br /&gt;
The system demonstrates the following performance characteristics:&lt;br /&gt;
&lt;br /&gt;
* Reliable detection of muscle activity across all subjects  &lt;br /&gt;
* Clear separation between rest and contraction states  &lt;br /&gt;
* Moderate to high signal quality depending on subject conditions  &lt;br /&gt;
* Repeatability ranging from acceptable to poor due to user-dependent factors  &lt;br /&gt;
&lt;br /&gt;
Overall, the designed EMG acquisition system is capable of stable signal acquisition and feature extraction, with performance primarily influenced by electrode contact quality, skin impedance, and motion consistency.&lt;br /&gt;
&lt;br /&gt;
===== Summary of Quantitative Metrics =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Subject !! RMS (Rest) !! RMS (Contraction) !! Separation Ratio !! iEMG (max) !! Noise RMS !! SNR (dB) !! CV (%) !! Evaluation&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;LIU&#039;&#039;&#039; || 0.0053 || 0.1064 || &#039;&#039;&#039;20.1×&#039;&#039;&#039; || 12.72 || 0.0046 || &#039;&#039;&#039;21.26&#039;&#039;&#039; || 12.77 || Strong signal, good quality&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;WANG&#039;&#039;&#039; || 0.0079 || 0.0283 || 3.57× || 11.10 || 0.0080 || 13.52 || &#039;&#039;&#039;24.77&#039;&#039;&#039; || Usable signal, poor repeatability&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ZHONG&#039;&#039;&#039; || 0.0141 || 0.0646 || 4.58× || 6.70 || 0.0126 || 6.66 || 10.60 || Acceptable performance&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Summary:&#039;&#039; Subject LIU shows the best overall performance, WANG provides usable but less stable signals, and ZHONG demonstrates moderate signal quality with good repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Activation Intensity =====&lt;br /&gt;
&lt;br /&gt;
Among the three subjects, &#039;&#039;&#039;LIU exhibits the strongest muscle activation&#039;&#039;&#039;, as indicated by the highest contraction RMS and iEMG values. ZHONG shows moderate activation, while WANG demonstrates comparable iEMG but lower RMS consistency.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Signal Quality =====&lt;br /&gt;
&lt;br /&gt;
Signal quality is evaluated based on SNR and noise level:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039; achieves the highest SNR and lowest noise → best signal quality  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039; shows moderate SNR → usable but less robust  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039; has the lowest SNR → weakest signal clarity  &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Repeatability =====&lt;br /&gt;
&lt;br /&gt;
Repeatability is evaluated using the coefficient of variation (CV):&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;ZHONG (10.60%)&#039;&#039;&#039; → most stable  &lt;br /&gt;
* &#039;&#039;&#039;LIU (12.77%)&#039;&#039;&#039; → acceptable  &lt;br /&gt;
* &#039;&#039;&#039;WANG (24.77%)&#039;&#039;&#039; → poor  &lt;br /&gt;
&lt;br /&gt;
This indicates that WANG’s contraction strength varies significantly between repetitions.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Engineering Interpretation of Inter-subject Differences =====&lt;br /&gt;
&lt;br /&gt;
The observed differences are mainly attributed to engineering and experimental factors rather than physiological differences.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Electrode contact quality&#039;&#039;&#039;  &lt;br /&gt;
  Variations in electrode placement, pressure, and gel contact affect signal amplitude and stability.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Skin impedance&#039;&#039;&#039;  &lt;br /&gt;
  Differences in skin condition (hydration, oil, hair) influence electrode–skin impedance, affecting noise level and signal coupling.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Muscle control consistency&#039;&#039;&#039;  &lt;br /&gt;
  Variations in contraction strength and timing affect repeatability and CV.&lt;br /&gt;
&lt;br /&gt;
Therefore, the variation across subjects reflects practical acquisition conditions rather than intrinsic system limitations.&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&lt;br /&gt;
This project presents a complete surface EMG (sEMG) acquisition and analysis system, integrating hardware design, signal conditioning, data processing, and experimental validation.&lt;br /&gt;
&lt;br /&gt;
From the hardware perspective, a dedicated analog front-end and data acquisition system were developed to capture low-amplitude bioelectrical signals with sufficient resolution and stability. The experimental setup, including electrode placement and measurement protocol, enables consistent and repeatable signal acquisition across different subjects.&lt;br /&gt;
&lt;br /&gt;
From the signal processing perspective, a structured pipeline was implemented, including filtering, rectification, envelope extraction, sliding-window segmentation, and feature extraction. Key features such as RMS, iEMG, and MAV were used to quantitatively characterize muscle activity.&lt;br /&gt;
&lt;br /&gt;
Experimental results demonstrate that:&lt;br /&gt;
&lt;br /&gt;
* EMG signals can be effectively extracted and denoised  &lt;br /&gt;
* Muscle contraction produces clear and repeatable signal patterns  &lt;br /&gt;
* Rest and contraction states can be reliably distinguished  &lt;br /&gt;
* Automatic detection accurately identifies contraction segments  &lt;br /&gt;
* The system achieves acceptable repeatability and signal quality  &lt;br /&gt;
&lt;br /&gt;
Overall, the proposed system provides a reliable framework for basic EMG signal acquisition and analysis. It is capable of capturing meaningful muscle activity and generating quantitative features that support further evaluation and interpretation.&lt;br /&gt;
&lt;br /&gt;
These results establish a solid foundation for subsequent multi-subject analysis and demonstrate the practical feasibility of the system for EMG-based monitoring applications.&lt;br /&gt;
&lt;br /&gt;
= Appendix =&lt;br /&gt;
&lt;br /&gt;
== EMG Signal Processing Code ==&lt;br /&gt;
&lt;br /&gt;
The following MATLAB code summarizes the core implementation of the EMG signal processing pipeline.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;matlab&amp;quot;&amp;gt;&lt;br /&gt;
% =========================&lt;br /&gt;
% EMG Analysis (Simplified)&lt;br /&gt;
% =========================&lt;br /&gt;
&lt;br /&gt;
clear; clc; close all;&lt;br /&gt;
&lt;br /&gt;
%% 1. Read data&lt;br /&gt;
filename = &#039;your_file.csv&#039;;&lt;br /&gt;
T = readtable(filename, &#039;VariableNamingRule&#039;,&#039;preserve&#039;);&lt;br /&gt;
&lt;br /&gt;
t_all = T.(&amp;quot;Time (s)&amp;quot;);&lt;br /&gt;
x_all = T.(&amp;quot;Filtered sEMG&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
t_all = t_all(:);&lt;br /&gt;
x_all = x_all(:);&lt;br /&gt;
&lt;br /&gt;
fs = 400;&lt;br /&gt;
&lt;br /&gt;
%% 2. Time normalization&lt;br /&gt;
t = t_all - t_all(1);&lt;br /&gt;
x = x_all;&lt;br /&gt;
&lt;br /&gt;
%% 3. Preprocessing&lt;br /&gt;
x = x - mean(x);   % Remove DC&lt;br /&gt;
&lt;br /&gt;
[b_bp, a_bp] = butter(4, [20 150]/(fs/2), &#039;bandpass&#039;);&lt;br /&gt;
x_filt = filtfilt(b_bp, a_bp, x);   % Band-pass filter&lt;br /&gt;
&lt;br /&gt;
x_rect = abs(x_filt);               % Rectification&lt;br /&gt;
env = movmean(x_rect, round(0.10*fs));  % Envelope&lt;br /&gt;
&lt;br /&gt;
%% 4. Sliding window feature extraction&lt;br /&gt;
win = round(0.25*fs);&lt;br /&gt;
step = round(0.05*fs);&lt;br /&gt;
&lt;br /&gt;
idx_start = 1:step:(length(x_filt)-win+1);&lt;br /&gt;
&lt;br /&gt;
for k = 1:length(idx_start)&lt;br /&gt;
    s = idx_start(k);&lt;br /&gt;
    e = s + win - 1;&lt;br /&gt;
    seg = x_filt(s:e);&lt;br /&gt;
&lt;br /&gt;
    RMS(k)  = sqrt(mean(seg.^2));&lt;br /&gt;
    iEMG(k) = sum(abs(seg));&lt;br /&gt;
    MAV(k)  = mean(abs(seg));&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
%% 5. Noise floor estimation&lt;br /&gt;
noise_floor_rms = sqrt(mean(x_filt(1:fs*3).^2));&lt;br /&gt;
&lt;br /&gt;
%% 6. Envelope-based detection&lt;br /&gt;
th = mean(env) + 0.5 * std(env);&lt;br /&gt;
is_active = env &amp;gt; th;&lt;br /&gt;
&lt;br /&gt;
%% 7. Signal-to-noise ratio&lt;br /&gt;
snr_db = 20 * log10(rms(x_filt) / noise_floor_rms);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
---&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
&lt;br /&gt;
* Sampling rate: 400 Hz  &lt;br /&gt;
* Band-pass filter: 20–150 Hz  &lt;br /&gt;
* Sliding window: 250 ms (step 50 ms)  &lt;br /&gt;
* Envelope window: 100 ms  &lt;br /&gt;
&lt;br /&gt;
The full implementation is available upon request.&lt;/div&gt;</summary>
		<author><name>Wang Jingyi</name></author>
	</entry>
	<entry>
		<id>https://pc5271.org/index.php?title=Surface_EMG_Sensor_for_Muscle_Activity_Measurement:_AFE_Design_and_Signal_Processing&amp;diff=1374</id>
		<title>Surface EMG Sensor for Muscle Activity Measurement: AFE Design and Signal Processing</title>
		<link rel="alternate" type="text/html" href="https://pc5271.org/index.php?title=Surface_EMG_Sensor_for_Muscle_Activity_Measurement:_AFE_Design_and_Signal_Processing&amp;diff=1374"/>
		<updated>2026-04-23T08:15:39Z</updated>

		<summary type="html">&lt;p&gt;Wang Jingyi: /* Engineering Interpretation of Inter-subject Differences */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Background and Theory==&lt;br /&gt;
&lt;br /&gt;
=== Surface EMG Signals ===&lt;br /&gt;
Surface electromyography (sEMG) refers to the bioelectrical signals detected on the skin surface during muscle contraction. These signals originate from the electrical activity of muscle fibers and provide a non-invasive way to monitor muscle activation. Compared with invasive EMG methods, sEMG is easier to apply, safer for repeated measurements, and more suitable for real-time monitoring. Therefore, it has been widely used in areas such as rehabilitation, motion analysis, human–machine interaction, and physiological monitoring.&lt;br /&gt;
&lt;br /&gt;
=== Characteristics of EMG Signals ===&lt;br /&gt;
EMG signals are generally weak, time-varying, and stochastic in nature. Their waveforms are typically bipolar, fluctuating around zero with both positive and negative components. The amplitude and frequency content of EMG signals depend on factors such as muscle contraction level, electrode placement, skin condition, and individual physiological differences. In practice, the useful frequency components of sEMG are mainly concentrated in a limited low-to-mid frequency range. Because of their low amplitude and variability, EMG signals usually require further conditioning before reliable interpretation and feature extraction can be performed.&lt;br /&gt;
&lt;br /&gt;
=== Bioelectrical Signal Acquisition Principles ===&lt;br /&gt;
The acquisition of bioelectrical signals is based on measuring the small potential difference on the skin surface using electrodes, then converting it into a processable electrical signal through amplification and digitization. For sEMG measurement, electrode placement and skin–electrode contact quality are especially important, since they directly affect signal amplitude and stability. In addition, the front-end acquisition circuit must provide sufficient sensitivity and good interference rejection, so that the recorded signal reflects actual muscle activity rather than environmental disturbance or poor contact conditions.&lt;br /&gt;
&lt;br /&gt;
=== Noise Sources in EMG (50 Hz, motion artifacts) ===&lt;br /&gt;
In practical EMG recording, the measured signal is easily contaminated by different types of noise. Two of the most common sources are power-line interference and motion artifacts. Power-line interference usually appears as a narrow-band component at 50 Hz in the local electrical environment, while motion artifacts are mainly caused by electrode movement, cable disturbance, or variations in the electrode–skin impedance, and are often concentrated in the low-frequency range. In addition, electronic noise from the acquisition hardware may also affect the recording quality. These unwanted components can reduce signal clarity and make muscle activity analysis less reliable, so they must be considered in the design of the signal processing pipeline.&lt;br /&gt;
[[File:background_theory_figure1.1_emg_noise_sources.png|center|thumb|700px|&#039;&#039;&#039;Figure 1.1.&#039;&#039;&#039; Principle of surface EMG acquisition.]]&lt;br /&gt;
&lt;br /&gt;
==System Architecture==&lt;br /&gt;
=== Total Structure Design ===&lt;br /&gt;
&lt;br /&gt;
For clarity，the proposed physiological signal acquisition system mainly consists of two core parts：the analog front－end （AFE）and the ADC board．The AFE is responsible for the preliminary conditioning of weak bioelectrical signals，including amplification，filtering，interference suppression，and level shifting，so that the analog waveform can be converted into a stable and measurable form．The ADC board then performs high－resolution digitization of the conditioned signal and transfers the sampled data to the host computer for subsequent display，storage，and analysis．Therefore，the overall system forms a complete signal－acquisition chain from weak physiological input to digital output．&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_1.jpg|thumb|center|800px|Figure 2.1. Overall system architecture of the proposed physiological signal acquisition platform，including the AFE and ADC modules．]]&lt;br /&gt;
&lt;br /&gt;
=== sEMG AFE Design ===&lt;br /&gt;
&lt;br /&gt;
To collect the weak bioelectric potential signals of the human body，an analog front－end（AFE）suitable sEMG measurements was designed．The module is powered by an external 5 V supply，and the complete circuit includes a first－ stage instrumentation amplifier based on INA128（Texas Instruments，Dallas，TX，USA），a band－pass filter，a 50 Hz notch filter，a second－order amplification and level shifting stage，a driver electrode circuit，a precise 1.5 V reference source，and a -5 V voltage generation module for powering the operational amplifiers．&lt;br /&gt;
&lt;br /&gt;
==== First－order Amplifier ====&lt;br /&gt;
&lt;br /&gt;
The input bioelectric signal is first acquired in differential form and applied to the INA128 instrumentation amplifier，which provides high input impedance，high common－mode rejection，and moderate initial gain for sEMG acquisition．This stage enlarges the weak physiological signal before filtering while reducing the risk of premature saturation caused by electrode offset or motion－induced disturbance，thereby preparing a more stable signal for the subsequent conditioning stages．&lt;br /&gt;
&lt;br /&gt;
==== Bandpass Filter ====&lt;br /&gt;
&lt;br /&gt;
After the instrumentation amplifier，the signal passes through a second－order active band－pass filter，as shown in Figure 2．2． This stage suppresses baseline drift and high－frequency noise outside the useful sEMG range，so that the low－frequency envelope information of sEMG can be preserved before further amplification．&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_2.jpg|thumb|center|800px|Figure 2.2. Schematic diagram of the active band-pass filter used in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the band-pass stage used to retain the main physiological signal band while suppressing unwanted lowand high-frequency components.&lt;br /&gt;
&lt;br /&gt;
==== Notch Filter ====&lt;br /&gt;
&lt;br /&gt;
To reduce power-line interference, a dedicated 50 Hz notch filter is introduced after the band-pass stage, as shown in Figure 2.3. This filter attenuates the mains-frequency component that commonly contaminates weak bioelectric measurements, thereby improving the signal-to-noise ratio of sEMG signals before the final amplification stage.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_3.jpg|thumb|center|800px|Figure 2.3. Schematic diagram of the 50 Hz notch filter used in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the circuit used to attenuate 50 Hz mains interference in the analog front end.&lt;br /&gt;
&lt;br /&gt;
==== Second-order Amplifier &amp;amp; Level Shifter ====&lt;br /&gt;
&lt;br /&gt;
After filtering, the signal enters the second-stage amplification and level-shifting circuit shown in Figure 2.4. In this stage, the filtered signal is further amplified to improve amplitude utilization and then shifted by a 1.5 V reference so that the output becomes a stable unipolar signal suitable for ADC sampling, while preserving linear operation and providing sufficient output swing margin.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_4.jpg|thumb|center|800px|Figure 2.4. Schematic diagram of the second-stage amplifier and level-shifting circuit in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows how the conditioned signal is further amplified and shifted to a suitable DC level before digitization.&lt;br /&gt;
&lt;br /&gt;
==== Power Module and Drive-electrode Circuit ====&lt;br /&gt;
&lt;br /&gt;
The AFE is powered by a 5 V supply and also integrates a 1.5 V precision reference, a -5 V generation circuit, and a driveelectrode circuit. These supporting modules provide the required supply rails and reference level for analog signal conditioning, while the drive-electrode circuit feeds back common-mode voltage to the body to suppress interference at the source. As a result, the complete AFE can support sEMG acquisition with adequate gain, filtering, and noise-reduction performance in a compact hardware structure.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_5.jpg|thumb|center|800px|Figure 2.5. Physical picture of the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the fabricated sEMG analog front-end hardware used in the system.&lt;br /&gt;
&lt;br /&gt;
Figure 2.5 presents the practical hardware implementation of the proposed sEMG AFE. It integrates amplification, filtering, level shifting, and driven-reference functions in a compact circuit for weak bioelectrical signal acquisition.&lt;br /&gt;
&lt;br /&gt;
=== ADS1256-based ADC Board ===&lt;br /&gt;
&lt;br /&gt;
To digitize the conditioned weak physiological signals with sufficient resolution and low noise, this project developed a dedicated ADC board based on the ADS1256 analog-to-digital converter (Texas Instruments, Dallas, TX, USA) and the STM32F103C8T6 microcontroller (STMicroelectronics, Geneva, Switzerland). The overall design objective of this board was not merely to realize analog-to-digital conversion, but to provide a complete hardware interface between the analog front-end and the digital processing unit, including precision reference generation, clocking, input protection and filtering, serial communication, power regulation, and MCU-based acquisition control. The ADS1256 was selected because it is a&lt;br /&gt;
&lt;br /&gt;
very low-noise 24-bit delta-sigma converter with a programmable gain amplifier (PGA), flexible input multiplexer, programmable digital filter, and SPI-compatible serial interface, which makes it well suited for weak low-frequency physiological signals after analog conditioning. The STM32F103C8T6 was used as the local controller because it provides a 32-bit Cortex-M3 core, up to 72 MHz system clock, SPI, USART, USB, and standard SWD debugging support in a compact and low-cost platform.&lt;br /&gt;
&lt;br /&gt;
==== ADC Core Architecture and Design Rationale ====&lt;br /&gt;
&lt;br /&gt;
The ADS1256 was selected as the core ADC because it provides high-resolution, low-noise delta-sigma conversion with an input multiplexer, programmable gain amplifier, and digital filter, which are suitable for weak and low-frequency physiological signals. As shown in Figure 2.6, this architecture emphasizes resolution and noise performance rather than high conversion bandwidth, making it appropriate for sEMG signal digitization after analog conditioning.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_6.jpg|thumb|center|800px|Figure 2.6. Internal functional structure of the ADS1256 analog-to-digital converter.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the main internal blocks of the ADS1256, including the multiplexer, PGA, modulator, and digital filter.&lt;br /&gt;
&lt;br /&gt;
==== Analog Front-End Interface, Reference, and Clocking ====&lt;br /&gt;
&lt;br /&gt;
The ADS1256 analog inputs are connected to the external header through a passive input-conditioning network that helps suppress high-frequency interference and improve input stability. In addition, the board includes a dedicated precision reference and clocking circuits so that the ADC can perform stable and accurate conversion. Together, these circuits provide a reliable analog interface and timing basis for high-resolution digitization of weak physiological signals.&lt;br /&gt;
&lt;br /&gt;
==== SPI Interface between ADS1256 and STM32F103C8T6 ====&lt;br /&gt;
&lt;br /&gt;
Communication between the ADS1256 and the STM32F103C8T6 is implemented through an SPI-compatible interface, with dedicated lines for chip select, serial clock, input/output data, data-ready notification, and hardware reset. This connection allows the MCU to configure the ADC, read conversion results in synchrony with DRDY, and maintain efficient and reliable acquisition control for multi-channel physiological measurements.&lt;br /&gt;
&lt;br /&gt;
==== Power Supply and On-board Regulation ====&lt;br /&gt;
&lt;br /&gt;
The ADC board uses a USB Type-B connector as the main power input and includes protection, voltage regulation, and local decoupling circuits to provide a stable supply for both the MCU and ADC-related hardware. In addition, analog ground and digital ground are separated in the PCB layout to reduce digital noise coupling into the analog path, which is particularly important for weak physiological signal acquisition.&lt;br /&gt;
&lt;br /&gt;
==== Basic Peripheral Circuits of the STM32F103C8T6 ====&lt;br /&gt;
&lt;br /&gt;
The STM32F103C8T6 serves as the local controller of the ADC board and is supported by several basic peripheral circuits, including an external crystal oscillator, reset network, BOOT0 configuration, SWD programming/debugging header, and a CH340N USB-to-UART bridge. These circuits ensure stable MCU operation, convenient firmware downloading and debugging, and reliable data transmission from the board to the host computer for real-time display and storage.&lt;br /&gt;
&lt;br /&gt;
==== Hardware-level Working Principle of the ADC Board ====&lt;br /&gt;
&lt;br /&gt;
In operation, the conditioned analog signal from the AFE enters the ADS1256 through the input header, is digitized with high resolution under the control of the local precision reference and clock, and is then read by the STM32 through the SPI interface. The MCU subsequently forwards the sampled data to the host computer through the serial communication link, so that the entire board functions as a compact digital acquisition backend connecting weak physiological analog signals to later software processing, display, and storage.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_7.jpg|thumb|center|800px|Figure 2.7. Photograph of the fabricated ADS1256-based ADC board developed in this project and the definitions of some key pins.]]&lt;br /&gt;
&lt;br /&gt;
Figure 2.7 shows the ADC board fabricated for this project. It integrates the ADS1256 conversion core, STM32 control circuit, power-conditioning circuits, and communication interfaces on a compact PCB for physiological signal digitization.&lt;br /&gt;
&lt;br /&gt;
== Signal Conditioning and Filtering ==&lt;br /&gt;
Although the AFE already performs preliminary band-pass filtering and 50 Hz interference suppression in the analog domain, the digitized sEMG signal may still contain residual noise due to component tolerances, electrode-contact variation, and environmental interference. Therefore, an additional digital filtering stage is implemented in software as a complementary post-processing step to improve signal quality and to provide a more stable input for rectification, envelope extraction, and subsequent analysis. In this sense, the software filtering is not a simple repetition of the analog filtering, but a refinement and compensation for non-ideal front-end behavior.&lt;br /&gt;
&lt;br /&gt;
Surface electromyographic (sEMG) signals are highly susceptible to several sources of contamination during acquisition. In practical measurements, the dominant disturbances usually include low-frequency motion artifacts caused by electrode movement and electrode–skin impedance variation, narrow-band power-line interference centered at 50 Hz, and broadband high-frequency electronic noise introduced by the acquisition hardware. These unwanted components degrade the quality of the recorded signal and may significantly affect the reliability of subsequent feature extraction, parameter estimation, and muscle activity interpretation. For this reason, an effective signal-conditioning procedure is necessary before any higher-level analysis is performed.&lt;br /&gt;
&lt;br /&gt;
In the present implementation, the filtering strategy follows the principle of restricting the signal bandwidth first and then removing the remaining narrow-band interference in a targeted manner. Accordingly, the raw sEMG signal is first processed by a fourth-order Butterworth IIR band-pass filter and then by a 50 Hz notch filter. This processing sequence is illustrated in the flowchart below, where the signal passes through band-pass filtering, notch filtering, full-wave rectification, and envelope extraction before producing the final processed output.&lt;br /&gt;
&lt;br /&gt;
[[File:flowchart.png|thumb|center|500px|Flowchart of the real-time sEMG signal conditioning pipeline.]]&lt;br /&gt;
&lt;br /&gt;
The rationale of this order is that the &#039;&#039;&#039;band-pass stage&#039;&#039;&#039; first confines the signal to the main spectral region of interest for sEMG, thereby attenuating motion artifacts at very low frequencies and suppressing high-frequency noise components outside the physiological band. After this spectral preconditioning, the notch stage can more effectively suppress the residual 50 Hz power-line interference that lies inside the useful sEMG band. In transfer-function form, the band-pass filter may be written as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;H_{BP}(z)=\frac{B_{BP}(z)}{A_{BP}(z)}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where the effective passband is selected as &amp;lt;math&amp;gt;20 \leq f \leq 160 \text{ Hz}&amp;lt;/math&amp;gt;. This frequency interval is consistent with the dominant spectral content of surface EMG: the lower cutoff near 20 Hz reduces motion artifacts and unstable low-frequency fluctuations, whereas the upper cutoff near 160 Hz removes high-frequency electronic noise while preserving the main energy-bearing components of the muscle signal. The use of a Butterworth structure is appropriate here because it provides a smooth monotonic passband response without ripple, which helps preserve signal morphology in real-time applications.&lt;br /&gt;
&lt;br /&gt;
After band limitation, a &#039;&#039;&#039;notch filter&#039;&#039;&#039; centered at the power-line frequency is applied to suppress interference that cannot be removed by the band-pass stage alone. The notch filter is designed around &amp;lt;math&amp;gt;f_0 = 50 \text{ Hz}&amp;lt;/math&amp;gt;, and its bandwidth is controlled by the quality factor &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;, which is expressed as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;Q = \frac{f_0}{\Delta f}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In transfer-function form, the notch stage is written as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;H_{N}(z)=\frac{B_{N}(z)}{A_{N}(z)}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the implemented program, a large quality factor is chosen so that the notch remains narrow, allowing effective rejection of the 50 Hz interference while minimizing distortion of neighboring useful spectral components. This is particularly important for sEMG because the interference frequency lies directly inside the physiological band of interest.&lt;br /&gt;
&lt;br /&gt;
Following the filtering stages, further signal conditioning is performed to obtain a representation that is more directly related to muscle activation intensity. The filtered sEMG waveform is first &#039;&#039;&#039;full-wave rectified&#039;&#039;&#039;, which converts the bipolar oscillatory signal into a unipolar signal by taking its absolute value.  Rectification does not remove noise by itself; instead, it transforms the signal into a form that is more suitable for amplitude-based analysis because both positive and negative deflections contribute positively to the activation measure.&lt;br /&gt;
&lt;br /&gt;
After rectification, the signal envelope is extracted to provide a smooth estimate of muscle activation level over time. In a general formulation, the envelope can be described as the &#039;&#039;&#039;low-pass filtered&#039;&#039;&#039; version of the rectified signal, namely &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y_{\mathrm{env}}[n] = \mathrm{LPF}\bigl(y_{\mathrm{rect}}[n]\bigr)&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the present code implementation, this operation is realized by short-time averaging over a finite window, which is equivalent to a moving-average low-pass smoothing of the rectified waveform. The corresponding expression is &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y_{\mathrm{env}}[n] = \frac{1}{N}\sum_{k=0}^{N-1} |x[n-k]|&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; is the window length in samples. With a window duration of approximately 200 ms, this envelope extraction method provides a stable and physiologically meaningful representation of muscle activation intensity, making it suitable for tasks such as force estimation, fatigue analysis, and motor-control studies.&lt;br /&gt;
&lt;br /&gt;
An important feature of the present &#039;&#039;&#039;implementation&#039;&#039;&#039; is that the entire filtering process is performed &#039;&#039;&#039;in real time&#039;&#039;&#039;, sample by sample, rather than by offline block processing. For this reason, IIR filters are preferred over FIR filters, since they can achieve comparable filtering performance with lower order, lower computational cost, and shorter delay. These properties are especially valuable in embedded systems, serial data streaming, and other low-latency experimental applications. However, unlike memoryless operations, an IIR filter depends not only on the current input but also on previous inputs and previous outputs. Its discrete-time behavior can therefore be represented by the recursive difference equation &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y[n] = \sum_{k=0}^{M} b_k x[n-k] - \sum_{k=1}^{N} a_k y[n-k]&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This equation makes clear that internal filter states must be preserved continuously during streaming operation. If the state variables were reinitialized for every incoming sample or data segment, artificial transients would appear and the output would no longer remain continuous.&lt;br /&gt;
&lt;br /&gt;
In the Python implementation, this state continuity is maintained using the internal initial-condition mechanism provided by SciPy, such as &amp;lt;code&amp;gt;lfilter_zi&amp;lt;/code&amp;gt;, together with recursive state updates during each filtering call. As a result, each newly acquired sample is passed first through the band-pass filter and then through the notch filter, while the internal states of both filters are updated after every step. This state-preserving sample-by-sample design ensures that the processing chain remains causal, continuous, and suitable for real-time display or downstream analysis without requiring storage of the entire signal segment.&lt;br /&gt;
&lt;br /&gt;
Overall, this signal-conditioning scheme provides an experimentally practical solution for real-time sEMG processing. The fourth-order Butterworth band-pass filter confines the signal to the main physiological band of interest, the 50 Hz notch filter removes narrow-band power-line contamination, and the subsequent rectification and envelope extraction generate a smooth amplitude descriptor of muscle activity. Combined with state-preserved streaming IIR implementation, this approach achieves a good balance between signal fidelity, computational efficiency, and real-time applicability in biomedical and physical experiment settings.&lt;br /&gt;
&lt;br /&gt;
== Experimental Setup ==&lt;br /&gt;
&lt;br /&gt;
=== Experimental Demonstration ===&lt;br /&gt;
&lt;br /&gt;
The experimental setup and data acquisition process are demonstrated in the video below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;text-align:center;&amp;quot;&amp;gt;&lt;br /&gt;
[[File:EMG_Experiment.mp4|center|800px]]&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The video illustrates the complete measurement procedure, including electrode placement, muscle activation, and real-time EMG signal visualization.&lt;br /&gt;
&lt;br /&gt;
=== Experimental Procedure ===&lt;br /&gt;
&lt;br /&gt;
Surface EMG signals were acquired using disposable electrodes placed on the forearm muscles responsible for wrist extension. &lt;br /&gt;
&lt;br /&gt;
Three electrodes were used in the measurement setup:&lt;br /&gt;
&lt;br /&gt;
* One electrode placed on the back of the hand serves as the reference electrode  &lt;br /&gt;
* The other two electrodes placed along the forearm muscle act as the differential input electrodes (positive and negative)  &lt;br /&gt;
&lt;br /&gt;
This configuration enables differential measurement of EMG signals while suppressing common-mode noise.&lt;br /&gt;
&lt;br /&gt;
The experimental movement consists of making a fist while extending the wrist backward. This action activates the forearm extensor muscles beneath the electrodes, producing measurable EMG signals.&lt;br /&gt;
&lt;br /&gt;
=== Data Acquisition Protocol ===&lt;br /&gt;
&lt;br /&gt;
Each subject performed repeated contraction–relaxation cycles under controlled conditions:&lt;br /&gt;
&lt;br /&gt;
* Number of subjects: 3  &lt;br /&gt;
* Number of trials per subject: 3  &lt;br /&gt;
* Duration of each trial: 30 seconds  &lt;br /&gt;
&lt;br /&gt;
During each trial, subjects were instructed to periodically contract and relax the muscle to generate clear dynamic EMG signals, while maintaining a stable resting state between contractions.&lt;br /&gt;
&lt;br /&gt;
=== System and Measurement Conditions ===&lt;br /&gt;
&lt;br /&gt;
The EMG signals were recorded and visualized in real time using a data acquisition system connected to a computer. The sampling rate was set to 400 Hz.&lt;br /&gt;
&lt;br /&gt;
To ensure consistency across measurements:&lt;br /&gt;
&lt;br /&gt;
* Electrode placement was kept consistent for all subjects  &lt;br /&gt;
* The same movement protocol was followed  &lt;br /&gt;
* Measurements were conducted under similar environmental conditions  &lt;br /&gt;
&lt;br /&gt;
=== Summary ===&lt;br /&gt;
&lt;br /&gt;
This experimental setup enables reliable acquisition of both resting and dynamic EMG signals, providing a consistent dataset for subsequent signal processing and performance evaluation.&lt;br /&gt;
&lt;br /&gt;
== Data Processing ==&lt;br /&gt;
&lt;br /&gt;
The objective of data processing is to convert raw surface electromyography (sEMG) recordings into stable, quantitative, and comparable indicators of muscle activity. Since EMG signals are low in amplitude, highly variable over time, and easily contaminated by noise, a dedicated processing pipeline is necessary before any experimental interpretation can be performed.&lt;br /&gt;
&lt;br /&gt;
In this project, the data processing workflow includes time normalization, signal pre-processing, sliding-window feature extraction, noise-floor estimation, and automatic contraction detection. The processed outputs are then used for subsequent experimental evaluation, including rest-versus-contraction discrimination, signal-to-noise ratio analysis, and repeatability assessment.&lt;br /&gt;
&lt;br /&gt;
=== Input Data and Time Normalization ===&lt;br /&gt;
&lt;br /&gt;
The acquired EMG data are read from CSV files containing two columns: time and filtered sEMG amplitude. In the MATLAB implementation, the time vector is normalized so that each recording starts from zero:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t = t_{all} - t_{all}(1)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This normalization is important because it removes the influence of absolute recording timestamps and makes different trials directly comparable on the same time axis.&lt;br /&gt;
&lt;br /&gt;
In addition, the signal type is automatically identified from the filename as either dynamic or rest. This design allows the same program to process both contraction recordings and resting recordings with different downstream analysis logic.&lt;br /&gt;
&lt;br /&gt;
=== Signal Pre-processing ===&lt;br /&gt;
&lt;br /&gt;
Raw EMG signals cannot be analyzed directly because they usually contain DC offset, low-frequency drift, motion artifacts, and residual high-frequency interference. Therefore, several pre-processing steps are applied before feature extraction.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(1) Baseline Removal&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The first step is DC offset removal:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
x_{dc}(t) = x(t) - \frac{1}{N}\sum_{i=1}^{N}x(i)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This operation centers the signal around zero. It is necessary because an uncorrected baseline would bias amplitude-based metrics and reduce the reliability of later envelope and feature calculations.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(2) Band-pass Filtering &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
After baseline correction, a fourth-order Butterworth band-pass filter is applied with a passband of 20–150 Hz.&lt;br /&gt;
&lt;br /&gt;
This step is introduced for two reasons:&lt;br /&gt;
&lt;br /&gt;
* The low-frequency cutoff at 20 Hz suppresses baseline drift and motion artifacts.&lt;br /&gt;
* The high-frequency cutoff at 150 Hz reduces unwanted high-frequency noise while preserving the main energy band of the recorded sEMG in this project.&lt;br /&gt;
&lt;br /&gt;
Compared with processing the raw waveform directly, band-pass filtering makes the subsequent time-domain features more stable and more physiologically meaningful.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(3) Full-wave Rectification&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The filtered EMG signal is bipolar, meaning that positive and negative phases coexist due to motor unit action potentials. If these positive and negative components are averaged directly, they may cancel each other out. To avoid this, full-wave rectification is performed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
x_{rect}(t) = |x_{filt}(t)|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This transforms the signal into a unipolar representation, so that all muscle activity contributes positively to the extracted features.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(4) Envelope Extraction &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Although the rectified signal reflects signal magnitude, it still fluctuates rapidly. To obtain a smoother representation of muscle activation level, an envelope is extracted using a moving average with a 100 ms window.&lt;br /&gt;
&lt;br /&gt;
Envelope extraction is important because contraction detection should reflect the overall activation trend rather than instantaneous spikes. A smoothed envelope is therefore more robust for identifying active and inactive muscle states.&lt;br /&gt;
&lt;br /&gt;
=== Sliding Window Design ===&lt;br /&gt;
&lt;br /&gt;
To quantify how muscle activity changes with time, the filtered signal is divided into overlapping short-time segments using a sliding window method.&lt;br /&gt;
&lt;br /&gt;
The window parameters are:&lt;br /&gt;
&lt;br /&gt;
* Window length: 250 ms&lt;br /&gt;
* Step size: 50 ms&lt;br /&gt;
&lt;br /&gt;
These values are chosen as a trade-off between temporal resolution and feature stability.&lt;br /&gt;
&lt;br /&gt;
A longer window improves statistical robustness because more samples are included in each calculation. However, if the window is too long, short contractions or rapid changes may be blurred. A smaller step size increases temporal continuity between adjacent feature points and makes the feature curves smoother in time. Therefore, the 250 ms / 50 ms design provides a practical balance between smoothing and time localization.&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt;-th segment, the feature time is defined as the mean time of that segment:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t_k = \frac{1}{N}\sum_{i=s_k}^{e_k} t(i)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;s_k&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;e_k&amp;lt;/math&amp;gt; denote the start and end indices of the window.&lt;br /&gt;
&lt;br /&gt;
=== Feature Extraction ===&lt;br /&gt;
&lt;br /&gt;
Within each sliding window, three time-domain features are extracted: RMS, iEMG, and MAV. These features are widely used in EMG analysis because they are simple, computationally efficient, and directly related to muscle activation intensity.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(1) Root Mean Square (RMS)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
RMS = \sqrt{\frac{1}{N}\sum_{i=1}^{N}x_i^2}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
RMS reflects the effective power of the EMG signal and is one of the most common indicators of contraction strength. It is sensitive to both amplitude and energy, making it especially useful for comparing rest and active states.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(2) Integrated EMG (iEMG)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
iEMG = \sum_{i=1}^{N}|x_i|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
iEMG describes the cumulative electrical activity within a window. It is often interpreted as a measure of total muscle effort over that time segment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(3) Mean Absolute Value (MAV)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
MAV = \frac{1}{N}\sum_{i=1}^{N}|x_i|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
MAV is an amplitude descriptor similar to iEMG, but normalized by the number of samples. It provides an efficient estimate of average signal level and is less computationally intensive than some other features.&lt;br /&gt;
&lt;br /&gt;
These three features are used together because they provide complementary descriptions of EMG intensity. RMS emphasizes signal energy, iEMG emphasizes cumulative activation, and MAV reflects average amplitude.&lt;br /&gt;
&lt;br /&gt;
=== Peak-value Extraction ===&lt;br /&gt;
&lt;br /&gt;
In addition to continuous feature curves, several key peak values are extracted from the processed signal:&lt;br /&gt;
&lt;br /&gt;
* maximum and minimum of the filtered EMG waveform&lt;br /&gt;
* peak of the envelope&lt;br /&gt;
* peak RMS&lt;br /&gt;
* peak iEMG&lt;br /&gt;
* peak MAV&lt;br /&gt;
&lt;br /&gt;
These peak values provide concise descriptors of the strongest activity observed in each recording. They are useful for quick comparison across trials and subjects.&lt;br /&gt;
&lt;br /&gt;
=== Noise Floor Estimation ===&lt;br /&gt;
&lt;br /&gt;
To evaluate signal quality, the noise floor is estimated from a reference resting interval. In the present implementation, the first 3 seconds of the recording are used as the default rest reference:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t \in [0,\min(3,t_{end})]&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this segment, three noise descriptors are computed:&lt;br /&gt;
&lt;br /&gt;
* Noise RMS&lt;br /&gt;
* Noise standard deviation&lt;br /&gt;
* Noise peak-to-peak amplitude&lt;br /&gt;
&lt;br /&gt;
Noise-floor estimation is important because EMG amplitude alone is not sufficient to judge recording quality. A large signal is only meaningful if it is sufficiently higher than the baseline noise level. Therefore, the noise floor serves as the reference for later SNR calculation and for designing contraction thresholds.&lt;br /&gt;
&lt;br /&gt;
=== Global Signal Metrics ===&lt;br /&gt;
&lt;br /&gt;
For each recording, three global metrics are also computed over the entire filtered signal:&lt;br /&gt;
&lt;br /&gt;
* Global RMS&lt;br /&gt;
* Global MAV&lt;br /&gt;
* Global iEMG&lt;br /&gt;
&lt;br /&gt;
These global descriptors summarize the overall signal level of the full recording and are later used in group-level comparisons.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Contraction Detection ===&lt;br /&gt;
&lt;br /&gt;
For dynamic recordings, an automatic contraction detection algorithm is used to identify repeated active segments. This is one of the key parts of the data processing pipeline, because it transforms a continuous EMG trace into discrete contraction events that can be counted and compared.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(1) Threshold Design&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The detection threshold is designed adaptively rather than using a fixed value. Two candidate thresholds are first calculated:&lt;br /&gt;
&lt;br /&gt;
* an envelope-based threshold derived from the global envelope mean and standard deviation&lt;br /&gt;
* a rest-reference threshold derived from the mean and standard deviation of the resting reference amplitude&lt;br /&gt;
&lt;br /&gt;
The final threshold is taken as the larger of the two after additional scaling. This strategy improves robustness because it combines the global activation level of the signal with the baseline noise characteristics of the individual recording.&lt;br /&gt;
&lt;br /&gt;
This adaptive threshold design is preferable to a manually fixed threshold because EMG amplitude can vary strongly between subjects, muscles, and recording sessions.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(2) Initial Segmentation&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
After thresholding the envelope, the signal is classified into active and inactive regions:&lt;br /&gt;
&lt;br /&gt;
* active: envelope above threshold&lt;br /&gt;
* inactive: envelope below threshold&lt;br /&gt;
&lt;br /&gt;
The rising and falling edges of the binary activity vector are then used to determine the start and end points of each candidate contraction segment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(3) Removal of Short Segments&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Very short active regions are often caused by noise fluctuations rather than true muscle contractions. Therefore, segments shorter than 0.20 s are discarded.&lt;br /&gt;
&lt;br /&gt;
This step prevents false positive detections and increases the physiological relevance of the segmentation results.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(4) Merging of Adjacent Segments &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If two neighboring active segments are separated by a very short gap, they are merged when the gap is less than 0.15 s.&lt;br /&gt;
&lt;br /&gt;
This operation is necessary because a single real contraction may be temporarily interrupted by a brief drop in the envelope caused by local fluctuation. Without merging, one contraction could be incorrectly counted as multiple repetitions.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(5) Repetition-level Metrics &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
For each detected contraction segment, two repetition-level metrics are extracted:&lt;br /&gt;
&lt;br /&gt;
* peak RMS of that contraction&lt;br /&gt;
* mean RMS of that contraction&lt;br /&gt;
&lt;br /&gt;
These metrics quantify both the strongest activation within each repetition and the average activation level over the repetition duration.&lt;br /&gt;
&lt;br /&gt;
=== Repeatability Analysis ===&lt;br /&gt;
&lt;br /&gt;
When multiple valid contractions are detected, repeatability is evaluated using the coefficient of variation (CV):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
CV = \frac{\sigma}{\mu}\times 100\%&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt; is the standard deviation and &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is the mean value across repetitions.&lt;br /&gt;
&lt;br /&gt;
Two CV values are computed:&lt;br /&gt;
&lt;br /&gt;
* CV of repetition peak RMS&lt;br /&gt;
* CV of repetition mean RMS&lt;br /&gt;
&lt;br /&gt;
A lower CV indicates better repeatability, meaning that repeated contractions produce more consistent EMG responses.&lt;br /&gt;
&lt;br /&gt;
=== Signal-to-Noise Ratio (SNR) ===&lt;br /&gt;
&lt;br /&gt;
In this project, the signal-to-noise ratio (SNR) is defined based on the ratio between contraction and rest activity:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
SNR_{dB} = 20\log_{10}\left(\frac{RMS_{contraction}}{RMS_{rest}}\right)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This definition is adopted because it directly reflects the system’s ability to distinguish active muscle contraction from baseline noise.&lt;br /&gt;
&lt;br /&gt;
Compared with global SNR definitions, this formulation is more relevant for practical EMG applications such as activity detection and classification.&lt;br /&gt;
&lt;br /&gt;
=== Rest-versus-Contraction Window Comparison ===&lt;br /&gt;
&lt;br /&gt;
To further distinguish inactive and active states, all sliding windows are divided into two groups:&lt;br /&gt;
&lt;br /&gt;
* rest windows: windows with envelope clearly below the threshold&lt;br /&gt;
* contraction windows: windows with envelope above the threshold&lt;br /&gt;
&lt;br /&gt;
The RMS values of these two groups are then compared statistically.&lt;br /&gt;
&lt;br /&gt;
This comparison is important because a practical EMG system should not only detect signal presence, but also clearly separate rest from contraction in a quantitative way. If the two RMS distributions are well separated, it indicates that the system has good discriminative capability.&lt;br /&gt;
&lt;br /&gt;
=== Output Data Structure ===&lt;br /&gt;
&lt;br /&gt;
The processed outputs are organized into structured data for experimental analysis:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(1) Time-series outputs&#039;&#039;&#039;&lt;br /&gt;
* Filtered EMG signal  &lt;br /&gt;
* Rectified signal  &lt;br /&gt;
* Envelope  &lt;br /&gt;
* RMS(t), iEMG(t), MAV(t)  &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(2) Recording-level outputs&#039;&#039;&#039; &lt;br /&gt;
* RMS (rest)  &lt;br /&gt;
* RMS (contraction)  &lt;br /&gt;
* iEMG  &lt;br /&gt;
* Noise metrics  &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(3) Dynamic-signal outputs &#039;&#039;&#039;&lt;br /&gt;
* Detected contractions  &lt;br /&gt;
* Repetition count  &lt;br /&gt;
* Peak RMS per repetition  &lt;br /&gt;
* Mean RMS per repetition  &lt;br /&gt;
* Coefficient of variation (CV)  &lt;br /&gt;
* Signal-to-noise ratio (SNR)  &lt;br /&gt;
&lt;br /&gt;
All extracted features are designed to directly support the evaluation of noise level, signal quality, activity discrimination, and repeatability in the subsequent experimental analysis.&lt;br /&gt;
&lt;br /&gt;
== Experimental Results ==&lt;br /&gt;
&lt;br /&gt;
This section presents representative results of the EMG acquisition and data processing pipeline under both dynamic (muscle contraction) and resting conditions.&lt;br /&gt;
&lt;br /&gt;
=== Representative Dynamic Signal Analysis ===&lt;br /&gt;
&lt;br /&gt;
[[File:Dynamic_Figure1.png|thumb|800px|center|Figure 5.1: Processed EMG signal under dynamic contraction, including filtered signal, rectified signal with envelope, and extracted features (RMS, iEMG, MAV).]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.1 shows the processed EMG signal during repeated muscle contractions.&lt;br /&gt;
&lt;br /&gt;
The filtered EMG waveform exhibits clear burst-like patterns corresponding to periodic contractions. The signal amplitude reaches a maximum of approximately 0.45, while the baseline remains centered around zero, indicating effective baseline removal and filtering.&lt;br /&gt;
&lt;br /&gt;
After rectification and envelope extraction, the contraction periods become clearly distinguishable. The envelope provides a smooth representation of muscle activation, with a peak value of approximately 0.145.&lt;br /&gt;
&lt;br /&gt;
The extracted time-domain features (RMS, iEMG, MAV) further quantify the signal. Among these, iEMG shows the strongest dynamic variation, indicating high sensitivity to contraction intensity.&lt;br /&gt;
&lt;br /&gt;
=== Noise Floor and Rest Reference ===&lt;br /&gt;
&lt;br /&gt;
[[File:Dynamic_Figure2.png|thumb|800px|center|Figure 5.2: Noise estimation, rest vs contraction comparison, automatic contraction detection, and repetition analysis.]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (top-left) shows the resting reference segment used for noise estimation.&lt;br /&gt;
&lt;br /&gt;
The signal remains centered around zero with small fluctuations. The noise characteristics are:&lt;br /&gt;
&lt;br /&gt;
* Noise RMS ≈ 0.0046  &lt;br /&gt;
* Standard deviation ≈ 0.0046  &lt;br /&gt;
* Peak-to-peak amplitude ≈ 0.071  &lt;br /&gt;
&lt;br /&gt;
This indicates a low noise floor and stable measurement conditions.&lt;br /&gt;
&lt;br /&gt;
=== Rest vs Contraction Discrimination ===&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (top-right) compares RMS values between rest and contraction states.&lt;br /&gt;
&lt;br /&gt;
The two distributions are clearly separated:&lt;br /&gt;
&lt;br /&gt;
* Rest mean RMS ≈ 0.0053  &lt;br /&gt;
* Contraction mean RMS ≈ 0.1064  &lt;br /&gt;
&lt;br /&gt;
This corresponds to an approximate 20× increase, demonstrating strong discriminability between inactive and active muscle states.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Contraction Detection ===&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (bottom-left) illustrates automatic detection based on the envelope signal.&lt;br /&gt;
&lt;br /&gt;
A threshold of approximately 0.040 is applied, resulting in stable segmentation of contraction periods.&lt;br /&gt;
&lt;br /&gt;
A total of 12 repetitions are detected, with good alignment to visible signal peaks.&lt;br /&gt;
&lt;br /&gt;
=== Repeatability Analysis ===&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (bottom-right) shows the peak RMS value of each detected contraction.&lt;br /&gt;
&lt;br /&gt;
The results indicate:&lt;br /&gt;
&lt;br /&gt;
* Mean peak RMS ≈ 0.1355  &lt;br /&gt;
* Standard deviation ≈ 0.0173  &lt;br /&gt;
* CV ≈ 12.77%  &lt;br /&gt;
* SNR ≈ 21.26 dB  &lt;br /&gt;
&lt;br /&gt;
This indicates acceptable repeatability and good signal quality.&lt;br /&gt;
&lt;br /&gt;
=== Representative Rest Signal Analysis ===&lt;br /&gt;
&lt;br /&gt;
[[File:Rest_Figure1.png|thumb|800px|center|Figure 5.3: Processed EMG signal under rest condition, showing low amplitude and absence of contraction patterns.]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.3 shows the EMG signal under resting conditions.&lt;br /&gt;
&lt;br /&gt;
The signal remains within a narrow amplitude range (approximately ±0.04) and shows no burst-like structures. The envelope remains close to zero, confirming the absence of muscle activity.&lt;br /&gt;
&lt;br /&gt;
The extracted features remain low:&lt;br /&gt;
&lt;br /&gt;
* RMS ≈ 0.007  &lt;br /&gt;
* MAV ≈ 0.005  &lt;br /&gt;
* iEMG remains stable  &lt;br /&gt;
&lt;br /&gt;
This confirms that no false activation is detected.&lt;br /&gt;
&lt;br /&gt;
=== Frequency-domain Characteristics ===&lt;br /&gt;
&lt;br /&gt;
[[File:Rest_Figure2.png|thumb|800px|center|Figure 5.4: Frequency-domain analysis and statistical characteristics of rest signal.]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.4 shows the frequency-domain characteristics of the resting signal.&lt;br /&gt;
&lt;br /&gt;
The power spectral density (PSD) indicates low overall signal energy without dominant peaks, confirming that the signal mainly consists of noise.&lt;br /&gt;
&lt;br /&gt;
=== Summary of Single-recording Performance ===&lt;br /&gt;
&lt;br /&gt;
From the representative results:&lt;br /&gt;
&lt;br /&gt;
* EMG signals are effectively extracted and denoised  &lt;br /&gt;
* Contraction events are clearly identifiable  &lt;br /&gt;
* Rest and contraction states are well separated  &lt;br /&gt;
* Automatic detection is stable and accurate  &lt;br /&gt;
* Repeatability is acceptable  &lt;br /&gt;
* No false activation occurs under rest conditions  &lt;br /&gt;
&lt;br /&gt;
=== Consistency Across Multiple Recordings ===&lt;br /&gt;
&lt;br /&gt;
The same data processing pipeline was applied to multiple recordings from different subjects and trials.&lt;br /&gt;
&lt;br /&gt;
Across all datasets, consistent patterns were observed:&lt;br /&gt;
&lt;br /&gt;
* Dynamic signals exhibit clear burst-like structures corresponding to repeated muscle contractions  &lt;br /&gt;
* Rest signals remain low in amplitude without distinct activation patterns  &lt;br /&gt;
* RMS values under contraction are consistently higher than those under rest  &lt;br /&gt;
* The automatic detection algorithm reliably identifies contraction segments  &lt;br /&gt;
&lt;br /&gt;
Although quantitative values (e.g., RMS, SNR, CV) vary across recordings due to differences in electrode contact, muscle activation strength, and individual conditions, the overall trends remain consistent.&lt;br /&gt;
&lt;br /&gt;
These results demonstrate the robustness and general applicability of the proposed signal processing method.&lt;br /&gt;
&lt;br /&gt;
== Multi-subject Analysis ==&lt;br /&gt;
=== System Evaluation ===&lt;br /&gt;
&lt;br /&gt;
This section evaluates the performance of the EMG acquisition system in terms of noise level, signal quality, activity discrimination, and repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Noise Floor Analysis ====&lt;br /&gt;
&lt;br /&gt;
The noise floor was evaluated using rest-state recordings, characterized by RMS noise, standard deviation, and peak-to-peak amplitude.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039; shows the lowest noise level (RMS ≈ 0.0046), indicating stable electrode contact and minimal interference.  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039; exhibits moderate noise (RMS ≈ 0.0080), likely influenced by motion artifacts or electrode–skin impedance variation.  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039; shows relatively higher noise (RMS ≈ 0.0126), suggesting increased baseline fluctuation.  &lt;br /&gt;
&lt;br /&gt;
Overall, the system maintains a low noise floor across subjects, although the quality depends on experimental conditions such as electrode contact and environmental interference.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Signal-to-Noise Ratio (SNR) ====&lt;br /&gt;
&lt;br /&gt;
The signal-to-noise ratio (SNR) is defined as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{SNR (dB)} = 20 \log_{10} \left( \frac{\mathrm{RMS}_{\mathrm{contraction}}}{\mathrm{RMS}_{\mathrm{rest}}} \right)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The measured SNR values are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: 21.26 dB → good signal quality  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: 13.52 dB → moderate and usable  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: 6.66 dB → low signal clarity  &lt;br /&gt;
&lt;br /&gt;
General interpretation:&lt;br /&gt;
&lt;br /&gt;
* &amp;gt;20 dB → good  &lt;br /&gt;
* 10–20 dB → usable  &lt;br /&gt;
* &amp;lt;10 dB → poor  &lt;br /&gt;
&lt;br /&gt;
These results show that the system can achieve reliable signal acquisition, although performance varies across subjects.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
====  Rest vs Contraction Discrimination ====&lt;br /&gt;
&lt;br /&gt;
A clear distinction between rest and contraction states is observed based on RMS values.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: 0.0053 → 0.1064 (≈20× increase)  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: 0.0079 → 0.0283 (≈3.6× increase)  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: 0.0141 → 0.0646 (≈4.6× increase)  &lt;br /&gt;
&lt;br /&gt;
This demonstrates that the system is capable of separating muscle activity from baseline noise.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Conclusion:&#039;&#039;  &lt;br /&gt;
The system can be used for basic muscle activity detection and simple classification tasks based on RMS features.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Repeatability of Repeated Contractions ====&lt;br /&gt;
&lt;br /&gt;
Repeatability is evaluated using the coefficient of variation (CV) of peak RMS values across repetitions.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! CV Range !! Evaluation&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt; 10% || Excellent&lt;br /&gt;
|-&lt;br /&gt;
| 10–20% || Acceptable&lt;br /&gt;
|-&lt;br /&gt;
| &amp;gt; 20% || Poor&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Results:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: CV = 12.77% → Acceptable  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: CV = 24.77% → Poor  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: CV = 10.60% → Acceptable  &lt;br /&gt;
&lt;br /&gt;
Although WANG&#039;s signal is detectable, its contraction amplitude varies significantly across repetitions, resulting in poor repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
=== Overall System Performance ===&lt;br /&gt;
&lt;br /&gt;
The system demonstrates the following performance characteristics:&lt;br /&gt;
&lt;br /&gt;
* Reliable detection of muscle activity across all subjects  &lt;br /&gt;
* Clear separation between rest and contraction states  &lt;br /&gt;
* Moderate to high signal quality depending on subject conditions  &lt;br /&gt;
* Repeatability ranging from acceptable to poor due to user-dependent factors  &lt;br /&gt;
&lt;br /&gt;
Overall, the designed EMG acquisition system is capable of stable signal acquisition and feature extraction, with performance primarily influenced by electrode contact quality, skin impedance, and motion consistency.&lt;br /&gt;
&lt;br /&gt;
===== Summary of Quantitative Metrics =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Subject !! RMS (Rest) !! RMS (Contraction) !! Separation Ratio !! iEMG (max) !! Noise RMS !! SNR (dB) !! CV (%) !! Evaluation&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;LIU&#039;&#039;&#039; || 0.0053 || 0.1064 || &#039;&#039;&#039;20.1×&#039;&#039;&#039; || 12.72 || 0.0046 || &#039;&#039;&#039;21.26&#039;&#039;&#039; || 12.77 || Strong signal, good quality&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;WANG&#039;&#039;&#039; || 0.0079 || 0.0283 || 3.57× || 11.10 || 0.0080 || 13.52 || &#039;&#039;&#039;24.77&#039;&#039;&#039; || Usable signal, poor repeatability&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ZHONG&#039;&#039;&#039; || 0.0141 || 0.0646 || 4.58× || 6.70 || 0.0126 || 6.66 || 10.60 || Acceptable performance&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Summary:&#039;&#039; Subject LIU shows the best overall performance, WANG provides usable but less stable signals, and ZHONG demonstrates moderate signal quality with good repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Activation Intensity =====&lt;br /&gt;
&lt;br /&gt;
Among the three subjects, &#039;&#039;&#039;LIU exhibits the strongest muscle activation&#039;&#039;&#039;, as indicated by the highest contraction RMS and iEMG values. ZHONG shows moderate activation, while WANG demonstrates comparable iEMG but lower RMS consistency.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Signal Quality =====&lt;br /&gt;
&lt;br /&gt;
Signal quality is evaluated based on SNR and noise level:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039; achieves the highest SNR and lowest noise → best signal quality  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039; shows moderate SNR → usable but less robust  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039; has the lowest SNR → weakest signal clarity  &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Repeatability =====&lt;br /&gt;
&lt;br /&gt;
Repeatability is evaluated using the coefficient of variation (CV):&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;ZHONG (10.60%)&#039;&#039;&#039; → most stable  &lt;br /&gt;
* &#039;&#039;&#039;LIU (12.77%)&#039;&#039;&#039; → acceptable  &lt;br /&gt;
* &#039;&#039;&#039;WANG (24.77%)&#039;&#039;&#039; → poor  &lt;br /&gt;
&lt;br /&gt;
This indicates that WANG’s contraction strength varies significantly between repetitions.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Engineering Interpretation of Inter-subject Differences =====&lt;br /&gt;
&lt;br /&gt;
The observed differences are mainly attributed to engineering and experimental factors rather than physiological differences.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Electrode contact quality&#039;&#039;&#039;  &lt;br /&gt;
  Variations in electrode placement, pressure, and gel contact affect signal amplitude and stability.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Skin impedance&#039;&#039;&#039;  &lt;br /&gt;
  Differences in skin condition (hydration, oil, hair) influence electrode–skin impedance, affecting noise level and signal coupling.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Muscle control consistency&#039;&#039;&#039;  &lt;br /&gt;
  Variations in contraction strength and timing affect repeatability and CV.&lt;br /&gt;
&lt;br /&gt;
Therefore, the variation across subjects reflects practical acquisition conditions rather than intrinsic system limitations.&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
&lt;br /&gt;
This project presents a complete surface EMG (sEMG) acquisition and analysis system, integrating hardware design, signal conditioning, data processing, and experimental validation.&lt;br /&gt;
&lt;br /&gt;
From the hardware perspective, a dedicated analog front-end and data acquisition system were developed to capture low-amplitude bioelectrical signals with sufficient resolution and stability. The experimental setup, including electrode placement and measurement protocol, enables consistent and repeatable signal acquisition across different subjects.&lt;br /&gt;
&lt;br /&gt;
From the signal processing perspective, a structured pipeline was implemented, including filtering, rectification, envelope extraction, sliding-window segmentation, and feature extraction. Key features such as RMS, iEMG, and MAV were used to quantitatively characterize muscle activity.&lt;br /&gt;
&lt;br /&gt;
Experimental results demonstrate that:&lt;br /&gt;
&lt;br /&gt;
* EMG signals can be effectively extracted and denoised  &lt;br /&gt;
* Muscle contraction produces clear and repeatable signal patterns  &lt;br /&gt;
* Rest and contraction states can be reliably distinguished  &lt;br /&gt;
* Automatic detection accurately identifies contraction segments  &lt;br /&gt;
* The system achieves acceptable repeatability and signal quality  &lt;br /&gt;
&lt;br /&gt;
Overall, the proposed system provides a reliable framework for basic EMG signal acquisition and analysis. It is capable of capturing meaningful muscle activity and generating quantitative features that support further evaluation and interpretation.&lt;br /&gt;
&lt;br /&gt;
These results establish a solid foundation for subsequent multi-subject analysis and demonstrate the practical feasibility of the system for EMG-based monitoring applications.&lt;/div&gt;</summary>
		<author><name>Wang Jingyi</name></author>
	</entry>
	<entry>
		<id>https://pc5271.org/index.php?title=Surface_EMG_Sensor_for_Muscle_Activity_Measurement:_AFE_Design_and_Signal_Processing&amp;diff=1373</id>
		<title>Surface EMG Sensor for Muscle Activity Measurement: AFE Design and Signal Processing</title>
		<link rel="alternate" type="text/html" href="https://pc5271.org/index.php?title=Surface_EMG_Sensor_for_Muscle_Activity_Measurement:_AFE_Design_and_Signal_Processing&amp;diff=1373"/>
		<updated>2026-04-23T07:59:21Z</updated>

		<summary type="html">&lt;p&gt;Wang Jingyi: /* Experimental Demonstration */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Background and Theory==&lt;br /&gt;
&lt;br /&gt;
=== Surface EMG Signals ===&lt;br /&gt;
Surface electromyography (sEMG) refers to the bioelectrical signals detected on the skin surface during muscle contraction. These signals originate from the electrical activity of muscle fibers and provide a non-invasive way to monitor muscle activation. Compared with invasive EMG methods, sEMG is easier to apply, safer for repeated measurements, and more suitable for real-time monitoring. Therefore, it has been widely used in areas such as rehabilitation, motion analysis, human–machine interaction, and physiological monitoring.&lt;br /&gt;
&lt;br /&gt;
=== Characteristics of EMG Signals ===&lt;br /&gt;
EMG signals are generally weak, time-varying, and stochastic in nature. Their waveforms are typically bipolar, fluctuating around zero with both positive and negative components. The amplitude and frequency content of EMG signals depend on factors such as muscle contraction level, electrode placement, skin condition, and individual physiological differences. In practice, the useful frequency components of sEMG are mainly concentrated in a limited low-to-mid frequency range. Because of their low amplitude and variability, EMG signals usually require further conditioning before reliable interpretation and feature extraction can be performed.&lt;br /&gt;
&lt;br /&gt;
=== Bioelectrical Signal Acquisition Principles ===&lt;br /&gt;
The acquisition of bioelectrical signals is based on measuring the small potential difference on the skin surface using electrodes, then converting it into a processable electrical signal through amplification and digitization. For sEMG measurement, electrode placement and skin–electrode contact quality are especially important, since they directly affect signal amplitude and stability. In addition, the front-end acquisition circuit must provide sufficient sensitivity and good interference rejection, so that the recorded signal reflects actual muscle activity rather than environmental disturbance or poor contact conditions.&lt;br /&gt;
&lt;br /&gt;
=== Noise Sources in EMG (50 Hz, motion artifacts) ===&lt;br /&gt;
In practical EMG recording, the measured signal is easily contaminated by different types of noise. Two of the most common sources are power-line interference and motion artifacts. Power-line interference usually appears as a narrow-band component at 50 Hz in the local electrical environment, while motion artifacts are mainly caused by electrode movement, cable disturbance, or variations in the electrode–skin impedance, and are often concentrated in the low-frequency range. In addition, electronic noise from the acquisition hardware may also affect the recording quality. These unwanted components can reduce signal clarity and make muscle activity analysis less reliable, so they must be considered in the design of the signal processing pipeline.&lt;br /&gt;
[[File:background_theory_figure1.1_emg_noise_sources.png|center|thumb|700px|&#039;&#039;&#039;Figure 1.1.&#039;&#039;&#039; Principle of surface EMG acquisition.]]&lt;br /&gt;
&lt;br /&gt;
==System Architecture==&lt;br /&gt;
=== Total Structure Design ===&lt;br /&gt;
&lt;br /&gt;
For clarity，the proposed physiological signal acquisition system mainly consists of two core parts：the analog front－end （AFE）and the ADC board．The AFE is responsible for the preliminary conditioning of weak bioelectrical signals，including amplification，filtering，interference suppression，and level shifting，so that the analog waveform can be converted into a stable and measurable form．The ADC board then performs high－resolution digitization of the conditioned signal and transfers the sampled data to the host computer for subsequent display，storage，and analysis．Therefore，the overall system forms a complete signal－acquisition chain from weak physiological input to digital output．&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_1.jpg|thumb|center|800px|Figure 2.1. Overall system architecture of the proposed physiological signal acquisition platform，including the AFE and ADC modules．]]&lt;br /&gt;
&lt;br /&gt;
=== sEMG AFE Design ===&lt;br /&gt;
&lt;br /&gt;
To collect the weak bioelectric potential signals of the human body，an analog front－end（AFE）suitable sEMG measurements was designed．The module is powered by an external 5 V supply，and the complete circuit includes a first－ stage instrumentation amplifier based on INA128（Texas Instruments，Dallas，TX，USA），a band－pass filter，a 50 Hz notch filter，a second－order amplification and level shifting stage，a driver electrode circuit，a precise 1.5 V reference source，and a -5 V voltage generation module for powering the operational amplifiers．&lt;br /&gt;
&lt;br /&gt;
==== First－order Amplifier ====&lt;br /&gt;
&lt;br /&gt;
The input bioelectric signal is first acquired in differential form and applied to the INA128 instrumentation amplifier，which provides high input impedance，high common－mode rejection，and moderate initial gain for sEMG acquisition．This stage enlarges the weak physiological signal before filtering while reducing the risk of premature saturation caused by electrode offset or motion－induced disturbance，thereby preparing a more stable signal for the subsequent conditioning stages．&lt;br /&gt;
&lt;br /&gt;
==== Bandpass Filter ====&lt;br /&gt;
&lt;br /&gt;
After the instrumentation amplifier，the signal passes through a second－order active band－pass filter，as shown in Figure 2．2． This stage suppresses baseline drift and high－frequency noise outside the useful sEMG range，so that the low－frequency envelope information of sEMG can be preserved before further amplification．&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_2.jpg|thumb|center|800px|Figure 2.2. Schematic diagram of the active band-pass filter used in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the band-pass stage used to retain the main physiological signal band while suppressing unwanted lowand high-frequency components.&lt;br /&gt;
&lt;br /&gt;
==== Notch Filter ====&lt;br /&gt;
&lt;br /&gt;
To reduce power-line interference, a dedicated 50 Hz notch filter is introduced after the band-pass stage, as shown in Figure 2.3. This filter attenuates the mains-frequency component that commonly contaminates weak bioelectric measurements, thereby improving the signal-to-noise ratio of sEMG signals before the final amplification stage.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_3.jpg|thumb|center|800px|Figure 2.3. Schematic diagram of the 50 Hz notch filter used in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the circuit used to attenuate 50 Hz mains interference in the analog front end.&lt;br /&gt;
&lt;br /&gt;
==== Second-order Amplifier &amp;amp; Level Shifter ====&lt;br /&gt;
&lt;br /&gt;
After filtering, the signal enters the second-stage amplification and level-shifting circuit shown in Figure 2.4. In this stage, the filtered signal is further amplified to improve amplitude utilization and then shifted by a 1.5 V reference so that the output becomes a stable unipolar signal suitable for ADC sampling, while preserving linear operation and providing sufficient output swing margin.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_4.jpg|thumb|center|800px|Figure 2.4. Schematic diagram of the second-stage amplifier and level-shifting circuit in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows how the conditioned signal is further amplified and shifted to a suitable DC level before digitization.&lt;br /&gt;
&lt;br /&gt;
==== Power Module and Drive-electrode Circuit ====&lt;br /&gt;
&lt;br /&gt;
The AFE is powered by a 5 V supply and also integrates a 1.5 V precision reference, a -5 V generation circuit, and a driveelectrode circuit. These supporting modules provide the required supply rails and reference level for analog signal conditioning, while the drive-electrode circuit feeds back common-mode voltage to the body to suppress interference at the source. As a result, the complete AFE can support sEMG acquisition with adequate gain, filtering, and noise-reduction performance in a compact hardware structure.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_5.jpg|thumb|center|800px|Figure 2.5. Physical picture of the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the fabricated sEMG analog front-end hardware used in the system.&lt;br /&gt;
&lt;br /&gt;
Figure 2.5 presents the practical hardware implementation of the proposed sEMG AFE. It integrates amplification, filtering, level shifting, and driven-reference functions in a compact circuit for weak bioelectrical signal acquisition.&lt;br /&gt;
&lt;br /&gt;
=== ADS1256-based ADC Board ===&lt;br /&gt;
&lt;br /&gt;
To digitize the conditioned weak physiological signals with sufficient resolution and low noise, this project developed a dedicated ADC board based on the ADS1256 analog-to-digital converter (Texas Instruments, Dallas, TX, USA) and the STM32F103C8T6 microcontroller (STMicroelectronics, Geneva, Switzerland). The overall design objective of this board was not merely to realize analog-to-digital conversion, but to provide a complete hardware interface between the analog front-end and the digital processing unit, including precision reference generation, clocking, input protection and filtering, serial communication, power regulation, and MCU-based acquisition control. The ADS1256 was selected because it is a&lt;br /&gt;
&lt;br /&gt;
very low-noise 24-bit delta-sigma converter with a programmable gain amplifier (PGA), flexible input multiplexer, programmable digital filter, and SPI-compatible serial interface, which makes it well suited for weak low-frequency physiological signals after analog conditioning. The STM32F103C8T6 was used as the local controller because it provides a 32-bit Cortex-M3 core, up to 72 MHz system clock, SPI, USART, USB, and standard SWD debugging support in a compact and low-cost platform.&lt;br /&gt;
&lt;br /&gt;
==== ADC Core Architecture and Design Rationale ====&lt;br /&gt;
&lt;br /&gt;
The ADS1256 was selected as the core ADC because it provides high-resolution, low-noise delta-sigma conversion with an input multiplexer, programmable gain amplifier, and digital filter, which are suitable for weak and low-frequency physiological signals. As shown in Figure 2.6, this architecture emphasizes resolution and noise performance rather than high conversion bandwidth, making it appropriate for sEMG signal digitization after analog conditioning.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_6.jpg|thumb|center|800px|Figure 2.6. Internal functional structure of the ADS1256 analog-to-digital converter.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the main internal blocks of the ADS1256, including the multiplexer, PGA, modulator, and digital filter.&lt;br /&gt;
&lt;br /&gt;
==== Analog Front-End Interface, Reference, and Clocking ====&lt;br /&gt;
&lt;br /&gt;
The ADS1256 analog inputs are connected to the external header through a passive input-conditioning network that helps suppress high-frequency interference and improve input stability. In addition, the board includes a dedicated precision reference and clocking circuits so that the ADC can perform stable and accurate conversion. Together, these circuits provide a reliable analog interface and timing basis for high-resolution digitization of weak physiological signals.&lt;br /&gt;
&lt;br /&gt;
==== SPI Interface between ADS1256 and STM32F103C8T6 ====&lt;br /&gt;
&lt;br /&gt;
Communication between the ADS1256 and the STM32F103C8T6 is implemented through an SPI-compatible interface, with dedicated lines for chip select, serial clock, input/output data, data-ready notification, and hardware reset. This connection allows the MCU to configure the ADC, read conversion results in synchrony with DRDY, and maintain efficient and reliable acquisition control for multi-channel physiological measurements.&lt;br /&gt;
&lt;br /&gt;
==== Power Supply and On-board Regulation ====&lt;br /&gt;
&lt;br /&gt;
The ADC board uses a USB Type-B connector as the main power input and includes protection, voltage regulation, and local decoupling circuits to provide a stable supply for both the MCU and ADC-related hardware. In addition, analog ground and digital ground are separated in the PCB layout to reduce digital noise coupling into the analog path, which is particularly important for weak physiological signal acquisition.&lt;br /&gt;
&lt;br /&gt;
==== Basic Peripheral Circuits of the STM32F103C8T6 ====&lt;br /&gt;
&lt;br /&gt;
The STM32F103C8T6 serves as the local controller of the ADC board and is supported by several basic peripheral circuits, including an external crystal oscillator, reset network, BOOT0 configuration, SWD programming/debugging header, and a CH340N USB-to-UART bridge. These circuits ensure stable MCU operation, convenient firmware downloading and debugging, and reliable data transmission from the board to the host computer for real-time display and storage.&lt;br /&gt;
&lt;br /&gt;
==== Hardware-level Working Principle of the ADC Board ====&lt;br /&gt;
&lt;br /&gt;
In operation, the conditioned analog signal from the AFE enters the ADS1256 through the input header, is digitized with high resolution under the control of the local precision reference and clock, and is then read by the STM32 through the SPI interface. The MCU subsequently forwards the sampled data to the host computer through the serial communication link, so that the entire board functions as a compact digital acquisition backend connecting weak physiological analog signals to later software processing, display, and storage.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_7.jpg|thumb|center|800px|Figure 2.7. Photograph of the fabricated ADS1256-based ADC board developed in this project and the definitions of some key pins.]]&lt;br /&gt;
&lt;br /&gt;
Figure 2.7 shows the ADC board fabricated for this project. It integrates the ADS1256 conversion core, STM32 control circuit, power-conditioning circuits, and communication interfaces on a compact PCB for physiological signal digitization.&lt;br /&gt;
&lt;br /&gt;
== Signal Conditioning and Filtering ==&lt;br /&gt;
Although the AFE already performs preliminary band-pass filtering and 50 Hz interference suppression in the analog domain, the digitized sEMG signal may still contain residual noise due to component tolerances, electrode-contact variation, and environmental interference. Therefore, an additional digital filtering stage is implemented in software as a complementary post-processing step to improve signal quality and to provide a more stable input for rectification, envelope extraction, and subsequent analysis. In this sense, the software filtering is not a simple repetition of the analog filtering, but a refinement and compensation for non-ideal front-end behavior.&lt;br /&gt;
&lt;br /&gt;
Surface electromyographic (sEMG) signals are highly susceptible to several sources of contamination during acquisition. In practical measurements, the dominant disturbances usually include low-frequency motion artifacts caused by electrode movement and electrode–skin impedance variation, narrow-band power-line interference centered at 50 Hz, and broadband high-frequency electronic noise introduced by the acquisition hardware. These unwanted components degrade the quality of the recorded signal and may significantly affect the reliability of subsequent feature extraction, parameter estimation, and muscle activity interpretation. For this reason, an effective signal-conditioning procedure is necessary before any higher-level analysis is performed.&lt;br /&gt;
&lt;br /&gt;
In the present implementation, the filtering strategy follows the principle of restricting the signal bandwidth first and then removing the remaining narrow-band interference in a targeted manner. Accordingly, the raw sEMG signal is first processed by a fourth-order Butterworth IIR band-pass filter and then by a 50 Hz notch filter. This processing sequence is illustrated in the flowchart below, where the signal passes through band-pass filtering, notch filtering, full-wave rectification, and envelope extraction before producing the final processed output.&lt;br /&gt;
&lt;br /&gt;
[[File:flowchart.png|thumb|center|500px|Flowchart of the real-time sEMG signal conditioning pipeline.]]&lt;br /&gt;
&lt;br /&gt;
The rationale of this order is that the &#039;&#039;&#039;band-pass stage&#039;&#039;&#039; first confines the signal to the main spectral region of interest for sEMG, thereby attenuating motion artifacts at very low frequencies and suppressing high-frequency noise components outside the physiological band. After this spectral preconditioning, the notch stage can more effectively suppress the residual 50 Hz power-line interference that lies inside the useful sEMG band. In transfer-function form, the band-pass filter may be written as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;H_{BP}(z)=\frac{B_{BP}(z)}{A_{BP}(z)}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where the effective passband is selected as &amp;lt;math&amp;gt;20 \leq f \leq 160 \text{ Hz}&amp;lt;/math&amp;gt;. This frequency interval is consistent with the dominant spectral content of surface EMG: the lower cutoff near 20 Hz reduces motion artifacts and unstable low-frequency fluctuations, whereas the upper cutoff near 160 Hz removes high-frequency electronic noise while preserving the main energy-bearing components of the muscle signal. The use of a Butterworth structure is appropriate here because it provides a smooth monotonic passband response without ripple, which helps preserve signal morphology in real-time applications.&lt;br /&gt;
&lt;br /&gt;
After band limitation, a &#039;&#039;&#039;notch filter&#039;&#039;&#039; centered at the power-line frequency is applied to suppress interference that cannot be removed by the band-pass stage alone. The notch filter is designed around &amp;lt;math&amp;gt;f_0 = 50 \text{ Hz}&amp;lt;/math&amp;gt;, and its bandwidth is controlled by the quality factor &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;, which is expressed as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;Q = \frac{f_0}{\Delta f}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In transfer-function form, the notch stage is written as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;H_{N}(z)=\frac{B_{N}(z)}{A_{N}(z)}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the implemented program, a large quality factor is chosen so that the notch remains narrow, allowing effective rejection of the 50 Hz interference while minimizing distortion of neighboring useful spectral components. This is particularly important for sEMG because the interference frequency lies directly inside the physiological band of interest.&lt;br /&gt;
&lt;br /&gt;
Following the filtering stages, further signal conditioning is performed to obtain a representation that is more directly related to muscle activation intensity. The filtered sEMG waveform is first &#039;&#039;&#039;full-wave rectified&#039;&#039;&#039;, which converts the bipolar oscillatory signal into a unipolar signal by taking its absolute value.  Rectification does not remove noise by itself; instead, it transforms the signal into a form that is more suitable for amplitude-based analysis because both positive and negative deflections contribute positively to the activation measure.&lt;br /&gt;
&lt;br /&gt;
After rectification, the signal envelope is extracted to provide a smooth estimate of muscle activation level over time. In a general formulation, the envelope can be described as the &#039;&#039;&#039;low-pass filtered&#039;&#039;&#039; version of the rectified signal, namely &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y_{\mathrm{env}}[n] = \mathrm{LPF}\bigl(y_{\mathrm{rect}}[n]\bigr)&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the present code implementation, this operation is realized by short-time averaging over a finite window, which is equivalent to a moving-average low-pass smoothing of the rectified waveform. The corresponding expression is &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y_{\mathrm{env}}[n] = \frac{1}{N}\sum_{k=0}^{N-1} |x[n-k]|&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; is the window length in samples. With a window duration of approximately 200 ms, this envelope extraction method provides a stable and physiologically meaningful representation of muscle activation intensity, making it suitable for tasks such as force estimation, fatigue analysis, and motor-control studies.&lt;br /&gt;
&lt;br /&gt;
An important feature of the present &#039;&#039;&#039;implementation&#039;&#039;&#039; is that the entire filtering process is performed &#039;&#039;&#039;in real time&#039;&#039;&#039;, sample by sample, rather than by offline block processing. For this reason, IIR filters are preferred over FIR filters, since they can achieve comparable filtering performance with lower order, lower computational cost, and shorter delay. These properties are especially valuable in embedded systems, serial data streaming, and other low-latency experimental applications. However, unlike memoryless operations, an IIR filter depends not only on the current input but also on previous inputs and previous outputs. Its discrete-time behavior can therefore be represented by the recursive difference equation &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y[n] = \sum_{k=0}^{M} b_k x[n-k] - \sum_{k=1}^{N} a_k y[n-k]&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This equation makes clear that internal filter states must be preserved continuously during streaming operation. If the state variables were reinitialized for every incoming sample or data segment, artificial transients would appear and the output would no longer remain continuous.&lt;br /&gt;
&lt;br /&gt;
In the Python implementation, this state continuity is maintained using the internal initial-condition mechanism provided by SciPy, such as &amp;lt;code&amp;gt;lfilter_zi&amp;lt;/code&amp;gt;, together with recursive state updates during each filtering call. As a result, each newly acquired sample is passed first through the band-pass filter and then through the notch filter, while the internal states of both filters are updated after every step. This state-preserving sample-by-sample design ensures that the processing chain remains causal, continuous, and suitable for real-time display or downstream analysis without requiring storage of the entire signal segment.&lt;br /&gt;
&lt;br /&gt;
Overall, this signal-conditioning scheme provides an experimentally practical solution for real-time sEMG processing. The fourth-order Butterworth band-pass filter confines the signal to the main physiological band of interest, the 50 Hz notch filter removes narrow-band power-line contamination, and the subsequent rectification and envelope extraction generate a smooth amplitude descriptor of muscle activity. Combined with state-preserved streaming IIR implementation, this approach achieves a good balance between signal fidelity, computational efficiency, and real-time applicability in biomedical and physical experiment settings.&lt;br /&gt;
&lt;br /&gt;
== Experimental Setup ==&lt;br /&gt;
&lt;br /&gt;
=== Experimental Demonstration ===&lt;br /&gt;
&lt;br /&gt;
The experimental setup and data acquisition process are demonstrated in the video below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;text-align:center;&amp;quot;&amp;gt;&lt;br /&gt;
[[File:EMG_Experiment.mp4|center|800px]]&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The video illustrates the complete measurement procedure, including electrode placement, muscle activation, and real-time EMG signal visualization.&lt;br /&gt;
&lt;br /&gt;
=== Experimental Procedure ===&lt;br /&gt;
&lt;br /&gt;
Surface EMG signals were acquired using disposable electrodes placed on the forearm muscles responsible for wrist extension. &lt;br /&gt;
&lt;br /&gt;
Three electrodes were used in the measurement setup:&lt;br /&gt;
&lt;br /&gt;
* One electrode placed on the back of the hand serves as the reference electrode  &lt;br /&gt;
* The other two electrodes placed along the forearm muscle act as the differential input electrodes (positive and negative)  &lt;br /&gt;
&lt;br /&gt;
This configuration enables differential measurement of EMG signals while suppressing common-mode noise.&lt;br /&gt;
&lt;br /&gt;
The experimental movement consists of making a fist while extending the wrist backward. This action activates the forearm extensor muscles beneath the electrodes, producing measurable EMG signals.&lt;br /&gt;
&lt;br /&gt;
=== Data Acquisition Protocol ===&lt;br /&gt;
&lt;br /&gt;
Each subject performed repeated contraction–relaxation cycles under controlled conditions:&lt;br /&gt;
&lt;br /&gt;
* Number of subjects: 3  &lt;br /&gt;
* Number of trials per subject: 3  &lt;br /&gt;
* Duration of each trial: 30 seconds  &lt;br /&gt;
&lt;br /&gt;
During each trial, subjects were instructed to periodically contract and relax the muscle to generate clear dynamic EMG signals, while maintaining a stable resting state between contractions.&lt;br /&gt;
&lt;br /&gt;
=== System and Measurement Conditions ===&lt;br /&gt;
&lt;br /&gt;
The EMG signals were recorded and visualized in real time using a data acquisition system connected to a computer. The sampling rate was set to 400 Hz.&lt;br /&gt;
&lt;br /&gt;
To ensure consistency across measurements:&lt;br /&gt;
&lt;br /&gt;
* Electrode placement was kept consistent for all subjects  &lt;br /&gt;
* The same movement protocol was followed  &lt;br /&gt;
* Measurements were conducted under similar environmental conditions  &lt;br /&gt;
&lt;br /&gt;
=== Summary ===&lt;br /&gt;
&lt;br /&gt;
This experimental setup enables reliable acquisition of both resting and dynamic EMG signals, providing a consistent dataset for subsequent signal processing and performance evaluation.&lt;br /&gt;
&lt;br /&gt;
== Data Processing ==&lt;br /&gt;
&lt;br /&gt;
The objective of data processing is to convert raw surface electromyography (sEMG) recordings into stable, quantitative, and comparable indicators of muscle activity. Since EMG signals are low in amplitude, highly variable over time, and easily contaminated by noise, a dedicated processing pipeline is necessary before any experimental interpretation can be performed.&lt;br /&gt;
&lt;br /&gt;
In this project, the data processing workflow includes time normalization, signal pre-processing, sliding-window feature extraction, noise-floor estimation, and automatic contraction detection. The processed outputs are then used for subsequent experimental evaluation, including rest-versus-contraction discrimination, signal-to-noise ratio analysis, and repeatability assessment.&lt;br /&gt;
&lt;br /&gt;
=== Input Data and Time Normalization ===&lt;br /&gt;
&lt;br /&gt;
The acquired EMG data are read from CSV files containing two columns: time and filtered sEMG amplitude. In the MATLAB implementation, the time vector is normalized so that each recording starts from zero:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t = t_{all} - t_{all}(1)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This normalization is important because it removes the influence of absolute recording timestamps and makes different trials directly comparable on the same time axis.&lt;br /&gt;
&lt;br /&gt;
In addition, the signal type is automatically identified from the filename as either dynamic or rest. This design allows the same program to process both contraction recordings and resting recordings with different downstream analysis logic.&lt;br /&gt;
&lt;br /&gt;
=== Signal Pre-processing ===&lt;br /&gt;
&lt;br /&gt;
Raw EMG signals cannot be analyzed directly because they usually contain DC offset, low-frequency drift, motion artifacts, and residual high-frequency interference. Therefore, several pre-processing steps are applied before feature extraction.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(1) Baseline Removal&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The first step is DC offset removal:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
x_{dc}(t) = x(t) - \frac{1}{N}\sum_{i=1}^{N}x(i)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This operation centers the signal around zero. It is necessary because an uncorrected baseline would bias amplitude-based metrics and reduce the reliability of later envelope and feature calculations.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(2) Band-pass Filtering &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
After baseline correction, a fourth-order Butterworth band-pass filter is applied with a passband of 20–150 Hz.&lt;br /&gt;
&lt;br /&gt;
This step is introduced for two reasons:&lt;br /&gt;
&lt;br /&gt;
* The low-frequency cutoff at 20 Hz suppresses baseline drift and motion artifacts.&lt;br /&gt;
* The high-frequency cutoff at 150 Hz reduces unwanted high-frequency noise while preserving the main energy band of the recorded sEMG in this project.&lt;br /&gt;
&lt;br /&gt;
Compared with processing the raw waveform directly, band-pass filtering makes the subsequent time-domain features more stable and more physiologically meaningful.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(3) Full-wave Rectification&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The filtered EMG signal is bipolar, meaning that positive and negative phases coexist due to motor unit action potentials. If these positive and negative components are averaged directly, they may cancel each other out. To avoid this, full-wave rectification is performed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
x_{rect}(t) = |x_{filt}(t)|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This transforms the signal into a unipolar representation, so that all muscle activity contributes positively to the extracted features.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(4) Envelope Extraction &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Although the rectified signal reflects signal magnitude, it still fluctuates rapidly. To obtain a smoother representation of muscle activation level, an envelope is extracted using a moving average with a 100 ms window.&lt;br /&gt;
&lt;br /&gt;
Envelope extraction is important because contraction detection should reflect the overall activation trend rather than instantaneous spikes. A smoothed envelope is therefore more robust for identifying active and inactive muscle states.&lt;br /&gt;
&lt;br /&gt;
=== Sliding Window Design ===&lt;br /&gt;
&lt;br /&gt;
To quantify how muscle activity changes with time, the filtered signal is divided into overlapping short-time segments using a sliding window method.&lt;br /&gt;
&lt;br /&gt;
The window parameters are:&lt;br /&gt;
&lt;br /&gt;
* Window length: 250 ms&lt;br /&gt;
* Step size: 50 ms&lt;br /&gt;
&lt;br /&gt;
These values are chosen as a trade-off between temporal resolution and feature stability.&lt;br /&gt;
&lt;br /&gt;
A longer window improves statistical robustness because more samples are included in each calculation. However, if the window is too long, short contractions or rapid changes may be blurred. A smaller step size increases temporal continuity between adjacent feature points and makes the feature curves smoother in time. Therefore, the 250 ms / 50 ms design provides a practical balance between smoothing and time localization.&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt;-th segment, the feature time is defined as the mean time of that segment:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t_k = \frac{1}{N}\sum_{i=s_k}^{e_k} t(i)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;s_k&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;e_k&amp;lt;/math&amp;gt; denote the start and end indices of the window.&lt;br /&gt;
&lt;br /&gt;
=== Feature Extraction ===&lt;br /&gt;
&lt;br /&gt;
Within each sliding window, three time-domain features are extracted: RMS, iEMG, and MAV. These features are widely used in EMG analysis because they are simple, computationally efficient, and directly related to muscle activation intensity.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(1) Root Mean Square (RMS)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
RMS = \sqrt{\frac{1}{N}\sum_{i=1}^{N}x_i^2}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
RMS reflects the effective power of the EMG signal and is one of the most common indicators of contraction strength. It is sensitive to both amplitude and energy, making it especially useful for comparing rest and active states.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(2) Integrated EMG (iEMG)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
iEMG = \sum_{i=1}^{N}|x_i|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
iEMG describes the cumulative electrical activity within a window. It is often interpreted as a measure of total muscle effort over that time segment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(3) Mean Absolute Value (MAV)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
MAV = \frac{1}{N}\sum_{i=1}^{N}|x_i|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
MAV is an amplitude descriptor similar to iEMG, but normalized by the number of samples. It provides an efficient estimate of average signal level and is less computationally intensive than some other features.&lt;br /&gt;
&lt;br /&gt;
These three features are used together because they provide complementary descriptions of EMG intensity. RMS emphasizes signal energy, iEMG emphasizes cumulative activation, and MAV reflects average amplitude.&lt;br /&gt;
&lt;br /&gt;
=== Peak-value Extraction ===&lt;br /&gt;
&lt;br /&gt;
In addition to continuous feature curves, several key peak values are extracted from the processed signal:&lt;br /&gt;
&lt;br /&gt;
* maximum and minimum of the filtered EMG waveform&lt;br /&gt;
* peak of the envelope&lt;br /&gt;
* peak RMS&lt;br /&gt;
* peak iEMG&lt;br /&gt;
* peak MAV&lt;br /&gt;
&lt;br /&gt;
These peak values provide concise descriptors of the strongest activity observed in each recording. They are useful for quick comparison across trials and subjects.&lt;br /&gt;
&lt;br /&gt;
=== Noise Floor Estimation ===&lt;br /&gt;
&lt;br /&gt;
To evaluate signal quality, the noise floor is estimated from a reference resting interval. In the present implementation, the first 3 seconds of the recording are used as the default rest reference:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t \in [0,\min(3,t_{end})]&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this segment, three noise descriptors are computed:&lt;br /&gt;
&lt;br /&gt;
* Noise RMS&lt;br /&gt;
* Noise standard deviation&lt;br /&gt;
* Noise peak-to-peak amplitude&lt;br /&gt;
&lt;br /&gt;
Noise-floor estimation is important because EMG amplitude alone is not sufficient to judge recording quality. A large signal is only meaningful if it is sufficiently higher than the baseline noise level. Therefore, the noise floor serves as the reference for later SNR calculation and for designing contraction thresholds.&lt;br /&gt;
&lt;br /&gt;
=== Global Signal Metrics ===&lt;br /&gt;
&lt;br /&gt;
For each recording, three global metrics are also computed over the entire filtered signal:&lt;br /&gt;
&lt;br /&gt;
* Global RMS&lt;br /&gt;
* Global MAV&lt;br /&gt;
* Global iEMG&lt;br /&gt;
&lt;br /&gt;
These global descriptors summarize the overall signal level of the full recording and are later used in group-level comparisons.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Contraction Detection ===&lt;br /&gt;
&lt;br /&gt;
For dynamic recordings, an automatic contraction detection algorithm is used to identify repeated active segments. This is one of the key parts of the data processing pipeline, because it transforms a continuous EMG trace into discrete contraction events that can be counted and compared.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(1) Threshold Design&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The detection threshold is designed adaptively rather than using a fixed value. Two candidate thresholds are first calculated:&lt;br /&gt;
&lt;br /&gt;
* an envelope-based threshold derived from the global envelope mean and standard deviation&lt;br /&gt;
* a rest-reference threshold derived from the mean and standard deviation of the resting reference amplitude&lt;br /&gt;
&lt;br /&gt;
The final threshold is taken as the larger of the two after additional scaling. This strategy improves robustness because it combines the global activation level of the signal with the baseline noise characteristics of the individual recording.&lt;br /&gt;
&lt;br /&gt;
This adaptive threshold design is preferable to a manually fixed threshold because EMG amplitude can vary strongly between subjects, muscles, and recording sessions.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(2) Initial Segmentation&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
After thresholding the envelope, the signal is classified into active and inactive regions:&lt;br /&gt;
&lt;br /&gt;
* active: envelope above threshold&lt;br /&gt;
* inactive: envelope below threshold&lt;br /&gt;
&lt;br /&gt;
The rising and falling edges of the binary activity vector are then used to determine the start and end points of each candidate contraction segment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(3) Removal of Short Segments&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Very short active regions are often caused by noise fluctuations rather than true muscle contractions. Therefore, segments shorter than 0.20 s are discarded.&lt;br /&gt;
&lt;br /&gt;
This step prevents false positive detections and increases the physiological relevance of the segmentation results.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(4) Merging of Adjacent Segments &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If two neighboring active segments are separated by a very short gap, they are merged when the gap is less than 0.15 s.&lt;br /&gt;
&lt;br /&gt;
This operation is necessary because a single real contraction may be temporarily interrupted by a brief drop in the envelope caused by local fluctuation. Without merging, one contraction could be incorrectly counted as multiple repetitions.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(5) Repetition-level Metrics &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
For each detected contraction segment, two repetition-level metrics are extracted:&lt;br /&gt;
&lt;br /&gt;
* peak RMS of that contraction&lt;br /&gt;
* mean RMS of that contraction&lt;br /&gt;
&lt;br /&gt;
These metrics quantify both the strongest activation within each repetition and the average activation level over the repetition duration.&lt;br /&gt;
&lt;br /&gt;
=== Repeatability Analysis ===&lt;br /&gt;
&lt;br /&gt;
When multiple valid contractions are detected, repeatability is evaluated using the coefficient of variation (CV):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
CV = \frac{\sigma}{\mu}\times 100\%&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt; is the standard deviation and &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is the mean value across repetitions.&lt;br /&gt;
&lt;br /&gt;
Two CV values are computed:&lt;br /&gt;
&lt;br /&gt;
* CV of repetition peak RMS&lt;br /&gt;
* CV of repetition mean RMS&lt;br /&gt;
&lt;br /&gt;
A lower CV indicates better repeatability, meaning that repeated contractions produce more consistent EMG responses.&lt;br /&gt;
&lt;br /&gt;
=== Signal-to-Noise Ratio (SNR) ===&lt;br /&gt;
&lt;br /&gt;
In this project, the signal-to-noise ratio (SNR) is defined based on the ratio between contraction and rest activity:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
SNR_{dB} = 20\log_{10}\left(\frac{RMS_{contraction}}{RMS_{rest}}\right)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This definition is adopted because it directly reflects the system’s ability to distinguish active muscle contraction from baseline noise.&lt;br /&gt;
&lt;br /&gt;
Compared with global SNR definitions, this formulation is more relevant for practical EMG applications such as activity detection and classification.&lt;br /&gt;
&lt;br /&gt;
=== Rest-versus-Contraction Window Comparison ===&lt;br /&gt;
&lt;br /&gt;
To further distinguish inactive and active states, all sliding windows are divided into two groups:&lt;br /&gt;
&lt;br /&gt;
* rest windows: windows with envelope clearly below the threshold&lt;br /&gt;
* contraction windows: windows with envelope above the threshold&lt;br /&gt;
&lt;br /&gt;
The RMS values of these two groups are then compared statistically.&lt;br /&gt;
&lt;br /&gt;
This comparison is important because a practical EMG system should not only detect signal presence, but also clearly separate rest from contraction in a quantitative way. If the two RMS distributions are well separated, it indicates that the system has good discriminative capability.&lt;br /&gt;
&lt;br /&gt;
=== Output Data Structure ===&lt;br /&gt;
&lt;br /&gt;
The processed outputs are organized into structured data for experimental analysis:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(1) Time-series outputs&#039;&#039;&#039;&lt;br /&gt;
* Filtered EMG signal  &lt;br /&gt;
* Rectified signal  &lt;br /&gt;
* Envelope  &lt;br /&gt;
* RMS(t), iEMG(t), MAV(t)  &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(2) Recording-level outputs&#039;&#039;&#039; &lt;br /&gt;
* RMS (rest)  &lt;br /&gt;
* RMS (contraction)  &lt;br /&gt;
* iEMG  &lt;br /&gt;
* Noise metrics  &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(3) Dynamic-signal outputs &#039;&#039;&#039;&lt;br /&gt;
* Detected contractions  &lt;br /&gt;
* Repetition count  &lt;br /&gt;
* Peak RMS per repetition  &lt;br /&gt;
* Mean RMS per repetition  &lt;br /&gt;
* Coefficient of variation (CV)  &lt;br /&gt;
* Signal-to-noise ratio (SNR)  &lt;br /&gt;
&lt;br /&gt;
All extracted features are designed to directly support the evaluation of noise level, signal quality, activity discrimination, and repeatability in the subsequent experimental analysis.&lt;br /&gt;
&lt;br /&gt;
== Experimental Results ==&lt;br /&gt;
&lt;br /&gt;
This section presents representative results of the EMG acquisition and data processing pipeline under both dynamic (muscle contraction) and resting conditions.&lt;br /&gt;
&lt;br /&gt;
=== Representative Dynamic Signal Analysis ===&lt;br /&gt;
&lt;br /&gt;
[[File:Dynamic_Figure1.png|thumb|800px|center|Figure 5.1: Processed EMG signal under dynamic contraction, including filtered signal, rectified signal with envelope, and extracted features (RMS, iEMG, MAV).]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.1 shows the processed EMG signal during repeated muscle contractions.&lt;br /&gt;
&lt;br /&gt;
The filtered EMG waveform exhibits clear burst-like patterns corresponding to periodic contractions. The signal amplitude reaches a maximum of approximately 0.45, while the baseline remains centered around zero, indicating effective baseline removal and filtering.&lt;br /&gt;
&lt;br /&gt;
After rectification and envelope extraction, the contraction periods become clearly distinguishable. The envelope provides a smooth representation of muscle activation, with a peak value of approximately 0.145.&lt;br /&gt;
&lt;br /&gt;
The extracted time-domain features (RMS, iEMG, MAV) further quantify the signal. Among these, iEMG shows the strongest dynamic variation, indicating high sensitivity to contraction intensity.&lt;br /&gt;
&lt;br /&gt;
=== Noise Floor and Rest Reference ===&lt;br /&gt;
&lt;br /&gt;
[[File:Dynamic_Figure2.png|thumb|800px|center|Figure 5.2: Noise estimation, rest vs contraction comparison, automatic contraction detection, and repetition analysis.]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (top-left) shows the resting reference segment used for noise estimation.&lt;br /&gt;
&lt;br /&gt;
The signal remains centered around zero with small fluctuations. The noise characteristics are:&lt;br /&gt;
&lt;br /&gt;
* Noise RMS ≈ 0.0046  &lt;br /&gt;
* Standard deviation ≈ 0.0046  &lt;br /&gt;
* Peak-to-peak amplitude ≈ 0.071  &lt;br /&gt;
&lt;br /&gt;
This indicates a low noise floor and stable measurement conditions.&lt;br /&gt;
&lt;br /&gt;
=== Rest vs Contraction Discrimination ===&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (top-right) compares RMS values between rest and contraction states.&lt;br /&gt;
&lt;br /&gt;
The two distributions are clearly separated:&lt;br /&gt;
&lt;br /&gt;
* Rest mean RMS ≈ 0.0053  &lt;br /&gt;
* Contraction mean RMS ≈ 0.1064  &lt;br /&gt;
&lt;br /&gt;
This corresponds to an approximate 20× increase, demonstrating strong discriminability between inactive and active muscle states.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Contraction Detection ===&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (bottom-left) illustrates automatic detection based on the envelope signal.&lt;br /&gt;
&lt;br /&gt;
A threshold of approximately 0.040 is applied, resulting in stable segmentation of contraction periods.&lt;br /&gt;
&lt;br /&gt;
A total of 12 repetitions are detected, with good alignment to visible signal peaks.&lt;br /&gt;
&lt;br /&gt;
=== Repeatability Analysis ===&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (bottom-right) shows the peak RMS value of each detected contraction.&lt;br /&gt;
&lt;br /&gt;
The results indicate:&lt;br /&gt;
&lt;br /&gt;
* Mean peak RMS ≈ 0.1355  &lt;br /&gt;
* Standard deviation ≈ 0.0173  &lt;br /&gt;
* CV ≈ 12.77%  &lt;br /&gt;
* SNR ≈ 21.26 dB  &lt;br /&gt;
&lt;br /&gt;
This indicates acceptable repeatability and good signal quality.&lt;br /&gt;
&lt;br /&gt;
=== Representative Rest Signal Analysis ===&lt;br /&gt;
&lt;br /&gt;
[[File:Rest_Figure1.png|thumb|800px|center|Figure 5.3: Processed EMG signal under rest condition, showing low amplitude and absence of contraction patterns.]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.3 shows the EMG signal under resting conditions.&lt;br /&gt;
&lt;br /&gt;
The signal remains within a narrow amplitude range (approximately ±0.04) and shows no burst-like structures. The envelope remains close to zero, confirming the absence of muscle activity.&lt;br /&gt;
&lt;br /&gt;
The extracted features remain low:&lt;br /&gt;
&lt;br /&gt;
* RMS ≈ 0.007  &lt;br /&gt;
* MAV ≈ 0.005  &lt;br /&gt;
* iEMG remains stable  &lt;br /&gt;
&lt;br /&gt;
This confirms that no false activation is detected.&lt;br /&gt;
&lt;br /&gt;
=== Frequency-domain Characteristics ===&lt;br /&gt;
&lt;br /&gt;
[[File:Rest_Figure2.png|thumb|800px|center|Figure 5.4: Frequency-domain analysis and statistical characteristics of rest signal.]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.4 shows the frequency-domain characteristics of the resting signal.&lt;br /&gt;
&lt;br /&gt;
The power spectral density (PSD) indicates low overall signal energy without dominant peaks, confirming that the signal mainly consists of noise.&lt;br /&gt;
&lt;br /&gt;
=== Summary of Single-recording Performance ===&lt;br /&gt;
&lt;br /&gt;
From the representative results:&lt;br /&gt;
&lt;br /&gt;
* EMG signals are effectively extracted and denoised  &lt;br /&gt;
* Contraction events are clearly identifiable  &lt;br /&gt;
* Rest and contraction states are well separated  &lt;br /&gt;
* Automatic detection is stable and accurate  &lt;br /&gt;
* Repeatability is acceptable  &lt;br /&gt;
* No false activation occurs under rest conditions  &lt;br /&gt;
&lt;br /&gt;
=== Consistency Across Multiple Recordings ===&lt;br /&gt;
&lt;br /&gt;
The same data processing pipeline was applied to multiple recordings from different subjects and trials.&lt;br /&gt;
&lt;br /&gt;
Across all datasets, consistent patterns were observed:&lt;br /&gt;
&lt;br /&gt;
* Dynamic signals exhibit clear burst-like structures corresponding to repeated muscle contractions  &lt;br /&gt;
* Rest signals remain low in amplitude without distinct activation patterns  &lt;br /&gt;
* RMS values under contraction are consistently higher than those under rest  &lt;br /&gt;
* The automatic detection algorithm reliably identifies contraction segments  &lt;br /&gt;
&lt;br /&gt;
Although quantitative values (e.g., RMS, SNR, CV) vary across recordings due to differences in electrode contact, muscle activation strength, and individual conditions, the overall trends remain consistent.&lt;br /&gt;
&lt;br /&gt;
These results demonstrate the robustness and general applicability of the proposed signal processing method.&lt;br /&gt;
&lt;br /&gt;
== Multi-subject Analysis ==&lt;br /&gt;
=== System Evaluation ===&lt;br /&gt;
&lt;br /&gt;
This section evaluates the performance of the EMG acquisition system in terms of noise level, signal quality, activity discrimination, and repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Noise Floor Analysis ====&lt;br /&gt;
&lt;br /&gt;
The noise floor was evaluated using rest-state recordings, characterized by RMS noise, standard deviation, and peak-to-peak amplitude.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039; shows the lowest noise level (RMS ≈ 0.0046), indicating stable electrode contact and minimal interference.  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039; exhibits moderate noise (RMS ≈ 0.0080), likely influenced by motion artifacts or electrode–skin impedance variation.  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039; shows relatively higher noise (RMS ≈ 0.0126), suggesting increased baseline fluctuation.  &lt;br /&gt;
&lt;br /&gt;
Overall, the system maintains a low noise floor across subjects, although the quality depends on experimental conditions such as electrode contact and environmental interference.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Signal-to-Noise Ratio (SNR) ====&lt;br /&gt;
&lt;br /&gt;
The signal-to-noise ratio (SNR) is defined as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{SNR (dB)} = 20 \log_{10} \left( \frac{\mathrm{RMS}_{\mathrm{contraction}}}{\mathrm{RMS}_{\mathrm{rest}}} \right)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The measured SNR values are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: 21.26 dB → good signal quality  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: 13.52 dB → moderate and usable  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: 6.66 dB → low signal clarity  &lt;br /&gt;
&lt;br /&gt;
General interpretation:&lt;br /&gt;
&lt;br /&gt;
* &amp;gt;20 dB → good  &lt;br /&gt;
* 10–20 dB → usable  &lt;br /&gt;
* &amp;lt;10 dB → poor  &lt;br /&gt;
&lt;br /&gt;
These results show that the system can achieve reliable signal acquisition, although performance varies across subjects.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
====  Rest vs Contraction Discrimination ====&lt;br /&gt;
&lt;br /&gt;
A clear distinction between rest and contraction states is observed based on RMS values.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: 0.0053 → 0.1064 (≈20× increase)  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: 0.0079 → 0.0283 (≈3.6× increase)  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: 0.0141 → 0.0646 (≈4.6× increase)  &lt;br /&gt;
&lt;br /&gt;
This demonstrates that the system is capable of separating muscle activity from baseline noise.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Conclusion:&#039;&#039;  &lt;br /&gt;
The system can be used for basic muscle activity detection and simple classification tasks based on RMS features.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Repeatability of Repeated Contractions ====&lt;br /&gt;
&lt;br /&gt;
Repeatability is evaluated using the coefficient of variation (CV) of peak RMS values across repetitions.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! CV Range !! Evaluation&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt; 10% || Excellent&lt;br /&gt;
|-&lt;br /&gt;
| 10–20% || Acceptable&lt;br /&gt;
|-&lt;br /&gt;
| &amp;gt; 20% || Poor&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Results:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: CV = 12.77% → Acceptable  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: CV = 24.77% → Poor  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: CV = 10.60% → Acceptable  &lt;br /&gt;
&lt;br /&gt;
Although WANG&#039;s signal is detectable, its contraction amplitude varies significantly across repetitions, resulting in poor repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
=== Overall System Performance ===&lt;br /&gt;
&lt;br /&gt;
The system demonstrates the following performance characteristics:&lt;br /&gt;
&lt;br /&gt;
* Reliable detection of muscle activity across all subjects  &lt;br /&gt;
* Clear separation between rest and contraction states  &lt;br /&gt;
* Moderate to high signal quality depending on subject conditions  &lt;br /&gt;
* Repeatability ranging from acceptable to poor due to user-dependent factors  &lt;br /&gt;
&lt;br /&gt;
Overall, the designed EMG acquisition system is capable of stable signal acquisition and feature extraction, with performance primarily influenced by electrode contact quality, skin impedance, and motion consistency.&lt;br /&gt;
&lt;br /&gt;
===== Summary of Quantitative Metrics =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Subject !! RMS (Rest) !! RMS (Contraction) !! Separation Ratio !! iEMG (max) !! Noise RMS !! SNR (dB) !! CV (%) !! Evaluation&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;LIU&#039;&#039;&#039; || 0.0053 || 0.1064 || &#039;&#039;&#039;20.1×&#039;&#039;&#039; || 12.72 || 0.0046 || &#039;&#039;&#039;21.26&#039;&#039;&#039; || 12.77 || Strong signal, good quality&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;WANG&#039;&#039;&#039; || 0.0079 || 0.0283 || 3.57× || 11.10 || 0.0080 || 13.52 || &#039;&#039;&#039;24.77&#039;&#039;&#039; || Usable signal, poor repeatability&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ZHONG&#039;&#039;&#039; || 0.0141 || 0.0646 || 4.58× || 6.70 || 0.0126 || 6.66 || 10.60 || Acceptable performance&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Summary:&#039;&#039; Subject LIU shows the best overall performance, WANG provides usable but less stable signals, and ZHONG demonstrates moderate signal quality with good repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Activation Intensity =====&lt;br /&gt;
&lt;br /&gt;
Among the three subjects, &#039;&#039;&#039;LIU exhibits the strongest muscle activation&#039;&#039;&#039;, as indicated by the highest contraction RMS and iEMG values. ZHONG shows moderate activation, while WANG demonstrates comparable iEMG but lower RMS consistency.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Signal Quality =====&lt;br /&gt;
&lt;br /&gt;
Signal quality is evaluated based on SNR and noise level:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039; achieves the highest SNR and lowest noise → best signal quality  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039; shows moderate SNR → usable but less robust  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039; has the lowest SNR → weakest signal clarity  &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Repeatability =====&lt;br /&gt;
&lt;br /&gt;
Repeatability is evaluated using the coefficient of variation (CV):&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;ZHONG (10.60%)&#039;&#039;&#039; → most stable  &lt;br /&gt;
* &#039;&#039;&#039;LIU (12.77%)&#039;&#039;&#039; → acceptable  &lt;br /&gt;
* &#039;&#039;&#039;WANG (24.77%)&#039;&#039;&#039; → poor  &lt;br /&gt;
&lt;br /&gt;
This indicates that WANG’s contraction strength varies significantly between repetitions.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Engineering Interpretation of Inter-subject Differences =====&lt;br /&gt;
&lt;br /&gt;
The observed differences are mainly attributed to engineering and experimental factors rather than physiological differences.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Electrode contact quality&#039;&#039;&#039;  &lt;br /&gt;
  Variations in electrode placement, pressure, and gel contact affect signal amplitude and stability.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Skin impedance&#039;&#039;&#039;  &lt;br /&gt;
  Differences in skin condition (hydration, oil, hair) influence electrode–skin impedance, affecting noise level and signal coupling.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Muscle control consistency&#039;&#039;&#039;  &lt;br /&gt;
  Variations in contraction strength and timing affect repeatability and CV.&lt;br /&gt;
&lt;br /&gt;
Therefore, the variation across subjects reflects practical acquisition conditions rather than intrinsic system limitations.&lt;/div&gt;</summary>
		<author><name>Wang Jingyi</name></author>
	</entry>
	<entry>
		<id>https://pc5271.org/index.php?title=File:EMG_Experiment.mp4&amp;diff=1372</id>
		<title>File:EMG Experiment.mp4</title>
		<link rel="alternate" type="text/html" href="https://pc5271.org/index.php?title=File:EMG_Experiment.mp4&amp;diff=1372"/>
		<updated>2026-04-23T07:55:32Z</updated>

		<summary type="html">&lt;p&gt;Wang Jingyi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Wang Jingyi</name></author>
	</entry>
	<entry>
		<id>https://pc5271.org/index.php?title=Surface_EMG_Sensor_for_Muscle_Activity_Measurement:_AFE_Design_and_Signal_Processing&amp;diff=1369</id>
		<title>Surface EMG Sensor for Muscle Activity Measurement: AFE Design and Signal Processing</title>
		<link rel="alternate" type="text/html" href="https://pc5271.org/index.php?title=Surface_EMG_Sensor_for_Muscle_Activity_Measurement:_AFE_Design_and_Signal_Processing&amp;diff=1369"/>
		<updated>2026-04-23T07:51:21Z</updated>

		<summary type="html">&lt;p&gt;Wang Jingyi: /* Experimental Setup */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Background and Theory==&lt;br /&gt;
&lt;br /&gt;
=== Surface EMG Signals ===&lt;br /&gt;
Surface electromyography (sEMG) refers to the bioelectrical signals detected on the skin surface during muscle contraction. These signals originate from the electrical activity of muscle fibers and provide a non-invasive way to monitor muscle activation. Compared with invasive EMG methods, sEMG is easier to apply, safer for repeated measurements, and more suitable for real-time monitoring. Therefore, it has been widely used in areas such as rehabilitation, motion analysis, human–machine interaction, and physiological monitoring.&lt;br /&gt;
&lt;br /&gt;
=== Characteristics of EMG Signals ===&lt;br /&gt;
EMG signals are generally weak, time-varying, and stochastic in nature. Their waveforms are typically bipolar, fluctuating around zero with both positive and negative components. The amplitude and frequency content of EMG signals depend on factors such as muscle contraction level, electrode placement, skin condition, and individual physiological differences. In practice, the useful frequency components of sEMG are mainly concentrated in a limited low-to-mid frequency range. Because of their low amplitude and variability, EMG signals usually require further conditioning before reliable interpretation and feature extraction can be performed.&lt;br /&gt;
&lt;br /&gt;
=== Bioelectrical Signal Acquisition Principles ===&lt;br /&gt;
The acquisition of bioelectrical signals is based on measuring the small potential difference on the skin surface using electrodes, then converting it into a processable electrical signal through amplification and digitization. For sEMG measurement, electrode placement and skin–electrode contact quality are especially important, since they directly affect signal amplitude and stability. In addition, the front-end acquisition circuit must provide sufficient sensitivity and good interference rejection, so that the recorded signal reflects actual muscle activity rather than environmental disturbance or poor contact conditions.&lt;br /&gt;
&lt;br /&gt;
=== Noise Sources in EMG (50 Hz, motion artifacts) ===&lt;br /&gt;
In practical EMG recording, the measured signal is easily contaminated by different types of noise. Two of the most common sources are power-line interference and motion artifacts. Power-line interference usually appears as a narrow-band component at 50 Hz in the local electrical environment, while motion artifacts are mainly caused by electrode movement, cable disturbance, or variations in the electrode–skin impedance, and are often concentrated in the low-frequency range. In addition, electronic noise from the acquisition hardware may also affect the recording quality. These unwanted components can reduce signal clarity and make muscle activity analysis less reliable, so they must be considered in the design of the signal processing pipeline.&lt;br /&gt;
[[File:background_theory_figure1.1_emg_noise_sources.png|center|thumb|700px|&#039;&#039;&#039;Figure 1.1.&#039;&#039;&#039; Principle of surface EMG acquisition.]]&lt;br /&gt;
&lt;br /&gt;
==System Architecture==&lt;br /&gt;
=== Total Structure Design ===&lt;br /&gt;
&lt;br /&gt;
For clarity，the proposed physiological signal acquisition system mainly consists of two core parts：the analog front－end （AFE）and the ADC board．The AFE is responsible for the preliminary conditioning of weak bioelectrical signals，including amplification，filtering，interference suppression，and level shifting，so that the analog waveform can be converted into a stable and measurable form．The ADC board then performs high－resolution digitization of the conditioned signal and transfers the sampled data to the host computer for subsequent display，storage，and analysis．Therefore，the overall system forms a complete signal－acquisition chain from weak physiological input to digital output．&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_1.jpg|thumb|center|800px|Figure 2.1. Overall system architecture of the proposed physiological signal acquisition platform，including the AFE and ADC modules．]]&lt;br /&gt;
&lt;br /&gt;
=== sEMG AFE Design ===&lt;br /&gt;
&lt;br /&gt;
To collect the weak bioelectric potential signals of the human body，an analog front－end（AFE）suitable sEMG measurements was designed．The module is powered by an external 5 V supply，and the complete circuit includes a first－ stage instrumentation amplifier based on INA128（Texas Instruments，Dallas，TX，USA），a band－pass filter，a 50 Hz notch filter，a second－order amplification and level shifting stage，a driver electrode circuit，a precise 1.5 V reference source，and a -5 V voltage generation module for powering the operational amplifiers．&lt;br /&gt;
&lt;br /&gt;
==== First－order Amplifier ====&lt;br /&gt;
&lt;br /&gt;
The input bioelectric signal is first acquired in differential form and applied to the INA128 instrumentation amplifier，which provides high input impedance，high common－mode rejection，and moderate initial gain for sEMG acquisition．This stage enlarges the weak physiological signal before filtering while reducing the risk of premature saturation caused by electrode offset or motion－induced disturbance，thereby preparing a more stable signal for the subsequent conditioning stages．&lt;br /&gt;
&lt;br /&gt;
==== Bandpass Filter ====&lt;br /&gt;
&lt;br /&gt;
After the instrumentation amplifier，the signal passes through a second－order active band－pass filter，as shown in Figure 2．2． This stage suppresses baseline drift and high－frequency noise outside the useful sEMG range，so that the low－frequency envelope information of sEMG can be preserved before further amplification．&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_2.jpg|thumb|center|800px|Figure 2.2. Schematic diagram of the active band-pass filter used in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the band-pass stage used to retain the main physiological signal band while suppressing unwanted lowand high-frequency components.&lt;br /&gt;
&lt;br /&gt;
==== Notch Filter ====&lt;br /&gt;
&lt;br /&gt;
To reduce power-line interference, a dedicated 50 Hz notch filter is introduced after the band-pass stage, as shown in Figure 2.3. This filter attenuates the mains-frequency component that commonly contaminates weak bioelectric measurements, thereby improving the signal-to-noise ratio of sEMG signals before the final amplification stage.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_3.jpg|thumb|center|800px|Figure 2.3. Schematic diagram of the 50 Hz notch filter used in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the circuit used to attenuate 50 Hz mains interference in the analog front end.&lt;br /&gt;
&lt;br /&gt;
==== Second-order Amplifier &amp;amp; Level Shifter ====&lt;br /&gt;
&lt;br /&gt;
After filtering, the signal enters the second-stage amplification and level-shifting circuit shown in Figure 2.4. In this stage, the filtered signal is further amplified to improve amplitude utilization and then shifted by a 1.5 V reference so that the output becomes a stable unipolar signal suitable for ADC sampling, while preserving linear operation and providing sufficient output swing margin.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_4.jpg|thumb|center|800px|Figure 2.4. Schematic diagram of the second-stage amplifier and level-shifting circuit in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows how the conditioned signal is further amplified and shifted to a suitable DC level before digitization.&lt;br /&gt;
&lt;br /&gt;
==== Power Module and Drive-electrode Circuit ====&lt;br /&gt;
&lt;br /&gt;
The AFE is powered by a 5 V supply and also integrates a 1.5 V precision reference, a -5 V generation circuit, and a driveelectrode circuit. These supporting modules provide the required supply rails and reference level for analog signal conditioning, while the drive-electrode circuit feeds back common-mode voltage to the body to suppress interference at the source. As a result, the complete AFE can support sEMG acquisition with adequate gain, filtering, and noise-reduction performance in a compact hardware structure.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_5.jpg|thumb|center|800px|Figure 2.5. Physical picture of the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the fabricated sEMG analog front-end hardware used in the system.&lt;br /&gt;
&lt;br /&gt;
Figure 2.5 presents the practical hardware implementation of the proposed sEMG AFE. It integrates amplification, filtering, level shifting, and driven-reference functions in a compact circuit for weak bioelectrical signal acquisition.&lt;br /&gt;
&lt;br /&gt;
=== ADS1256-based ADC Board ===&lt;br /&gt;
&lt;br /&gt;
To digitize the conditioned weak physiological signals with sufficient resolution and low noise, this project developed a dedicated ADC board based on the ADS1256 analog-to-digital converter (Texas Instruments, Dallas, TX, USA) and the STM32F103C8T6 microcontroller (STMicroelectronics, Geneva, Switzerland). The overall design objective of this board was not merely to realize analog-to-digital conversion, but to provide a complete hardware interface between the analog front-end and the digital processing unit, including precision reference generation, clocking, input protection and filtering, serial communication, power regulation, and MCU-based acquisition control. The ADS1256 was selected because it is a&lt;br /&gt;
&lt;br /&gt;
very low-noise 24-bit delta-sigma converter with a programmable gain amplifier (PGA), flexible input multiplexer, programmable digital filter, and SPI-compatible serial interface, which makes it well suited for weak low-frequency physiological signals after analog conditioning. The STM32F103C8T6 was used as the local controller because it provides a 32-bit Cortex-M3 core, up to 72 MHz system clock, SPI, USART, USB, and standard SWD debugging support in a compact and low-cost platform.&lt;br /&gt;
&lt;br /&gt;
==== ADC Core Architecture and Design Rationale ====&lt;br /&gt;
&lt;br /&gt;
The ADS1256 was selected as the core ADC because it provides high-resolution, low-noise delta-sigma conversion with an input multiplexer, programmable gain amplifier, and digital filter, which are suitable for weak and low-frequency physiological signals. As shown in Figure 2.6, this architecture emphasizes resolution and noise performance rather than high conversion bandwidth, making it appropriate for sEMG signal digitization after analog conditioning.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_6.jpg|thumb|center|800px|Figure 2.6. Internal functional structure of the ADS1256 analog-to-digital converter.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the main internal blocks of the ADS1256, including the multiplexer, PGA, modulator, and digital filter.&lt;br /&gt;
&lt;br /&gt;
==== Analog Front-End Interface, Reference, and Clocking ====&lt;br /&gt;
&lt;br /&gt;
The ADS1256 analog inputs are connected to the external header through a passive input-conditioning network that helps suppress high-frequency interference and improve input stability. In addition, the board includes a dedicated precision reference and clocking circuits so that the ADC can perform stable and accurate conversion. Together, these circuits provide a reliable analog interface and timing basis for high-resolution digitization of weak physiological signals.&lt;br /&gt;
&lt;br /&gt;
==== SPI Interface between ADS1256 and STM32F103C8T6 ====&lt;br /&gt;
&lt;br /&gt;
Communication between the ADS1256 and the STM32F103C8T6 is implemented through an SPI-compatible interface, with dedicated lines for chip select, serial clock, input/output data, data-ready notification, and hardware reset. This connection allows the MCU to configure the ADC, read conversion results in synchrony with DRDY, and maintain efficient and reliable acquisition control for multi-channel physiological measurements.&lt;br /&gt;
&lt;br /&gt;
==== Power Supply and On-board Regulation ====&lt;br /&gt;
&lt;br /&gt;
The ADC board uses a USB Type-B connector as the main power input and includes protection, voltage regulation, and local decoupling circuits to provide a stable supply for both the MCU and ADC-related hardware. In addition, analog ground and digital ground are separated in the PCB layout to reduce digital noise coupling into the analog path, which is particularly important for weak physiological signal acquisition.&lt;br /&gt;
&lt;br /&gt;
==== Basic Peripheral Circuits of the STM32F103C8T6 ====&lt;br /&gt;
&lt;br /&gt;
The STM32F103C8T6 serves as the local controller of the ADC board and is supported by several basic peripheral circuits, including an external crystal oscillator, reset network, BOOT0 configuration, SWD programming/debugging header, and a CH340N USB-to-UART bridge. These circuits ensure stable MCU operation, convenient firmware downloading and debugging, and reliable data transmission from the board to the host computer for real-time display and storage.&lt;br /&gt;
&lt;br /&gt;
==== Hardware-level Working Principle of the ADC Board ====&lt;br /&gt;
&lt;br /&gt;
In operation, the conditioned analog signal from the AFE enters the ADS1256 through the input header, is digitized with high resolution under the control of the local precision reference and clock, and is then read by the STM32 through the SPI interface. The MCU subsequently forwards the sampled data to the host computer through the serial communication link, so that the entire board functions as a compact digital acquisition backend connecting weak physiological analog signals to later software processing, display, and storage.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_7.jpg|thumb|center|800px|Figure 2.7. Photograph of the fabricated ADS1256-based ADC board developed in this project and the definitions of some key pins.]]&lt;br /&gt;
&lt;br /&gt;
Figure 2.7 shows the ADC board fabricated for this project. It integrates the ADS1256 conversion core, STM32 control circuit, power-conditioning circuits, and communication interfaces on a compact PCB for physiological signal digitization.&lt;br /&gt;
&lt;br /&gt;
== Signal Conditioning and Filtering ==&lt;br /&gt;
Although the AFE already performs preliminary band-pass filtering and 50 Hz interference suppression in the analog domain, the digitized sEMG signal may still contain residual noise due to component tolerances, electrode-contact variation, and environmental interference. Therefore, an additional digital filtering stage is implemented in software as a complementary post-processing step to improve signal quality and to provide a more stable input for rectification, envelope extraction, and subsequent analysis. In this sense, the software filtering is not a simple repetition of the analog filtering, but a refinement and compensation for non-ideal front-end behavior.&lt;br /&gt;
&lt;br /&gt;
Surface electromyographic (sEMG) signals are highly susceptible to several sources of contamination during acquisition. In practical measurements, the dominant disturbances usually include low-frequency motion artifacts caused by electrode movement and electrode–skin impedance variation, narrow-band power-line interference centered at 50 Hz, and broadband high-frequency electronic noise introduced by the acquisition hardware. These unwanted components degrade the quality of the recorded signal and may significantly affect the reliability of subsequent feature extraction, parameter estimation, and muscle activity interpretation. For this reason, an effective signal-conditioning procedure is necessary before any higher-level analysis is performed.&lt;br /&gt;
&lt;br /&gt;
In the present implementation, the filtering strategy follows the principle of restricting the signal bandwidth first and then removing the remaining narrow-band interference in a targeted manner. Accordingly, the raw sEMG signal is first processed by a fourth-order Butterworth IIR band-pass filter and then by a 50 Hz notch filter. This processing sequence is illustrated in the flowchart below, where the signal passes through band-pass filtering, notch filtering, full-wave rectification, and envelope extraction before producing the final processed output.&lt;br /&gt;
&lt;br /&gt;
[[File:flowchart.png|thumb|center|500px|Flowchart of the real-time sEMG signal conditioning pipeline.]]&lt;br /&gt;
&lt;br /&gt;
The rationale of this order is that the &#039;&#039;&#039;band-pass stage&#039;&#039;&#039; first confines the signal to the main spectral region of interest for sEMG, thereby attenuating motion artifacts at very low frequencies and suppressing high-frequency noise components outside the physiological band. After this spectral preconditioning, the notch stage can more effectively suppress the residual 50 Hz power-line interference that lies inside the useful sEMG band. In transfer-function form, the band-pass filter may be written as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;H_{BP}(z)=\frac{B_{BP}(z)}{A_{BP}(z)}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where the effective passband is selected as &amp;lt;math&amp;gt;20 \leq f \leq 160 \text{ Hz}&amp;lt;/math&amp;gt;. This frequency interval is consistent with the dominant spectral content of surface EMG: the lower cutoff near 20 Hz reduces motion artifacts and unstable low-frequency fluctuations, whereas the upper cutoff near 160 Hz removes high-frequency electronic noise while preserving the main energy-bearing components of the muscle signal. The use of a Butterworth structure is appropriate here because it provides a smooth monotonic passband response without ripple, which helps preserve signal morphology in real-time applications.&lt;br /&gt;
&lt;br /&gt;
After band limitation, a &#039;&#039;&#039;notch filter&#039;&#039;&#039; centered at the power-line frequency is applied to suppress interference that cannot be removed by the band-pass stage alone. The notch filter is designed around &amp;lt;math&amp;gt;f_0 = 50 \text{ Hz}&amp;lt;/math&amp;gt;, and its bandwidth is controlled by the quality factor &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;, which is expressed as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;Q = \frac{f_0}{\Delta f}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In transfer-function form, the notch stage is written as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;H_{N}(z)=\frac{B_{N}(z)}{A_{N}(z)}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the implemented program, a large quality factor is chosen so that the notch remains narrow, allowing effective rejection of the 50 Hz interference while minimizing distortion of neighboring useful spectral components. This is particularly important for sEMG because the interference frequency lies directly inside the physiological band of interest.&lt;br /&gt;
&lt;br /&gt;
Following the filtering stages, further signal conditioning is performed to obtain a representation that is more directly related to muscle activation intensity. The filtered sEMG waveform is first &#039;&#039;&#039;full-wave rectified&#039;&#039;&#039;, which converts the bipolar oscillatory signal into a unipolar signal by taking its absolute value.  Rectification does not remove noise by itself; instead, it transforms the signal into a form that is more suitable for amplitude-based analysis because both positive and negative deflections contribute positively to the activation measure.&lt;br /&gt;
&lt;br /&gt;
After rectification, the signal envelope is extracted to provide a smooth estimate of muscle activation level over time. In a general formulation, the envelope can be described as the &#039;&#039;&#039;low-pass filtered&#039;&#039;&#039; version of the rectified signal, namely &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y_{\mathrm{env}}[n] = \mathrm{LPF}\bigl(y_{\mathrm{rect}}[n]\bigr)&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the present code implementation, this operation is realized by short-time averaging over a finite window, which is equivalent to a moving-average low-pass smoothing of the rectified waveform. The corresponding expression is &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y_{\mathrm{env}}[n] = \frac{1}{N}\sum_{k=0}^{N-1} |x[n-k]|&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; is the window length in samples. With a window duration of approximately 200 ms, this envelope extraction method provides a stable and physiologically meaningful representation of muscle activation intensity, making it suitable for tasks such as force estimation, fatigue analysis, and motor-control studies.&lt;br /&gt;
&lt;br /&gt;
An important feature of the present &#039;&#039;&#039;implementation&#039;&#039;&#039; is that the entire filtering process is performed &#039;&#039;&#039;in real time&#039;&#039;&#039;, sample by sample, rather than by offline block processing. For this reason, IIR filters are preferred over FIR filters, since they can achieve comparable filtering performance with lower order, lower computational cost, and shorter delay. These properties are especially valuable in embedded systems, serial data streaming, and other low-latency experimental applications. However, unlike memoryless operations, an IIR filter depends not only on the current input but also on previous inputs and previous outputs. Its discrete-time behavior can therefore be represented by the recursive difference equation &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y[n] = \sum_{k=0}^{M} b_k x[n-k] - \sum_{k=1}^{N} a_k y[n-k]&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This equation makes clear that internal filter states must be preserved continuously during streaming operation. If the state variables were reinitialized for every incoming sample or data segment, artificial transients would appear and the output would no longer remain continuous.&lt;br /&gt;
&lt;br /&gt;
In the Python implementation, this state continuity is maintained using the internal initial-condition mechanism provided by SciPy, such as &amp;lt;code&amp;gt;lfilter_zi&amp;lt;/code&amp;gt;, together with recursive state updates during each filtering call. As a result, each newly acquired sample is passed first through the band-pass filter and then through the notch filter, while the internal states of both filters are updated after every step. This state-preserving sample-by-sample design ensures that the processing chain remains causal, continuous, and suitable for real-time display or downstream analysis without requiring storage of the entire signal segment.&lt;br /&gt;
&lt;br /&gt;
Overall, this signal-conditioning scheme provides an experimentally practical solution for real-time sEMG processing. The fourth-order Butterworth band-pass filter confines the signal to the main physiological band of interest, the 50 Hz notch filter removes narrow-band power-line contamination, and the subsequent rectification and envelope extraction generate a smooth amplitude descriptor of muscle activity. Combined with state-preserved streaming IIR implementation, this approach achieves a good balance between signal fidelity, computational efficiency, and real-time applicability in biomedical and physical experiment settings.&lt;br /&gt;
&lt;br /&gt;
== Experimental Setup ==&lt;br /&gt;
&lt;br /&gt;
=== Experimental Demonstration ===&lt;br /&gt;
&lt;br /&gt;
The experimental setup and data acquisition process are demonstrated in the video below.&lt;br /&gt;
&lt;br /&gt;
[[File:EMG_Experiment.mp4|center|800px]]&lt;br /&gt;
&lt;br /&gt;
The video illustrates the complete measurement procedure, including electrode placement, muscle activation, and real-time EMG signal visualization.&lt;br /&gt;
&lt;br /&gt;
=== Experimental Procedure ===&lt;br /&gt;
&lt;br /&gt;
Surface EMG signals were acquired using disposable electrodes placed on the forearm muscles responsible for wrist extension. &lt;br /&gt;
&lt;br /&gt;
Three electrodes were used in the measurement setup:&lt;br /&gt;
&lt;br /&gt;
* One electrode placed on the back of the hand serves as the reference electrode  &lt;br /&gt;
* The other two electrodes placed along the forearm muscle act as the differential input electrodes (positive and negative)  &lt;br /&gt;
&lt;br /&gt;
This configuration enables differential measurement of EMG signals while suppressing common-mode noise.&lt;br /&gt;
&lt;br /&gt;
The experimental movement consists of making a fist while extending the wrist backward. This action activates the forearm extensor muscles beneath the electrodes, producing measurable EMG signals.&lt;br /&gt;
&lt;br /&gt;
=== Data Acquisition Protocol ===&lt;br /&gt;
&lt;br /&gt;
Each subject performed repeated contraction–relaxation cycles under controlled conditions:&lt;br /&gt;
&lt;br /&gt;
* Number of subjects: 3  &lt;br /&gt;
* Number of trials per subject: 3  &lt;br /&gt;
* Duration of each trial: 30 seconds  &lt;br /&gt;
&lt;br /&gt;
During each trial, subjects were instructed to periodically contract and relax the muscle to generate clear dynamic EMG signals, while maintaining a stable resting state between contractions.&lt;br /&gt;
&lt;br /&gt;
=== System and Measurement Conditions ===&lt;br /&gt;
&lt;br /&gt;
The EMG signals were recorded and visualized in real time using a data acquisition system connected to a computer. The sampling rate was set to 400 Hz.&lt;br /&gt;
&lt;br /&gt;
To ensure consistency across measurements:&lt;br /&gt;
&lt;br /&gt;
* Electrode placement was kept consistent for all subjects  &lt;br /&gt;
* The same movement protocol was followed  &lt;br /&gt;
* Measurements were conducted under similar environmental conditions  &lt;br /&gt;
&lt;br /&gt;
=== Summary ===&lt;br /&gt;
&lt;br /&gt;
This experimental setup enables reliable acquisition of both resting and dynamic EMG signals, providing a consistent dataset for subsequent signal processing and performance evaluation.&lt;br /&gt;
&lt;br /&gt;
== Data Processing ==&lt;br /&gt;
&lt;br /&gt;
The objective of data processing is to convert raw surface electromyography (sEMG) recordings into stable, quantitative, and comparable indicators of muscle activity. Since EMG signals are low in amplitude, highly variable over time, and easily contaminated by noise, a dedicated processing pipeline is necessary before any experimental interpretation can be performed.&lt;br /&gt;
&lt;br /&gt;
In this project, the data processing workflow includes time normalization, signal pre-processing, sliding-window feature extraction, noise-floor estimation, and automatic contraction detection. The processed outputs are then used for subsequent experimental evaluation, including rest-versus-contraction discrimination, signal-to-noise ratio analysis, and repeatability assessment.&lt;br /&gt;
&lt;br /&gt;
=== Input Data and Time Normalization ===&lt;br /&gt;
&lt;br /&gt;
The acquired EMG data are read from CSV files containing two columns: time and filtered sEMG amplitude. In the MATLAB implementation, the time vector is normalized so that each recording starts from zero:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t = t_{all} - t_{all}(1)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This normalization is important because it removes the influence of absolute recording timestamps and makes different trials directly comparable on the same time axis.&lt;br /&gt;
&lt;br /&gt;
In addition, the signal type is automatically identified from the filename as either dynamic or rest. This design allows the same program to process both contraction recordings and resting recordings with different downstream analysis logic.&lt;br /&gt;
&lt;br /&gt;
=== Signal Pre-processing ===&lt;br /&gt;
&lt;br /&gt;
Raw EMG signals cannot be analyzed directly because they usually contain DC offset, low-frequency drift, motion artifacts, and residual high-frequency interference. Therefore, several pre-processing steps are applied before feature extraction.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(1) Baseline Removal&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The first step is DC offset removal:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
x_{dc}(t) = x(t) - \frac{1}{N}\sum_{i=1}^{N}x(i)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This operation centers the signal around zero. It is necessary because an uncorrected baseline would bias amplitude-based metrics and reduce the reliability of later envelope and feature calculations.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(2) Band-pass Filtering &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
After baseline correction, a fourth-order Butterworth band-pass filter is applied with a passband of 20–150 Hz.&lt;br /&gt;
&lt;br /&gt;
This step is introduced for two reasons:&lt;br /&gt;
&lt;br /&gt;
* The low-frequency cutoff at 20 Hz suppresses baseline drift and motion artifacts.&lt;br /&gt;
* The high-frequency cutoff at 150 Hz reduces unwanted high-frequency noise while preserving the main energy band of the recorded sEMG in this project.&lt;br /&gt;
&lt;br /&gt;
Compared with processing the raw waveform directly, band-pass filtering makes the subsequent time-domain features more stable and more physiologically meaningful.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(3) Full-wave Rectification&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The filtered EMG signal is bipolar, meaning that positive and negative phases coexist due to motor unit action potentials. If these positive and negative components are averaged directly, they may cancel each other out. To avoid this, full-wave rectification is performed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
x_{rect}(t) = |x_{filt}(t)|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This transforms the signal into a unipolar representation, so that all muscle activity contributes positively to the extracted features.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(4) Envelope Extraction &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Although the rectified signal reflects signal magnitude, it still fluctuates rapidly. To obtain a smoother representation of muscle activation level, an envelope is extracted using a moving average with a 100 ms window.&lt;br /&gt;
&lt;br /&gt;
Envelope extraction is important because contraction detection should reflect the overall activation trend rather than instantaneous spikes. A smoothed envelope is therefore more robust for identifying active and inactive muscle states.&lt;br /&gt;
&lt;br /&gt;
=== Sliding Window Design ===&lt;br /&gt;
&lt;br /&gt;
To quantify how muscle activity changes with time, the filtered signal is divided into overlapping short-time segments using a sliding window method.&lt;br /&gt;
&lt;br /&gt;
The window parameters are:&lt;br /&gt;
&lt;br /&gt;
* Window length: 250 ms&lt;br /&gt;
* Step size: 50 ms&lt;br /&gt;
&lt;br /&gt;
These values are chosen as a trade-off between temporal resolution and feature stability.&lt;br /&gt;
&lt;br /&gt;
A longer window improves statistical robustness because more samples are included in each calculation. However, if the window is too long, short contractions or rapid changes may be blurred. A smaller step size increases temporal continuity between adjacent feature points and makes the feature curves smoother in time. Therefore, the 250 ms / 50 ms design provides a practical balance between smoothing and time localization.&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt;-th segment, the feature time is defined as the mean time of that segment:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t_k = \frac{1}{N}\sum_{i=s_k}^{e_k} t(i)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;s_k&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;e_k&amp;lt;/math&amp;gt; denote the start and end indices of the window.&lt;br /&gt;
&lt;br /&gt;
=== Feature Extraction ===&lt;br /&gt;
&lt;br /&gt;
Within each sliding window, three time-domain features are extracted: RMS, iEMG, and MAV. These features are widely used in EMG analysis because they are simple, computationally efficient, and directly related to muscle activation intensity.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(1) Root Mean Square (RMS)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
RMS = \sqrt{\frac{1}{N}\sum_{i=1}^{N}x_i^2}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
RMS reflects the effective power of the EMG signal and is one of the most common indicators of contraction strength. It is sensitive to both amplitude and energy, making it especially useful for comparing rest and active states.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(2) Integrated EMG (iEMG)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
iEMG = \sum_{i=1}^{N}|x_i|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
iEMG describes the cumulative electrical activity within a window. It is often interpreted as a measure of total muscle effort over that time segment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(3) Mean Absolute Value (MAV)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
MAV = \frac{1}{N}\sum_{i=1}^{N}|x_i|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
MAV is an amplitude descriptor similar to iEMG, but normalized by the number of samples. It provides an efficient estimate of average signal level and is less computationally intensive than some other features.&lt;br /&gt;
&lt;br /&gt;
These three features are used together because they provide complementary descriptions of EMG intensity. RMS emphasizes signal energy, iEMG emphasizes cumulative activation, and MAV reflects average amplitude.&lt;br /&gt;
&lt;br /&gt;
=== Peak-value Extraction ===&lt;br /&gt;
&lt;br /&gt;
In addition to continuous feature curves, several key peak values are extracted from the processed signal:&lt;br /&gt;
&lt;br /&gt;
* maximum and minimum of the filtered EMG waveform&lt;br /&gt;
* peak of the envelope&lt;br /&gt;
* peak RMS&lt;br /&gt;
* peak iEMG&lt;br /&gt;
* peak MAV&lt;br /&gt;
&lt;br /&gt;
These peak values provide concise descriptors of the strongest activity observed in each recording. They are useful for quick comparison across trials and subjects.&lt;br /&gt;
&lt;br /&gt;
=== Noise Floor Estimation ===&lt;br /&gt;
&lt;br /&gt;
To evaluate signal quality, the noise floor is estimated from a reference resting interval. In the present implementation, the first 3 seconds of the recording are used as the default rest reference:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t \in [0,\min(3,t_{end})]&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this segment, three noise descriptors are computed:&lt;br /&gt;
&lt;br /&gt;
* Noise RMS&lt;br /&gt;
* Noise standard deviation&lt;br /&gt;
* Noise peak-to-peak amplitude&lt;br /&gt;
&lt;br /&gt;
Noise-floor estimation is important because EMG amplitude alone is not sufficient to judge recording quality. A large signal is only meaningful if it is sufficiently higher than the baseline noise level. Therefore, the noise floor serves as the reference for later SNR calculation and for designing contraction thresholds.&lt;br /&gt;
&lt;br /&gt;
=== Global Signal Metrics ===&lt;br /&gt;
&lt;br /&gt;
For each recording, three global metrics are also computed over the entire filtered signal:&lt;br /&gt;
&lt;br /&gt;
* Global RMS&lt;br /&gt;
* Global MAV&lt;br /&gt;
* Global iEMG&lt;br /&gt;
&lt;br /&gt;
These global descriptors summarize the overall signal level of the full recording and are later used in group-level comparisons.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Contraction Detection ===&lt;br /&gt;
&lt;br /&gt;
For dynamic recordings, an automatic contraction detection algorithm is used to identify repeated active segments. This is one of the key parts of the data processing pipeline, because it transforms a continuous EMG trace into discrete contraction events that can be counted and compared.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(1) Threshold Design&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The detection threshold is designed adaptively rather than using a fixed value. Two candidate thresholds are first calculated:&lt;br /&gt;
&lt;br /&gt;
* an envelope-based threshold derived from the global envelope mean and standard deviation&lt;br /&gt;
* a rest-reference threshold derived from the mean and standard deviation of the resting reference amplitude&lt;br /&gt;
&lt;br /&gt;
The final threshold is taken as the larger of the two after additional scaling. This strategy improves robustness because it combines the global activation level of the signal with the baseline noise characteristics of the individual recording.&lt;br /&gt;
&lt;br /&gt;
This adaptive threshold design is preferable to a manually fixed threshold because EMG amplitude can vary strongly between subjects, muscles, and recording sessions.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(2) Initial Segmentation&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
After thresholding the envelope, the signal is classified into active and inactive regions:&lt;br /&gt;
&lt;br /&gt;
* active: envelope above threshold&lt;br /&gt;
* inactive: envelope below threshold&lt;br /&gt;
&lt;br /&gt;
The rising and falling edges of the binary activity vector are then used to determine the start and end points of each candidate contraction segment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(3) Removal of Short Segments&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Very short active regions are often caused by noise fluctuations rather than true muscle contractions. Therefore, segments shorter than 0.20 s are discarded.&lt;br /&gt;
&lt;br /&gt;
This step prevents false positive detections and increases the physiological relevance of the segmentation results.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(4) Merging of Adjacent Segments &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If two neighboring active segments are separated by a very short gap, they are merged when the gap is less than 0.15 s.&lt;br /&gt;
&lt;br /&gt;
This operation is necessary because a single real contraction may be temporarily interrupted by a brief drop in the envelope caused by local fluctuation. Without merging, one contraction could be incorrectly counted as multiple repetitions.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(5) Repetition-level Metrics &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
For each detected contraction segment, two repetition-level metrics are extracted:&lt;br /&gt;
&lt;br /&gt;
* peak RMS of that contraction&lt;br /&gt;
* mean RMS of that contraction&lt;br /&gt;
&lt;br /&gt;
These metrics quantify both the strongest activation within each repetition and the average activation level over the repetition duration.&lt;br /&gt;
&lt;br /&gt;
=== Repeatability Analysis ===&lt;br /&gt;
&lt;br /&gt;
When multiple valid contractions are detected, repeatability is evaluated using the coefficient of variation (CV):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
CV = \frac{\sigma}{\mu}\times 100\%&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt; is the standard deviation and &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is the mean value across repetitions.&lt;br /&gt;
&lt;br /&gt;
Two CV values are computed:&lt;br /&gt;
&lt;br /&gt;
* CV of repetition peak RMS&lt;br /&gt;
* CV of repetition mean RMS&lt;br /&gt;
&lt;br /&gt;
A lower CV indicates better repeatability, meaning that repeated contractions produce more consistent EMG responses.&lt;br /&gt;
&lt;br /&gt;
=== Signal-to-Noise Ratio (SNR) ===&lt;br /&gt;
&lt;br /&gt;
In this project, the signal-to-noise ratio (SNR) is defined based on the ratio between contraction and rest activity:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
SNR_{dB} = 20\log_{10}\left(\frac{RMS_{contraction}}{RMS_{rest}}\right)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This definition is adopted because it directly reflects the system’s ability to distinguish active muscle contraction from baseline noise.&lt;br /&gt;
&lt;br /&gt;
Compared with global SNR definitions, this formulation is more relevant for practical EMG applications such as activity detection and classification.&lt;br /&gt;
&lt;br /&gt;
=== Rest-versus-Contraction Window Comparison ===&lt;br /&gt;
&lt;br /&gt;
To further distinguish inactive and active states, all sliding windows are divided into two groups:&lt;br /&gt;
&lt;br /&gt;
* rest windows: windows with envelope clearly below the threshold&lt;br /&gt;
* contraction windows: windows with envelope above the threshold&lt;br /&gt;
&lt;br /&gt;
The RMS values of these two groups are then compared statistically.&lt;br /&gt;
&lt;br /&gt;
This comparison is important because a practical EMG system should not only detect signal presence, but also clearly separate rest from contraction in a quantitative way. If the two RMS distributions are well separated, it indicates that the system has good discriminative capability.&lt;br /&gt;
&lt;br /&gt;
=== Output Data Structure ===&lt;br /&gt;
&lt;br /&gt;
The processed outputs are organized into structured data for experimental analysis:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(1) Time-series outputs&#039;&#039;&#039;&lt;br /&gt;
* Filtered EMG signal  &lt;br /&gt;
* Rectified signal  &lt;br /&gt;
* Envelope  &lt;br /&gt;
* RMS(t), iEMG(t), MAV(t)  &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(2) Recording-level outputs&#039;&#039;&#039; &lt;br /&gt;
* RMS (rest)  &lt;br /&gt;
* RMS (contraction)  &lt;br /&gt;
* iEMG  &lt;br /&gt;
* Noise metrics  &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(3) Dynamic-signal outputs &#039;&#039;&#039;&lt;br /&gt;
* Detected contractions  &lt;br /&gt;
* Repetition count  &lt;br /&gt;
* Peak RMS per repetition  &lt;br /&gt;
* Mean RMS per repetition  &lt;br /&gt;
* Coefficient of variation (CV)  &lt;br /&gt;
* Signal-to-noise ratio (SNR)  &lt;br /&gt;
&lt;br /&gt;
All extracted features are designed to directly support the evaluation of noise level, signal quality, activity discrimination, and repeatability in the subsequent experimental analysis.&lt;br /&gt;
&lt;br /&gt;
== Experimental Results ==&lt;br /&gt;
&lt;br /&gt;
This section presents representative results of the EMG acquisition and data processing pipeline under both dynamic (muscle contraction) and resting conditions.&lt;br /&gt;
&lt;br /&gt;
=== Representative Dynamic Signal Analysis ===&lt;br /&gt;
&lt;br /&gt;
[[File:Dynamic_Figure1.png|thumb|800px|center|Figure 5.1: Processed EMG signal under dynamic contraction, including filtered signal, rectified signal with envelope, and extracted features (RMS, iEMG, MAV).]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.1 shows the processed EMG signal during repeated muscle contractions.&lt;br /&gt;
&lt;br /&gt;
The filtered EMG waveform exhibits clear burst-like patterns corresponding to periodic contractions. The signal amplitude reaches a maximum of approximately 0.45, while the baseline remains centered around zero, indicating effective baseline removal and filtering.&lt;br /&gt;
&lt;br /&gt;
After rectification and envelope extraction, the contraction periods become clearly distinguishable. The envelope provides a smooth representation of muscle activation, with a peak value of approximately 0.145.&lt;br /&gt;
&lt;br /&gt;
The extracted time-domain features (RMS, iEMG, MAV) further quantify the signal. Among these, iEMG shows the strongest dynamic variation, indicating high sensitivity to contraction intensity.&lt;br /&gt;
&lt;br /&gt;
=== Noise Floor and Rest Reference ===&lt;br /&gt;
&lt;br /&gt;
[[File:Dynamic_Figure2.png|thumb|800px|center|Figure 5.2: Noise estimation, rest vs contraction comparison, automatic contraction detection, and repetition analysis.]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (top-left) shows the resting reference segment used for noise estimation.&lt;br /&gt;
&lt;br /&gt;
The signal remains centered around zero with small fluctuations. The noise characteristics are:&lt;br /&gt;
&lt;br /&gt;
* Noise RMS ≈ 0.0046  &lt;br /&gt;
* Standard deviation ≈ 0.0046  &lt;br /&gt;
* Peak-to-peak amplitude ≈ 0.071  &lt;br /&gt;
&lt;br /&gt;
This indicates a low noise floor and stable measurement conditions.&lt;br /&gt;
&lt;br /&gt;
=== Rest vs Contraction Discrimination ===&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (top-right) compares RMS values between rest and contraction states.&lt;br /&gt;
&lt;br /&gt;
The two distributions are clearly separated:&lt;br /&gt;
&lt;br /&gt;
* Rest mean RMS ≈ 0.0053  &lt;br /&gt;
* Contraction mean RMS ≈ 0.1064  &lt;br /&gt;
&lt;br /&gt;
This corresponds to an approximate 20× increase, demonstrating strong discriminability between inactive and active muscle states.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Contraction Detection ===&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (bottom-left) illustrates automatic detection based on the envelope signal.&lt;br /&gt;
&lt;br /&gt;
A threshold of approximately 0.040 is applied, resulting in stable segmentation of contraction periods.&lt;br /&gt;
&lt;br /&gt;
A total of 12 repetitions are detected, with good alignment to visible signal peaks.&lt;br /&gt;
&lt;br /&gt;
=== Repeatability Analysis ===&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (bottom-right) shows the peak RMS value of each detected contraction.&lt;br /&gt;
&lt;br /&gt;
The results indicate:&lt;br /&gt;
&lt;br /&gt;
* Mean peak RMS ≈ 0.1355  &lt;br /&gt;
* Standard deviation ≈ 0.0173  &lt;br /&gt;
* CV ≈ 12.77%  &lt;br /&gt;
* SNR ≈ 21.26 dB  &lt;br /&gt;
&lt;br /&gt;
This indicates acceptable repeatability and good signal quality.&lt;br /&gt;
&lt;br /&gt;
=== Representative Rest Signal Analysis ===&lt;br /&gt;
&lt;br /&gt;
[[File:Rest_Figure1.png|thumb|800px|center|Figure 5.3: Processed EMG signal under rest condition, showing low amplitude and absence of contraction patterns.]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.3 shows the EMG signal under resting conditions.&lt;br /&gt;
&lt;br /&gt;
The signal remains within a narrow amplitude range (approximately ±0.04) and shows no burst-like structures. The envelope remains close to zero, confirming the absence of muscle activity.&lt;br /&gt;
&lt;br /&gt;
The extracted features remain low:&lt;br /&gt;
&lt;br /&gt;
* RMS ≈ 0.007  &lt;br /&gt;
* MAV ≈ 0.005  &lt;br /&gt;
* iEMG remains stable  &lt;br /&gt;
&lt;br /&gt;
This confirms that no false activation is detected.&lt;br /&gt;
&lt;br /&gt;
=== Frequency-domain Characteristics ===&lt;br /&gt;
&lt;br /&gt;
[[File:Rest_Figure2.png|thumb|800px|center|Figure 5.4: Frequency-domain analysis and statistical characteristics of rest signal.]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.4 shows the frequency-domain characteristics of the resting signal.&lt;br /&gt;
&lt;br /&gt;
The power spectral density (PSD) indicates low overall signal energy without dominant peaks, confirming that the signal mainly consists of noise.&lt;br /&gt;
&lt;br /&gt;
=== Summary of Single-recording Performance ===&lt;br /&gt;
&lt;br /&gt;
From the representative results:&lt;br /&gt;
&lt;br /&gt;
* EMG signals are effectively extracted and denoised  &lt;br /&gt;
* Contraction events are clearly identifiable  &lt;br /&gt;
* Rest and contraction states are well separated  &lt;br /&gt;
* Automatic detection is stable and accurate  &lt;br /&gt;
* Repeatability is acceptable  &lt;br /&gt;
* No false activation occurs under rest conditions  &lt;br /&gt;
&lt;br /&gt;
=== Consistency Across Multiple Recordings ===&lt;br /&gt;
&lt;br /&gt;
The same data processing pipeline was applied to multiple recordings from different subjects and trials.&lt;br /&gt;
&lt;br /&gt;
Across all datasets, consistent patterns were observed:&lt;br /&gt;
&lt;br /&gt;
* Dynamic signals exhibit clear burst-like structures corresponding to repeated muscle contractions  &lt;br /&gt;
* Rest signals remain low in amplitude without distinct activation patterns  &lt;br /&gt;
* RMS values under contraction are consistently higher than those under rest  &lt;br /&gt;
* The automatic detection algorithm reliably identifies contraction segments  &lt;br /&gt;
&lt;br /&gt;
Although quantitative values (e.g., RMS, SNR, CV) vary across recordings due to differences in electrode contact, muscle activation strength, and individual conditions, the overall trends remain consistent.&lt;br /&gt;
&lt;br /&gt;
These results demonstrate the robustness and general applicability of the proposed signal processing method.&lt;br /&gt;
&lt;br /&gt;
== Multi-subject Analysis ==&lt;br /&gt;
=== System Evaluation ===&lt;br /&gt;
&lt;br /&gt;
This section evaluates the performance of the EMG acquisition system in terms of noise level, signal quality, activity discrimination, and repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Noise Floor Analysis ====&lt;br /&gt;
&lt;br /&gt;
The noise floor was evaluated using rest-state recordings, characterized by RMS noise, standard deviation, and peak-to-peak amplitude.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039; shows the lowest noise level (RMS ≈ 0.0046), indicating stable electrode contact and minimal interference.  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039; exhibits moderate noise (RMS ≈ 0.0080), likely influenced by motion artifacts or electrode–skin impedance variation.  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039; shows relatively higher noise (RMS ≈ 0.0126), suggesting increased baseline fluctuation.  &lt;br /&gt;
&lt;br /&gt;
Overall, the system maintains a low noise floor across subjects, although the quality depends on experimental conditions such as electrode contact and environmental interference.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Signal-to-Noise Ratio (SNR) ====&lt;br /&gt;
&lt;br /&gt;
The signal-to-noise ratio (SNR) is defined as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{SNR (dB)} = 20 \log_{10} \left( \frac{\mathrm{RMS}_{\mathrm{contraction}}}{\mathrm{RMS}_{\mathrm{rest}}} \right)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The measured SNR values are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: 21.26 dB → good signal quality  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: 13.52 dB → moderate and usable  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: 6.66 dB → low signal clarity  &lt;br /&gt;
&lt;br /&gt;
General interpretation:&lt;br /&gt;
&lt;br /&gt;
* &amp;gt;20 dB → good  &lt;br /&gt;
* 10–20 dB → usable  &lt;br /&gt;
* &amp;lt;10 dB → poor  &lt;br /&gt;
&lt;br /&gt;
These results show that the system can achieve reliable signal acquisition, although performance varies across subjects.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
====  Rest vs Contraction Discrimination ====&lt;br /&gt;
&lt;br /&gt;
A clear distinction between rest and contraction states is observed based on RMS values.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: 0.0053 → 0.1064 (≈20× increase)  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: 0.0079 → 0.0283 (≈3.6× increase)  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: 0.0141 → 0.0646 (≈4.6× increase)  &lt;br /&gt;
&lt;br /&gt;
This demonstrates that the system is capable of separating muscle activity from baseline noise.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Conclusion:&#039;&#039;  &lt;br /&gt;
The system can be used for basic muscle activity detection and simple classification tasks based on RMS features.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Repeatability of Repeated Contractions ====&lt;br /&gt;
&lt;br /&gt;
Repeatability is evaluated using the coefficient of variation (CV) of peak RMS values across repetitions.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! CV Range !! Evaluation&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt; 10% || Excellent&lt;br /&gt;
|-&lt;br /&gt;
| 10–20% || Acceptable&lt;br /&gt;
|-&lt;br /&gt;
| &amp;gt; 20% || Poor&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Results:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: CV = 12.77% → Acceptable  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: CV = 24.77% → Poor  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: CV = 10.60% → Acceptable  &lt;br /&gt;
&lt;br /&gt;
Although WANG&#039;s signal is detectable, its contraction amplitude varies significantly across repetitions, resulting in poor repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
=== Overall System Performance ===&lt;br /&gt;
&lt;br /&gt;
The system demonstrates the following performance characteristics:&lt;br /&gt;
&lt;br /&gt;
* Reliable detection of muscle activity across all subjects  &lt;br /&gt;
* Clear separation between rest and contraction states  &lt;br /&gt;
* Moderate to high signal quality depending on subject conditions  &lt;br /&gt;
* Repeatability ranging from acceptable to poor due to user-dependent factors  &lt;br /&gt;
&lt;br /&gt;
Overall, the designed EMG acquisition system is capable of stable signal acquisition and feature extraction, with performance primarily influenced by electrode contact quality, skin impedance, and motion consistency.&lt;br /&gt;
&lt;br /&gt;
===== Summary of Quantitative Metrics =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Subject !! RMS (Rest) !! RMS (Contraction) !! Separation Ratio !! iEMG (max) !! Noise RMS !! SNR (dB) !! CV (%) !! Evaluation&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;LIU&#039;&#039;&#039; || 0.0053 || 0.1064 || &#039;&#039;&#039;20.1×&#039;&#039;&#039; || 12.72 || 0.0046 || &#039;&#039;&#039;21.26&#039;&#039;&#039; || 12.77 || Strong signal, good quality&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;WANG&#039;&#039;&#039; || 0.0079 || 0.0283 || 3.57× || 11.10 || 0.0080 || 13.52 || &#039;&#039;&#039;24.77&#039;&#039;&#039; || Usable signal, poor repeatability&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ZHONG&#039;&#039;&#039; || 0.0141 || 0.0646 || 4.58× || 6.70 || 0.0126 || 6.66 || 10.60 || Acceptable performance&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Summary:&#039;&#039; Subject LIU shows the best overall performance, WANG provides usable but less stable signals, and ZHONG demonstrates moderate signal quality with good repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Activation Intensity =====&lt;br /&gt;
&lt;br /&gt;
Among the three subjects, &#039;&#039;&#039;LIU exhibits the strongest muscle activation&#039;&#039;&#039;, as indicated by the highest contraction RMS and iEMG values. ZHONG shows moderate activation, while WANG demonstrates comparable iEMG but lower RMS consistency.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Signal Quality =====&lt;br /&gt;
&lt;br /&gt;
Signal quality is evaluated based on SNR and noise level:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039; achieves the highest SNR and lowest noise → best signal quality  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039; shows moderate SNR → usable but less robust  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039; has the lowest SNR → weakest signal clarity  &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Repeatability =====&lt;br /&gt;
&lt;br /&gt;
Repeatability is evaluated using the coefficient of variation (CV):&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;ZHONG (10.60%)&#039;&#039;&#039; → most stable  &lt;br /&gt;
* &#039;&#039;&#039;LIU (12.77%)&#039;&#039;&#039; → acceptable  &lt;br /&gt;
* &#039;&#039;&#039;WANG (24.77%)&#039;&#039;&#039; → poor  &lt;br /&gt;
&lt;br /&gt;
This indicates that WANG’s contraction strength varies significantly between repetitions.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Engineering Interpretation of Inter-subject Differences =====&lt;br /&gt;
&lt;br /&gt;
The observed differences are mainly attributed to engineering and experimental factors rather than physiological differences.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Electrode contact quality&#039;&#039;&#039;  &lt;br /&gt;
  Variations in electrode placement, pressure, and gel contact affect signal amplitude and stability.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Skin impedance&#039;&#039;&#039;  &lt;br /&gt;
  Differences in skin condition (hydration, oil, hair) influence electrode–skin impedance, affecting noise level and signal coupling.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Muscle control consistency&#039;&#039;&#039;  &lt;br /&gt;
  Variations in contraction strength and timing affect repeatability and CV.&lt;br /&gt;
&lt;br /&gt;
Therefore, the variation across subjects reflects practical acquisition conditions rather than intrinsic system limitations.&lt;/div&gt;</summary>
		<author><name>Wang Jingyi</name></author>
	</entry>
	<entry>
		<id>https://pc5271.org/index.php?title=Surface_EMG_Sensor_for_Muscle_Activity_Measurement:_AFE_Design_and_Signal_Processing&amp;diff=1368</id>
		<title>Surface EMG Sensor for Muscle Activity Measurement: AFE Design and Signal Processing</title>
		<link rel="alternate" type="text/html" href="https://pc5271.org/index.php?title=Surface_EMG_Sensor_for_Muscle_Activity_Measurement:_AFE_Design_and_Signal_Processing&amp;diff=1368"/>
		<updated>2026-04-23T07:49:48Z</updated>

		<summary type="html">&lt;p&gt;Wang Jingyi: /* Experimental Setup */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Background and Theory==&lt;br /&gt;
&lt;br /&gt;
=== Surface EMG Signals ===&lt;br /&gt;
Surface electromyography (sEMG) refers to the bioelectrical signals detected on the skin surface during muscle contraction. These signals originate from the electrical activity of muscle fibers and provide a non-invasive way to monitor muscle activation. Compared with invasive EMG methods, sEMG is easier to apply, safer for repeated measurements, and more suitable for real-time monitoring. Therefore, it has been widely used in areas such as rehabilitation, motion analysis, human–machine interaction, and physiological monitoring.&lt;br /&gt;
&lt;br /&gt;
=== Characteristics of EMG Signals ===&lt;br /&gt;
EMG signals are generally weak, time-varying, and stochastic in nature. Their waveforms are typically bipolar, fluctuating around zero with both positive and negative components. The amplitude and frequency content of EMG signals depend on factors such as muscle contraction level, electrode placement, skin condition, and individual physiological differences. In practice, the useful frequency components of sEMG are mainly concentrated in a limited low-to-mid frequency range. Because of their low amplitude and variability, EMG signals usually require further conditioning before reliable interpretation and feature extraction can be performed.&lt;br /&gt;
&lt;br /&gt;
=== Bioelectrical Signal Acquisition Principles ===&lt;br /&gt;
The acquisition of bioelectrical signals is based on measuring the small potential difference on the skin surface using electrodes, then converting it into a processable electrical signal through amplification and digitization. For sEMG measurement, electrode placement and skin–electrode contact quality are especially important, since they directly affect signal amplitude and stability. In addition, the front-end acquisition circuit must provide sufficient sensitivity and good interference rejection, so that the recorded signal reflects actual muscle activity rather than environmental disturbance or poor contact conditions.&lt;br /&gt;
&lt;br /&gt;
=== Noise Sources in EMG (50 Hz, motion artifacts) ===&lt;br /&gt;
In practical EMG recording, the measured signal is easily contaminated by different types of noise. Two of the most common sources are power-line interference and motion artifacts. Power-line interference usually appears as a narrow-band component at 50 Hz in the local electrical environment, while motion artifacts are mainly caused by electrode movement, cable disturbance, or variations in the electrode–skin impedance, and are often concentrated in the low-frequency range. In addition, electronic noise from the acquisition hardware may also affect the recording quality. These unwanted components can reduce signal clarity and make muscle activity analysis less reliable, so they must be considered in the design of the signal processing pipeline.&lt;br /&gt;
[[File:background_theory_figure1.1_emg_noise_sources.png|center|thumb|700px|&#039;&#039;&#039;Figure 1.1.&#039;&#039;&#039; Principle of surface EMG acquisition.]]&lt;br /&gt;
&lt;br /&gt;
==System Architecture==&lt;br /&gt;
=== Total Structure Design ===&lt;br /&gt;
&lt;br /&gt;
For clarity，the proposed physiological signal acquisition system mainly consists of two core parts：the analog front－end （AFE）and the ADC board．The AFE is responsible for the preliminary conditioning of weak bioelectrical signals，including amplification，filtering，interference suppression，and level shifting，so that the analog waveform can be converted into a stable and measurable form．The ADC board then performs high－resolution digitization of the conditioned signal and transfers the sampled data to the host computer for subsequent display，storage，and analysis．Therefore，the overall system forms a complete signal－acquisition chain from weak physiological input to digital output．&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_1.jpg|thumb|center|800px|Figure 2.1. Overall system architecture of the proposed physiological signal acquisition platform，including the AFE and ADC modules．]]&lt;br /&gt;
&lt;br /&gt;
=== sEMG AFE Design ===&lt;br /&gt;
&lt;br /&gt;
To collect the weak bioelectric potential signals of the human body，an analog front－end（AFE）suitable sEMG measurements was designed．The module is powered by an external 5 V supply，and the complete circuit includes a first－ stage instrumentation amplifier based on INA128（Texas Instruments，Dallas，TX，USA），a band－pass filter，a 50 Hz notch filter，a second－order amplification and level shifting stage，a driver electrode circuit，a precise 1.5 V reference source，and a -5 V voltage generation module for powering the operational amplifiers．&lt;br /&gt;
&lt;br /&gt;
==== First－order Amplifier ====&lt;br /&gt;
&lt;br /&gt;
The input bioelectric signal is first acquired in differential form and applied to the INA128 instrumentation amplifier，which provides high input impedance，high common－mode rejection，and moderate initial gain for sEMG acquisition．This stage enlarges the weak physiological signal before filtering while reducing the risk of premature saturation caused by electrode offset or motion－induced disturbance，thereby preparing a more stable signal for the subsequent conditioning stages．&lt;br /&gt;
&lt;br /&gt;
==== Bandpass Filter ====&lt;br /&gt;
&lt;br /&gt;
After the instrumentation amplifier，the signal passes through a second－order active band－pass filter，as shown in Figure 2．2． This stage suppresses baseline drift and high－frequency noise outside the useful sEMG range，so that the low－frequency envelope information of sEMG can be preserved before further amplification．&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_2.jpg|thumb|center|800px|Figure 2.2. Schematic diagram of the active band-pass filter used in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the band-pass stage used to retain the main physiological signal band while suppressing unwanted lowand high-frequency components.&lt;br /&gt;
&lt;br /&gt;
==== Notch Filter ====&lt;br /&gt;
&lt;br /&gt;
To reduce power-line interference, a dedicated 50 Hz notch filter is introduced after the band-pass stage, as shown in Figure 2.3. This filter attenuates the mains-frequency component that commonly contaminates weak bioelectric measurements, thereby improving the signal-to-noise ratio of sEMG signals before the final amplification stage.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_3.jpg|thumb|center|800px|Figure 2.3. Schematic diagram of the 50 Hz notch filter used in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the circuit used to attenuate 50 Hz mains interference in the analog front end.&lt;br /&gt;
&lt;br /&gt;
==== Second-order Amplifier &amp;amp; Level Shifter ====&lt;br /&gt;
&lt;br /&gt;
After filtering, the signal enters the second-stage amplification and level-shifting circuit shown in Figure 2.4. In this stage, the filtered signal is further amplified to improve amplitude utilization and then shifted by a 1.5 V reference so that the output becomes a stable unipolar signal suitable for ADC sampling, while preserving linear operation and providing sufficient output swing margin.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_4.jpg|thumb|center|800px|Figure 2.4. Schematic diagram of the second-stage amplifier and level-shifting circuit in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows how the conditioned signal is further amplified and shifted to a suitable DC level before digitization.&lt;br /&gt;
&lt;br /&gt;
==== Power Module and Drive-electrode Circuit ====&lt;br /&gt;
&lt;br /&gt;
The AFE is powered by a 5 V supply and also integrates a 1.5 V precision reference, a -5 V generation circuit, and a driveelectrode circuit. These supporting modules provide the required supply rails and reference level for analog signal conditioning, while the drive-electrode circuit feeds back common-mode voltage to the body to suppress interference at the source. As a result, the complete AFE can support sEMG acquisition with adequate gain, filtering, and noise-reduction performance in a compact hardware structure.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_5.jpg|thumb|center|800px|Figure 2.5. Physical picture of the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the fabricated sEMG analog front-end hardware used in the system.&lt;br /&gt;
&lt;br /&gt;
Figure 2.5 presents the practical hardware implementation of the proposed sEMG AFE. It integrates amplification, filtering, level shifting, and driven-reference functions in a compact circuit for weak bioelectrical signal acquisition.&lt;br /&gt;
&lt;br /&gt;
=== ADS1256-based ADC Board ===&lt;br /&gt;
&lt;br /&gt;
To digitize the conditioned weak physiological signals with sufficient resolution and low noise, this project developed a dedicated ADC board based on the ADS1256 analog-to-digital converter (Texas Instruments, Dallas, TX, USA) and the STM32F103C8T6 microcontroller (STMicroelectronics, Geneva, Switzerland). The overall design objective of this board was not merely to realize analog-to-digital conversion, but to provide a complete hardware interface between the analog front-end and the digital processing unit, including precision reference generation, clocking, input protection and filtering, serial communication, power regulation, and MCU-based acquisition control. The ADS1256 was selected because it is a&lt;br /&gt;
&lt;br /&gt;
very low-noise 24-bit delta-sigma converter with a programmable gain amplifier (PGA), flexible input multiplexer, programmable digital filter, and SPI-compatible serial interface, which makes it well suited for weak low-frequency physiological signals after analog conditioning. The STM32F103C8T6 was used as the local controller because it provides a 32-bit Cortex-M3 core, up to 72 MHz system clock, SPI, USART, USB, and standard SWD debugging support in a compact and low-cost platform.&lt;br /&gt;
&lt;br /&gt;
==== ADC Core Architecture and Design Rationale ====&lt;br /&gt;
&lt;br /&gt;
The ADS1256 was selected as the core ADC because it provides high-resolution, low-noise delta-sigma conversion with an input multiplexer, programmable gain amplifier, and digital filter, which are suitable for weak and low-frequency physiological signals. As shown in Figure 2.6, this architecture emphasizes resolution and noise performance rather than high conversion bandwidth, making it appropriate for sEMG signal digitization after analog conditioning.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_6.jpg|thumb|center|800px|Figure 2.6. Internal functional structure of the ADS1256 analog-to-digital converter.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the main internal blocks of the ADS1256, including the multiplexer, PGA, modulator, and digital filter.&lt;br /&gt;
&lt;br /&gt;
==== Analog Front-End Interface, Reference, and Clocking ====&lt;br /&gt;
&lt;br /&gt;
The ADS1256 analog inputs are connected to the external header through a passive input-conditioning network that helps suppress high-frequency interference and improve input stability. In addition, the board includes a dedicated precision reference and clocking circuits so that the ADC can perform stable and accurate conversion. Together, these circuits provide a reliable analog interface and timing basis for high-resolution digitization of weak physiological signals.&lt;br /&gt;
&lt;br /&gt;
==== SPI Interface between ADS1256 and STM32F103C8T6 ====&lt;br /&gt;
&lt;br /&gt;
Communication between the ADS1256 and the STM32F103C8T6 is implemented through an SPI-compatible interface, with dedicated lines for chip select, serial clock, input/output data, data-ready notification, and hardware reset. This connection allows the MCU to configure the ADC, read conversion results in synchrony with DRDY, and maintain efficient and reliable acquisition control for multi-channel physiological measurements.&lt;br /&gt;
&lt;br /&gt;
==== Power Supply and On-board Regulation ====&lt;br /&gt;
&lt;br /&gt;
The ADC board uses a USB Type-B connector as the main power input and includes protection, voltage regulation, and local decoupling circuits to provide a stable supply for both the MCU and ADC-related hardware. In addition, analog ground and digital ground are separated in the PCB layout to reduce digital noise coupling into the analog path, which is particularly important for weak physiological signal acquisition.&lt;br /&gt;
&lt;br /&gt;
==== Basic Peripheral Circuits of the STM32F103C8T6 ====&lt;br /&gt;
&lt;br /&gt;
The STM32F103C8T6 serves as the local controller of the ADC board and is supported by several basic peripheral circuits, including an external crystal oscillator, reset network, BOOT0 configuration, SWD programming/debugging header, and a CH340N USB-to-UART bridge. These circuits ensure stable MCU operation, convenient firmware downloading and debugging, and reliable data transmission from the board to the host computer for real-time display and storage.&lt;br /&gt;
&lt;br /&gt;
==== Hardware-level Working Principle of the ADC Board ====&lt;br /&gt;
&lt;br /&gt;
In operation, the conditioned analog signal from the AFE enters the ADS1256 through the input header, is digitized with high resolution under the control of the local precision reference and clock, and is then read by the STM32 through the SPI interface. The MCU subsequently forwards the sampled data to the host computer through the serial communication link, so that the entire board functions as a compact digital acquisition backend connecting weak physiological analog signals to later software processing, display, and storage.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_7.jpg|thumb|center|800px|Figure 2.7. Photograph of the fabricated ADS1256-based ADC board developed in this project and the definitions of some key pins.]]&lt;br /&gt;
&lt;br /&gt;
Figure 2.7 shows the ADC board fabricated for this project. It integrates the ADS1256 conversion core, STM32 control circuit, power-conditioning circuits, and communication interfaces on a compact PCB for physiological signal digitization.&lt;br /&gt;
&lt;br /&gt;
== Signal Conditioning and Filtering ==&lt;br /&gt;
Although the AFE already performs preliminary band-pass filtering and 50 Hz interference suppression in the analog domain, the digitized sEMG signal may still contain residual noise due to component tolerances, electrode-contact variation, and environmental interference. Therefore, an additional digital filtering stage is implemented in software as a complementary post-processing step to improve signal quality and to provide a more stable input for rectification, envelope extraction, and subsequent analysis. In this sense, the software filtering is not a simple repetition of the analog filtering, but a refinement and compensation for non-ideal front-end behavior.&lt;br /&gt;
&lt;br /&gt;
Surface electromyographic (sEMG) signals are highly susceptible to several sources of contamination during acquisition. In practical measurements, the dominant disturbances usually include low-frequency motion artifacts caused by electrode movement and electrode–skin impedance variation, narrow-band power-line interference centered at 50 Hz, and broadband high-frequency electronic noise introduced by the acquisition hardware. These unwanted components degrade the quality of the recorded signal and may significantly affect the reliability of subsequent feature extraction, parameter estimation, and muscle activity interpretation. For this reason, an effective signal-conditioning procedure is necessary before any higher-level analysis is performed.&lt;br /&gt;
&lt;br /&gt;
In the present implementation, the filtering strategy follows the principle of restricting the signal bandwidth first and then removing the remaining narrow-band interference in a targeted manner. Accordingly, the raw sEMG signal is first processed by a fourth-order Butterworth IIR band-pass filter and then by a 50 Hz notch filter. This processing sequence is illustrated in the flowchart below, where the signal passes through band-pass filtering, notch filtering, full-wave rectification, and envelope extraction before producing the final processed output.&lt;br /&gt;
&lt;br /&gt;
[[File:flowchart.png|thumb|center|500px|Flowchart of the real-time sEMG signal conditioning pipeline.]]&lt;br /&gt;
&lt;br /&gt;
The rationale of this order is that the &#039;&#039;&#039;band-pass stage&#039;&#039;&#039; first confines the signal to the main spectral region of interest for sEMG, thereby attenuating motion artifacts at very low frequencies and suppressing high-frequency noise components outside the physiological band. After this spectral preconditioning, the notch stage can more effectively suppress the residual 50 Hz power-line interference that lies inside the useful sEMG band. In transfer-function form, the band-pass filter may be written as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;H_{BP}(z)=\frac{B_{BP}(z)}{A_{BP}(z)}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where the effective passband is selected as &amp;lt;math&amp;gt;20 \leq f \leq 160 \text{ Hz}&amp;lt;/math&amp;gt;. This frequency interval is consistent with the dominant spectral content of surface EMG: the lower cutoff near 20 Hz reduces motion artifacts and unstable low-frequency fluctuations, whereas the upper cutoff near 160 Hz removes high-frequency electronic noise while preserving the main energy-bearing components of the muscle signal. The use of a Butterworth structure is appropriate here because it provides a smooth monotonic passband response without ripple, which helps preserve signal morphology in real-time applications.&lt;br /&gt;
&lt;br /&gt;
After band limitation, a &#039;&#039;&#039;notch filter&#039;&#039;&#039; centered at the power-line frequency is applied to suppress interference that cannot be removed by the band-pass stage alone. The notch filter is designed around &amp;lt;math&amp;gt;f_0 = 50 \text{ Hz}&amp;lt;/math&amp;gt;, and its bandwidth is controlled by the quality factor &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;, which is expressed as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;Q = \frac{f_0}{\Delta f}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In transfer-function form, the notch stage is written as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;H_{N}(z)=\frac{B_{N}(z)}{A_{N}(z)}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the implemented program, a large quality factor is chosen so that the notch remains narrow, allowing effective rejection of the 50 Hz interference while minimizing distortion of neighboring useful spectral components. This is particularly important for sEMG because the interference frequency lies directly inside the physiological band of interest.&lt;br /&gt;
&lt;br /&gt;
Following the filtering stages, further signal conditioning is performed to obtain a representation that is more directly related to muscle activation intensity. The filtered sEMG waveform is first &#039;&#039;&#039;full-wave rectified&#039;&#039;&#039;, which converts the bipolar oscillatory signal into a unipolar signal by taking its absolute value.  Rectification does not remove noise by itself; instead, it transforms the signal into a form that is more suitable for amplitude-based analysis because both positive and negative deflections contribute positively to the activation measure.&lt;br /&gt;
&lt;br /&gt;
After rectification, the signal envelope is extracted to provide a smooth estimate of muscle activation level over time. In a general formulation, the envelope can be described as the &#039;&#039;&#039;low-pass filtered&#039;&#039;&#039; version of the rectified signal, namely &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y_{\mathrm{env}}[n] = \mathrm{LPF}\bigl(y_{\mathrm{rect}}[n]\bigr)&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the present code implementation, this operation is realized by short-time averaging over a finite window, which is equivalent to a moving-average low-pass smoothing of the rectified waveform. The corresponding expression is &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y_{\mathrm{env}}[n] = \frac{1}{N}\sum_{k=0}^{N-1} |x[n-k]|&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; is the window length in samples. With a window duration of approximately 200 ms, this envelope extraction method provides a stable and physiologically meaningful representation of muscle activation intensity, making it suitable for tasks such as force estimation, fatigue analysis, and motor-control studies.&lt;br /&gt;
&lt;br /&gt;
An important feature of the present &#039;&#039;&#039;implementation&#039;&#039;&#039; is that the entire filtering process is performed &#039;&#039;&#039;in real time&#039;&#039;&#039;, sample by sample, rather than by offline block processing. For this reason, IIR filters are preferred over FIR filters, since they can achieve comparable filtering performance with lower order, lower computational cost, and shorter delay. These properties are especially valuable in embedded systems, serial data streaming, and other low-latency experimental applications. However, unlike memoryless operations, an IIR filter depends not only on the current input but also on previous inputs and previous outputs. Its discrete-time behavior can therefore be represented by the recursive difference equation &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y[n] = \sum_{k=0}^{M} b_k x[n-k] - \sum_{k=1}^{N} a_k y[n-k]&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This equation makes clear that internal filter states must be preserved continuously during streaming operation. If the state variables were reinitialized for every incoming sample or data segment, artificial transients would appear and the output would no longer remain continuous.&lt;br /&gt;
&lt;br /&gt;
In the Python implementation, this state continuity is maintained using the internal initial-condition mechanism provided by SciPy, such as &amp;lt;code&amp;gt;lfilter_zi&amp;lt;/code&amp;gt;, together with recursive state updates during each filtering call. As a result, each newly acquired sample is passed first through the band-pass filter and then through the notch filter, while the internal states of both filters are updated after every step. This state-preserving sample-by-sample design ensures that the processing chain remains causal, continuous, and suitable for real-time display or downstream analysis without requiring storage of the entire signal segment.&lt;br /&gt;
&lt;br /&gt;
Overall, this signal-conditioning scheme provides an experimentally practical solution for real-time sEMG processing. The fourth-order Butterworth band-pass filter confines the signal to the main physiological band of interest, the 50 Hz notch filter removes narrow-band power-line contamination, and the subsequent rectification and envelope extraction generate a smooth amplitude descriptor of muscle activity. Combined with state-preserved streaming IIR implementation, this approach achieves a good balance between signal fidelity, computational efficiency, and real-time applicability in biomedical and physical experiment settings.&lt;br /&gt;
&lt;br /&gt;
== Experimental Setup ==&lt;br /&gt;
&lt;br /&gt;
=== Experimental Demonstration ===&lt;br /&gt;
&lt;br /&gt;
The experimental setup and data acquisition process are demonstrated in the video below.&lt;br /&gt;
&lt;br /&gt;
[https://www.youtube.com/watch?v=xxxx Click here to watch the full demonstration]&lt;br /&gt;
&lt;br /&gt;
The video illustrates the complete measurement procedure, including electrode placement, muscle activation, and real-time EMG signal visualization.&lt;br /&gt;
&lt;br /&gt;
=== Experimental Procedure ===&lt;br /&gt;
&lt;br /&gt;
Surface EMG signals were acquired using disposable electrodes placed on the forearm muscles responsible for wrist extension. &lt;br /&gt;
&lt;br /&gt;
Three electrodes were used in the measurement setup:&lt;br /&gt;
&lt;br /&gt;
* One electrode placed on the back of the hand serves as the reference electrode  &lt;br /&gt;
* The other two electrodes placed along the forearm muscle act as the differential input electrodes (positive and negative)  &lt;br /&gt;
&lt;br /&gt;
This configuration enables differential measurement of EMG signals while suppressing common-mode noise.&lt;br /&gt;
&lt;br /&gt;
The experimental movement consists of making a fist while extending the wrist backward. This action activates the forearm extensor muscles beneath the electrodes, producing measurable EMG signals.&lt;br /&gt;
&lt;br /&gt;
=== Data Acquisition Protocol ===&lt;br /&gt;
&lt;br /&gt;
Each subject performed repeated contraction–relaxation cycles under controlled conditions:&lt;br /&gt;
&lt;br /&gt;
* Number of subjects: 3  &lt;br /&gt;
* Number of trials per subject: 3  &lt;br /&gt;
* Duration of each trial: 30 seconds  &lt;br /&gt;
&lt;br /&gt;
During each trial, subjects were instructed to periodically contract and relax the muscle to generate clear dynamic EMG signals, while maintaining a stable resting state between contractions.&lt;br /&gt;
&lt;br /&gt;
=== System and Measurement Conditions ===&lt;br /&gt;
&lt;br /&gt;
The EMG signals were recorded and visualized in real time using a data acquisition system connected to a computer. The sampling rate was set to 400 Hz.&lt;br /&gt;
&lt;br /&gt;
To ensure consistency across measurements:&lt;br /&gt;
&lt;br /&gt;
* Electrode placement was kept consistent for all subjects  &lt;br /&gt;
* The same movement protocol was followed  &lt;br /&gt;
* Measurements were conducted under similar environmental conditions  &lt;br /&gt;
&lt;br /&gt;
=== Summary ===&lt;br /&gt;
&lt;br /&gt;
This experimental setup enables reliable acquisition of both resting and dynamic EMG signals, providing a consistent dataset for subsequent signal processing and performance evaluation.&lt;br /&gt;
&lt;br /&gt;
== Data Processing ==&lt;br /&gt;
&lt;br /&gt;
The objective of data processing is to convert raw surface electromyography (sEMG) recordings into stable, quantitative, and comparable indicators of muscle activity. Since EMG signals are low in amplitude, highly variable over time, and easily contaminated by noise, a dedicated processing pipeline is necessary before any experimental interpretation can be performed.&lt;br /&gt;
&lt;br /&gt;
In this project, the data processing workflow includes time normalization, signal pre-processing, sliding-window feature extraction, noise-floor estimation, and automatic contraction detection. The processed outputs are then used for subsequent experimental evaluation, including rest-versus-contraction discrimination, signal-to-noise ratio analysis, and repeatability assessment.&lt;br /&gt;
&lt;br /&gt;
=== Input Data and Time Normalization ===&lt;br /&gt;
&lt;br /&gt;
The acquired EMG data are read from CSV files containing two columns: time and filtered sEMG amplitude. In the MATLAB implementation, the time vector is normalized so that each recording starts from zero:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t = t_{all} - t_{all}(1)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This normalization is important because it removes the influence of absolute recording timestamps and makes different trials directly comparable on the same time axis.&lt;br /&gt;
&lt;br /&gt;
In addition, the signal type is automatically identified from the filename as either dynamic or rest. This design allows the same program to process both contraction recordings and resting recordings with different downstream analysis logic.&lt;br /&gt;
&lt;br /&gt;
=== Signal Pre-processing ===&lt;br /&gt;
&lt;br /&gt;
Raw EMG signals cannot be analyzed directly because they usually contain DC offset, low-frequency drift, motion artifacts, and residual high-frequency interference. Therefore, several pre-processing steps are applied before feature extraction.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(1) Baseline Removal&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The first step is DC offset removal:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
x_{dc}(t) = x(t) - \frac{1}{N}\sum_{i=1}^{N}x(i)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This operation centers the signal around zero. It is necessary because an uncorrected baseline would bias amplitude-based metrics and reduce the reliability of later envelope and feature calculations.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(2) Band-pass Filtering &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
After baseline correction, a fourth-order Butterworth band-pass filter is applied with a passband of 20–150 Hz.&lt;br /&gt;
&lt;br /&gt;
This step is introduced for two reasons:&lt;br /&gt;
&lt;br /&gt;
* The low-frequency cutoff at 20 Hz suppresses baseline drift and motion artifacts.&lt;br /&gt;
* The high-frequency cutoff at 150 Hz reduces unwanted high-frequency noise while preserving the main energy band of the recorded sEMG in this project.&lt;br /&gt;
&lt;br /&gt;
Compared with processing the raw waveform directly, band-pass filtering makes the subsequent time-domain features more stable and more physiologically meaningful.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(3) Full-wave Rectification&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The filtered EMG signal is bipolar, meaning that positive and negative phases coexist due to motor unit action potentials. If these positive and negative components are averaged directly, they may cancel each other out. To avoid this, full-wave rectification is performed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
x_{rect}(t) = |x_{filt}(t)|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This transforms the signal into a unipolar representation, so that all muscle activity contributes positively to the extracted features.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(4) Envelope Extraction &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Although the rectified signal reflects signal magnitude, it still fluctuates rapidly. To obtain a smoother representation of muscle activation level, an envelope is extracted using a moving average with a 100 ms window.&lt;br /&gt;
&lt;br /&gt;
Envelope extraction is important because contraction detection should reflect the overall activation trend rather than instantaneous spikes. A smoothed envelope is therefore more robust for identifying active and inactive muscle states.&lt;br /&gt;
&lt;br /&gt;
=== Sliding Window Design ===&lt;br /&gt;
&lt;br /&gt;
To quantify how muscle activity changes with time, the filtered signal is divided into overlapping short-time segments using a sliding window method.&lt;br /&gt;
&lt;br /&gt;
The window parameters are:&lt;br /&gt;
&lt;br /&gt;
* Window length: 250 ms&lt;br /&gt;
* Step size: 50 ms&lt;br /&gt;
&lt;br /&gt;
These values are chosen as a trade-off between temporal resolution and feature stability.&lt;br /&gt;
&lt;br /&gt;
A longer window improves statistical robustness because more samples are included in each calculation. However, if the window is too long, short contractions or rapid changes may be blurred. A smaller step size increases temporal continuity between adjacent feature points and makes the feature curves smoother in time. Therefore, the 250 ms / 50 ms design provides a practical balance between smoothing and time localization.&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt;-th segment, the feature time is defined as the mean time of that segment:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t_k = \frac{1}{N}\sum_{i=s_k}^{e_k} t(i)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;s_k&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;e_k&amp;lt;/math&amp;gt; denote the start and end indices of the window.&lt;br /&gt;
&lt;br /&gt;
=== Feature Extraction ===&lt;br /&gt;
&lt;br /&gt;
Within each sliding window, three time-domain features are extracted: RMS, iEMG, and MAV. These features are widely used in EMG analysis because they are simple, computationally efficient, and directly related to muscle activation intensity.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(1) Root Mean Square (RMS)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
RMS = \sqrt{\frac{1}{N}\sum_{i=1}^{N}x_i^2}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
RMS reflects the effective power of the EMG signal and is one of the most common indicators of contraction strength. It is sensitive to both amplitude and energy, making it especially useful for comparing rest and active states.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(2) Integrated EMG (iEMG)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
iEMG = \sum_{i=1}^{N}|x_i|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
iEMG describes the cumulative electrical activity within a window. It is often interpreted as a measure of total muscle effort over that time segment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(3) Mean Absolute Value (MAV)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
MAV = \frac{1}{N}\sum_{i=1}^{N}|x_i|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
MAV is an amplitude descriptor similar to iEMG, but normalized by the number of samples. It provides an efficient estimate of average signal level and is less computationally intensive than some other features.&lt;br /&gt;
&lt;br /&gt;
These three features are used together because they provide complementary descriptions of EMG intensity. RMS emphasizes signal energy, iEMG emphasizes cumulative activation, and MAV reflects average amplitude.&lt;br /&gt;
&lt;br /&gt;
=== Peak-value Extraction ===&lt;br /&gt;
&lt;br /&gt;
In addition to continuous feature curves, several key peak values are extracted from the processed signal:&lt;br /&gt;
&lt;br /&gt;
* maximum and minimum of the filtered EMG waveform&lt;br /&gt;
* peak of the envelope&lt;br /&gt;
* peak RMS&lt;br /&gt;
* peak iEMG&lt;br /&gt;
* peak MAV&lt;br /&gt;
&lt;br /&gt;
These peak values provide concise descriptors of the strongest activity observed in each recording. They are useful for quick comparison across trials and subjects.&lt;br /&gt;
&lt;br /&gt;
=== Noise Floor Estimation ===&lt;br /&gt;
&lt;br /&gt;
To evaluate signal quality, the noise floor is estimated from a reference resting interval. In the present implementation, the first 3 seconds of the recording are used as the default rest reference:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t \in [0,\min(3,t_{end})]&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this segment, three noise descriptors are computed:&lt;br /&gt;
&lt;br /&gt;
* Noise RMS&lt;br /&gt;
* Noise standard deviation&lt;br /&gt;
* Noise peak-to-peak amplitude&lt;br /&gt;
&lt;br /&gt;
Noise-floor estimation is important because EMG amplitude alone is not sufficient to judge recording quality. A large signal is only meaningful if it is sufficiently higher than the baseline noise level. Therefore, the noise floor serves as the reference for later SNR calculation and for designing contraction thresholds.&lt;br /&gt;
&lt;br /&gt;
=== Global Signal Metrics ===&lt;br /&gt;
&lt;br /&gt;
For each recording, three global metrics are also computed over the entire filtered signal:&lt;br /&gt;
&lt;br /&gt;
* Global RMS&lt;br /&gt;
* Global MAV&lt;br /&gt;
* Global iEMG&lt;br /&gt;
&lt;br /&gt;
These global descriptors summarize the overall signal level of the full recording and are later used in group-level comparisons.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Contraction Detection ===&lt;br /&gt;
&lt;br /&gt;
For dynamic recordings, an automatic contraction detection algorithm is used to identify repeated active segments. This is one of the key parts of the data processing pipeline, because it transforms a continuous EMG trace into discrete contraction events that can be counted and compared.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(1) Threshold Design&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The detection threshold is designed adaptively rather than using a fixed value. Two candidate thresholds are first calculated:&lt;br /&gt;
&lt;br /&gt;
* an envelope-based threshold derived from the global envelope mean and standard deviation&lt;br /&gt;
* a rest-reference threshold derived from the mean and standard deviation of the resting reference amplitude&lt;br /&gt;
&lt;br /&gt;
The final threshold is taken as the larger of the two after additional scaling. This strategy improves robustness because it combines the global activation level of the signal with the baseline noise characteristics of the individual recording.&lt;br /&gt;
&lt;br /&gt;
This adaptive threshold design is preferable to a manually fixed threshold because EMG amplitude can vary strongly between subjects, muscles, and recording sessions.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(2) Initial Segmentation&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
After thresholding the envelope, the signal is classified into active and inactive regions:&lt;br /&gt;
&lt;br /&gt;
* active: envelope above threshold&lt;br /&gt;
* inactive: envelope below threshold&lt;br /&gt;
&lt;br /&gt;
The rising and falling edges of the binary activity vector are then used to determine the start and end points of each candidate contraction segment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(3) Removal of Short Segments&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Very short active regions are often caused by noise fluctuations rather than true muscle contractions. Therefore, segments shorter than 0.20 s are discarded.&lt;br /&gt;
&lt;br /&gt;
This step prevents false positive detections and increases the physiological relevance of the segmentation results.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(4) Merging of Adjacent Segments &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If two neighboring active segments are separated by a very short gap, they are merged when the gap is less than 0.15 s.&lt;br /&gt;
&lt;br /&gt;
This operation is necessary because a single real contraction may be temporarily interrupted by a brief drop in the envelope caused by local fluctuation. Without merging, one contraction could be incorrectly counted as multiple repetitions.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(5) Repetition-level Metrics &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
For each detected contraction segment, two repetition-level metrics are extracted:&lt;br /&gt;
&lt;br /&gt;
* peak RMS of that contraction&lt;br /&gt;
* mean RMS of that contraction&lt;br /&gt;
&lt;br /&gt;
These metrics quantify both the strongest activation within each repetition and the average activation level over the repetition duration.&lt;br /&gt;
&lt;br /&gt;
=== Repeatability Analysis ===&lt;br /&gt;
&lt;br /&gt;
When multiple valid contractions are detected, repeatability is evaluated using the coefficient of variation (CV):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
CV = \frac{\sigma}{\mu}\times 100\%&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt; is the standard deviation and &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is the mean value across repetitions.&lt;br /&gt;
&lt;br /&gt;
Two CV values are computed:&lt;br /&gt;
&lt;br /&gt;
* CV of repetition peak RMS&lt;br /&gt;
* CV of repetition mean RMS&lt;br /&gt;
&lt;br /&gt;
A lower CV indicates better repeatability, meaning that repeated contractions produce more consistent EMG responses.&lt;br /&gt;
&lt;br /&gt;
=== Signal-to-Noise Ratio (SNR) ===&lt;br /&gt;
&lt;br /&gt;
In this project, the signal-to-noise ratio (SNR) is defined based on the ratio between contraction and rest activity:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
SNR_{dB} = 20\log_{10}\left(\frac{RMS_{contraction}}{RMS_{rest}}\right)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This definition is adopted because it directly reflects the system’s ability to distinguish active muscle contraction from baseline noise.&lt;br /&gt;
&lt;br /&gt;
Compared with global SNR definitions, this formulation is more relevant for practical EMG applications such as activity detection and classification.&lt;br /&gt;
&lt;br /&gt;
=== Rest-versus-Contraction Window Comparison ===&lt;br /&gt;
&lt;br /&gt;
To further distinguish inactive and active states, all sliding windows are divided into two groups:&lt;br /&gt;
&lt;br /&gt;
* rest windows: windows with envelope clearly below the threshold&lt;br /&gt;
* contraction windows: windows with envelope above the threshold&lt;br /&gt;
&lt;br /&gt;
The RMS values of these two groups are then compared statistically.&lt;br /&gt;
&lt;br /&gt;
This comparison is important because a practical EMG system should not only detect signal presence, but also clearly separate rest from contraction in a quantitative way. If the two RMS distributions are well separated, it indicates that the system has good discriminative capability.&lt;br /&gt;
&lt;br /&gt;
=== Output Data Structure ===&lt;br /&gt;
&lt;br /&gt;
The processed outputs are organized into structured data for experimental analysis:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(1) Time-series outputs&#039;&#039;&#039;&lt;br /&gt;
* Filtered EMG signal  &lt;br /&gt;
* Rectified signal  &lt;br /&gt;
* Envelope  &lt;br /&gt;
* RMS(t), iEMG(t), MAV(t)  &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(2) Recording-level outputs&#039;&#039;&#039; &lt;br /&gt;
* RMS (rest)  &lt;br /&gt;
* RMS (contraction)  &lt;br /&gt;
* iEMG  &lt;br /&gt;
* Noise metrics  &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(3) Dynamic-signal outputs &#039;&#039;&#039;&lt;br /&gt;
* Detected contractions  &lt;br /&gt;
* Repetition count  &lt;br /&gt;
* Peak RMS per repetition  &lt;br /&gt;
* Mean RMS per repetition  &lt;br /&gt;
* Coefficient of variation (CV)  &lt;br /&gt;
* Signal-to-noise ratio (SNR)  &lt;br /&gt;
&lt;br /&gt;
All extracted features are designed to directly support the evaluation of noise level, signal quality, activity discrimination, and repeatability in the subsequent experimental analysis.&lt;br /&gt;
&lt;br /&gt;
== Experimental Results ==&lt;br /&gt;
&lt;br /&gt;
This section presents representative results of the EMG acquisition and data processing pipeline under both dynamic (muscle contraction) and resting conditions.&lt;br /&gt;
&lt;br /&gt;
=== Representative Dynamic Signal Analysis ===&lt;br /&gt;
&lt;br /&gt;
[[File:Dynamic_Figure1.png|thumb|800px|center|Figure 5.1: Processed EMG signal under dynamic contraction, including filtered signal, rectified signal with envelope, and extracted features (RMS, iEMG, MAV).]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.1 shows the processed EMG signal during repeated muscle contractions.&lt;br /&gt;
&lt;br /&gt;
The filtered EMG waveform exhibits clear burst-like patterns corresponding to periodic contractions. The signal amplitude reaches a maximum of approximately 0.45, while the baseline remains centered around zero, indicating effective baseline removal and filtering.&lt;br /&gt;
&lt;br /&gt;
After rectification and envelope extraction, the contraction periods become clearly distinguishable. The envelope provides a smooth representation of muscle activation, with a peak value of approximately 0.145.&lt;br /&gt;
&lt;br /&gt;
The extracted time-domain features (RMS, iEMG, MAV) further quantify the signal. Among these, iEMG shows the strongest dynamic variation, indicating high sensitivity to contraction intensity.&lt;br /&gt;
&lt;br /&gt;
=== Noise Floor and Rest Reference ===&lt;br /&gt;
&lt;br /&gt;
[[File:Dynamic_Figure2.png|thumb|800px|center|Figure 5.2: Noise estimation, rest vs contraction comparison, automatic contraction detection, and repetition analysis.]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (top-left) shows the resting reference segment used for noise estimation.&lt;br /&gt;
&lt;br /&gt;
The signal remains centered around zero with small fluctuations. The noise characteristics are:&lt;br /&gt;
&lt;br /&gt;
* Noise RMS ≈ 0.0046  &lt;br /&gt;
* Standard deviation ≈ 0.0046  &lt;br /&gt;
* Peak-to-peak amplitude ≈ 0.071  &lt;br /&gt;
&lt;br /&gt;
This indicates a low noise floor and stable measurement conditions.&lt;br /&gt;
&lt;br /&gt;
=== Rest vs Contraction Discrimination ===&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (top-right) compares RMS values between rest and contraction states.&lt;br /&gt;
&lt;br /&gt;
The two distributions are clearly separated:&lt;br /&gt;
&lt;br /&gt;
* Rest mean RMS ≈ 0.0053  &lt;br /&gt;
* Contraction mean RMS ≈ 0.1064  &lt;br /&gt;
&lt;br /&gt;
This corresponds to an approximate 20× increase, demonstrating strong discriminability between inactive and active muscle states.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Contraction Detection ===&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (bottom-left) illustrates automatic detection based on the envelope signal.&lt;br /&gt;
&lt;br /&gt;
A threshold of approximately 0.040 is applied, resulting in stable segmentation of contraction periods.&lt;br /&gt;
&lt;br /&gt;
A total of 12 repetitions are detected, with good alignment to visible signal peaks.&lt;br /&gt;
&lt;br /&gt;
=== Repeatability Analysis ===&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (bottom-right) shows the peak RMS value of each detected contraction.&lt;br /&gt;
&lt;br /&gt;
The results indicate:&lt;br /&gt;
&lt;br /&gt;
* Mean peak RMS ≈ 0.1355  &lt;br /&gt;
* Standard deviation ≈ 0.0173  &lt;br /&gt;
* CV ≈ 12.77%  &lt;br /&gt;
* SNR ≈ 21.26 dB  &lt;br /&gt;
&lt;br /&gt;
This indicates acceptable repeatability and good signal quality.&lt;br /&gt;
&lt;br /&gt;
=== Representative Rest Signal Analysis ===&lt;br /&gt;
&lt;br /&gt;
[[File:Rest_Figure1.png|thumb|800px|center|Figure 5.3: Processed EMG signal under rest condition, showing low amplitude and absence of contraction patterns.]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.3 shows the EMG signal under resting conditions.&lt;br /&gt;
&lt;br /&gt;
The signal remains within a narrow amplitude range (approximately ±0.04) and shows no burst-like structures. The envelope remains close to zero, confirming the absence of muscle activity.&lt;br /&gt;
&lt;br /&gt;
The extracted features remain low:&lt;br /&gt;
&lt;br /&gt;
* RMS ≈ 0.007  &lt;br /&gt;
* MAV ≈ 0.005  &lt;br /&gt;
* iEMG remains stable  &lt;br /&gt;
&lt;br /&gt;
This confirms that no false activation is detected.&lt;br /&gt;
&lt;br /&gt;
=== Frequency-domain Characteristics ===&lt;br /&gt;
&lt;br /&gt;
[[File:Rest_Figure2.png|thumb|800px|center|Figure 5.4: Frequency-domain analysis and statistical characteristics of rest signal.]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.4 shows the frequency-domain characteristics of the resting signal.&lt;br /&gt;
&lt;br /&gt;
The power spectral density (PSD) indicates low overall signal energy without dominant peaks, confirming that the signal mainly consists of noise.&lt;br /&gt;
&lt;br /&gt;
=== Summary of Single-recording Performance ===&lt;br /&gt;
&lt;br /&gt;
From the representative results:&lt;br /&gt;
&lt;br /&gt;
* EMG signals are effectively extracted and denoised  &lt;br /&gt;
* Contraction events are clearly identifiable  &lt;br /&gt;
* Rest and contraction states are well separated  &lt;br /&gt;
* Automatic detection is stable and accurate  &lt;br /&gt;
* Repeatability is acceptable  &lt;br /&gt;
* No false activation occurs under rest conditions  &lt;br /&gt;
&lt;br /&gt;
=== Consistency Across Multiple Recordings ===&lt;br /&gt;
&lt;br /&gt;
The same data processing pipeline was applied to multiple recordings from different subjects and trials.&lt;br /&gt;
&lt;br /&gt;
Across all datasets, consistent patterns were observed:&lt;br /&gt;
&lt;br /&gt;
* Dynamic signals exhibit clear burst-like structures corresponding to repeated muscle contractions  &lt;br /&gt;
* Rest signals remain low in amplitude without distinct activation patterns  &lt;br /&gt;
* RMS values under contraction are consistently higher than those under rest  &lt;br /&gt;
* The automatic detection algorithm reliably identifies contraction segments  &lt;br /&gt;
&lt;br /&gt;
Although quantitative values (e.g., RMS, SNR, CV) vary across recordings due to differences in electrode contact, muscle activation strength, and individual conditions, the overall trends remain consistent.&lt;br /&gt;
&lt;br /&gt;
These results demonstrate the robustness and general applicability of the proposed signal processing method.&lt;br /&gt;
&lt;br /&gt;
== Multi-subject Analysis ==&lt;br /&gt;
=== System Evaluation ===&lt;br /&gt;
&lt;br /&gt;
This section evaluates the performance of the EMG acquisition system in terms of noise level, signal quality, activity discrimination, and repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Noise Floor Analysis ====&lt;br /&gt;
&lt;br /&gt;
The noise floor was evaluated using rest-state recordings, characterized by RMS noise, standard deviation, and peak-to-peak amplitude.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039; shows the lowest noise level (RMS ≈ 0.0046), indicating stable electrode contact and minimal interference.  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039; exhibits moderate noise (RMS ≈ 0.0080), likely influenced by motion artifacts or electrode–skin impedance variation.  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039; shows relatively higher noise (RMS ≈ 0.0126), suggesting increased baseline fluctuation.  &lt;br /&gt;
&lt;br /&gt;
Overall, the system maintains a low noise floor across subjects, although the quality depends on experimental conditions such as electrode contact and environmental interference.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Signal-to-Noise Ratio (SNR) ====&lt;br /&gt;
&lt;br /&gt;
The signal-to-noise ratio (SNR) is defined as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{SNR (dB)} = 20 \log_{10} \left( \frac{\mathrm{RMS}_{\mathrm{contraction}}}{\mathrm{RMS}_{\mathrm{rest}}} \right)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The measured SNR values are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: 21.26 dB → good signal quality  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: 13.52 dB → moderate and usable  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: 6.66 dB → low signal clarity  &lt;br /&gt;
&lt;br /&gt;
General interpretation:&lt;br /&gt;
&lt;br /&gt;
* &amp;gt;20 dB → good  &lt;br /&gt;
* 10–20 dB → usable  &lt;br /&gt;
* &amp;lt;10 dB → poor  &lt;br /&gt;
&lt;br /&gt;
These results show that the system can achieve reliable signal acquisition, although performance varies across subjects.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
====  Rest vs Contraction Discrimination ====&lt;br /&gt;
&lt;br /&gt;
A clear distinction between rest and contraction states is observed based on RMS values.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: 0.0053 → 0.1064 (≈20× increase)  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: 0.0079 → 0.0283 (≈3.6× increase)  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: 0.0141 → 0.0646 (≈4.6× increase)  &lt;br /&gt;
&lt;br /&gt;
This demonstrates that the system is capable of separating muscle activity from baseline noise.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Conclusion:&#039;&#039;  &lt;br /&gt;
The system can be used for basic muscle activity detection and simple classification tasks based on RMS features.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Repeatability of Repeated Contractions ====&lt;br /&gt;
&lt;br /&gt;
Repeatability is evaluated using the coefficient of variation (CV) of peak RMS values across repetitions.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! CV Range !! Evaluation&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt; 10% || Excellent&lt;br /&gt;
|-&lt;br /&gt;
| 10–20% || Acceptable&lt;br /&gt;
|-&lt;br /&gt;
| &amp;gt; 20% || Poor&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Results:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: CV = 12.77% → Acceptable  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: CV = 24.77% → Poor  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: CV = 10.60% → Acceptable  &lt;br /&gt;
&lt;br /&gt;
Although WANG&#039;s signal is detectable, its contraction amplitude varies significantly across repetitions, resulting in poor repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
=== Overall System Performance ===&lt;br /&gt;
&lt;br /&gt;
The system demonstrates the following performance characteristics:&lt;br /&gt;
&lt;br /&gt;
* Reliable detection of muscle activity across all subjects  &lt;br /&gt;
* Clear separation between rest and contraction states  &lt;br /&gt;
* Moderate to high signal quality depending on subject conditions  &lt;br /&gt;
* Repeatability ranging from acceptable to poor due to user-dependent factors  &lt;br /&gt;
&lt;br /&gt;
Overall, the designed EMG acquisition system is capable of stable signal acquisition and feature extraction, with performance primarily influenced by electrode contact quality, skin impedance, and motion consistency.&lt;br /&gt;
&lt;br /&gt;
===== Summary of Quantitative Metrics =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Subject !! RMS (Rest) !! RMS (Contraction) !! Separation Ratio !! iEMG (max) !! Noise RMS !! SNR (dB) !! CV (%) !! Evaluation&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;LIU&#039;&#039;&#039; || 0.0053 || 0.1064 || &#039;&#039;&#039;20.1×&#039;&#039;&#039; || 12.72 || 0.0046 || &#039;&#039;&#039;21.26&#039;&#039;&#039; || 12.77 || Strong signal, good quality&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;WANG&#039;&#039;&#039; || 0.0079 || 0.0283 || 3.57× || 11.10 || 0.0080 || 13.52 || &#039;&#039;&#039;24.77&#039;&#039;&#039; || Usable signal, poor repeatability&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ZHONG&#039;&#039;&#039; || 0.0141 || 0.0646 || 4.58× || 6.70 || 0.0126 || 6.66 || 10.60 || Acceptable performance&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Summary:&#039;&#039; Subject LIU shows the best overall performance, WANG provides usable but less stable signals, and ZHONG demonstrates moderate signal quality with good repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Activation Intensity =====&lt;br /&gt;
&lt;br /&gt;
Among the three subjects, &#039;&#039;&#039;LIU exhibits the strongest muscle activation&#039;&#039;&#039;, as indicated by the highest contraction RMS and iEMG values. ZHONG shows moderate activation, while WANG demonstrates comparable iEMG but lower RMS consistency.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Signal Quality =====&lt;br /&gt;
&lt;br /&gt;
Signal quality is evaluated based on SNR and noise level:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039; achieves the highest SNR and lowest noise → best signal quality  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039; shows moderate SNR → usable but less robust  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039; has the lowest SNR → weakest signal clarity  &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Repeatability =====&lt;br /&gt;
&lt;br /&gt;
Repeatability is evaluated using the coefficient of variation (CV):&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;ZHONG (10.60%)&#039;&#039;&#039; → most stable  &lt;br /&gt;
* &#039;&#039;&#039;LIU (12.77%)&#039;&#039;&#039; → acceptable  &lt;br /&gt;
* &#039;&#039;&#039;WANG (24.77%)&#039;&#039;&#039; → poor  &lt;br /&gt;
&lt;br /&gt;
This indicates that WANG’s contraction strength varies significantly between repetitions.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Engineering Interpretation of Inter-subject Differences =====&lt;br /&gt;
&lt;br /&gt;
The observed differences are mainly attributed to engineering and experimental factors rather than physiological differences.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Electrode contact quality&#039;&#039;&#039;  &lt;br /&gt;
  Variations in electrode placement, pressure, and gel contact affect signal amplitude and stability.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Skin impedance&#039;&#039;&#039;  &lt;br /&gt;
  Differences in skin condition (hydration, oil, hair) influence electrode–skin impedance, affecting noise level and signal coupling.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Muscle control consistency&#039;&#039;&#039;  &lt;br /&gt;
  Variations in contraction strength and timing affect repeatability and CV.&lt;br /&gt;
&lt;br /&gt;
Therefore, the variation across subjects reflects practical acquisition conditions rather than intrinsic system limitations.&lt;/div&gt;</summary>
		<author><name>Wang Jingyi</name></author>
	</entry>
	<entry>
		<id>https://pc5271.org/index.php?title=Surface_EMG_Sensor_for_Muscle_Activity_Measurement:_AFE_Design_and_Signal_Processing&amp;diff=1366</id>
		<title>Surface EMG Sensor for Muscle Activity Measurement: AFE Design and Signal Processing</title>
		<link rel="alternate" type="text/html" href="https://pc5271.org/index.php?title=Surface_EMG_Sensor_for_Muscle_Activity_Measurement:_AFE_Design_and_Signal_Processing&amp;diff=1366"/>
		<updated>2026-04-23T07:43:32Z</updated>

		<summary type="html">&lt;p&gt;Wang Jingyi: /* Signal Conditioning and Filtering */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Background and Theory==&lt;br /&gt;
&lt;br /&gt;
=== Surface EMG Signals ===&lt;br /&gt;
Surface electromyography (sEMG) refers to the bioelectrical signals detected on the skin surface during muscle contraction. These signals originate from the electrical activity of muscle fibers and provide a non-invasive way to monitor muscle activation. Compared with invasive EMG methods, sEMG is easier to apply, safer for repeated measurements, and more suitable for real-time monitoring. Therefore, it has been widely used in areas such as rehabilitation, motion analysis, human–machine interaction, and physiological monitoring.&lt;br /&gt;
&lt;br /&gt;
=== Characteristics of EMG Signals ===&lt;br /&gt;
EMG signals are generally weak, time-varying, and stochastic in nature. Their waveforms are typically bipolar, fluctuating around zero with both positive and negative components. The amplitude and frequency content of EMG signals depend on factors such as muscle contraction level, electrode placement, skin condition, and individual physiological differences. In practice, the useful frequency components of sEMG are mainly concentrated in a limited low-to-mid frequency range. Because of their low amplitude and variability, EMG signals usually require further conditioning before reliable interpretation and feature extraction can be performed.&lt;br /&gt;
&lt;br /&gt;
=== Bioelectrical Signal Acquisition Principles ===&lt;br /&gt;
The acquisition of bioelectrical signals is based on measuring the small potential difference on the skin surface using electrodes, then converting it into a processable electrical signal through amplification and digitization. For sEMG measurement, electrode placement and skin–electrode contact quality are especially important, since they directly affect signal amplitude and stability. In addition, the front-end acquisition circuit must provide sufficient sensitivity and good interference rejection, so that the recorded signal reflects actual muscle activity rather than environmental disturbance or poor contact conditions.&lt;br /&gt;
&lt;br /&gt;
=== Noise Sources in EMG (50 Hz, motion artifacts) ===&lt;br /&gt;
In practical EMG recording, the measured signal is easily contaminated by different types of noise. Two of the most common sources are power-line interference and motion artifacts. Power-line interference usually appears as a narrow-band component at 50 Hz in the local electrical environment, while motion artifacts are mainly caused by electrode movement, cable disturbance, or variations in the electrode–skin impedance, and are often concentrated in the low-frequency range. In addition, electronic noise from the acquisition hardware may also affect the recording quality. These unwanted components can reduce signal clarity and make muscle activity analysis less reliable, so they must be considered in the design of the signal processing pipeline.&lt;br /&gt;
[[File:background_theory_figure1.1_emg_noise_sources.png|center|thumb|700px|&#039;&#039;&#039;Figure 1.1.&#039;&#039;&#039; Principle of surface EMG acquisition.]]&lt;br /&gt;
&lt;br /&gt;
==System Architecture==&lt;br /&gt;
=== Total Structure Design ===&lt;br /&gt;
&lt;br /&gt;
For clarity，the proposed physiological signal acquisition system mainly consists of two core parts：the analog front－end （AFE）and the ADC board．The AFE is responsible for the preliminary conditioning of weak bioelectrical signals，including amplification，filtering，interference suppression，and level shifting，so that the analog waveform can be converted into a stable and measurable form．The ADC board then performs high－resolution digitization of the conditioned signal and transfers the sampled data to the host computer for subsequent display，storage，and analysis．Therefore，the overall system forms a complete signal－acquisition chain from weak physiological input to digital output．&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_1.jpg|thumb|center|800px|Figure 2.1. Overall system architecture of the proposed physiological signal acquisition platform，including the AFE and ADC modules．]]&lt;br /&gt;
&lt;br /&gt;
=== sEMG AFE Design ===&lt;br /&gt;
&lt;br /&gt;
To collect the weak bioelectric potential signals of the human body，an analog front－end（AFE）suitable sEMG measurements was designed．The module is powered by an external 5 V supply，and the complete circuit includes a first－ stage instrumentation amplifier based on INA128（Texas Instruments，Dallas，TX，USA），a band－pass filter，a 50 Hz notch filter，a second－order amplification and level shifting stage，a driver electrode circuit，a precise 1.5 V reference source，and a -5 V voltage generation module for powering the operational amplifiers．&lt;br /&gt;
&lt;br /&gt;
==== First－order Amplifier ====&lt;br /&gt;
&lt;br /&gt;
The input bioelectric signal is first acquired in differential form and applied to the INA128 instrumentation amplifier，which provides high input impedance，high common－mode rejection，and moderate initial gain for sEMG acquisition．This stage enlarges the weak physiological signal before filtering while reducing the risk of premature saturation caused by electrode offset or motion－induced disturbance，thereby preparing a more stable signal for the subsequent conditioning stages．&lt;br /&gt;
&lt;br /&gt;
==== Bandpass Filter ====&lt;br /&gt;
&lt;br /&gt;
After the instrumentation amplifier，the signal passes through a second－order active band－pass filter，as shown in Figure 2．2． This stage suppresses baseline drift and high－frequency noise outside the useful sEMG range，so that the low－frequency envelope information of sEMG can be preserved before further amplification．&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_2.jpg|thumb|center|800px|Figure 2.2. Schematic diagram of the active band-pass filter used in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the band-pass stage used to retain the main physiological signal band while suppressing unwanted lowand high-frequency components.&lt;br /&gt;
&lt;br /&gt;
==== Notch Filter ====&lt;br /&gt;
&lt;br /&gt;
To reduce power-line interference, a dedicated 50 Hz notch filter is introduced after the band-pass stage, as shown in Figure 2.3. This filter attenuates the mains-frequency component that commonly contaminates weak bioelectric measurements, thereby improving the signal-to-noise ratio of sEMG signals before the final amplification stage.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_3.jpg|thumb|center|800px|Figure 2.3. Schematic diagram of the 50 Hz notch filter used in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the circuit used to attenuate 50 Hz mains interference in the analog front end.&lt;br /&gt;
&lt;br /&gt;
==== Second-order Amplifier &amp;amp; Level Shifter ====&lt;br /&gt;
&lt;br /&gt;
After filtering, the signal enters the second-stage amplification and level-shifting circuit shown in Figure 2.4. In this stage, the filtered signal is further amplified to improve amplitude utilization and then shifted by a 1.5 V reference so that the output becomes a stable unipolar signal suitable for ADC sampling, while preserving linear operation and providing sufficient output swing margin.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_4.jpg|thumb|center|800px|Figure 2.4. Schematic diagram of the second-stage amplifier and level-shifting circuit in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows how the conditioned signal is further amplified and shifted to a suitable DC level before digitization.&lt;br /&gt;
&lt;br /&gt;
==== Power Module and Drive-electrode Circuit ====&lt;br /&gt;
&lt;br /&gt;
The AFE is powered by a 5 V supply and also integrates a 1.5 V precision reference, a -5 V generation circuit, and a driveelectrode circuit. These supporting modules provide the required supply rails and reference level for analog signal conditioning, while the drive-electrode circuit feeds back common-mode voltage to the body to suppress interference at the source. As a result, the complete AFE can support sEMG acquisition with adequate gain, filtering, and noise-reduction performance in a compact hardware structure.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_5.jpg|thumb|center|800px|Figure 2.5. Physical picture of the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the fabricated sEMG analog front-end hardware used in the system.&lt;br /&gt;
&lt;br /&gt;
Figure 2.5 presents the practical hardware implementation of the proposed sEMG AFE. It integrates amplification, filtering, level shifting, and driven-reference functions in a compact circuit for weak bioelectrical signal acquisition.&lt;br /&gt;
&lt;br /&gt;
=== ADS1256-based ADC Board ===&lt;br /&gt;
&lt;br /&gt;
To digitize the conditioned weak physiological signals with sufficient resolution and low noise, this project developed a dedicated ADC board based on the ADS1256 analog-to-digital converter (Texas Instruments, Dallas, TX, USA) and the STM32F103C8T6 microcontroller (STMicroelectronics, Geneva, Switzerland). The overall design objective of this board was not merely to realize analog-to-digital conversion, but to provide a complete hardware interface between the analog front-end and the digital processing unit, including precision reference generation, clocking, input protection and filtering, serial communication, power regulation, and MCU-based acquisition control. The ADS1256 was selected because it is a&lt;br /&gt;
&lt;br /&gt;
very low-noise 24-bit delta-sigma converter with a programmable gain amplifier (PGA), flexible input multiplexer, programmable digital filter, and SPI-compatible serial interface, which makes it well suited for weak low-frequency physiological signals after analog conditioning. The STM32F103C8T6 was used as the local controller because it provides a 32-bit Cortex-M3 core, up to 72 MHz system clock, SPI, USART, USB, and standard SWD debugging support in a compact and low-cost platform.&lt;br /&gt;
&lt;br /&gt;
==== ADC Core Architecture and Design Rationale ====&lt;br /&gt;
&lt;br /&gt;
The ADS1256 was selected as the core ADC because it provides high-resolution, low-noise delta-sigma conversion with an input multiplexer, programmable gain amplifier, and digital filter, which are suitable for weak and low-frequency physiological signals. As shown in Figure 2.6, this architecture emphasizes resolution and noise performance rather than high conversion bandwidth, making it appropriate for sEMG signal digitization after analog conditioning.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_6.jpg|thumb|center|800px|Figure 2.6. Internal functional structure of the ADS1256 analog-to-digital converter.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the main internal blocks of the ADS1256, including the multiplexer, PGA, modulator, and digital filter.&lt;br /&gt;
&lt;br /&gt;
==== Analog Front-End Interface, Reference, and Clocking ====&lt;br /&gt;
&lt;br /&gt;
The ADS1256 analog inputs are connected to the external header through a passive input-conditioning network that helps suppress high-frequency interference and improve input stability. In addition, the board includes a dedicated precision reference and clocking circuits so that the ADC can perform stable and accurate conversion. Together, these circuits provide a reliable analog interface and timing basis for high-resolution digitization of weak physiological signals.&lt;br /&gt;
&lt;br /&gt;
==== SPI Interface between ADS1256 and STM32F103C8T6 ====&lt;br /&gt;
&lt;br /&gt;
Communication between the ADS1256 and the STM32F103C8T6 is implemented through an SPI-compatible interface, with dedicated lines for chip select, serial clock, input/output data, data-ready notification, and hardware reset. This connection allows the MCU to configure the ADC, read conversion results in synchrony with DRDY, and maintain efficient and reliable acquisition control for multi-channel physiological measurements.&lt;br /&gt;
&lt;br /&gt;
==== Power Supply and On-board Regulation ====&lt;br /&gt;
&lt;br /&gt;
The ADC board uses a USB Type-B connector as the main power input and includes protection, voltage regulation, and local decoupling circuits to provide a stable supply for both the MCU and ADC-related hardware. In addition, analog ground and digital ground are separated in the PCB layout to reduce digital noise coupling into the analog path, which is particularly important for weak physiological signal acquisition.&lt;br /&gt;
&lt;br /&gt;
==== Basic Peripheral Circuits of the STM32F103C8T6 ====&lt;br /&gt;
&lt;br /&gt;
The STM32F103C8T6 serves as the local controller of the ADC board and is supported by several basic peripheral circuits, including an external crystal oscillator, reset network, BOOT0 configuration, SWD programming/debugging header, and a CH340N USB-to-UART bridge. These circuits ensure stable MCU operation, convenient firmware downloading and debugging, and reliable data transmission from the board to the host computer for real-time display and storage.&lt;br /&gt;
&lt;br /&gt;
==== Hardware-level Working Principle of the ADC Board ====&lt;br /&gt;
&lt;br /&gt;
In operation, the conditioned analog signal from the AFE enters the ADS1256 through the input header, is digitized with high resolution under the control of the local precision reference and clock, and is then read by the STM32 through the SPI interface. The MCU subsequently forwards the sampled data to the host computer through the serial communication link, so that the entire board functions as a compact digital acquisition backend connecting weak physiological analog signals to later software processing, display, and storage.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_7.jpg|thumb|center|800px|Figure 2.7. Photograph of the fabricated ADS1256-based ADC board developed in this project and the definitions of some key pins.]]&lt;br /&gt;
&lt;br /&gt;
Figure 2.7 shows the ADC board fabricated for this project. It integrates the ADS1256 conversion core, STM32 control circuit, power-conditioning circuits, and communication interfaces on a compact PCB for physiological signal digitization.&lt;br /&gt;
&lt;br /&gt;
== Signal Conditioning and Filtering ==&lt;br /&gt;
Although the AFE already performs preliminary band-pass filtering and 50 Hz interference suppression in the analog domain, the digitized sEMG signal may still contain residual noise due to component tolerances, electrode-contact variation, and environmental interference. Therefore, an additional digital filtering stage is implemented in software as a complementary post-processing step to improve signal quality and to provide a more stable input for rectification, envelope extraction, and subsequent analysis. In this sense, the software filtering is not a simple repetition of the analog filtering, but a refinement and compensation for non-ideal front-end behavior.&lt;br /&gt;
&lt;br /&gt;
Surface electromyographic (sEMG) signals are highly susceptible to several sources of contamination during acquisition. In practical measurements, the dominant disturbances usually include low-frequency motion artifacts caused by electrode movement and electrode–skin impedance variation, narrow-band power-line interference centered at 50 Hz, and broadband high-frequency electronic noise introduced by the acquisition hardware. These unwanted components degrade the quality of the recorded signal and may significantly affect the reliability of subsequent feature extraction, parameter estimation, and muscle activity interpretation. For this reason, an effective signal-conditioning procedure is necessary before any higher-level analysis is performed.&lt;br /&gt;
&lt;br /&gt;
In the present implementation, the filtering strategy follows the principle of restricting the signal bandwidth first and then removing the remaining narrow-band interference in a targeted manner. Accordingly, the raw sEMG signal is first processed by a fourth-order Butterworth IIR band-pass filter and then by a 50 Hz notch filter. This processing sequence is illustrated in the flowchart below, where the signal passes through band-pass filtering, notch filtering, full-wave rectification, and envelope extraction before producing the final processed output.&lt;br /&gt;
&lt;br /&gt;
[[File:flowchart.png|thumb|center|500px|Flowchart of the real-time sEMG signal conditioning pipeline.]]&lt;br /&gt;
&lt;br /&gt;
The rationale of this order is that the &#039;&#039;&#039;band-pass stage&#039;&#039;&#039; first confines the signal to the main spectral region of interest for sEMG, thereby attenuating motion artifacts at very low frequencies and suppressing high-frequency noise components outside the physiological band. After this spectral preconditioning, the notch stage can more effectively suppress the residual 50 Hz power-line interference that lies inside the useful sEMG band. In transfer-function form, the band-pass filter may be written as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;H_{BP}(z)=\frac{B_{BP}(z)}{A_{BP}(z)}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where the effective passband is selected as &amp;lt;math&amp;gt;20 \leq f \leq 160 \text{ Hz}&amp;lt;/math&amp;gt;. This frequency interval is consistent with the dominant spectral content of surface EMG: the lower cutoff near 20 Hz reduces motion artifacts and unstable low-frequency fluctuations, whereas the upper cutoff near 160 Hz removes high-frequency electronic noise while preserving the main energy-bearing components of the muscle signal. The use of a Butterworth structure is appropriate here because it provides a smooth monotonic passband response without ripple, which helps preserve signal morphology in real-time applications.&lt;br /&gt;
&lt;br /&gt;
After band limitation, a &#039;&#039;&#039;notch filter&#039;&#039;&#039; centered at the power-line frequency is applied to suppress interference that cannot be removed by the band-pass stage alone. The notch filter is designed around &amp;lt;math&amp;gt;f_0 = 50 \text{ Hz}&amp;lt;/math&amp;gt;, and its bandwidth is controlled by the quality factor &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;, which is expressed as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;Q = \frac{f_0}{\Delta f}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In transfer-function form, the notch stage is written as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;H_{N}(z)=\frac{B_{N}(z)}{A_{N}(z)}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the implemented program, a large quality factor is chosen so that the notch remains narrow, allowing effective rejection of the 50 Hz interference while minimizing distortion of neighboring useful spectral components. This is particularly important for sEMG because the interference frequency lies directly inside the physiological band of interest.&lt;br /&gt;
&lt;br /&gt;
Following the filtering stages, further signal conditioning is performed to obtain a representation that is more directly related to muscle activation intensity. The filtered sEMG waveform is first &#039;&#039;&#039;full-wave rectified&#039;&#039;&#039;, which converts the bipolar oscillatory signal into a unipolar signal by taking its absolute value.  Rectification does not remove noise by itself; instead, it transforms the signal into a form that is more suitable for amplitude-based analysis because both positive and negative deflections contribute positively to the activation measure.&lt;br /&gt;
&lt;br /&gt;
After rectification, the signal envelope is extracted to provide a smooth estimate of muscle activation level over time. In a general formulation, the envelope can be described as the &#039;&#039;&#039;low-pass filtered&#039;&#039;&#039; version of the rectified signal, namely &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y_{\mathrm{env}}[n] = \mathrm{LPF}\bigl(y_{\mathrm{rect}}[n]\bigr)&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the present code implementation, this operation is realized by short-time averaging over a finite window, which is equivalent to a moving-average low-pass smoothing of the rectified waveform. The corresponding expression is &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y_{\mathrm{env}}[n] = \frac{1}{N}\sum_{k=0}^{N-1} |x[n-k]|&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; is the window length in samples. With a window duration of approximately 200 ms, this envelope extraction method provides a stable and physiologically meaningful representation of muscle activation intensity, making it suitable for tasks such as force estimation, fatigue analysis, and motor-control studies.&lt;br /&gt;
&lt;br /&gt;
An important feature of the present &#039;&#039;&#039;implementation&#039;&#039;&#039; is that the entire filtering process is performed &#039;&#039;&#039;in real time&#039;&#039;&#039;, sample by sample, rather than by offline block processing. For this reason, IIR filters are preferred over FIR filters, since they can achieve comparable filtering performance with lower order, lower computational cost, and shorter delay. These properties are especially valuable in embedded systems, serial data streaming, and other low-latency experimental applications. However, unlike memoryless operations, an IIR filter depends not only on the current input but also on previous inputs and previous outputs. Its discrete-time behavior can therefore be represented by the recursive difference equation &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y[n] = \sum_{k=0}^{M} b_k x[n-k] - \sum_{k=1}^{N} a_k y[n-k]&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This equation makes clear that internal filter states must be preserved continuously during streaming operation. If the state variables were reinitialized for every incoming sample or data segment, artificial transients would appear and the output would no longer remain continuous.&lt;br /&gt;
&lt;br /&gt;
In the Python implementation, this state continuity is maintained using the internal initial-condition mechanism provided by SciPy, such as &amp;lt;code&amp;gt;lfilter_zi&amp;lt;/code&amp;gt;, together with recursive state updates during each filtering call. As a result, each newly acquired sample is passed first through the band-pass filter and then through the notch filter, while the internal states of both filters are updated after every step. This state-preserving sample-by-sample design ensures that the processing chain remains causal, continuous, and suitable for real-time display or downstream analysis without requiring storage of the entire signal segment.&lt;br /&gt;
&lt;br /&gt;
Overall, this signal-conditioning scheme provides an experimentally practical solution for real-time sEMG processing. The fourth-order Butterworth band-pass filter confines the signal to the main physiological band of interest, the 50 Hz notch filter removes narrow-band power-line contamination, and the subsequent rectification and envelope extraction generate a smooth amplitude descriptor of muscle activity. Combined with state-preserved streaming IIR implementation, this approach achieves a good balance between signal fidelity, computational efficiency, and real-time applicability in biomedical and physical experiment settings.&lt;br /&gt;
&lt;br /&gt;
== Experimental Setup ==&lt;br /&gt;
&lt;br /&gt;
=== Experimental Demonstration ===&lt;br /&gt;
&lt;br /&gt;
The experimental setup and data acquisition process are demonstrated in the video below.&lt;br /&gt;
&lt;br /&gt;
[https://www.youtube.com/watch?v=xxxx Click here to watch the full demonstration]&lt;br /&gt;
&lt;br /&gt;
The video illustrates the complete measurement procedure, including electrode placement, muscle activation, and real-time EMG signal visualization.&lt;br /&gt;
&lt;br /&gt;
=== Experimental Procedure ===&lt;br /&gt;
&lt;br /&gt;
Surface EMG signals were acquired using disposable electrodes placed on the forearm muscles responsible for wrist extension. Three electrodes were attached along the muscle region to capture differential EMG signals.&lt;br /&gt;
&lt;br /&gt;
The experimental movement consists of making a fist while extending the wrist backward. This action activates the forearm extensor muscles beneath the electrodes, producing measurable EMG signals.&lt;br /&gt;
&lt;br /&gt;
=== Data Acquisition Protocol ===&lt;br /&gt;
&lt;br /&gt;
Each subject performed repeated contraction–relaxation cycles under controlled conditions:&lt;br /&gt;
&lt;br /&gt;
* Number of subjects: 3  &lt;br /&gt;
* Number of trials per subject: 3  &lt;br /&gt;
* Duration of each trial: 30 seconds  &lt;br /&gt;
&lt;br /&gt;
During each trial, subjects were instructed to periodically contract and relax the muscle to generate clear dynamic EMG signals, while also maintaining a stable resting state between contractions.&lt;br /&gt;
&lt;br /&gt;
=== System and Measurement Conditions ===&lt;br /&gt;
&lt;br /&gt;
The EMG signals were recorded and visualized in real time using a data acquisition system connected to a computer. The sampling rate was set to 400 Hz.&lt;br /&gt;
&lt;br /&gt;
To ensure consistency across measurements:&lt;br /&gt;
&lt;br /&gt;
* Electrode placement was kept consistent for all subjects  &lt;br /&gt;
* The same movement protocol was followed  &lt;br /&gt;
* Measurements were conducted under similar environmental conditions  &lt;br /&gt;
&lt;br /&gt;
=== Summary ===&lt;br /&gt;
&lt;br /&gt;
This experimental setup enables reliable acquisition of both resting and dynamic EMG signals, providing a consistent dataset for subsequent signal processing and performance evaluation.&lt;br /&gt;
&lt;br /&gt;
== Data Processing ==&lt;br /&gt;
&lt;br /&gt;
The objective of data processing is to convert raw surface electromyography (sEMG) recordings into stable, quantitative, and comparable indicators of muscle activity. Since EMG signals are low in amplitude, highly variable over time, and easily contaminated by noise, a dedicated processing pipeline is necessary before any experimental interpretation can be performed.&lt;br /&gt;
&lt;br /&gt;
In this project, the data processing workflow includes time normalization, signal pre-processing, sliding-window feature extraction, noise-floor estimation, and automatic contraction detection. The processed outputs are then used for subsequent experimental evaluation, including rest-versus-contraction discrimination, signal-to-noise ratio analysis, and repeatability assessment.&lt;br /&gt;
&lt;br /&gt;
=== Input Data and Time Normalization ===&lt;br /&gt;
&lt;br /&gt;
The acquired EMG data are read from CSV files containing two columns: time and filtered sEMG amplitude. In the MATLAB implementation, the time vector is normalized so that each recording starts from zero:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t = t_{all} - t_{all}(1)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This normalization is important because it removes the influence of absolute recording timestamps and makes different trials directly comparable on the same time axis.&lt;br /&gt;
&lt;br /&gt;
In addition, the signal type is automatically identified from the filename as either dynamic or rest. This design allows the same program to process both contraction recordings and resting recordings with different downstream analysis logic.&lt;br /&gt;
&lt;br /&gt;
=== Signal Pre-processing ===&lt;br /&gt;
&lt;br /&gt;
Raw EMG signals cannot be analyzed directly because they usually contain DC offset, low-frequency drift, motion artifacts, and residual high-frequency interference. Therefore, several pre-processing steps are applied before feature extraction.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(1) Baseline Removal&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The first step is DC offset removal:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
x_{dc}(t) = x(t) - \frac{1}{N}\sum_{i=1}^{N}x(i)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This operation centers the signal around zero. It is necessary because an uncorrected baseline would bias amplitude-based metrics and reduce the reliability of later envelope and feature calculations.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(2) Band-pass Filtering &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
After baseline correction, a fourth-order Butterworth band-pass filter is applied with a passband of 20–150 Hz.&lt;br /&gt;
&lt;br /&gt;
This step is introduced for two reasons:&lt;br /&gt;
&lt;br /&gt;
* The low-frequency cutoff at 20 Hz suppresses baseline drift and motion artifacts.&lt;br /&gt;
* The high-frequency cutoff at 150 Hz reduces unwanted high-frequency noise while preserving the main energy band of the recorded sEMG in this project.&lt;br /&gt;
&lt;br /&gt;
Compared with processing the raw waveform directly, band-pass filtering makes the subsequent time-domain features more stable and more physiologically meaningful.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(3) Full-wave Rectification&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The filtered EMG signal is bipolar, meaning that positive and negative phases coexist due to motor unit action potentials. If these positive and negative components are averaged directly, they may cancel each other out. To avoid this, full-wave rectification is performed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
x_{rect}(t) = |x_{filt}(t)|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This transforms the signal into a unipolar representation, so that all muscle activity contributes positively to the extracted features.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(4) Envelope Extraction &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Although the rectified signal reflects signal magnitude, it still fluctuates rapidly. To obtain a smoother representation of muscle activation level, an envelope is extracted using a moving average with a 100 ms window.&lt;br /&gt;
&lt;br /&gt;
Envelope extraction is important because contraction detection should reflect the overall activation trend rather than instantaneous spikes. A smoothed envelope is therefore more robust for identifying active and inactive muscle states.&lt;br /&gt;
&lt;br /&gt;
=== Sliding Window Design ===&lt;br /&gt;
&lt;br /&gt;
To quantify how muscle activity changes with time, the filtered signal is divided into overlapping short-time segments using a sliding window method.&lt;br /&gt;
&lt;br /&gt;
The window parameters are:&lt;br /&gt;
&lt;br /&gt;
* Window length: 250 ms&lt;br /&gt;
* Step size: 50 ms&lt;br /&gt;
&lt;br /&gt;
These values are chosen as a trade-off between temporal resolution and feature stability.&lt;br /&gt;
&lt;br /&gt;
A longer window improves statistical robustness because more samples are included in each calculation. However, if the window is too long, short contractions or rapid changes may be blurred. A smaller step size increases temporal continuity between adjacent feature points and makes the feature curves smoother in time. Therefore, the 250 ms / 50 ms design provides a practical balance between smoothing and time localization.&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt;-th segment, the feature time is defined as the mean time of that segment:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t_k = \frac{1}{N}\sum_{i=s_k}^{e_k} t(i)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;s_k&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;e_k&amp;lt;/math&amp;gt; denote the start and end indices of the window.&lt;br /&gt;
&lt;br /&gt;
=== Feature Extraction ===&lt;br /&gt;
&lt;br /&gt;
Within each sliding window, three time-domain features are extracted: RMS, iEMG, and MAV. These features are widely used in EMG analysis because they are simple, computationally efficient, and directly related to muscle activation intensity.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(1) Root Mean Square (RMS)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
RMS = \sqrt{\frac{1}{N}\sum_{i=1}^{N}x_i^2}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
RMS reflects the effective power of the EMG signal and is one of the most common indicators of contraction strength. It is sensitive to both amplitude and energy, making it especially useful for comparing rest and active states.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(2) Integrated EMG (iEMG)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
iEMG = \sum_{i=1}^{N}|x_i|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
iEMG describes the cumulative electrical activity within a window. It is often interpreted as a measure of total muscle effort over that time segment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(3) Mean Absolute Value (MAV)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
MAV = \frac{1}{N}\sum_{i=1}^{N}|x_i|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
MAV is an amplitude descriptor similar to iEMG, but normalized by the number of samples. It provides an efficient estimate of average signal level and is less computationally intensive than some other features.&lt;br /&gt;
&lt;br /&gt;
These three features are used together because they provide complementary descriptions of EMG intensity. RMS emphasizes signal energy, iEMG emphasizes cumulative activation, and MAV reflects average amplitude.&lt;br /&gt;
&lt;br /&gt;
=== Peak-value Extraction ===&lt;br /&gt;
&lt;br /&gt;
In addition to continuous feature curves, several key peak values are extracted from the processed signal:&lt;br /&gt;
&lt;br /&gt;
* maximum and minimum of the filtered EMG waveform&lt;br /&gt;
* peak of the envelope&lt;br /&gt;
* peak RMS&lt;br /&gt;
* peak iEMG&lt;br /&gt;
* peak MAV&lt;br /&gt;
&lt;br /&gt;
These peak values provide concise descriptors of the strongest activity observed in each recording. They are useful for quick comparison across trials and subjects.&lt;br /&gt;
&lt;br /&gt;
=== Noise Floor Estimation ===&lt;br /&gt;
&lt;br /&gt;
To evaluate signal quality, the noise floor is estimated from a reference resting interval. In the present implementation, the first 3 seconds of the recording are used as the default rest reference:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t \in [0,\min(3,t_{end})]&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this segment, three noise descriptors are computed:&lt;br /&gt;
&lt;br /&gt;
* Noise RMS&lt;br /&gt;
* Noise standard deviation&lt;br /&gt;
* Noise peak-to-peak amplitude&lt;br /&gt;
&lt;br /&gt;
Noise-floor estimation is important because EMG amplitude alone is not sufficient to judge recording quality. A large signal is only meaningful if it is sufficiently higher than the baseline noise level. Therefore, the noise floor serves as the reference for later SNR calculation and for designing contraction thresholds.&lt;br /&gt;
&lt;br /&gt;
=== Global Signal Metrics ===&lt;br /&gt;
&lt;br /&gt;
For each recording, three global metrics are also computed over the entire filtered signal:&lt;br /&gt;
&lt;br /&gt;
* Global RMS&lt;br /&gt;
* Global MAV&lt;br /&gt;
* Global iEMG&lt;br /&gt;
&lt;br /&gt;
These global descriptors summarize the overall signal level of the full recording and are later used in group-level comparisons.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Contraction Detection ===&lt;br /&gt;
&lt;br /&gt;
For dynamic recordings, an automatic contraction detection algorithm is used to identify repeated active segments. This is one of the key parts of the data processing pipeline, because it transforms a continuous EMG trace into discrete contraction events that can be counted and compared.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(1) Threshold Design&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The detection threshold is designed adaptively rather than using a fixed value. Two candidate thresholds are first calculated:&lt;br /&gt;
&lt;br /&gt;
* an envelope-based threshold derived from the global envelope mean and standard deviation&lt;br /&gt;
* a rest-reference threshold derived from the mean and standard deviation of the resting reference amplitude&lt;br /&gt;
&lt;br /&gt;
The final threshold is taken as the larger of the two after additional scaling. This strategy improves robustness because it combines the global activation level of the signal with the baseline noise characteristics of the individual recording.&lt;br /&gt;
&lt;br /&gt;
This adaptive threshold design is preferable to a manually fixed threshold because EMG amplitude can vary strongly between subjects, muscles, and recording sessions.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(2) Initial Segmentation&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
After thresholding the envelope, the signal is classified into active and inactive regions:&lt;br /&gt;
&lt;br /&gt;
* active: envelope above threshold&lt;br /&gt;
* inactive: envelope below threshold&lt;br /&gt;
&lt;br /&gt;
The rising and falling edges of the binary activity vector are then used to determine the start and end points of each candidate contraction segment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(3) Removal of Short Segments&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Very short active regions are often caused by noise fluctuations rather than true muscle contractions. Therefore, segments shorter than 0.20 s are discarded.&lt;br /&gt;
&lt;br /&gt;
This step prevents false positive detections and increases the physiological relevance of the segmentation results.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(4) Merging of Adjacent Segments &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If two neighboring active segments are separated by a very short gap, they are merged when the gap is less than 0.15 s.&lt;br /&gt;
&lt;br /&gt;
This operation is necessary because a single real contraction may be temporarily interrupted by a brief drop in the envelope caused by local fluctuation. Without merging, one contraction could be incorrectly counted as multiple repetitions.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(5) Repetition-level Metrics &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
For each detected contraction segment, two repetition-level metrics are extracted:&lt;br /&gt;
&lt;br /&gt;
* peak RMS of that contraction&lt;br /&gt;
* mean RMS of that contraction&lt;br /&gt;
&lt;br /&gt;
These metrics quantify both the strongest activation within each repetition and the average activation level over the repetition duration.&lt;br /&gt;
&lt;br /&gt;
=== Repeatability Analysis ===&lt;br /&gt;
&lt;br /&gt;
When multiple valid contractions are detected, repeatability is evaluated using the coefficient of variation (CV):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
CV = \frac{\sigma}{\mu}\times 100\%&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt; is the standard deviation and &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is the mean value across repetitions.&lt;br /&gt;
&lt;br /&gt;
Two CV values are computed:&lt;br /&gt;
&lt;br /&gt;
* CV of repetition peak RMS&lt;br /&gt;
* CV of repetition mean RMS&lt;br /&gt;
&lt;br /&gt;
A lower CV indicates better repeatability, meaning that repeated contractions produce more consistent EMG responses.&lt;br /&gt;
&lt;br /&gt;
=== Signal-to-Noise Ratio (SNR) ===&lt;br /&gt;
&lt;br /&gt;
In this project, the signal-to-noise ratio (SNR) is defined based on the ratio between contraction and rest activity:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
SNR_{dB} = 20\log_{10}\left(\frac{RMS_{contraction}}{RMS_{rest}}\right)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This definition is adopted because it directly reflects the system’s ability to distinguish active muscle contraction from baseline noise.&lt;br /&gt;
&lt;br /&gt;
Compared with global SNR definitions, this formulation is more relevant for practical EMG applications such as activity detection and classification.&lt;br /&gt;
&lt;br /&gt;
=== Rest-versus-Contraction Window Comparison ===&lt;br /&gt;
&lt;br /&gt;
To further distinguish inactive and active states, all sliding windows are divided into two groups:&lt;br /&gt;
&lt;br /&gt;
* rest windows: windows with envelope clearly below the threshold&lt;br /&gt;
* contraction windows: windows with envelope above the threshold&lt;br /&gt;
&lt;br /&gt;
The RMS values of these two groups are then compared statistically.&lt;br /&gt;
&lt;br /&gt;
This comparison is important because a practical EMG system should not only detect signal presence, but also clearly separate rest from contraction in a quantitative way. If the two RMS distributions are well separated, it indicates that the system has good discriminative capability.&lt;br /&gt;
&lt;br /&gt;
=== Output Data Structure ===&lt;br /&gt;
&lt;br /&gt;
The processed outputs are organized into structured data for experimental analysis:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(1) Time-series outputs&#039;&#039;&#039;&lt;br /&gt;
* Filtered EMG signal  &lt;br /&gt;
* Rectified signal  &lt;br /&gt;
* Envelope  &lt;br /&gt;
* RMS(t), iEMG(t), MAV(t)  &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(2) Recording-level outputs&#039;&#039;&#039; &lt;br /&gt;
* RMS (rest)  &lt;br /&gt;
* RMS (contraction)  &lt;br /&gt;
* iEMG  &lt;br /&gt;
* Noise metrics  &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(3) Dynamic-signal outputs &#039;&#039;&#039;&lt;br /&gt;
* Detected contractions  &lt;br /&gt;
* Repetition count  &lt;br /&gt;
* Peak RMS per repetition  &lt;br /&gt;
* Mean RMS per repetition  &lt;br /&gt;
* Coefficient of variation (CV)  &lt;br /&gt;
* Signal-to-noise ratio (SNR)  &lt;br /&gt;
&lt;br /&gt;
All extracted features are designed to directly support the evaluation of noise level, signal quality, activity discrimination, and repeatability in the subsequent experimental analysis.&lt;br /&gt;
&lt;br /&gt;
== Experimental Results ==&lt;br /&gt;
&lt;br /&gt;
This section presents representative results of the EMG acquisition and data processing pipeline under both dynamic (muscle contraction) and resting conditions.&lt;br /&gt;
&lt;br /&gt;
=== Representative Dynamic Signal Analysis ===&lt;br /&gt;
&lt;br /&gt;
[[File:Dynamic_Figure1.png|thumb|800px|center|Figure 5.1: Processed EMG signal under dynamic contraction, including filtered signal, rectified signal with envelope, and extracted features (RMS, iEMG, MAV).]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.1 shows the processed EMG signal during repeated muscle contractions.&lt;br /&gt;
&lt;br /&gt;
The filtered EMG waveform exhibits clear burst-like patterns corresponding to periodic contractions. The signal amplitude reaches a maximum of approximately 0.45, while the baseline remains centered around zero, indicating effective baseline removal and filtering.&lt;br /&gt;
&lt;br /&gt;
After rectification and envelope extraction, the contraction periods become clearly distinguishable. The envelope provides a smooth representation of muscle activation, with a peak value of approximately 0.145.&lt;br /&gt;
&lt;br /&gt;
The extracted time-domain features (RMS, iEMG, MAV) further quantify the signal. Among these, iEMG shows the strongest dynamic variation, indicating high sensitivity to contraction intensity.&lt;br /&gt;
&lt;br /&gt;
=== Noise Floor and Rest Reference ===&lt;br /&gt;
&lt;br /&gt;
[[File:Dynamic_Figure2.png|thumb|800px|center|Figure 5.2: Noise estimation, rest vs contraction comparison, automatic contraction detection, and repetition analysis.]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (top-left) shows the resting reference segment used for noise estimation.&lt;br /&gt;
&lt;br /&gt;
The signal remains centered around zero with small fluctuations. The noise characteristics are:&lt;br /&gt;
&lt;br /&gt;
* Noise RMS ≈ 0.0046  &lt;br /&gt;
* Standard deviation ≈ 0.0046  &lt;br /&gt;
* Peak-to-peak amplitude ≈ 0.071  &lt;br /&gt;
&lt;br /&gt;
This indicates a low noise floor and stable measurement conditions.&lt;br /&gt;
&lt;br /&gt;
=== Rest vs Contraction Discrimination ===&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (top-right) compares RMS values between rest and contraction states.&lt;br /&gt;
&lt;br /&gt;
The two distributions are clearly separated:&lt;br /&gt;
&lt;br /&gt;
* Rest mean RMS ≈ 0.0053  &lt;br /&gt;
* Contraction mean RMS ≈ 0.1064  &lt;br /&gt;
&lt;br /&gt;
This corresponds to an approximate 20× increase, demonstrating strong discriminability between inactive and active muscle states.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Contraction Detection ===&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (bottom-left) illustrates automatic detection based on the envelope signal.&lt;br /&gt;
&lt;br /&gt;
A threshold of approximately 0.040 is applied, resulting in stable segmentation of contraction periods.&lt;br /&gt;
&lt;br /&gt;
A total of 12 repetitions are detected, with good alignment to visible signal peaks.&lt;br /&gt;
&lt;br /&gt;
=== Repeatability Analysis ===&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (bottom-right) shows the peak RMS value of each detected contraction.&lt;br /&gt;
&lt;br /&gt;
The results indicate:&lt;br /&gt;
&lt;br /&gt;
* Mean peak RMS ≈ 0.1355  &lt;br /&gt;
* Standard deviation ≈ 0.0173  &lt;br /&gt;
* CV ≈ 12.77%  &lt;br /&gt;
* SNR ≈ 21.26 dB  &lt;br /&gt;
&lt;br /&gt;
This indicates acceptable repeatability and good signal quality.&lt;br /&gt;
&lt;br /&gt;
=== Representative Rest Signal Analysis ===&lt;br /&gt;
&lt;br /&gt;
[[File:Rest_Figure1.png|thumb|800px|center|Figure 5.3: Processed EMG signal under rest condition, showing low amplitude and absence of contraction patterns.]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.3 shows the EMG signal under resting conditions.&lt;br /&gt;
&lt;br /&gt;
The signal remains within a narrow amplitude range (approximately ±0.04) and shows no burst-like structures. The envelope remains close to zero, confirming the absence of muscle activity.&lt;br /&gt;
&lt;br /&gt;
The extracted features remain low:&lt;br /&gt;
&lt;br /&gt;
* RMS ≈ 0.007  &lt;br /&gt;
* MAV ≈ 0.005  &lt;br /&gt;
* iEMG remains stable  &lt;br /&gt;
&lt;br /&gt;
This confirms that no false activation is detected.&lt;br /&gt;
&lt;br /&gt;
=== Frequency-domain Characteristics ===&lt;br /&gt;
&lt;br /&gt;
[[File:Rest_Figure2.png|thumb|800px|center|Figure 5.4: Frequency-domain analysis and statistical characteristics of rest signal.]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.4 shows the frequency-domain characteristics of the resting signal.&lt;br /&gt;
&lt;br /&gt;
The power spectral density (PSD) indicates low overall signal energy without dominant peaks, confirming that the signal mainly consists of noise.&lt;br /&gt;
&lt;br /&gt;
=== Summary of Single-recording Performance ===&lt;br /&gt;
&lt;br /&gt;
From the representative results:&lt;br /&gt;
&lt;br /&gt;
* EMG signals are effectively extracted and denoised  &lt;br /&gt;
* Contraction events are clearly identifiable  &lt;br /&gt;
* Rest and contraction states are well separated  &lt;br /&gt;
* Automatic detection is stable and accurate  &lt;br /&gt;
* Repeatability is acceptable  &lt;br /&gt;
* No false activation occurs under rest conditions  &lt;br /&gt;
&lt;br /&gt;
=== Consistency Across Multiple Recordings ===&lt;br /&gt;
&lt;br /&gt;
The same data processing pipeline was applied to multiple recordings from different subjects and trials.&lt;br /&gt;
&lt;br /&gt;
Across all datasets, consistent patterns were observed:&lt;br /&gt;
&lt;br /&gt;
* Dynamic signals exhibit clear burst-like structures corresponding to repeated muscle contractions  &lt;br /&gt;
* Rest signals remain low in amplitude without distinct activation patterns  &lt;br /&gt;
* RMS values under contraction are consistently higher than those under rest  &lt;br /&gt;
* The automatic detection algorithm reliably identifies contraction segments  &lt;br /&gt;
&lt;br /&gt;
Although quantitative values (e.g., RMS, SNR, CV) vary across recordings due to differences in electrode contact, muscle activation strength, and individual conditions, the overall trends remain consistent.&lt;br /&gt;
&lt;br /&gt;
These results demonstrate the robustness and general applicability of the proposed signal processing method.&lt;br /&gt;
&lt;br /&gt;
== Multi-subject Analysis ==&lt;br /&gt;
=== System Evaluation ===&lt;br /&gt;
&lt;br /&gt;
This section evaluates the performance of the EMG acquisition system in terms of noise level, signal quality, activity discrimination, and repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Noise Floor Analysis ====&lt;br /&gt;
&lt;br /&gt;
The noise floor was evaluated using rest-state recordings, characterized by RMS noise, standard deviation, and peak-to-peak amplitude.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039; shows the lowest noise level (RMS ≈ 0.0046), indicating stable electrode contact and minimal interference.  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039; exhibits moderate noise (RMS ≈ 0.0080), likely influenced by motion artifacts or electrode–skin impedance variation.  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039; shows relatively higher noise (RMS ≈ 0.0126), suggesting increased baseline fluctuation.  &lt;br /&gt;
&lt;br /&gt;
Overall, the system maintains a low noise floor across subjects, although the quality depends on experimental conditions such as electrode contact and environmental interference.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Signal-to-Noise Ratio (SNR) ====&lt;br /&gt;
&lt;br /&gt;
The signal-to-noise ratio (SNR) is defined as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{SNR (dB)} = 20 \log_{10} \left( \frac{\mathrm{RMS}_{\mathrm{contraction}}}{\mathrm{RMS}_{\mathrm{rest}}} \right)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The measured SNR values are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: 21.26 dB → good signal quality  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: 13.52 dB → moderate and usable  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: 6.66 dB → low signal clarity  &lt;br /&gt;
&lt;br /&gt;
General interpretation:&lt;br /&gt;
&lt;br /&gt;
* &amp;gt;20 dB → good  &lt;br /&gt;
* 10–20 dB → usable  &lt;br /&gt;
* &amp;lt;10 dB → poor  &lt;br /&gt;
&lt;br /&gt;
These results show that the system can achieve reliable signal acquisition, although performance varies across subjects.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
====  Rest vs Contraction Discrimination ====&lt;br /&gt;
&lt;br /&gt;
A clear distinction between rest and contraction states is observed based on RMS values.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: 0.0053 → 0.1064 (≈20× increase)  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: 0.0079 → 0.0283 (≈3.6× increase)  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: 0.0141 → 0.0646 (≈4.6× increase)  &lt;br /&gt;
&lt;br /&gt;
This demonstrates that the system is capable of separating muscle activity from baseline noise.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Conclusion:&#039;&#039;  &lt;br /&gt;
The system can be used for basic muscle activity detection and simple classification tasks based on RMS features.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Repeatability of Repeated Contractions ====&lt;br /&gt;
&lt;br /&gt;
Repeatability is evaluated using the coefficient of variation (CV) of peak RMS values across repetitions.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! CV Range !! Evaluation&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt; 10% || Excellent&lt;br /&gt;
|-&lt;br /&gt;
| 10–20% || Acceptable&lt;br /&gt;
|-&lt;br /&gt;
| &amp;gt; 20% || Poor&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Results:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: CV = 12.77% → Acceptable  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: CV = 24.77% → Poor  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: CV = 10.60% → Acceptable  &lt;br /&gt;
&lt;br /&gt;
Although WANG&#039;s signal is detectable, its contraction amplitude varies significantly across repetitions, resulting in poor repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
=== Overall System Performance ===&lt;br /&gt;
&lt;br /&gt;
The system demonstrates the following performance characteristics:&lt;br /&gt;
&lt;br /&gt;
* Reliable detection of muscle activity across all subjects  &lt;br /&gt;
* Clear separation between rest and contraction states  &lt;br /&gt;
* Moderate to high signal quality depending on subject conditions  &lt;br /&gt;
* Repeatability ranging from acceptable to poor due to user-dependent factors  &lt;br /&gt;
&lt;br /&gt;
Overall, the designed EMG acquisition system is capable of stable signal acquisition and feature extraction, with performance primarily influenced by electrode contact quality, skin impedance, and motion consistency.&lt;br /&gt;
&lt;br /&gt;
===== Summary of Quantitative Metrics =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Subject !! RMS (Rest) !! RMS (Contraction) !! Separation Ratio !! iEMG (max) !! Noise RMS !! SNR (dB) !! CV (%) !! Evaluation&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;LIU&#039;&#039;&#039; || 0.0053 || 0.1064 || &#039;&#039;&#039;20.1×&#039;&#039;&#039; || 12.72 || 0.0046 || &#039;&#039;&#039;21.26&#039;&#039;&#039; || 12.77 || Strong signal, good quality&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;WANG&#039;&#039;&#039; || 0.0079 || 0.0283 || 3.57× || 11.10 || 0.0080 || 13.52 || &#039;&#039;&#039;24.77&#039;&#039;&#039; || Usable signal, poor repeatability&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ZHONG&#039;&#039;&#039; || 0.0141 || 0.0646 || 4.58× || 6.70 || 0.0126 || 6.66 || 10.60 || Acceptable performance&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Summary:&#039;&#039; Subject LIU shows the best overall performance, WANG provides usable but less stable signals, and ZHONG demonstrates moderate signal quality with good repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Activation Intensity =====&lt;br /&gt;
&lt;br /&gt;
Among the three subjects, &#039;&#039;&#039;LIU exhibits the strongest muscle activation&#039;&#039;&#039;, as indicated by the highest contraction RMS and iEMG values. ZHONG shows moderate activation, while WANG demonstrates comparable iEMG but lower RMS consistency.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Signal Quality =====&lt;br /&gt;
&lt;br /&gt;
Signal quality is evaluated based on SNR and noise level:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039; achieves the highest SNR and lowest noise → best signal quality  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039; shows moderate SNR → usable but less robust  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039; has the lowest SNR → weakest signal clarity  &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Repeatability =====&lt;br /&gt;
&lt;br /&gt;
Repeatability is evaluated using the coefficient of variation (CV):&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;ZHONG (10.60%)&#039;&#039;&#039; → most stable  &lt;br /&gt;
* &#039;&#039;&#039;LIU (12.77%)&#039;&#039;&#039; → acceptable  &lt;br /&gt;
* &#039;&#039;&#039;WANG (24.77%)&#039;&#039;&#039; → poor  &lt;br /&gt;
&lt;br /&gt;
This indicates that WANG’s contraction strength varies significantly between repetitions.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Engineering Interpretation of Inter-subject Differences =====&lt;br /&gt;
&lt;br /&gt;
The observed differences are mainly attributed to engineering and experimental factors rather than physiological differences.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Electrode contact quality&#039;&#039;&#039;  &lt;br /&gt;
  Variations in electrode placement, pressure, and gel contact affect signal amplitude and stability.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Skin impedance&#039;&#039;&#039;  &lt;br /&gt;
  Differences in skin condition (hydration, oil, hair) influence electrode–skin impedance, affecting noise level and signal coupling.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Muscle control consistency&#039;&#039;&#039;  &lt;br /&gt;
  Variations in contraction strength and timing affect repeatability and CV.&lt;br /&gt;
&lt;br /&gt;
Therefore, the variation across subjects reflects practical acquisition conditions rather than intrinsic system limitations.&lt;/div&gt;</summary>
		<author><name>Wang Jingyi</name></author>
	</entry>
	<entry>
		<id>https://pc5271.org/index.php?title=Surface_EMG_Sensor_for_Muscle_Activity_Measurement:_AFE_Design_and_Signal_Processing&amp;diff=1365</id>
		<title>Surface EMG Sensor for Muscle Activity Measurement: AFE Design and Signal Processing</title>
		<link rel="alternate" type="text/html" href="https://pc5271.org/index.php?title=Surface_EMG_Sensor_for_Muscle_Activity_Measurement:_AFE_Design_and_Signal_Processing&amp;diff=1365"/>
		<updated>2026-04-23T07:42:40Z</updated>

		<summary type="html">&lt;p&gt;Wang Jingyi: /* Experimental Setup */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Background and Theory==&lt;br /&gt;
&lt;br /&gt;
=== Surface EMG Signals ===&lt;br /&gt;
Surface electromyography (sEMG) refers to the bioelectrical signals detected on the skin surface during muscle contraction. These signals originate from the electrical activity of muscle fibers and provide a non-invasive way to monitor muscle activation. Compared with invasive EMG methods, sEMG is easier to apply, safer for repeated measurements, and more suitable for real-time monitoring. Therefore, it has been widely used in areas such as rehabilitation, motion analysis, human–machine interaction, and physiological monitoring.&lt;br /&gt;
&lt;br /&gt;
=== Characteristics of EMG Signals ===&lt;br /&gt;
EMG signals are generally weak, time-varying, and stochastic in nature. Their waveforms are typically bipolar, fluctuating around zero with both positive and negative components. The amplitude and frequency content of EMG signals depend on factors such as muscle contraction level, electrode placement, skin condition, and individual physiological differences. In practice, the useful frequency components of sEMG are mainly concentrated in a limited low-to-mid frequency range. Because of their low amplitude and variability, EMG signals usually require further conditioning before reliable interpretation and feature extraction can be performed.&lt;br /&gt;
&lt;br /&gt;
=== Bioelectrical Signal Acquisition Principles ===&lt;br /&gt;
The acquisition of bioelectrical signals is based on measuring the small potential difference on the skin surface using electrodes, then converting it into a processable electrical signal through amplification and digitization. For sEMG measurement, electrode placement and skin–electrode contact quality are especially important, since they directly affect signal amplitude and stability. In addition, the front-end acquisition circuit must provide sufficient sensitivity and good interference rejection, so that the recorded signal reflects actual muscle activity rather than environmental disturbance or poor contact conditions.&lt;br /&gt;
&lt;br /&gt;
=== Noise Sources in EMG (50 Hz, motion artifacts) ===&lt;br /&gt;
In practical EMG recording, the measured signal is easily contaminated by different types of noise. Two of the most common sources are power-line interference and motion artifacts. Power-line interference usually appears as a narrow-band component at 50 Hz in the local electrical environment, while motion artifacts are mainly caused by electrode movement, cable disturbance, or variations in the electrode–skin impedance, and are often concentrated in the low-frequency range. In addition, electronic noise from the acquisition hardware may also affect the recording quality. These unwanted components can reduce signal clarity and make muscle activity analysis less reliable, so they must be considered in the design of the signal processing pipeline.&lt;br /&gt;
[[File:background_theory_figure1.1_emg_noise_sources.png|center|thumb|700px|&#039;&#039;&#039;Figure 1.1.&#039;&#039;&#039; Principle of surface EMG acquisition.]]&lt;br /&gt;
&lt;br /&gt;
==System Architecture==&lt;br /&gt;
=== Total Structure Design ===&lt;br /&gt;
&lt;br /&gt;
For clarity，the proposed physiological signal acquisition system mainly consists of two core parts：the analog front－end （AFE）and the ADC board．The AFE is responsible for the preliminary conditioning of weak bioelectrical signals，including amplification，filtering，interference suppression，and level shifting，so that the analog waveform can be converted into a stable and measurable form．The ADC board then performs high－resolution digitization of the conditioned signal and transfers the sampled data to the host computer for subsequent display，storage，and analysis．Therefore，the overall system forms a complete signal－acquisition chain from weak physiological input to digital output．&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_1.jpg|thumb|center|800px|Figure 2.1. Overall system architecture of the proposed physiological signal acquisition platform，including the AFE and ADC modules．]]&lt;br /&gt;
&lt;br /&gt;
=== sEMG AFE Design ===&lt;br /&gt;
&lt;br /&gt;
To collect the weak bioelectric potential signals of the human body，an analog front－end（AFE）suitable sEMG measurements was designed．The module is powered by an external 5 V supply，and the complete circuit includes a first－ stage instrumentation amplifier based on INA128（Texas Instruments，Dallas，TX，USA），a band－pass filter，a 50 Hz notch filter，a second－order amplification and level shifting stage，a driver electrode circuit，a precise 1.5 V reference source，and a -5 V voltage generation module for powering the operational amplifiers．&lt;br /&gt;
&lt;br /&gt;
==== First－order Amplifier ====&lt;br /&gt;
&lt;br /&gt;
The input bioelectric signal is first acquired in differential form and applied to the INA128 instrumentation amplifier，which provides high input impedance，high common－mode rejection，and moderate initial gain for sEMG acquisition．This stage enlarges the weak physiological signal before filtering while reducing the risk of premature saturation caused by electrode offset or motion－induced disturbance，thereby preparing a more stable signal for the subsequent conditioning stages．&lt;br /&gt;
&lt;br /&gt;
==== Bandpass Filter ====&lt;br /&gt;
&lt;br /&gt;
After the instrumentation amplifier，the signal passes through a second－order active band－pass filter，as shown in Figure 2．2． This stage suppresses baseline drift and high－frequency noise outside the useful sEMG range，so that the low－frequency envelope information of sEMG can be preserved before further amplification．&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_2.jpg|thumb|center|800px|Figure 2.2. Schematic diagram of the active band-pass filter used in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the band-pass stage used to retain the main physiological signal band while suppressing unwanted lowand high-frequency components.&lt;br /&gt;
&lt;br /&gt;
==== Notch Filter ====&lt;br /&gt;
&lt;br /&gt;
To reduce power-line interference, a dedicated 50 Hz notch filter is introduced after the band-pass stage, as shown in Figure 2.3. This filter attenuates the mains-frequency component that commonly contaminates weak bioelectric measurements, thereby improving the signal-to-noise ratio of sEMG signals before the final amplification stage.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_3.jpg|thumb|center|800px|Figure 2.3. Schematic diagram of the 50 Hz notch filter used in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the circuit used to attenuate 50 Hz mains interference in the analog front end.&lt;br /&gt;
&lt;br /&gt;
==== Second-order Amplifier &amp;amp; Level Shifter ====&lt;br /&gt;
&lt;br /&gt;
After filtering, the signal enters the second-stage amplification and level-shifting circuit shown in Figure 2.4. In this stage, the filtered signal is further amplified to improve amplitude utilization and then shifted by a 1.5 V reference so that the output becomes a stable unipolar signal suitable for ADC sampling, while preserving linear operation and providing sufficient output swing margin.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_4.jpg|thumb|center|800px|Figure 2.4. Schematic diagram of the second-stage amplifier and level-shifting circuit in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows how the conditioned signal is further amplified and shifted to a suitable DC level before digitization.&lt;br /&gt;
&lt;br /&gt;
==== Power Module and Drive-electrode Circuit ====&lt;br /&gt;
&lt;br /&gt;
The AFE is powered by a 5 V supply and also integrates a 1.5 V precision reference, a -5 V generation circuit, and a driveelectrode circuit. These supporting modules provide the required supply rails and reference level for analog signal conditioning, while the drive-electrode circuit feeds back common-mode voltage to the body to suppress interference at the source. As a result, the complete AFE can support sEMG acquisition with adequate gain, filtering, and noise-reduction performance in a compact hardware structure.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_5.jpg|thumb|center|800px|Figure 2.5. Physical picture of the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the fabricated sEMG analog front-end hardware used in the system.&lt;br /&gt;
&lt;br /&gt;
Figure 2.5 presents the practical hardware implementation of the proposed sEMG AFE. It integrates amplification, filtering, level shifting, and driven-reference functions in a compact circuit for weak bioelectrical signal acquisition.&lt;br /&gt;
&lt;br /&gt;
=== ADS1256-based ADC Board ===&lt;br /&gt;
&lt;br /&gt;
To digitize the conditioned weak physiological signals with sufficient resolution and low noise, this project developed a dedicated ADC board based on the ADS1256 analog-to-digital converter (Texas Instruments, Dallas, TX, USA) and the STM32F103C8T6 microcontroller (STMicroelectronics, Geneva, Switzerland). The overall design objective of this board was not merely to realize analog-to-digital conversion, but to provide a complete hardware interface between the analog front-end and the digital processing unit, including precision reference generation, clocking, input protection and filtering, serial communication, power regulation, and MCU-based acquisition control. The ADS1256 was selected because it is a&lt;br /&gt;
&lt;br /&gt;
very low-noise 24-bit delta-sigma converter with a programmable gain amplifier (PGA), flexible input multiplexer, programmable digital filter, and SPI-compatible serial interface, which makes it well suited for weak low-frequency physiological signals after analog conditioning. The STM32F103C8T6 was used as the local controller because it provides a 32-bit Cortex-M3 core, up to 72 MHz system clock, SPI, USART, USB, and standard SWD debugging support in a compact and low-cost platform.&lt;br /&gt;
&lt;br /&gt;
==== ADC Core Architecture and Design Rationale ====&lt;br /&gt;
&lt;br /&gt;
The ADS1256 was selected as the core ADC because it provides high-resolution, low-noise delta-sigma conversion with an input multiplexer, programmable gain amplifier, and digital filter, which are suitable for weak and low-frequency physiological signals. As shown in Figure 2.6, this architecture emphasizes resolution and noise performance rather than high conversion bandwidth, making it appropriate for sEMG signal digitization after analog conditioning.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_6.jpg|thumb|center|800px|Figure 2.6. Internal functional structure of the ADS1256 analog-to-digital converter.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the main internal blocks of the ADS1256, including the multiplexer, PGA, modulator, and digital filter.&lt;br /&gt;
&lt;br /&gt;
==== Analog Front-End Interface, Reference, and Clocking ====&lt;br /&gt;
&lt;br /&gt;
The ADS1256 analog inputs are connected to the external header through a passive input-conditioning network that helps suppress high-frequency interference and improve input stability. In addition, the board includes a dedicated precision reference and clocking circuits so that the ADC can perform stable and accurate conversion. Together, these circuits provide a reliable analog interface and timing basis for high-resolution digitization of weak physiological signals.&lt;br /&gt;
&lt;br /&gt;
==== SPI Interface between ADS1256 and STM32F103C8T6 ====&lt;br /&gt;
&lt;br /&gt;
Communication between the ADS1256 and the STM32F103C8T6 is implemented through an SPI-compatible interface, with dedicated lines for chip select, serial clock, input/output data, data-ready notification, and hardware reset. This connection allows the MCU to configure the ADC, read conversion results in synchrony with DRDY, and maintain efficient and reliable acquisition control for multi-channel physiological measurements.&lt;br /&gt;
&lt;br /&gt;
==== Power Supply and On-board Regulation ====&lt;br /&gt;
&lt;br /&gt;
The ADC board uses a USB Type-B connector as the main power input and includes protection, voltage regulation, and local decoupling circuits to provide a stable supply for both the MCU and ADC-related hardware. In addition, analog ground and digital ground are separated in the PCB layout to reduce digital noise coupling into the analog path, which is particularly important for weak physiological signal acquisition.&lt;br /&gt;
&lt;br /&gt;
==== Basic Peripheral Circuits of the STM32F103C8T6 ====&lt;br /&gt;
&lt;br /&gt;
The STM32F103C8T6 serves as the local controller of the ADC board and is supported by several basic peripheral circuits, including an external crystal oscillator, reset network, BOOT0 configuration, SWD programming/debugging header, and a CH340N USB-to-UART bridge. These circuits ensure stable MCU operation, convenient firmware downloading and debugging, and reliable data transmission from the board to the host computer for real-time display and storage.&lt;br /&gt;
&lt;br /&gt;
==== Hardware-level Working Principle of the ADC Board ====&lt;br /&gt;
&lt;br /&gt;
In operation, the conditioned analog signal from the AFE enters the ADS1256 through the input header, is digitized with high resolution under the control of the local precision reference and clock, and is then read by the STM32 through the SPI interface. The MCU subsequently forwards the sampled data to the host computer through the serial communication link, so that the entire board functions as a compact digital acquisition backend connecting weak physiological analog signals to later software processing, display, and storage.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_7.jpg|thumb|center|800px|Figure 2.7. Photograph of the fabricated ADS1256-based ADC board developed in this project and the definitions of some key pins.]]&lt;br /&gt;
&lt;br /&gt;
Figure 2.7 shows the ADC board fabricated for this project. It integrates the ADS1256 conversion core, STM32 control circuit, power-conditioning circuits, and communication interfaces on a compact PCB for physiological signal digitization.&lt;br /&gt;
&lt;br /&gt;
== Signal Conditioning and Filtering ==&lt;br /&gt;
Although the AFE already performs preliminary band-pass filtering and 50 Hz interference suppression in the analog domain, the digitized sEMG signal may still contain residual noise due to component tolerances, electrode-contact variation, and environmental interference. Therefore, an additional digital filtering stage is implemented in software as a complementary post-processing step to improve signal quality and to provide a more stable input for rectification, envelope extraction, and subsequent analysis. In this sense, the software filtering is not a simple repetition of the analog filtering, but a refinement and compensation for non-ideal front-end behavior.&lt;br /&gt;
&lt;br /&gt;
Surface electromyographic (sEMG) signals are highly susceptible to several sources of contamination during acquisition. In practical measurements, the dominant disturbances usually include low-frequency motion artifacts caused by electrode movement and electrode–skin impedance variation, narrow-band power-line interference centered at 50 Hz, and broadband high-frequency electronic noise introduced by the acquisition hardware. These unwanted components degrade the quality of the recorded signal and may significantly affect the reliability of subsequent feature extraction, parameter estimation, and muscle activity interpretation. For this reason, an effective signal-conditioning procedure is necessary before any higher-level analysis is performed.&lt;br /&gt;
&lt;br /&gt;
In the present implementation, the filtering strategy follows the principle of restricting the signal bandwidth first and then removing the remaining narrow-band interference in a targeted manner. Accordingly, the raw sEMG signal is first processed by a fourth-order Butterworth IIR band-pass filter and then by a 50 Hz notch filter. This processing sequence is illustrated in the flowchart below, where the signal passes through band-pass filtering, notch filtering, full-wave rectification, and envelope extraction before producing the final processed output.&lt;br /&gt;
&lt;br /&gt;
[[File:flowchart.png|thumb|center|500px|Flowchart of the real-time sEMG signal conditioning pipeline.]]&lt;br /&gt;
&lt;br /&gt;
The rationale of this order is that the &#039;&#039;&#039;band-pass stage&#039;&#039;&#039; first confines the signal to the main spectral region of interest for sEMG, thereby attenuating motion artifacts at very low frequencies and suppressing high-frequency noise components outside the physiological band. After this spectral preconditioning, the notch stage can more effectively suppress the residual 50 Hz power-line interference that lies inside the useful sEMG band. In transfer-function form, the band-pass filter may be written as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;H_{BP}(z)=\frac{B_{BP}(z)}{A_{BP}(z)}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where the effective passband is selected as &amp;lt;math&amp;gt;20 \leq f \leq 160 \text{ Hz}&amp;lt;/math&amp;gt;. This frequency interval is consistent with the dominant spectral content of surface EMG: the lower cutoff near 20 Hz reduces motion artifacts and unstable low-frequency fluctuations, whereas the upper cutoff near 160 Hz removes high-frequency electronic noise while preserving the main energy-bearing components of the muscle signal. The use of a Butterworth structure is appropriate here because it provides a smooth monotonic passband response without ripple, which helps preserve signal morphology in real-time applications.&lt;br /&gt;
&lt;br /&gt;
After band limitation, a &#039;&#039;&#039;notch filter&#039;&#039;&#039; centered at the power-line frequency is applied to suppress interference that cannot be removed by the band-pass stage alone. The notch filter is designed around &amp;lt;math&amp;gt;f_0 = 50 \text{ Hz}&amp;lt;/math&amp;gt;, and its bandwidth is controlled by the quality factor &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;, which is expressed as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;Q = \frac{f_0}{\Delta f}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In transfer-function form, the notch stage is written as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;H_{N}(z)=\frac{B_{N}(z)}{A_{N}(z)}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the implemented program, a large quality factor is chosen so that the notch remains narrow, allowing effective rejection of the 50 Hz interference while minimizing distortion of neighboring useful spectral components. This is particularly important for sEMG because the interference frequency lies directly inside the physiological band of interest.&lt;br /&gt;
&lt;br /&gt;
Following the filtering stages, further signal conditioning is performed to obtain a representation that is more directly related to muscle activation intensity. The filtered sEMG waveform is first &#039;&#039;&#039;full-wave rectified&#039;&#039;&#039;, which converts the bipolar oscillatory signal into a unipolar signal by taking its absolute value.  Rectification does not remove noise by itself; instead, it transforms the signal into a form that is more suitable for amplitude-based analysis because both positive and negative deflections contribute positively to the activation measure.&lt;br /&gt;
&lt;br /&gt;
After rectification, the signal envelope is extracted to provide a smooth estimate of muscle activation level over time. In a general formulation, the envelope can be described as the &#039;&#039;&#039;low-pass filtered&#039;&#039;&#039; version of the rectified signal, namely &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y_{\mathrm{env}}[n] = \mathrm{LPF}\bigl(y_{\mathrm{rect}}[n]\bigr)&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the present code implementation, this operation is realized by short-time averaging over a finite window, which is equivalent to a moving-average low-pass smoothing of the rectified waveform. The corresponding expression is &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y_{\mathrm{env}}[n] = \frac{1}{N}\sum_{k=0}^{N-1} |x[n-k]|&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; is the window length in samples. With a window duration of approximately 200 ms, this envelope extraction method provides a stable and physiologically meaningful representation of muscle activation intensity, making it suitable for tasks such as force estimation, fatigue analysis, and motor-control studies.&lt;br /&gt;
&lt;br /&gt;
An important feature of the present &#039;&#039;&#039;implementation&#039;&#039;&#039; is that the entire filtering process is performed &#039;&#039;&#039;in real time&#039;&#039;&#039;, sample by sample, rather than by offline block processing. For this reason, IIR filters are preferred over FIR filters, since they can achieve comparable filtering performance with lower order, lower computational cost, and shorter delay. These properties are especially valuable in embedded systems, serial data streaming, and other low-latency experimental applications. However, unlike memoryless operations, an IIR filter depends not only on the current input but also on previous inputs and previous outputs. Its discrete-time behavior can therefore be represented by the recursive difference equation &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y[n] = \sum_{k=0}^{M} b_k x[n-k] - \sum_{k=1}^{N} a_k y[n-k]&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This equation makes clear that internal filter states must be preserved continuously during streaming operation. If the state variables were reinitialized for every incoming sample or data segment, artificial transients would appear and the output would no longer remain continuous.&lt;br /&gt;
&lt;br /&gt;
In the Python implementation, this state continuity is maintained using the internal initial-condition mechanism provided by SciPy, such as &amp;lt;code&amp;gt;lfilter_zi&amp;lt;/code&amp;gt;, together with recursive state updates during each filtering call. As a result, each newly acquired sample is passed first through the band-pass filter and then through the notch filter, while the internal states of both filters are updated after every step. This state-preserving sample-by-sample design ensures that the processing chain remains causal, continuous, and suitable for real-time display or downstream analysis without requiring storage of the entire signal segment.&lt;br /&gt;
&lt;br /&gt;
Overall, this signal-conditioning scheme provides an experimentally practical solution for real-time sEMG processing. The fourth-order Butterworth band-pass filter confines the signal to the main physiological band of interest, the 50 Hz notch filter removes narrow-band power-line contamination, and the subsequent rectification and envelope extraction generate a smooth amplitude descriptor of muscle activity. Combined with state-preserved streaming IIR implementation, this approach achieves a good balance between signal fidelity, computational efficiency, and real-time applicability in biomedical and physical experiment settings.&lt;br /&gt;
&lt;br /&gt;
== Data Processing ==&lt;br /&gt;
&lt;br /&gt;
The objective of data processing is to convert raw surface electromyography (sEMG) recordings into stable, quantitative, and comparable indicators of muscle activity. Since EMG signals are low in amplitude, highly variable over time, and easily contaminated by noise, a dedicated processing pipeline is necessary before any experimental interpretation can be performed.&lt;br /&gt;
&lt;br /&gt;
In this project, the data processing workflow includes time normalization, signal pre-processing, sliding-window feature extraction, noise-floor estimation, and automatic contraction detection. The processed outputs are then used for subsequent experimental evaluation, including rest-versus-contraction discrimination, signal-to-noise ratio analysis, and repeatability assessment.&lt;br /&gt;
&lt;br /&gt;
=== Input Data and Time Normalization ===&lt;br /&gt;
&lt;br /&gt;
The acquired EMG data are read from CSV files containing two columns: time and filtered sEMG amplitude. In the MATLAB implementation, the time vector is normalized so that each recording starts from zero:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t = t_{all} - t_{all}(1)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This normalization is important because it removes the influence of absolute recording timestamps and makes different trials directly comparable on the same time axis.&lt;br /&gt;
&lt;br /&gt;
In addition, the signal type is automatically identified from the filename as either dynamic or rest. This design allows the same program to process both contraction recordings and resting recordings with different downstream analysis logic.&lt;br /&gt;
&lt;br /&gt;
=== Signal Pre-processing ===&lt;br /&gt;
&lt;br /&gt;
Raw EMG signals cannot be analyzed directly because they usually contain DC offset, low-frequency drift, motion artifacts, and residual high-frequency interference. Therefore, several pre-processing steps are applied before feature extraction.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(1) Baseline Removal&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The first step is DC offset removal:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
x_{dc}(t) = x(t) - \frac{1}{N}\sum_{i=1}^{N}x(i)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This operation centers the signal around zero. It is necessary because an uncorrected baseline would bias amplitude-based metrics and reduce the reliability of later envelope and feature calculations.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(2) Band-pass Filtering &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
After baseline correction, a fourth-order Butterworth band-pass filter is applied with a passband of 20–150 Hz.&lt;br /&gt;
&lt;br /&gt;
This step is introduced for two reasons:&lt;br /&gt;
&lt;br /&gt;
* The low-frequency cutoff at 20 Hz suppresses baseline drift and motion artifacts.&lt;br /&gt;
* The high-frequency cutoff at 150 Hz reduces unwanted high-frequency noise while preserving the main energy band of the recorded sEMG in this project.&lt;br /&gt;
&lt;br /&gt;
Compared with processing the raw waveform directly, band-pass filtering makes the subsequent time-domain features more stable and more physiologically meaningful.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(3) Full-wave Rectification&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The filtered EMG signal is bipolar, meaning that positive and negative phases coexist due to motor unit action potentials. If these positive and negative components are averaged directly, they may cancel each other out. To avoid this, full-wave rectification is performed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
x_{rect}(t) = |x_{filt}(t)|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This transforms the signal into a unipolar representation, so that all muscle activity contributes positively to the extracted features.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(4) Envelope Extraction &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Although the rectified signal reflects signal magnitude, it still fluctuates rapidly. To obtain a smoother representation of muscle activation level, an envelope is extracted using a moving average with a 100 ms window.&lt;br /&gt;
&lt;br /&gt;
Envelope extraction is important because contraction detection should reflect the overall activation trend rather than instantaneous spikes. A smoothed envelope is therefore more robust for identifying active and inactive muscle states.&lt;br /&gt;
&lt;br /&gt;
=== Sliding Window Design ===&lt;br /&gt;
&lt;br /&gt;
To quantify how muscle activity changes with time, the filtered signal is divided into overlapping short-time segments using a sliding window method.&lt;br /&gt;
&lt;br /&gt;
The window parameters are:&lt;br /&gt;
&lt;br /&gt;
* Window length: 250 ms&lt;br /&gt;
* Step size: 50 ms&lt;br /&gt;
&lt;br /&gt;
These values are chosen as a trade-off between temporal resolution and feature stability.&lt;br /&gt;
&lt;br /&gt;
A longer window improves statistical robustness because more samples are included in each calculation. However, if the window is too long, short contractions or rapid changes may be blurred. A smaller step size increases temporal continuity between adjacent feature points and makes the feature curves smoother in time. Therefore, the 250 ms / 50 ms design provides a practical balance between smoothing and time localization.&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt;-th segment, the feature time is defined as the mean time of that segment:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t_k = \frac{1}{N}\sum_{i=s_k}^{e_k} t(i)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;s_k&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;e_k&amp;lt;/math&amp;gt; denote the start and end indices of the window.&lt;br /&gt;
&lt;br /&gt;
=== Feature Extraction ===&lt;br /&gt;
&lt;br /&gt;
Within each sliding window, three time-domain features are extracted: RMS, iEMG, and MAV. These features are widely used in EMG analysis because they are simple, computationally efficient, and directly related to muscle activation intensity.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(1) Root Mean Square (RMS)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
RMS = \sqrt{\frac{1}{N}\sum_{i=1}^{N}x_i^2}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
RMS reflects the effective power of the EMG signal and is one of the most common indicators of contraction strength. It is sensitive to both amplitude and energy, making it especially useful for comparing rest and active states.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(2) Integrated EMG (iEMG)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
iEMG = \sum_{i=1}^{N}|x_i|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
iEMG describes the cumulative electrical activity within a window. It is often interpreted as a measure of total muscle effort over that time segment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(3) Mean Absolute Value (MAV)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
MAV = \frac{1}{N}\sum_{i=1}^{N}|x_i|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
MAV is an amplitude descriptor similar to iEMG, but normalized by the number of samples. It provides an efficient estimate of average signal level and is less computationally intensive than some other features.&lt;br /&gt;
&lt;br /&gt;
These three features are used together because they provide complementary descriptions of EMG intensity. RMS emphasizes signal energy, iEMG emphasizes cumulative activation, and MAV reflects average amplitude.&lt;br /&gt;
&lt;br /&gt;
=== Peak-value Extraction ===&lt;br /&gt;
&lt;br /&gt;
In addition to continuous feature curves, several key peak values are extracted from the processed signal:&lt;br /&gt;
&lt;br /&gt;
* maximum and minimum of the filtered EMG waveform&lt;br /&gt;
* peak of the envelope&lt;br /&gt;
* peak RMS&lt;br /&gt;
* peak iEMG&lt;br /&gt;
* peak MAV&lt;br /&gt;
&lt;br /&gt;
These peak values provide concise descriptors of the strongest activity observed in each recording. They are useful for quick comparison across trials and subjects.&lt;br /&gt;
&lt;br /&gt;
=== Noise Floor Estimation ===&lt;br /&gt;
&lt;br /&gt;
To evaluate signal quality, the noise floor is estimated from a reference resting interval. In the present implementation, the first 3 seconds of the recording are used as the default rest reference:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t \in [0,\min(3,t_{end})]&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this segment, three noise descriptors are computed:&lt;br /&gt;
&lt;br /&gt;
* Noise RMS&lt;br /&gt;
* Noise standard deviation&lt;br /&gt;
* Noise peak-to-peak amplitude&lt;br /&gt;
&lt;br /&gt;
Noise-floor estimation is important because EMG amplitude alone is not sufficient to judge recording quality. A large signal is only meaningful if it is sufficiently higher than the baseline noise level. Therefore, the noise floor serves as the reference for later SNR calculation and for designing contraction thresholds.&lt;br /&gt;
&lt;br /&gt;
=== Global Signal Metrics ===&lt;br /&gt;
&lt;br /&gt;
For each recording, three global metrics are also computed over the entire filtered signal:&lt;br /&gt;
&lt;br /&gt;
* Global RMS&lt;br /&gt;
* Global MAV&lt;br /&gt;
* Global iEMG&lt;br /&gt;
&lt;br /&gt;
These global descriptors summarize the overall signal level of the full recording and are later used in group-level comparisons.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Contraction Detection ===&lt;br /&gt;
&lt;br /&gt;
For dynamic recordings, an automatic contraction detection algorithm is used to identify repeated active segments. This is one of the key parts of the data processing pipeline, because it transforms a continuous EMG trace into discrete contraction events that can be counted and compared.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(1) Threshold Design&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The detection threshold is designed adaptively rather than using a fixed value. Two candidate thresholds are first calculated:&lt;br /&gt;
&lt;br /&gt;
* an envelope-based threshold derived from the global envelope mean and standard deviation&lt;br /&gt;
* a rest-reference threshold derived from the mean and standard deviation of the resting reference amplitude&lt;br /&gt;
&lt;br /&gt;
The final threshold is taken as the larger of the two after additional scaling. This strategy improves robustness because it combines the global activation level of the signal with the baseline noise characteristics of the individual recording.&lt;br /&gt;
&lt;br /&gt;
This adaptive threshold design is preferable to a manually fixed threshold because EMG amplitude can vary strongly between subjects, muscles, and recording sessions.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(2) Initial Segmentation&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
After thresholding the envelope, the signal is classified into active and inactive regions:&lt;br /&gt;
&lt;br /&gt;
* active: envelope above threshold&lt;br /&gt;
* inactive: envelope below threshold&lt;br /&gt;
&lt;br /&gt;
The rising and falling edges of the binary activity vector are then used to determine the start and end points of each candidate contraction segment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(3) Removal of Short Segments&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Very short active regions are often caused by noise fluctuations rather than true muscle contractions. Therefore, segments shorter than 0.20 s are discarded.&lt;br /&gt;
&lt;br /&gt;
This step prevents false positive detections and increases the physiological relevance of the segmentation results.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(4) Merging of Adjacent Segments &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If two neighboring active segments are separated by a very short gap, they are merged when the gap is less than 0.15 s.&lt;br /&gt;
&lt;br /&gt;
This operation is necessary because a single real contraction may be temporarily interrupted by a brief drop in the envelope caused by local fluctuation. Without merging, one contraction could be incorrectly counted as multiple repetitions.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(5) Repetition-level Metrics &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
For each detected contraction segment, two repetition-level metrics are extracted:&lt;br /&gt;
&lt;br /&gt;
* peak RMS of that contraction&lt;br /&gt;
* mean RMS of that contraction&lt;br /&gt;
&lt;br /&gt;
These metrics quantify both the strongest activation within each repetition and the average activation level over the repetition duration.&lt;br /&gt;
&lt;br /&gt;
=== Repeatability Analysis ===&lt;br /&gt;
&lt;br /&gt;
When multiple valid contractions are detected, repeatability is evaluated using the coefficient of variation (CV):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
CV = \frac{\sigma}{\mu}\times 100\%&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt; is the standard deviation and &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is the mean value across repetitions.&lt;br /&gt;
&lt;br /&gt;
Two CV values are computed:&lt;br /&gt;
&lt;br /&gt;
* CV of repetition peak RMS&lt;br /&gt;
* CV of repetition mean RMS&lt;br /&gt;
&lt;br /&gt;
A lower CV indicates better repeatability, meaning that repeated contractions produce more consistent EMG responses.&lt;br /&gt;
&lt;br /&gt;
=== Signal-to-Noise Ratio (SNR) ===&lt;br /&gt;
&lt;br /&gt;
In this project, the signal-to-noise ratio (SNR) is defined based on the ratio between contraction and rest activity:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
SNR_{dB} = 20\log_{10}\left(\frac{RMS_{contraction}}{RMS_{rest}}\right)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This definition is adopted because it directly reflects the system’s ability to distinguish active muscle contraction from baseline noise.&lt;br /&gt;
&lt;br /&gt;
Compared with global SNR definitions, this formulation is more relevant for practical EMG applications such as activity detection and classification.&lt;br /&gt;
&lt;br /&gt;
=== Rest-versus-Contraction Window Comparison ===&lt;br /&gt;
&lt;br /&gt;
To further distinguish inactive and active states, all sliding windows are divided into two groups:&lt;br /&gt;
&lt;br /&gt;
* rest windows: windows with envelope clearly below the threshold&lt;br /&gt;
* contraction windows: windows with envelope above the threshold&lt;br /&gt;
&lt;br /&gt;
The RMS values of these two groups are then compared statistically.&lt;br /&gt;
&lt;br /&gt;
This comparison is important because a practical EMG system should not only detect signal presence, but also clearly separate rest from contraction in a quantitative way. If the two RMS distributions are well separated, it indicates that the system has good discriminative capability.&lt;br /&gt;
&lt;br /&gt;
=== Output Data Structure ===&lt;br /&gt;
&lt;br /&gt;
The processed outputs are organized into structured data for experimental analysis:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(1) Time-series outputs&#039;&#039;&#039;&lt;br /&gt;
* Filtered EMG signal  &lt;br /&gt;
* Rectified signal  &lt;br /&gt;
* Envelope  &lt;br /&gt;
* RMS(t), iEMG(t), MAV(t)  &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(2) Recording-level outputs&#039;&#039;&#039; &lt;br /&gt;
* RMS (rest)  &lt;br /&gt;
* RMS (contraction)  &lt;br /&gt;
* iEMG  &lt;br /&gt;
* Noise metrics  &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(3) Dynamic-signal outputs &#039;&#039;&#039;&lt;br /&gt;
* Detected contractions  &lt;br /&gt;
* Repetition count  &lt;br /&gt;
* Peak RMS per repetition  &lt;br /&gt;
* Mean RMS per repetition  &lt;br /&gt;
* Coefficient of variation (CV)  &lt;br /&gt;
* Signal-to-noise ratio (SNR)  &lt;br /&gt;
&lt;br /&gt;
All extracted features are designed to directly support the evaluation of noise level, signal quality, activity discrimination, and repeatability in the subsequent experimental analysis.&lt;br /&gt;
&lt;br /&gt;
== Experimental Results ==&lt;br /&gt;
&lt;br /&gt;
This section presents representative results of the EMG acquisition and data processing pipeline under both dynamic (muscle contraction) and resting conditions.&lt;br /&gt;
&lt;br /&gt;
=== Representative Dynamic Signal Analysis ===&lt;br /&gt;
&lt;br /&gt;
[[File:Dynamic_Figure1.png|thumb|800px|center|Figure 5.1: Processed EMG signal under dynamic contraction, including filtered signal, rectified signal with envelope, and extracted features (RMS, iEMG, MAV).]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.1 shows the processed EMG signal during repeated muscle contractions.&lt;br /&gt;
&lt;br /&gt;
The filtered EMG waveform exhibits clear burst-like patterns corresponding to periodic contractions. The signal amplitude reaches a maximum of approximately 0.45, while the baseline remains centered around zero, indicating effective baseline removal and filtering.&lt;br /&gt;
&lt;br /&gt;
After rectification and envelope extraction, the contraction periods become clearly distinguishable. The envelope provides a smooth representation of muscle activation, with a peak value of approximately 0.145.&lt;br /&gt;
&lt;br /&gt;
The extracted time-domain features (RMS, iEMG, MAV) further quantify the signal. Among these, iEMG shows the strongest dynamic variation, indicating high sensitivity to contraction intensity.&lt;br /&gt;
&lt;br /&gt;
=== Noise Floor and Rest Reference ===&lt;br /&gt;
&lt;br /&gt;
[[File:Dynamic_Figure2.png|thumb|800px|center|Figure 5.2: Noise estimation, rest vs contraction comparison, automatic contraction detection, and repetition analysis.]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (top-left) shows the resting reference segment used for noise estimation.&lt;br /&gt;
&lt;br /&gt;
The signal remains centered around zero with small fluctuations. The noise characteristics are:&lt;br /&gt;
&lt;br /&gt;
* Noise RMS ≈ 0.0046  &lt;br /&gt;
* Standard deviation ≈ 0.0046  &lt;br /&gt;
* Peak-to-peak amplitude ≈ 0.071  &lt;br /&gt;
&lt;br /&gt;
This indicates a low noise floor and stable measurement conditions.&lt;br /&gt;
&lt;br /&gt;
=== Rest vs Contraction Discrimination ===&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (top-right) compares RMS values between rest and contraction states.&lt;br /&gt;
&lt;br /&gt;
The two distributions are clearly separated:&lt;br /&gt;
&lt;br /&gt;
* Rest mean RMS ≈ 0.0053  &lt;br /&gt;
* Contraction mean RMS ≈ 0.1064  &lt;br /&gt;
&lt;br /&gt;
This corresponds to an approximate 20× increase, demonstrating strong discriminability between inactive and active muscle states.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Contraction Detection ===&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (bottom-left) illustrates automatic detection based on the envelope signal.&lt;br /&gt;
&lt;br /&gt;
A threshold of approximately 0.040 is applied, resulting in stable segmentation of contraction periods.&lt;br /&gt;
&lt;br /&gt;
A total of 12 repetitions are detected, with good alignment to visible signal peaks.&lt;br /&gt;
&lt;br /&gt;
=== Repeatability Analysis ===&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (bottom-right) shows the peak RMS value of each detected contraction.&lt;br /&gt;
&lt;br /&gt;
The results indicate:&lt;br /&gt;
&lt;br /&gt;
* Mean peak RMS ≈ 0.1355  &lt;br /&gt;
* Standard deviation ≈ 0.0173  &lt;br /&gt;
* CV ≈ 12.77%  &lt;br /&gt;
* SNR ≈ 21.26 dB  &lt;br /&gt;
&lt;br /&gt;
This indicates acceptable repeatability and good signal quality.&lt;br /&gt;
&lt;br /&gt;
=== Representative Rest Signal Analysis ===&lt;br /&gt;
&lt;br /&gt;
[[File:Rest_Figure1.png|thumb|800px|center|Figure 5.3: Processed EMG signal under rest condition, showing low amplitude and absence of contraction patterns.]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.3 shows the EMG signal under resting conditions.&lt;br /&gt;
&lt;br /&gt;
The signal remains within a narrow amplitude range (approximately ±0.04) and shows no burst-like structures. The envelope remains close to zero, confirming the absence of muscle activity.&lt;br /&gt;
&lt;br /&gt;
The extracted features remain low:&lt;br /&gt;
&lt;br /&gt;
* RMS ≈ 0.007  &lt;br /&gt;
* MAV ≈ 0.005  &lt;br /&gt;
* iEMG remains stable  &lt;br /&gt;
&lt;br /&gt;
This confirms that no false activation is detected.&lt;br /&gt;
&lt;br /&gt;
=== Frequency-domain Characteristics ===&lt;br /&gt;
&lt;br /&gt;
[[File:Rest_Figure2.png|thumb|800px|center|Figure 5.4: Frequency-domain analysis and statistical characteristics of rest signal.]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.4 shows the frequency-domain characteristics of the resting signal.&lt;br /&gt;
&lt;br /&gt;
The power spectral density (PSD) indicates low overall signal energy without dominant peaks, confirming that the signal mainly consists of noise.&lt;br /&gt;
&lt;br /&gt;
=== Summary of Single-recording Performance ===&lt;br /&gt;
&lt;br /&gt;
From the representative results:&lt;br /&gt;
&lt;br /&gt;
* EMG signals are effectively extracted and denoised  &lt;br /&gt;
* Contraction events are clearly identifiable  &lt;br /&gt;
* Rest and contraction states are well separated  &lt;br /&gt;
* Automatic detection is stable and accurate  &lt;br /&gt;
* Repeatability is acceptable  &lt;br /&gt;
* No false activation occurs under rest conditions  &lt;br /&gt;
&lt;br /&gt;
=== Consistency Across Multiple Recordings ===&lt;br /&gt;
&lt;br /&gt;
The same data processing pipeline was applied to multiple recordings from different subjects and trials.&lt;br /&gt;
&lt;br /&gt;
Across all datasets, consistent patterns were observed:&lt;br /&gt;
&lt;br /&gt;
* Dynamic signals exhibit clear burst-like structures corresponding to repeated muscle contractions  &lt;br /&gt;
* Rest signals remain low in amplitude without distinct activation patterns  &lt;br /&gt;
* RMS values under contraction are consistently higher than those under rest  &lt;br /&gt;
* The automatic detection algorithm reliably identifies contraction segments  &lt;br /&gt;
&lt;br /&gt;
Although quantitative values (e.g., RMS, SNR, CV) vary across recordings due to differences in electrode contact, muscle activation strength, and individual conditions, the overall trends remain consistent.&lt;br /&gt;
&lt;br /&gt;
These results demonstrate the robustness and general applicability of the proposed signal processing method.&lt;br /&gt;
&lt;br /&gt;
== Multi-subject Analysis ==&lt;br /&gt;
=== System Evaluation ===&lt;br /&gt;
&lt;br /&gt;
This section evaluates the performance of the EMG acquisition system in terms of noise level, signal quality, activity discrimination, and repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Noise Floor Analysis ====&lt;br /&gt;
&lt;br /&gt;
The noise floor was evaluated using rest-state recordings, characterized by RMS noise, standard deviation, and peak-to-peak amplitude.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039; shows the lowest noise level (RMS ≈ 0.0046), indicating stable electrode contact and minimal interference.  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039; exhibits moderate noise (RMS ≈ 0.0080), likely influenced by motion artifacts or electrode–skin impedance variation.  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039; shows relatively higher noise (RMS ≈ 0.0126), suggesting increased baseline fluctuation.  &lt;br /&gt;
&lt;br /&gt;
Overall, the system maintains a low noise floor across subjects, although the quality depends on experimental conditions such as electrode contact and environmental interference.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Signal-to-Noise Ratio (SNR) ====&lt;br /&gt;
&lt;br /&gt;
The signal-to-noise ratio (SNR) is defined as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{SNR (dB)} = 20 \log_{10} \left( \frac{\mathrm{RMS}_{\mathrm{contraction}}}{\mathrm{RMS}_{\mathrm{rest}}} \right)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The measured SNR values are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: 21.26 dB → good signal quality  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: 13.52 dB → moderate and usable  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: 6.66 dB → low signal clarity  &lt;br /&gt;
&lt;br /&gt;
General interpretation:&lt;br /&gt;
&lt;br /&gt;
* &amp;gt;20 dB → good  &lt;br /&gt;
* 10–20 dB → usable  &lt;br /&gt;
* &amp;lt;10 dB → poor  &lt;br /&gt;
&lt;br /&gt;
These results show that the system can achieve reliable signal acquisition, although performance varies across subjects.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
====  Rest vs Contraction Discrimination ====&lt;br /&gt;
&lt;br /&gt;
A clear distinction between rest and contraction states is observed based on RMS values.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: 0.0053 → 0.1064 (≈20× increase)  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: 0.0079 → 0.0283 (≈3.6× increase)  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: 0.0141 → 0.0646 (≈4.6× increase)  &lt;br /&gt;
&lt;br /&gt;
This demonstrates that the system is capable of separating muscle activity from baseline noise.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Conclusion:&#039;&#039;  &lt;br /&gt;
The system can be used for basic muscle activity detection and simple classification tasks based on RMS features.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Repeatability of Repeated Contractions ====&lt;br /&gt;
&lt;br /&gt;
Repeatability is evaluated using the coefficient of variation (CV) of peak RMS values across repetitions.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! CV Range !! Evaluation&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt; 10% || Excellent&lt;br /&gt;
|-&lt;br /&gt;
| 10–20% || Acceptable&lt;br /&gt;
|-&lt;br /&gt;
| &amp;gt; 20% || Poor&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Results:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: CV = 12.77% → Acceptable  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: CV = 24.77% → Poor  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: CV = 10.60% → Acceptable  &lt;br /&gt;
&lt;br /&gt;
Although WANG&#039;s signal is detectable, its contraction amplitude varies significantly across repetitions, resulting in poor repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
=== Overall System Performance ===&lt;br /&gt;
&lt;br /&gt;
The system demonstrates the following performance characteristics:&lt;br /&gt;
&lt;br /&gt;
* Reliable detection of muscle activity across all subjects  &lt;br /&gt;
* Clear separation between rest and contraction states  &lt;br /&gt;
* Moderate to high signal quality depending on subject conditions  &lt;br /&gt;
* Repeatability ranging from acceptable to poor due to user-dependent factors  &lt;br /&gt;
&lt;br /&gt;
Overall, the designed EMG acquisition system is capable of stable signal acquisition and feature extraction, with performance primarily influenced by electrode contact quality, skin impedance, and motion consistency.&lt;br /&gt;
&lt;br /&gt;
===== Summary of Quantitative Metrics =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Subject !! RMS (Rest) !! RMS (Contraction) !! Separation Ratio !! iEMG (max) !! Noise RMS !! SNR (dB) !! CV (%) !! Evaluation&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;LIU&#039;&#039;&#039; || 0.0053 || 0.1064 || &#039;&#039;&#039;20.1×&#039;&#039;&#039; || 12.72 || 0.0046 || &#039;&#039;&#039;21.26&#039;&#039;&#039; || 12.77 || Strong signal, good quality&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;WANG&#039;&#039;&#039; || 0.0079 || 0.0283 || 3.57× || 11.10 || 0.0080 || 13.52 || &#039;&#039;&#039;24.77&#039;&#039;&#039; || Usable signal, poor repeatability&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ZHONG&#039;&#039;&#039; || 0.0141 || 0.0646 || 4.58× || 6.70 || 0.0126 || 6.66 || 10.60 || Acceptable performance&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Summary:&#039;&#039; Subject LIU shows the best overall performance, WANG provides usable but less stable signals, and ZHONG demonstrates moderate signal quality with good repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Activation Intensity =====&lt;br /&gt;
&lt;br /&gt;
Among the three subjects, &#039;&#039;&#039;LIU exhibits the strongest muscle activation&#039;&#039;&#039;, as indicated by the highest contraction RMS and iEMG values. ZHONG shows moderate activation, while WANG demonstrates comparable iEMG but lower RMS consistency.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Signal Quality =====&lt;br /&gt;
&lt;br /&gt;
Signal quality is evaluated based on SNR and noise level:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039; achieves the highest SNR and lowest noise → best signal quality  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039; shows moderate SNR → usable but less robust  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039; has the lowest SNR → weakest signal clarity  &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Repeatability =====&lt;br /&gt;
&lt;br /&gt;
Repeatability is evaluated using the coefficient of variation (CV):&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;ZHONG (10.60%)&#039;&#039;&#039; → most stable  &lt;br /&gt;
* &#039;&#039;&#039;LIU (12.77%)&#039;&#039;&#039; → acceptable  &lt;br /&gt;
* &#039;&#039;&#039;WANG (24.77%)&#039;&#039;&#039; → poor  &lt;br /&gt;
&lt;br /&gt;
This indicates that WANG’s contraction strength varies significantly between repetitions.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Engineering Interpretation of Inter-subject Differences =====&lt;br /&gt;
&lt;br /&gt;
The observed differences are mainly attributed to engineering and experimental factors rather than physiological differences.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Electrode contact quality&#039;&#039;&#039;  &lt;br /&gt;
  Variations in electrode placement, pressure, and gel contact affect signal amplitude and stability.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Skin impedance&#039;&#039;&#039;  &lt;br /&gt;
  Differences in skin condition (hydration, oil, hair) influence electrode–skin impedance, affecting noise level and signal coupling.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Muscle control consistency&#039;&#039;&#039;  &lt;br /&gt;
  Variations in contraction strength and timing affect repeatability and CV.&lt;br /&gt;
&lt;br /&gt;
Therefore, the variation across subjects reflects practical acquisition conditions rather than intrinsic system limitations.&lt;/div&gt;</summary>
		<author><name>Wang Jingyi</name></author>
	</entry>
	<entry>
		<id>https://pc5271.org/index.php?title=Surface_EMG_Sensor_for_Muscle_Activity_Measurement:_AFE_Design_and_Signal_Processing&amp;diff=1364</id>
		<title>Surface EMG Sensor for Muscle Activity Measurement: AFE Design and Signal Processing</title>
		<link rel="alternate" type="text/html" href="https://pc5271.org/index.php?title=Surface_EMG_Sensor_for_Muscle_Activity_Measurement:_AFE_Design_and_Signal_Processing&amp;diff=1364"/>
		<updated>2026-04-23T07:42:23Z</updated>

		<summary type="html">&lt;p&gt;Wang Jingyi: /* System and Measurement Conditions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Background and Theory==&lt;br /&gt;
&lt;br /&gt;
=== Surface EMG Signals ===&lt;br /&gt;
Surface electromyography (sEMG) refers to the bioelectrical signals detected on the skin surface during muscle contraction. These signals originate from the electrical activity of muscle fibers and provide a non-invasive way to monitor muscle activation. Compared with invasive EMG methods, sEMG is easier to apply, safer for repeated measurements, and more suitable for real-time monitoring. Therefore, it has been widely used in areas such as rehabilitation, motion analysis, human–machine interaction, and physiological monitoring.&lt;br /&gt;
&lt;br /&gt;
=== Characteristics of EMG Signals ===&lt;br /&gt;
EMG signals are generally weak, time-varying, and stochastic in nature. Their waveforms are typically bipolar, fluctuating around zero with both positive and negative components. The amplitude and frequency content of EMG signals depend on factors such as muscle contraction level, electrode placement, skin condition, and individual physiological differences. In practice, the useful frequency components of sEMG are mainly concentrated in a limited low-to-mid frequency range. Because of their low amplitude and variability, EMG signals usually require further conditioning before reliable interpretation and feature extraction can be performed.&lt;br /&gt;
&lt;br /&gt;
=== Bioelectrical Signal Acquisition Principles ===&lt;br /&gt;
The acquisition of bioelectrical signals is based on measuring the small potential difference on the skin surface using electrodes, then converting it into a processable electrical signal through amplification and digitization. For sEMG measurement, electrode placement and skin–electrode contact quality are especially important, since they directly affect signal amplitude and stability. In addition, the front-end acquisition circuit must provide sufficient sensitivity and good interference rejection, so that the recorded signal reflects actual muscle activity rather than environmental disturbance or poor contact conditions.&lt;br /&gt;
&lt;br /&gt;
=== Noise Sources in EMG (50 Hz, motion artifacts) ===&lt;br /&gt;
In practical EMG recording, the measured signal is easily contaminated by different types of noise. Two of the most common sources are power-line interference and motion artifacts. Power-line interference usually appears as a narrow-band component at 50 Hz in the local electrical environment, while motion artifacts are mainly caused by electrode movement, cable disturbance, or variations in the electrode–skin impedance, and are often concentrated in the low-frequency range. In addition, electronic noise from the acquisition hardware may also affect the recording quality. These unwanted components can reduce signal clarity and make muscle activity analysis less reliable, so they must be considered in the design of the signal processing pipeline.&lt;br /&gt;
[[File:background_theory_figure1.1_emg_noise_sources.png|center|thumb|700px|&#039;&#039;&#039;Figure 1.1.&#039;&#039;&#039; Principle of surface EMG acquisition.]]&lt;br /&gt;
&lt;br /&gt;
==System Architecture==&lt;br /&gt;
=== Total Structure Design ===&lt;br /&gt;
&lt;br /&gt;
For clarity，the proposed physiological signal acquisition system mainly consists of two core parts：the analog front－end （AFE）and the ADC board．The AFE is responsible for the preliminary conditioning of weak bioelectrical signals，including amplification，filtering，interference suppression，and level shifting，so that the analog waveform can be converted into a stable and measurable form．The ADC board then performs high－resolution digitization of the conditioned signal and transfers the sampled data to the host computer for subsequent display，storage，and analysis．Therefore，the overall system forms a complete signal－acquisition chain from weak physiological input to digital output．&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_1.jpg|thumb|center|800px|Figure 2.1. Overall system architecture of the proposed physiological signal acquisition platform，including the AFE and ADC modules．]]&lt;br /&gt;
&lt;br /&gt;
=== sEMG AFE Design ===&lt;br /&gt;
&lt;br /&gt;
To collect the weak bioelectric potential signals of the human body，an analog front－end（AFE）suitable sEMG measurements was designed．The module is powered by an external 5 V supply，and the complete circuit includes a first－ stage instrumentation amplifier based on INA128（Texas Instruments，Dallas，TX，USA），a band－pass filter，a 50 Hz notch filter，a second－order amplification and level shifting stage，a driver electrode circuit，a precise 1.5 V reference source，and a -5 V voltage generation module for powering the operational amplifiers．&lt;br /&gt;
&lt;br /&gt;
==== First－order Amplifier ====&lt;br /&gt;
&lt;br /&gt;
The input bioelectric signal is first acquired in differential form and applied to the INA128 instrumentation amplifier，which provides high input impedance，high common－mode rejection，and moderate initial gain for sEMG acquisition．This stage enlarges the weak physiological signal before filtering while reducing the risk of premature saturation caused by electrode offset or motion－induced disturbance，thereby preparing a more stable signal for the subsequent conditioning stages．&lt;br /&gt;
&lt;br /&gt;
==== Bandpass Filter ====&lt;br /&gt;
&lt;br /&gt;
After the instrumentation amplifier，the signal passes through a second－order active band－pass filter，as shown in Figure 2．2． This stage suppresses baseline drift and high－frequency noise outside the useful sEMG range，so that the low－frequency envelope information of sEMG can be preserved before further amplification．&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_2.jpg|thumb|center|800px|Figure 2.2. Schematic diagram of the active band-pass filter used in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the band-pass stage used to retain the main physiological signal band while suppressing unwanted lowand high-frequency components.&lt;br /&gt;
&lt;br /&gt;
==== Notch Filter ====&lt;br /&gt;
&lt;br /&gt;
To reduce power-line interference, a dedicated 50 Hz notch filter is introduced after the band-pass stage, as shown in Figure 2.3. This filter attenuates the mains-frequency component that commonly contaminates weak bioelectric measurements, thereby improving the signal-to-noise ratio of sEMG signals before the final amplification stage.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_3.jpg|thumb|center|800px|Figure 2.3. Schematic diagram of the 50 Hz notch filter used in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the circuit used to attenuate 50 Hz mains interference in the analog front end.&lt;br /&gt;
&lt;br /&gt;
==== Second-order Amplifier &amp;amp; Level Shifter ====&lt;br /&gt;
&lt;br /&gt;
After filtering, the signal enters the second-stage amplification and level-shifting circuit shown in Figure 2.4. In this stage, the filtered signal is further amplified to improve amplitude utilization and then shifted by a 1.5 V reference so that the output becomes a stable unipolar signal suitable for ADC sampling, while preserving linear operation and providing sufficient output swing margin.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_4.jpg|thumb|center|800px|Figure 2.4. Schematic diagram of the second-stage amplifier and level-shifting circuit in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows how the conditioned signal is further amplified and shifted to a suitable DC level before digitization.&lt;br /&gt;
&lt;br /&gt;
==== Power Module and Drive-electrode Circuit ====&lt;br /&gt;
&lt;br /&gt;
The AFE is powered by a 5 V supply and also integrates a 1.5 V precision reference, a -5 V generation circuit, and a driveelectrode circuit. These supporting modules provide the required supply rails and reference level for analog signal conditioning, while the drive-electrode circuit feeds back common-mode voltage to the body to suppress interference at the source. As a result, the complete AFE can support sEMG acquisition with adequate gain, filtering, and noise-reduction performance in a compact hardware structure.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_5.jpg|thumb|center|800px|Figure 2.5. Physical picture of the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the fabricated sEMG analog front-end hardware used in the system.&lt;br /&gt;
&lt;br /&gt;
Figure 2.5 presents the practical hardware implementation of the proposed sEMG AFE. It integrates amplification, filtering, level shifting, and driven-reference functions in a compact circuit for weak bioelectrical signal acquisition.&lt;br /&gt;
&lt;br /&gt;
=== ADS1256-based ADC Board ===&lt;br /&gt;
&lt;br /&gt;
To digitize the conditioned weak physiological signals with sufficient resolution and low noise, this project developed a dedicated ADC board based on the ADS1256 analog-to-digital converter (Texas Instruments, Dallas, TX, USA) and the STM32F103C8T6 microcontroller (STMicroelectronics, Geneva, Switzerland). The overall design objective of this board was not merely to realize analog-to-digital conversion, but to provide a complete hardware interface between the analog front-end and the digital processing unit, including precision reference generation, clocking, input protection and filtering, serial communication, power regulation, and MCU-based acquisition control. The ADS1256 was selected because it is a&lt;br /&gt;
&lt;br /&gt;
very low-noise 24-bit delta-sigma converter with a programmable gain amplifier (PGA), flexible input multiplexer, programmable digital filter, and SPI-compatible serial interface, which makes it well suited for weak low-frequency physiological signals after analog conditioning. The STM32F103C8T6 was used as the local controller because it provides a 32-bit Cortex-M3 core, up to 72 MHz system clock, SPI, USART, USB, and standard SWD debugging support in a compact and low-cost platform.&lt;br /&gt;
&lt;br /&gt;
==== ADC Core Architecture and Design Rationale ====&lt;br /&gt;
&lt;br /&gt;
The ADS1256 was selected as the core ADC because it provides high-resolution, low-noise delta-sigma conversion with an input multiplexer, programmable gain amplifier, and digital filter, which are suitable for weak and low-frequency physiological signals. As shown in Figure 2.6, this architecture emphasizes resolution and noise performance rather than high conversion bandwidth, making it appropriate for sEMG signal digitization after analog conditioning.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_6.jpg|thumb|center|800px|Figure 2.6. Internal functional structure of the ADS1256 analog-to-digital converter.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the main internal blocks of the ADS1256, including the multiplexer, PGA, modulator, and digital filter.&lt;br /&gt;
&lt;br /&gt;
==== Analog Front-End Interface, Reference, and Clocking ====&lt;br /&gt;
&lt;br /&gt;
The ADS1256 analog inputs are connected to the external header through a passive input-conditioning network that helps suppress high-frequency interference and improve input stability. In addition, the board includes a dedicated precision reference and clocking circuits so that the ADC can perform stable and accurate conversion. Together, these circuits provide a reliable analog interface and timing basis for high-resolution digitization of weak physiological signals.&lt;br /&gt;
&lt;br /&gt;
==== SPI Interface between ADS1256 and STM32F103C8T6 ====&lt;br /&gt;
&lt;br /&gt;
Communication between the ADS1256 and the STM32F103C8T6 is implemented through an SPI-compatible interface, with dedicated lines for chip select, serial clock, input/output data, data-ready notification, and hardware reset. This connection allows the MCU to configure the ADC, read conversion results in synchrony with DRDY, and maintain efficient and reliable acquisition control for multi-channel physiological measurements.&lt;br /&gt;
&lt;br /&gt;
==== Power Supply and On-board Regulation ====&lt;br /&gt;
&lt;br /&gt;
The ADC board uses a USB Type-B connector as the main power input and includes protection, voltage regulation, and local decoupling circuits to provide a stable supply for both the MCU and ADC-related hardware. In addition, analog ground and digital ground are separated in the PCB layout to reduce digital noise coupling into the analog path, which is particularly important for weak physiological signal acquisition.&lt;br /&gt;
&lt;br /&gt;
==== Basic Peripheral Circuits of the STM32F103C8T6 ====&lt;br /&gt;
&lt;br /&gt;
The STM32F103C8T6 serves as the local controller of the ADC board and is supported by several basic peripheral circuits, including an external crystal oscillator, reset network, BOOT0 configuration, SWD programming/debugging header, and a CH340N USB-to-UART bridge. These circuits ensure stable MCU operation, convenient firmware downloading and debugging, and reliable data transmission from the board to the host computer for real-time display and storage.&lt;br /&gt;
&lt;br /&gt;
==== Hardware-level Working Principle of the ADC Board ====&lt;br /&gt;
&lt;br /&gt;
In operation, the conditioned analog signal from the AFE enters the ADS1256 through the input header, is digitized with high resolution under the control of the local precision reference and clock, and is then read by the STM32 through the SPI interface. The MCU subsequently forwards the sampled data to the host computer through the serial communication link, so that the entire board functions as a compact digital acquisition backend connecting weak physiological analog signals to later software processing, display, and storage.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_7.jpg|thumb|center|800px|Figure 2.7. Photograph of the fabricated ADS1256-based ADC board developed in this project and the definitions of some key pins.]]&lt;br /&gt;
&lt;br /&gt;
Figure 2.7 shows the ADC board fabricated for this project. It integrates the ADS1256 conversion core, STM32 control circuit, power-conditioning circuits, and communication interfaces on a compact PCB for physiological signal digitization.&lt;br /&gt;
&lt;br /&gt;
= Experimental Setup =&lt;br /&gt;
&lt;br /&gt;
== Experimental Demonstration ==&lt;br /&gt;
&lt;br /&gt;
The experimental setup and data acquisition process are demonstrated in the video below.&lt;br /&gt;
&lt;br /&gt;
[https://www.youtube.com/watch?v=xxxx Click here to watch the full demonstration]&lt;br /&gt;
&lt;br /&gt;
The video illustrates the complete measurement procedure, including electrode placement, muscle activation, and real-time EMG signal visualization.&lt;br /&gt;
&lt;br /&gt;
---&lt;br /&gt;
&lt;br /&gt;
== Experimental Procedure ==&lt;br /&gt;
&lt;br /&gt;
Surface EMG signals were acquired using disposable electrodes placed on the forearm muscles responsible for wrist extension. Three electrodes were attached along the muscle region to capture differential EMG signals.&lt;br /&gt;
&lt;br /&gt;
The experimental movement consists of making a fist while extending the wrist backward. This action activates the forearm extensor muscles beneath the electrodes, producing measurable EMG signals.&lt;br /&gt;
&lt;br /&gt;
---&lt;br /&gt;
&lt;br /&gt;
== Data Acquisition Protocol ==&lt;br /&gt;
&lt;br /&gt;
Each subject performed repeated contraction–relaxation cycles under controlled conditions:&lt;br /&gt;
&lt;br /&gt;
* Number of subjects: 3  &lt;br /&gt;
* Number of trials per subject: 3  &lt;br /&gt;
* Duration of each trial: 30 seconds  &lt;br /&gt;
&lt;br /&gt;
During each trial, subjects were instructed to periodically contract and relax the muscle to generate clear dynamic EMG signals, while also maintaining a stable resting state between contractions.&lt;br /&gt;
&lt;br /&gt;
---&lt;br /&gt;
&lt;br /&gt;
== Signal Conditioning and Filtering ==&lt;br /&gt;
Although the AFE already performs preliminary band-pass filtering and 50 Hz interference suppression in the analog domain, the digitized sEMG signal may still contain residual noise due to component tolerances, electrode-contact variation, and environmental interference. Therefore, an additional digital filtering stage is implemented in software as a complementary post-processing step to improve signal quality and to provide a more stable input for rectification, envelope extraction, and subsequent analysis. In this sense, the software filtering is not a simple repetition of the analog filtering, but a refinement and compensation for non-ideal front-end behavior.&lt;br /&gt;
&lt;br /&gt;
Surface electromyographic (sEMG) signals are highly susceptible to several sources of contamination during acquisition. In practical measurements, the dominant disturbances usually include low-frequency motion artifacts caused by electrode movement and electrode–skin impedance variation, narrow-band power-line interference centered at 50 Hz, and broadband high-frequency electronic noise introduced by the acquisition hardware. These unwanted components degrade the quality of the recorded signal and may significantly affect the reliability of subsequent feature extraction, parameter estimation, and muscle activity interpretation. For this reason, an effective signal-conditioning procedure is necessary before any higher-level analysis is performed.&lt;br /&gt;
&lt;br /&gt;
In the present implementation, the filtering strategy follows the principle of restricting the signal bandwidth first and then removing the remaining narrow-band interference in a targeted manner. Accordingly, the raw sEMG signal is first processed by a fourth-order Butterworth IIR band-pass filter and then by a 50 Hz notch filter. This processing sequence is illustrated in the flowchart below, where the signal passes through band-pass filtering, notch filtering, full-wave rectification, and envelope extraction before producing the final processed output.&lt;br /&gt;
&lt;br /&gt;
[[File:flowchart.png|thumb|center|500px|Flowchart of the real-time sEMG signal conditioning pipeline.]]&lt;br /&gt;
&lt;br /&gt;
The rationale of this order is that the &#039;&#039;&#039;band-pass stage&#039;&#039;&#039; first confines the signal to the main spectral region of interest for sEMG, thereby attenuating motion artifacts at very low frequencies and suppressing high-frequency noise components outside the physiological band. After this spectral preconditioning, the notch stage can more effectively suppress the residual 50 Hz power-line interference that lies inside the useful sEMG band. In transfer-function form, the band-pass filter may be written as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;H_{BP}(z)=\frac{B_{BP}(z)}{A_{BP}(z)}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where the effective passband is selected as &amp;lt;math&amp;gt;20 \leq f \leq 160 \text{ Hz}&amp;lt;/math&amp;gt;. This frequency interval is consistent with the dominant spectral content of surface EMG: the lower cutoff near 20 Hz reduces motion artifacts and unstable low-frequency fluctuations, whereas the upper cutoff near 160 Hz removes high-frequency electronic noise while preserving the main energy-bearing components of the muscle signal. The use of a Butterworth structure is appropriate here because it provides a smooth monotonic passband response without ripple, which helps preserve signal morphology in real-time applications.&lt;br /&gt;
&lt;br /&gt;
After band limitation, a &#039;&#039;&#039;notch filter&#039;&#039;&#039; centered at the power-line frequency is applied to suppress interference that cannot be removed by the band-pass stage alone. The notch filter is designed around &amp;lt;math&amp;gt;f_0 = 50 \text{ Hz}&amp;lt;/math&amp;gt;, and its bandwidth is controlled by the quality factor &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;, which is expressed as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;Q = \frac{f_0}{\Delta f}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In transfer-function form, the notch stage is written as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;H_{N}(z)=\frac{B_{N}(z)}{A_{N}(z)}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the implemented program, a large quality factor is chosen so that the notch remains narrow, allowing effective rejection of the 50 Hz interference while minimizing distortion of neighboring useful spectral components. This is particularly important for sEMG because the interference frequency lies directly inside the physiological band of interest.&lt;br /&gt;
&lt;br /&gt;
Following the filtering stages, further signal conditioning is performed to obtain a representation that is more directly related to muscle activation intensity. The filtered sEMG waveform is first &#039;&#039;&#039;full-wave rectified&#039;&#039;&#039;, which converts the bipolar oscillatory signal into a unipolar signal by taking its absolute value.  Rectification does not remove noise by itself; instead, it transforms the signal into a form that is more suitable for amplitude-based analysis because both positive and negative deflections contribute positively to the activation measure.&lt;br /&gt;
&lt;br /&gt;
After rectification, the signal envelope is extracted to provide a smooth estimate of muscle activation level over time. In a general formulation, the envelope can be described as the &#039;&#039;&#039;low-pass filtered&#039;&#039;&#039; version of the rectified signal, namely &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y_{\mathrm{env}}[n] = \mathrm{LPF}\bigl(y_{\mathrm{rect}}[n]\bigr)&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the present code implementation, this operation is realized by short-time averaging over a finite window, which is equivalent to a moving-average low-pass smoothing of the rectified waveform. The corresponding expression is &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y_{\mathrm{env}}[n] = \frac{1}{N}\sum_{k=0}^{N-1} |x[n-k]|&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; is the window length in samples. With a window duration of approximately 200 ms, this envelope extraction method provides a stable and physiologically meaningful representation of muscle activation intensity, making it suitable for tasks such as force estimation, fatigue analysis, and motor-control studies.&lt;br /&gt;
&lt;br /&gt;
An important feature of the present &#039;&#039;&#039;implementation&#039;&#039;&#039; is that the entire filtering process is performed &#039;&#039;&#039;in real time&#039;&#039;&#039;, sample by sample, rather than by offline block processing. For this reason, IIR filters are preferred over FIR filters, since they can achieve comparable filtering performance with lower order, lower computational cost, and shorter delay. These properties are especially valuable in embedded systems, serial data streaming, and other low-latency experimental applications. However, unlike memoryless operations, an IIR filter depends not only on the current input but also on previous inputs and previous outputs. Its discrete-time behavior can therefore be represented by the recursive difference equation &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y[n] = \sum_{k=0}^{M} b_k x[n-k] - \sum_{k=1}^{N} a_k y[n-k]&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This equation makes clear that internal filter states must be preserved continuously during streaming operation. If the state variables were reinitialized for every incoming sample or data segment, artificial transients would appear and the output would no longer remain continuous.&lt;br /&gt;
&lt;br /&gt;
In the Python implementation, this state continuity is maintained using the internal initial-condition mechanism provided by SciPy, such as &amp;lt;code&amp;gt;lfilter_zi&amp;lt;/code&amp;gt;, together with recursive state updates during each filtering call. As a result, each newly acquired sample is passed first through the band-pass filter and then through the notch filter, while the internal states of both filters are updated after every step. This state-preserving sample-by-sample design ensures that the processing chain remains causal, continuous, and suitable for real-time display or downstream analysis without requiring storage of the entire signal segment.&lt;br /&gt;
&lt;br /&gt;
Overall, this signal-conditioning scheme provides an experimentally practical solution for real-time sEMG processing. The fourth-order Butterworth band-pass filter confines the signal to the main physiological band of interest, the 50 Hz notch filter removes narrow-band power-line contamination, and the subsequent rectification and envelope extraction generate a smooth amplitude descriptor of muscle activity. Combined with state-preserved streaming IIR implementation, this approach achieves a good balance between signal fidelity, computational efficiency, and real-time applicability in biomedical and physical experiment settings.&lt;br /&gt;
&lt;br /&gt;
== Data Processing ==&lt;br /&gt;
&lt;br /&gt;
The objective of data processing is to convert raw surface electromyography (sEMG) recordings into stable, quantitative, and comparable indicators of muscle activity. Since EMG signals are low in amplitude, highly variable over time, and easily contaminated by noise, a dedicated processing pipeline is necessary before any experimental interpretation can be performed.&lt;br /&gt;
&lt;br /&gt;
In this project, the data processing workflow includes time normalization, signal pre-processing, sliding-window feature extraction, noise-floor estimation, and automatic contraction detection. The processed outputs are then used for subsequent experimental evaluation, including rest-versus-contraction discrimination, signal-to-noise ratio analysis, and repeatability assessment.&lt;br /&gt;
&lt;br /&gt;
=== Input Data and Time Normalization ===&lt;br /&gt;
&lt;br /&gt;
The acquired EMG data are read from CSV files containing two columns: time and filtered sEMG amplitude. In the MATLAB implementation, the time vector is normalized so that each recording starts from zero:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t = t_{all} - t_{all}(1)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This normalization is important because it removes the influence of absolute recording timestamps and makes different trials directly comparable on the same time axis.&lt;br /&gt;
&lt;br /&gt;
In addition, the signal type is automatically identified from the filename as either dynamic or rest. This design allows the same program to process both contraction recordings and resting recordings with different downstream analysis logic.&lt;br /&gt;
&lt;br /&gt;
=== Signal Pre-processing ===&lt;br /&gt;
&lt;br /&gt;
Raw EMG signals cannot be analyzed directly because they usually contain DC offset, low-frequency drift, motion artifacts, and residual high-frequency interference. Therefore, several pre-processing steps are applied before feature extraction.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(1) Baseline Removal&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The first step is DC offset removal:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
x_{dc}(t) = x(t) - \frac{1}{N}\sum_{i=1}^{N}x(i)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This operation centers the signal around zero. It is necessary because an uncorrected baseline would bias amplitude-based metrics and reduce the reliability of later envelope and feature calculations.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(2) Band-pass Filtering &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
After baseline correction, a fourth-order Butterworth band-pass filter is applied with a passband of 20–150 Hz.&lt;br /&gt;
&lt;br /&gt;
This step is introduced for two reasons:&lt;br /&gt;
&lt;br /&gt;
* The low-frequency cutoff at 20 Hz suppresses baseline drift and motion artifacts.&lt;br /&gt;
* The high-frequency cutoff at 150 Hz reduces unwanted high-frequency noise while preserving the main energy band of the recorded sEMG in this project.&lt;br /&gt;
&lt;br /&gt;
Compared with processing the raw waveform directly, band-pass filtering makes the subsequent time-domain features more stable and more physiologically meaningful.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(3) Full-wave Rectification&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The filtered EMG signal is bipolar, meaning that positive and negative phases coexist due to motor unit action potentials. If these positive and negative components are averaged directly, they may cancel each other out. To avoid this, full-wave rectification is performed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
x_{rect}(t) = |x_{filt}(t)|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This transforms the signal into a unipolar representation, so that all muscle activity contributes positively to the extracted features.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(4) Envelope Extraction &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Although the rectified signal reflects signal magnitude, it still fluctuates rapidly. To obtain a smoother representation of muscle activation level, an envelope is extracted using a moving average with a 100 ms window.&lt;br /&gt;
&lt;br /&gt;
Envelope extraction is important because contraction detection should reflect the overall activation trend rather than instantaneous spikes. A smoothed envelope is therefore more robust for identifying active and inactive muscle states.&lt;br /&gt;
&lt;br /&gt;
=== Sliding Window Design ===&lt;br /&gt;
&lt;br /&gt;
To quantify how muscle activity changes with time, the filtered signal is divided into overlapping short-time segments using a sliding window method.&lt;br /&gt;
&lt;br /&gt;
The window parameters are:&lt;br /&gt;
&lt;br /&gt;
* Window length: 250 ms&lt;br /&gt;
* Step size: 50 ms&lt;br /&gt;
&lt;br /&gt;
These values are chosen as a trade-off between temporal resolution and feature stability.&lt;br /&gt;
&lt;br /&gt;
A longer window improves statistical robustness because more samples are included in each calculation. However, if the window is too long, short contractions or rapid changes may be blurred. A smaller step size increases temporal continuity between adjacent feature points and makes the feature curves smoother in time. Therefore, the 250 ms / 50 ms design provides a practical balance between smoothing and time localization.&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt;-th segment, the feature time is defined as the mean time of that segment:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t_k = \frac{1}{N}\sum_{i=s_k}^{e_k} t(i)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;s_k&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;e_k&amp;lt;/math&amp;gt; denote the start and end indices of the window.&lt;br /&gt;
&lt;br /&gt;
=== Feature Extraction ===&lt;br /&gt;
&lt;br /&gt;
Within each sliding window, three time-domain features are extracted: RMS, iEMG, and MAV. These features are widely used in EMG analysis because they are simple, computationally efficient, and directly related to muscle activation intensity.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(1) Root Mean Square (RMS)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
RMS = \sqrt{\frac{1}{N}\sum_{i=1}^{N}x_i^2}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
RMS reflects the effective power of the EMG signal and is one of the most common indicators of contraction strength. It is sensitive to both amplitude and energy, making it especially useful for comparing rest and active states.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(2) Integrated EMG (iEMG)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
iEMG = \sum_{i=1}^{N}|x_i|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
iEMG describes the cumulative electrical activity within a window. It is often interpreted as a measure of total muscle effort over that time segment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(3) Mean Absolute Value (MAV)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
MAV = \frac{1}{N}\sum_{i=1}^{N}|x_i|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
MAV is an amplitude descriptor similar to iEMG, but normalized by the number of samples. It provides an efficient estimate of average signal level and is less computationally intensive than some other features.&lt;br /&gt;
&lt;br /&gt;
These three features are used together because they provide complementary descriptions of EMG intensity. RMS emphasizes signal energy, iEMG emphasizes cumulative activation, and MAV reflects average amplitude.&lt;br /&gt;
&lt;br /&gt;
=== Peak-value Extraction ===&lt;br /&gt;
&lt;br /&gt;
In addition to continuous feature curves, several key peak values are extracted from the processed signal:&lt;br /&gt;
&lt;br /&gt;
* maximum and minimum of the filtered EMG waveform&lt;br /&gt;
* peak of the envelope&lt;br /&gt;
* peak RMS&lt;br /&gt;
* peak iEMG&lt;br /&gt;
* peak MAV&lt;br /&gt;
&lt;br /&gt;
These peak values provide concise descriptors of the strongest activity observed in each recording. They are useful for quick comparison across trials and subjects.&lt;br /&gt;
&lt;br /&gt;
=== Noise Floor Estimation ===&lt;br /&gt;
&lt;br /&gt;
To evaluate signal quality, the noise floor is estimated from a reference resting interval. In the present implementation, the first 3 seconds of the recording are used as the default rest reference:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t \in [0,\min(3,t_{end})]&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this segment, three noise descriptors are computed:&lt;br /&gt;
&lt;br /&gt;
* Noise RMS&lt;br /&gt;
* Noise standard deviation&lt;br /&gt;
* Noise peak-to-peak amplitude&lt;br /&gt;
&lt;br /&gt;
Noise-floor estimation is important because EMG amplitude alone is not sufficient to judge recording quality. A large signal is only meaningful if it is sufficiently higher than the baseline noise level. Therefore, the noise floor serves as the reference for later SNR calculation and for designing contraction thresholds.&lt;br /&gt;
&lt;br /&gt;
=== Global Signal Metrics ===&lt;br /&gt;
&lt;br /&gt;
For each recording, three global metrics are also computed over the entire filtered signal:&lt;br /&gt;
&lt;br /&gt;
* Global RMS&lt;br /&gt;
* Global MAV&lt;br /&gt;
* Global iEMG&lt;br /&gt;
&lt;br /&gt;
These global descriptors summarize the overall signal level of the full recording and are later used in group-level comparisons.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Contraction Detection ===&lt;br /&gt;
&lt;br /&gt;
For dynamic recordings, an automatic contraction detection algorithm is used to identify repeated active segments. This is one of the key parts of the data processing pipeline, because it transforms a continuous EMG trace into discrete contraction events that can be counted and compared.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(1) Threshold Design&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The detection threshold is designed adaptively rather than using a fixed value. Two candidate thresholds are first calculated:&lt;br /&gt;
&lt;br /&gt;
* an envelope-based threshold derived from the global envelope mean and standard deviation&lt;br /&gt;
* a rest-reference threshold derived from the mean and standard deviation of the resting reference amplitude&lt;br /&gt;
&lt;br /&gt;
The final threshold is taken as the larger of the two after additional scaling. This strategy improves robustness because it combines the global activation level of the signal with the baseline noise characteristics of the individual recording.&lt;br /&gt;
&lt;br /&gt;
This adaptive threshold design is preferable to a manually fixed threshold because EMG amplitude can vary strongly between subjects, muscles, and recording sessions.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(2) Initial Segmentation&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
After thresholding the envelope, the signal is classified into active and inactive regions:&lt;br /&gt;
&lt;br /&gt;
* active: envelope above threshold&lt;br /&gt;
* inactive: envelope below threshold&lt;br /&gt;
&lt;br /&gt;
The rising and falling edges of the binary activity vector are then used to determine the start and end points of each candidate contraction segment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(3) Removal of Short Segments&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Very short active regions are often caused by noise fluctuations rather than true muscle contractions. Therefore, segments shorter than 0.20 s are discarded.&lt;br /&gt;
&lt;br /&gt;
This step prevents false positive detections and increases the physiological relevance of the segmentation results.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(4) Merging of Adjacent Segments &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If two neighboring active segments are separated by a very short gap, they are merged when the gap is less than 0.15 s.&lt;br /&gt;
&lt;br /&gt;
This operation is necessary because a single real contraction may be temporarily interrupted by a brief drop in the envelope caused by local fluctuation. Without merging, one contraction could be incorrectly counted as multiple repetitions.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(5) Repetition-level Metrics &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
For each detected contraction segment, two repetition-level metrics are extracted:&lt;br /&gt;
&lt;br /&gt;
* peak RMS of that contraction&lt;br /&gt;
* mean RMS of that contraction&lt;br /&gt;
&lt;br /&gt;
These metrics quantify both the strongest activation within each repetition and the average activation level over the repetition duration.&lt;br /&gt;
&lt;br /&gt;
=== Repeatability Analysis ===&lt;br /&gt;
&lt;br /&gt;
When multiple valid contractions are detected, repeatability is evaluated using the coefficient of variation (CV):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
CV = \frac{\sigma}{\mu}\times 100\%&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt; is the standard deviation and &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is the mean value across repetitions.&lt;br /&gt;
&lt;br /&gt;
Two CV values are computed:&lt;br /&gt;
&lt;br /&gt;
* CV of repetition peak RMS&lt;br /&gt;
* CV of repetition mean RMS&lt;br /&gt;
&lt;br /&gt;
A lower CV indicates better repeatability, meaning that repeated contractions produce more consistent EMG responses.&lt;br /&gt;
&lt;br /&gt;
=== Signal-to-Noise Ratio (SNR) ===&lt;br /&gt;
&lt;br /&gt;
In this project, the signal-to-noise ratio (SNR) is defined based on the ratio between contraction and rest activity:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
SNR_{dB} = 20\log_{10}\left(\frac{RMS_{contraction}}{RMS_{rest}}\right)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This definition is adopted because it directly reflects the system’s ability to distinguish active muscle contraction from baseline noise.&lt;br /&gt;
&lt;br /&gt;
Compared with global SNR definitions, this formulation is more relevant for practical EMG applications such as activity detection and classification.&lt;br /&gt;
&lt;br /&gt;
=== Rest-versus-Contraction Window Comparison ===&lt;br /&gt;
&lt;br /&gt;
To further distinguish inactive and active states, all sliding windows are divided into two groups:&lt;br /&gt;
&lt;br /&gt;
* rest windows: windows with envelope clearly below the threshold&lt;br /&gt;
* contraction windows: windows with envelope above the threshold&lt;br /&gt;
&lt;br /&gt;
The RMS values of these two groups are then compared statistically.&lt;br /&gt;
&lt;br /&gt;
This comparison is important because a practical EMG system should not only detect signal presence, but also clearly separate rest from contraction in a quantitative way. If the two RMS distributions are well separated, it indicates that the system has good discriminative capability.&lt;br /&gt;
&lt;br /&gt;
=== Output Data Structure ===&lt;br /&gt;
&lt;br /&gt;
The processed outputs are organized into structured data for experimental analysis:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(1) Time-series outputs&#039;&#039;&#039;&lt;br /&gt;
* Filtered EMG signal  &lt;br /&gt;
* Rectified signal  &lt;br /&gt;
* Envelope  &lt;br /&gt;
* RMS(t), iEMG(t), MAV(t)  &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(2) Recording-level outputs&#039;&#039;&#039; &lt;br /&gt;
* RMS (rest)  &lt;br /&gt;
* RMS (contraction)  &lt;br /&gt;
* iEMG  &lt;br /&gt;
* Noise metrics  &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(3) Dynamic-signal outputs &#039;&#039;&#039;&lt;br /&gt;
* Detected contractions  &lt;br /&gt;
* Repetition count  &lt;br /&gt;
* Peak RMS per repetition  &lt;br /&gt;
* Mean RMS per repetition  &lt;br /&gt;
* Coefficient of variation (CV)  &lt;br /&gt;
* Signal-to-noise ratio (SNR)  &lt;br /&gt;
&lt;br /&gt;
All extracted features are designed to directly support the evaluation of noise level, signal quality, activity discrimination, and repeatability in the subsequent experimental analysis.&lt;br /&gt;
&lt;br /&gt;
== Experimental Results ==&lt;br /&gt;
&lt;br /&gt;
This section presents representative results of the EMG acquisition and data processing pipeline under both dynamic (muscle contraction) and resting conditions.&lt;br /&gt;
&lt;br /&gt;
=== Representative Dynamic Signal Analysis ===&lt;br /&gt;
&lt;br /&gt;
[[File:Dynamic_Figure1.png|thumb|800px|center|Figure 5.1: Processed EMG signal under dynamic contraction, including filtered signal, rectified signal with envelope, and extracted features (RMS, iEMG, MAV).]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.1 shows the processed EMG signal during repeated muscle contractions.&lt;br /&gt;
&lt;br /&gt;
The filtered EMG waveform exhibits clear burst-like patterns corresponding to periodic contractions. The signal amplitude reaches a maximum of approximately 0.45, while the baseline remains centered around zero, indicating effective baseline removal and filtering.&lt;br /&gt;
&lt;br /&gt;
After rectification and envelope extraction, the contraction periods become clearly distinguishable. The envelope provides a smooth representation of muscle activation, with a peak value of approximately 0.145.&lt;br /&gt;
&lt;br /&gt;
The extracted time-domain features (RMS, iEMG, MAV) further quantify the signal. Among these, iEMG shows the strongest dynamic variation, indicating high sensitivity to contraction intensity.&lt;br /&gt;
&lt;br /&gt;
=== Noise Floor and Rest Reference ===&lt;br /&gt;
&lt;br /&gt;
[[File:Dynamic_Figure2.png|thumb|800px|center|Figure 5.2: Noise estimation, rest vs contraction comparison, automatic contraction detection, and repetition analysis.]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (top-left) shows the resting reference segment used for noise estimation.&lt;br /&gt;
&lt;br /&gt;
The signal remains centered around zero with small fluctuations. The noise characteristics are:&lt;br /&gt;
&lt;br /&gt;
* Noise RMS ≈ 0.0046  &lt;br /&gt;
* Standard deviation ≈ 0.0046  &lt;br /&gt;
* Peak-to-peak amplitude ≈ 0.071  &lt;br /&gt;
&lt;br /&gt;
This indicates a low noise floor and stable measurement conditions.&lt;br /&gt;
&lt;br /&gt;
=== Rest vs Contraction Discrimination ===&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (top-right) compares RMS values between rest and contraction states.&lt;br /&gt;
&lt;br /&gt;
The two distributions are clearly separated:&lt;br /&gt;
&lt;br /&gt;
* Rest mean RMS ≈ 0.0053  &lt;br /&gt;
* Contraction mean RMS ≈ 0.1064  &lt;br /&gt;
&lt;br /&gt;
This corresponds to an approximate 20× increase, demonstrating strong discriminability between inactive and active muscle states.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Contraction Detection ===&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (bottom-left) illustrates automatic detection based on the envelope signal.&lt;br /&gt;
&lt;br /&gt;
A threshold of approximately 0.040 is applied, resulting in stable segmentation of contraction periods.&lt;br /&gt;
&lt;br /&gt;
A total of 12 repetitions are detected, with good alignment to visible signal peaks.&lt;br /&gt;
&lt;br /&gt;
=== Repeatability Analysis ===&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (bottom-right) shows the peak RMS value of each detected contraction.&lt;br /&gt;
&lt;br /&gt;
The results indicate:&lt;br /&gt;
&lt;br /&gt;
* Mean peak RMS ≈ 0.1355  &lt;br /&gt;
* Standard deviation ≈ 0.0173  &lt;br /&gt;
* CV ≈ 12.77%  &lt;br /&gt;
* SNR ≈ 21.26 dB  &lt;br /&gt;
&lt;br /&gt;
This indicates acceptable repeatability and good signal quality.&lt;br /&gt;
&lt;br /&gt;
=== Representative Rest Signal Analysis ===&lt;br /&gt;
&lt;br /&gt;
[[File:Rest_Figure1.png|thumb|800px|center|Figure 5.3: Processed EMG signal under rest condition, showing low amplitude and absence of contraction patterns.]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.3 shows the EMG signal under resting conditions.&lt;br /&gt;
&lt;br /&gt;
The signal remains within a narrow amplitude range (approximately ±0.04) and shows no burst-like structures. The envelope remains close to zero, confirming the absence of muscle activity.&lt;br /&gt;
&lt;br /&gt;
The extracted features remain low:&lt;br /&gt;
&lt;br /&gt;
* RMS ≈ 0.007  &lt;br /&gt;
* MAV ≈ 0.005  &lt;br /&gt;
* iEMG remains stable  &lt;br /&gt;
&lt;br /&gt;
This confirms that no false activation is detected.&lt;br /&gt;
&lt;br /&gt;
=== Frequency-domain Characteristics ===&lt;br /&gt;
&lt;br /&gt;
[[File:Rest_Figure2.png|thumb|800px|center|Figure 5.4: Frequency-domain analysis and statistical characteristics of rest signal.]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.4 shows the frequency-domain characteristics of the resting signal.&lt;br /&gt;
&lt;br /&gt;
The power spectral density (PSD) indicates low overall signal energy without dominant peaks, confirming that the signal mainly consists of noise.&lt;br /&gt;
&lt;br /&gt;
=== Summary of Single-recording Performance ===&lt;br /&gt;
&lt;br /&gt;
From the representative results:&lt;br /&gt;
&lt;br /&gt;
* EMG signals are effectively extracted and denoised  &lt;br /&gt;
* Contraction events are clearly identifiable  &lt;br /&gt;
* Rest and contraction states are well separated  &lt;br /&gt;
* Automatic detection is stable and accurate  &lt;br /&gt;
* Repeatability is acceptable  &lt;br /&gt;
* No false activation occurs under rest conditions  &lt;br /&gt;
&lt;br /&gt;
=== Consistency Across Multiple Recordings ===&lt;br /&gt;
&lt;br /&gt;
The same data processing pipeline was applied to multiple recordings from different subjects and trials.&lt;br /&gt;
&lt;br /&gt;
Across all datasets, consistent patterns were observed:&lt;br /&gt;
&lt;br /&gt;
* Dynamic signals exhibit clear burst-like structures corresponding to repeated muscle contractions  &lt;br /&gt;
* Rest signals remain low in amplitude without distinct activation patterns  &lt;br /&gt;
* RMS values under contraction are consistently higher than those under rest  &lt;br /&gt;
* The automatic detection algorithm reliably identifies contraction segments  &lt;br /&gt;
&lt;br /&gt;
Although quantitative values (e.g., RMS, SNR, CV) vary across recordings due to differences in electrode contact, muscle activation strength, and individual conditions, the overall trends remain consistent.&lt;br /&gt;
&lt;br /&gt;
These results demonstrate the robustness and general applicability of the proposed signal processing method.&lt;br /&gt;
&lt;br /&gt;
== Multi-subject Analysis ==&lt;br /&gt;
=== System Evaluation ===&lt;br /&gt;
&lt;br /&gt;
This section evaluates the performance of the EMG acquisition system in terms of noise level, signal quality, activity discrimination, and repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Noise Floor Analysis ====&lt;br /&gt;
&lt;br /&gt;
The noise floor was evaluated using rest-state recordings, characterized by RMS noise, standard deviation, and peak-to-peak amplitude.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039; shows the lowest noise level (RMS ≈ 0.0046), indicating stable electrode contact and minimal interference.  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039; exhibits moderate noise (RMS ≈ 0.0080), likely influenced by motion artifacts or electrode–skin impedance variation.  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039; shows relatively higher noise (RMS ≈ 0.0126), suggesting increased baseline fluctuation.  &lt;br /&gt;
&lt;br /&gt;
Overall, the system maintains a low noise floor across subjects, although the quality depends on experimental conditions such as electrode contact and environmental interference.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Signal-to-Noise Ratio (SNR) ====&lt;br /&gt;
&lt;br /&gt;
The signal-to-noise ratio (SNR) is defined as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{SNR (dB)} = 20 \log_{10} \left( \frac{\mathrm{RMS}_{\mathrm{contraction}}}{\mathrm{RMS}_{\mathrm{rest}}} \right)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The measured SNR values are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: 21.26 dB → good signal quality  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: 13.52 dB → moderate and usable  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: 6.66 dB → low signal clarity  &lt;br /&gt;
&lt;br /&gt;
General interpretation:&lt;br /&gt;
&lt;br /&gt;
* &amp;gt;20 dB → good  &lt;br /&gt;
* 10–20 dB → usable  &lt;br /&gt;
* &amp;lt;10 dB → poor  &lt;br /&gt;
&lt;br /&gt;
These results show that the system can achieve reliable signal acquisition, although performance varies across subjects.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
====  Rest vs Contraction Discrimination ====&lt;br /&gt;
&lt;br /&gt;
A clear distinction between rest and contraction states is observed based on RMS values.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: 0.0053 → 0.1064 (≈20× increase)  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: 0.0079 → 0.0283 (≈3.6× increase)  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: 0.0141 → 0.0646 (≈4.6× increase)  &lt;br /&gt;
&lt;br /&gt;
This demonstrates that the system is capable of separating muscle activity from baseline noise.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Conclusion:&#039;&#039;  &lt;br /&gt;
The system can be used for basic muscle activity detection and simple classification tasks based on RMS features.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Repeatability of Repeated Contractions ====&lt;br /&gt;
&lt;br /&gt;
Repeatability is evaluated using the coefficient of variation (CV) of peak RMS values across repetitions.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! CV Range !! Evaluation&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt; 10% || Excellent&lt;br /&gt;
|-&lt;br /&gt;
| 10–20% || Acceptable&lt;br /&gt;
|-&lt;br /&gt;
| &amp;gt; 20% || Poor&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Results:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: CV = 12.77% → Acceptable  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: CV = 24.77% → Poor  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: CV = 10.60% → Acceptable  &lt;br /&gt;
&lt;br /&gt;
Although WANG&#039;s signal is detectable, its contraction amplitude varies significantly across repetitions, resulting in poor repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
=== Overall System Performance ===&lt;br /&gt;
&lt;br /&gt;
The system demonstrates the following performance characteristics:&lt;br /&gt;
&lt;br /&gt;
* Reliable detection of muscle activity across all subjects  &lt;br /&gt;
* Clear separation between rest and contraction states  &lt;br /&gt;
* Moderate to high signal quality depending on subject conditions  &lt;br /&gt;
* Repeatability ranging from acceptable to poor due to user-dependent factors  &lt;br /&gt;
&lt;br /&gt;
Overall, the designed EMG acquisition system is capable of stable signal acquisition and feature extraction, with performance primarily influenced by electrode contact quality, skin impedance, and motion consistency.&lt;br /&gt;
&lt;br /&gt;
===== Summary of Quantitative Metrics =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Subject !! RMS (Rest) !! RMS (Contraction) !! Separation Ratio !! iEMG (max) !! Noise RMS !! SNR (dB) !! CV (%) !! Evaluation&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;LIU&#039;&#039;&#039; || 0.0053 || 0.1064 || &#039;&#039;&#039;20.1×&#039;&#039;&#039; || 12.72 || 0.0046 || &#039;&#039;&#039;21.26&#039;&#039;&#039; || 12.77 || Strong signal, good quality&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;WANG&#039;&#039;&#039; || 0.0079 || 0.0283 || 3.57× || 11.10 || 0.0080 || 13.52 || &#039;&#039;&#039;24.77&#039;&#039;&#039; || Usable signal, poor repeatability&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ZHONG&#039;&#039;&#039; || 0.0141 || 0.0646 || 4.58× || 6.70 || 0.0126 || 6.66 || 10.60 || Acceptable performance&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Summary:&#039;&#039; Subject LIU shows the best overall performance, WANG provides usable but less stable signals, and ZHONG demonstrates moderate signal quality with good repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Activation Intensity =====&lt;br /&gt;
&lt;br /&gt;
Among the three subjects, &#039;&#039;&#039;LIU exhibits the strongest muscle activation&#039;&#039;&#039;, as indicated by the highest contraction RMS and iEMG values. ZHONG shows moderate activation, while WANG demonstrates comparable iEMG but lower RMS consistency.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Signal Quality =====&lt;br /&gt;
&lt;br /&gt;
Signal quality is evaluated based on SNR and noise level:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039; achieves the highest SNR and lowest noise → best signal quality  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039; shows moderate SNR → usable but less robust  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039; has the lowest SNR → weakest signal clarity  &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Repeatability =====&lt;br /&gt;
&lt;br /&gt;
Repeatability is evaluated using the coefficient of variation (CV):&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;ZHONG (10.60%)&#039;&#039;&#039; → most stable  &lt;br /&gt;
* &#039;&#039;&#039;LIU (12.77%)&#039;&#039;&#039; → acceptable  &lt;br /&gt;
* &#039;&#039;&#039;WANG (24.77%)&#039;&#039;&#039; → poor  &lt;br /&gt;
&lt;br /&gt;
This indicates that WANG’s contraction strength varies significantly between repetitions.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Engineering Interpretation of Inter-subject Differences =====&lt;br /&gt;
&lt;br /&gt;
The observed differences are mainly attributed to engineering and experimental factors rather than physiological differences.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Electrode contact quality&#039;&#039;&#039;  &lt;br /&gt;
  Variations in electrode placement, pressure, and gel contact affect signal amplitude and stability.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Skin impedance&#039;&#039;&#039;  &lt;br /&gt;
  Differences in skin condition (hydration, oil, hair) influence electrode–skin impedance, affecting noise level and signal coupling.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Muscle control consistency&#039;&#039;&#039;  &lt;br /&gt;
  Variations in contraction strength and timing affect repeatability and CV.&lt;br /&gt;
&lt;br /&gt;
Therefore, the variation across subjects reflects practical acquisition conditions rather than intrinsic system limitations.&lt;/div&gt;</summary>
		<author><name>Wang Jingyi</name></author>
	</entry>
	<entry>
		<id>https://pc5271.org/index.php?title=Surface_EMG_Sensor_for_Muscle_Activity_Measurement:_AFE_Design_and_Signal_Processing&amp;diff=1363</id>
		<title>Surface EMG Sensor for Muscle Activity Measurement: AFE Design and Signal Processing</title>
		<link rel="alternate" type="text/html" href="https://pc5271.org/index.php?title=Surface_EMG_Sensor_for_Muscle_Activity_Measurement:_AFE_Design_and_Signal_Processing&amp;diff=1363"/>
		<updated>2026-04-23T07:42:12Z</updated>

		<summary type="html">&lt;p&gt;Wang Jingyi: /* Summary */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Background and Theory==&lt;br /&gt;
&lt;br /&gt;
=== Surface EMG Signals ===&lt;br /&gt;
Surface electromyography (sEMG) refers to the bioelectrical signals detected on the skin surface during muscle contraction. These signals originate from the electrical activity of muscle fibers and provide a non-invasive way to monitor muscle activation. Compared with invasive EMG methods, sEMG is easier to apply, safer for repeated measurements, and more suitable for real-time monitoring. Therefore, it has been widely used in areas such as rehabilitation, motion analysis, human–machine interaction, and physiological monitoring.&lt;br /&gt;
&lt;br /&gt;
=== Characteristics of EMG Signals ===&lt;br /&gt;
EMG signals are generally weak, time-varying, and stochastic in nature. Their waveforms are typically bipolar, fluctuating around zero with both positive and negative components. The amplitude and frequency content of EMG signals depend on factors such as muscle contraction level, electrode placement, skin condition, and individual physiological differences. In practice, the useful frequency components of sEMG are mainly concentrated in a limited low-to-mid frequency range. Because of their low amplitude and variability, EMG signals usually require further conditioning before reliable interpretation and feature extraction can be performed.&lt;br /&gt;
&lt;br /&gt;
=== Bioelectrical Signal Acquisition Principles ===&lt;br /&gt;
The acquisition of bioelectrical signals is based on measuring the small potential difference on the skin surface using electrodes, then converting it into a processable electrical signal through amplification and digitization. For sEMG measurement, electrode placement and skin–electrode contact quality are especially important, since they directly affect signal amplitude and stability. In addition, the front-end acquisition circuit must provide sufficient sensitivity and good interference rejection, so that the recorded signal reflects actual muscle activity rather than environmental disturbance or poor contact conditions.&lt;br /&gt;
&lt;br /&gt;
=== Noise Sources in EMG (50 Hz, motion artifacts) ===&lt;br /&gt;
In practical EMG recording, the measured signal is easily contaminated by different types of noise. Two of the most common sources are power-line interference and motion artifacts. Power-line interference usually appears as a narrow-band component at 50 Hz in the local electrical environment, while motion artifacts are mainly caused by electrode movement, cable disturbance, or variations in the electrode–skin impedance, and are often concentrated in the low-frequency range. In addition, electronic noise from the acquisition hardware may also affect the recording quality. These unwanted components can reduce signal clarity and make muscle activity analysis less reliable, so they must be considered in the design of the signal processing pipeline.&lt;br /&gt;
[[File:background_theory_figure1.1_emg_noise_sources.png|center|thumb|700px|&#039;&#039;&#039;Figure 1.1.&#039;&#039;&#039; Principle of surface EMG acquisition.]]&lt;br /&gt;
&lt;br /&gt;
==System Architecture==&lt;br /&gt;
=== Total Structure Design ===&lt;br /&gt;
&lt;br /&gt;
For clarity，the proposed physiological signal acquisition system mainly consists of two core parts：the analog front－end （AFE）and the ADC board．The AFE is responsible for the preliminary conditioning of weak bioelectrical signals，including amplification，filtering，interference suppression，and level shifting，so that the analog waveform can be converted into a stable and measurable form．The ADC board then performs high－resolution digitization of the conditioned signal and transfers the sampled data to the host computer for subsequent display，storage，and analysis．Therefore，the overall system forms a complete signal－acquisition chain from weak physiological input to digital output．&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_1.jpg|thumb|center|800px|Figure 2.1. Overall system architecture of the proposed physiological signal acquisition platform，including the AFE and ADC modules．]]&lt;br /&gt;
&lt;br /&gt;
=== sEMG AFE Design ===&lt;br /&gt;
&lt;br /&gt;
To collect the weak bioelectric potential signals of the human body，an analog front－end（AFE）suitable sEMG measurements was designed．The module is powered by an external 5 V supply，and the complete circuit includes a first－ stage instrumentation amplifier based on INA128（Texas Instruments，Dallas，TX，USA），a band－pass filter，a 50 Hz notch filter，a second－order amplification and level shifting stage，a driver electrode circuit，a precise 1.5 V reference source，and a -5 V voltage generation module for powering the operational amplifiers．&lt;br /&gt;
&lt;br /&gt;
==== First－order Amplifier ====&lt;br /&gt;
&lt;br /&gt;
The input bioelectric signal is first acquired in differential form and applied to the INA128 instrumentation amplifier，which provides high input impedance，high common－mode rejection，and moderate initial gain for sEMG acquisition．This stage enlarges the weak physiological signal before filtering while reducing the risk of premature saturation caused by electrode offset or motion－induced disturbance，thereby preparing a more stable signal for the subsequent conditioning stages．&lt;br /&gt;
&lt;br /&gt;
==== Bandpass Filter ====&lt;br /&gt;
&lt;br /&gt;
After the instrumentation amplifier，the signal passes through a second－order active band－pass filter，as shown in Figure 2．2． This stage suppresses baseline drift and high－frequency noise outside the useful sEMG range，so that the low－frequency envelope information of sEMG can be preserved before further amplification．&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_2.jpg|thumb|center|800px|Figure 2.2. Schematic diagram of the active band-pass filter used in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the band-pass stage used to retain the main physiological signal band while suppressing unwanted lowand high-frequency components.&lt;br /&gt;
&lt;br /&gt;
==== Notch Filter ====&lt;br /&gt;
&lt;br /&gt;
To reduce power-line interference, a dedicated 50 Hz notch filter is introduced after the band-pass stage, as shown in Figure 2.3. This filter attenuates the mains-frequency component that commonly contaminates weak bioelectric measurements, thereby improving the signal-to-noise ratio of sEMG signals before the final amplification stage.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_3.jpg|thumb|center|800px|Figure 2.3. Schematic diagram of the 50 Hz notch filter used in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the circuit used to attenuate 50 Hz mains interference in the analog front end.&lt;br /&gt;
&lt;br /&gt;
==== Second-order Amplifier &amp;amp; Level Shifter ====&lt;br /&gt;
&lt;br /&gt;
After filtering, the signal enters the second-stage amplification and level-shifting circuit shown in Figure 2.4. In this stage, the filtered signal is further amplified to improve amplitude utilization and then shifted by a 1.5 V reference so that the output becomes a stable unipolar signal suitable for ADC sampling, while preserving linear operation and providing sufficient output swing margin.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_4.jpg|thumb|center|800px|Figure 2.4. Schematic diagram of the second-stage amplifier and level-shifting circuit in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows how the conditioned signal is further amplified and shifted to a suitable DC level before digitization.&lt;br /&gt;
&lt;br /&gt;
==== Power Module and Drive-electrode Circuit ====&lt;br /&gt;
&lt;br /&gt;
The AFE is powered by a 5 V supply and also integrates a 1.5 V precision reference, a -5 V generation circuit, and a driveelectrode circuit. These supporting modules provide the required supply rails and reference level for analog signal conditioning, while the drive-electrode circuit feeds back common-mode voltage to the body to suppress interference at the source. As a result, the complete AFE can support sEMG acquisition with adequate gain, filtering, and noise-reduction performance in a compact hardware structure.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_5.jpg|thumb|center|800px|Figure 2.5. Physical picture of the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the fabricated sEMG analog front-end hardware used in the system.&lt;br /&gt;
&lt;br /&gt;
Figure 2.5 presents the practical hardware implementation of the proposed sEMG AFE. It integrates amplification, filtering, level shifting, and driven-reference functions in a compact circuit for weak bioelectrical signal acquisition.&lt;br /&gt;
&lt;br /&gt;
=== ADS1256-based ADC Board ===&lt;br /&gt;
&lt;br /&gt;
To digitize the conditioned weak physiological signals with sufficient resolution and low noise, this project developed a dedicated ADC board based on the ADS1256 analog-to-digital converter (Texas Instruments, Dallas, TX, USA) and the STM32F103C8T6 microcontroller (STMicroelectronics, Geneva, Switzerland). The overall design objective of this board was not merely to realize analog-to-digital conversion, but to provide a complete hardware interface between the analog front-end and the digital processing unit, including precision reference generation, clocking, input protection and filtering, serial communication, power regulation, and MCU-based acquisition control. The ADS1256 was selected because it is a&lt;br /&gt;
&lt;br /&gt;
very low-noise 24-bit delta-sigma converter with a programmable gain amplifier (PGA), flexible input multiplexer, programmable digital filter, and SPI-compatible serial interface, which makes it well suited for weak low-frequency physiological signals after analog conditioning. The STM32F103C8T6 was used as the local controller because it provides a 32-bit Cortex-M3 core, up to 72 MHz system clock, SPI, USART, USB, and standard SWD debugging support in a compact and low-cost platform.&lt;br /&gt;
&lt;br /&gt;
==== ADC Core Architecture and Design Rationale ====&lt;br /&gt;
&lt;br /&gt;
The ADS1256 was selected as the core ADC because it provides high-resolution, low-noise delta-sigma conversion with an input multiplexer, programmable gain amplifier, and digital filter, which are suitable for weak and low-frequency physiological signals. As shown in Figure 2.6, this architecture emphasizes resolution and noise performance rather than high conversion bandwidth, making it appropriate for sEMG signal digitization after analog conditioning.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_6.jpg|thumb|center|800px|Figure 2.6. Internal functional structure of the ADS1256 analog-to-digital converter.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the main internal blocks of the ADS1256, including the multiplexer, PGA, modulator, and digital filter.&lt;br /&gt;
&lt;br /&gt;
==== Analog Front-End Interface, Reference, and Clocking ====&lt;br /&gt;
&lt;br /&gt;
The ADS1256 analog inputs are connected to the external header through a passive input-conditioning network that helps suppress high-frequency interference and improve input stability. In addition, the board includes a dedicated precision reference and clocking circuits so that the ADC can perform stable and accurate conversion. Together, these circuits provide a reliable analog interface and timing basis for high-resolution digitization of weak physiological signals.&lt;br /&gt;
&lt;br /&gt;
==== SPI Interface between ADS1256 and STM32F103C8T6 ====&lt;br /&gt;
&lt;br /&gt;
Communication between the ADS1256 and the STM32F103C8T6 is implemented through an SPI-compatible interface, with dedicated lines for chip select, serial clock, input/output data, data-ready notification, and hardware reset. This connection allows the MCU to configure the ADC, read conversion results in synchrony with DRDY, and maintain efficient and reliable acquisition control for multi-channel physiological measurements.&lt;br /&gt;
&lt;br /&gt;
==== Power Supply and On-board Regulation ====&lt;br /&gt;
&lt;br /&gt;
The ADC board uses a USB Type-B connector as the main power input and includes protection, voltage regulation, and local decoupling circuits to provide a stable supply for both the MCU and ADC-related hardware. In addition, analog ground and digital ground are separated in the PCB layout to reduce digital noise coupling into the analog path, which is particularly important for weak physiological signal acquisition.&lt;br /&gt;
&lt;br /&gt;
==== Basic Peripheral Circuits of the STM32F103C8T6 ====&lt;br /&gt;
&lt;br /&gt;
The STM32F103C8T6 serves as the local controller of the ADC board and is supported by several basic peripheral circuits, including an external crystal oscillator, reset network, BOOT0 configuration, SWD programming/debugging header, and a CH340N USB-to-UART bridge. These circuits ensure stable MCU operation, convenient firmware downloading and debugging, and reliable data transmission from the board to the host computer for real-time display and storage.&lt;br /&gt;
&lt;br /&gt;
==== Hardware-level Working Principle of the ADC Board ====&lt;br /&gt;
&lt;br /&gt;
In operation, the conditioned analog signal from the AFE enters the ADS1256 through the input header, is digitized with high resolution under the control of the local precision reference and clock, and is then read by the STM32 through the SPI interface. The MCU subsequently forwards the sampled data to the host computer through the serial communication link, so that the entire board functions as a compact digital acquisition backend connecting weak physiological analog signals to later software processing, display, and storage.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_7.jpg|thumb|center|800px|Figure 2.7. Photograph of the fabricated ADS1256-based ADC board developed in this project and the definitions of some key pins.]]&lt;br /&gt;
&lt;br /&gt;
Figure 2.7 shows the ADC board fabricated for this project. It integrates the ADS1256 conversion core, STM32 control circuit, power-conditioning circuits, and communication interfaces on a compact PCB for physiological signal digitization.&lt;br /&gt;
&lt;br /&gt;
= Experimental Setup =&lt;br /&gt;
&lt;br /&gt;
== Experimental Demonstration ==&lt;br /&gt;
&lt;br /&gt;
The experimental setup and data acquisition process are demonstrated in the video below.&lt;br /&gt;
&lt;br /&gt;
[https://www.youtube.com/watch?v=xxxx Click here to watch the full demonstration]&lt;br /&gt;
&lt;br /&gt;
The video illustrates the complete measurement procedure, including electrode placement, muscle activation, and real-time EMG signal visualization.&lt;br /&gt;
&lt;br /&gt;
---&lt;br /&gt;
&lt;br /&gt;
== Experimental Procedure ==&lt;br /&gt;
&lt;br /&gt;
Surface EMG signals were acquired using disposable electrodes placed on the forearm muscles responsible for wrist extension. Three electrodes were attached along the muscle region to capture differential EMG signals.&lt;br /&gt;
&lt;br /&gt;
The experimental movement consists of making a fist while extending the wrist backward. This action activates the forearm extensor muscles beneath the electrodes, producing measurable EMG signals.&lt;br /&gt;
&lt;br /&gt;
---&lt;br /&gt;
&lt;br /&gt;
== Data Acquisition Protocol ==&lt;br /&gt;
&lt;br /&gt;
Each subject performed repeated contraction–relaxation cycles under controlled conditions:&lt;br /&gt;
&lt;br /&gt;
* Number of subjects: 3  &lt;br /&gt;
* Number of trials per subject: 3  &lt;br /&gt;
* Duration of each trial: 30 seconds  &lt;br /&gt;
&lt;br /&gt;
During each trial, subjects were instructed to periodically contract and relax the muscle to generate clear dynamic EMG signals, while also maintaining a stable resting state between contractions.&lt;br /&gt;
&lt;br /&gt;
---&lt;br /&gt;
&lt;br /&gt;
== System and Measurement Conditions ==&lt;br /&gt;
&lt;br /&gt;
The EMG signals were recorded and visualized in real time using a data acquisition system connected to a computer. The sampling rate was set to 400 Hz.&lt;br /&gt;
&lt;br /&gt;
To ensure consistency across measurements:&lt;br /&gt;
&lt;br /&gt;
* Electrode placement was kept consistent for all subjects  &lt;br /&gt;
* The same movement protocol was followed  &lt;br /&gt;
* Measurements were conducted under similar environmental conditions  &lt;br /&gt;
&lt;br /&gt;
---&lt;br /&gt;
&lt;br /&gt;
== Signal Conditioning and Filtering ==&lt;br /&gt;
Although the AFE already performs preliminary band-pass filtering and 50 Hz interference suppression in the analog domain, the digitized sEMG signal may still contain residual noise due to component tolerances, electrode-contact variation, and environmental interference. Therefore, an additional digital filtering stage is implemented in software as a complementary post-processing step to improve signal quality and to provide a more stable input for rectification, envelope extraction, and subsequent analysis. In this sense, the software filtering is not a simple repetition of the analog filtering, but a refinement and compensation for non-ideal front-end behavior.&lt;br /&gt;
&lt;br /&gt;
Surface electromyographic (sEMG) signals are highly susceptible to several sources of contamination during acquisition. In practical measurements, the dominant disturbances usually include low-frequency motion artifacts caused by electrode movement and electrode–skin impedance variation, narrow-band power-line interference centered at 50 Hz, and broadband high-frequency electronic noise introduced by the acquisition hardware. These unwanted components degrade the quality of the recorded signal and may significantly affect the reliability of subsequent feature extraction, parameter estimation, and muscle activity interpretation. For this reason, an effective signal-conditioning procedure is necessary before any higher-level analysis is performed.&lt;br /&gt;
&lt;br /&gt;
In the present implementation, the filtering strategy follows the principle of restricting the signal bandwidth first and then removing the remaining narrow-band interference in a targeted manner. Accordingly, the raw sEMG signal is first processed by a fourth-order Butterworth IIR band-pass filter and then by a 50 Hz notch filter. This processing sequence is illustrated in the flowchart below, where the signal passes through band-pass filtering, notch filtering, full-wave rectification, and envelope extraction before producing the final processed output.&lt;br /&gt;
&lt;br /&gt;
[[File:flowchart.png|thumb|center|500px|Flowchart of the real-time sEMG signal conditioning pipeline.]]&lt;br /&gt;
&lt;br /&gt;
The rationale of this order is that the &#039;&#039;&#039;band-pass stage&#039;&#039;&#039; first confines the signal to the main spectral region of interest for sEMG, thereby attenuating motion artifacts at very low frequencies and suppressing high-frequency noise components outside the physiological band. After this spectral preconditioning, the notch stage can more effectively suppress the residual 50 Hz power-line interference that lies inside the useful sEMG band. In transfer-function form, the band-pass filter may be written as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;H_{BP}(z)=\frac{B_{BP}(z)}{A_{BP}(z)}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where the effective passband is selected as &amp;lt;math&amp;gt;20 \leq f \leq 160 \text{ Hz}&amp;lt;/math&amp;gt;. This frequency interval is consistent with the dominant spectral content of surface EMG: the lower cutoff near 20 Hz reduces motion artifacts and unstable low-frequency fluctuations, whereas the upper cutoff near 160 Hz removes high-frequency electronic noise while preserving the main energy-bearing components of the muscle signal. The use of a Butterworth structure is appropriate here because it provides a smooth monotonic passband response without ripple, which helps preserve signal morphology in real-time applications.&lt;br /&gt;
&lt;br /&gt;
After band limitation, a &#039;&#039;&#039;notch filter&#039;&#039;&#039; centered at the power-line frequency is applied to suppress interference that cannot be removed by the band-pass stage alone. The notch filter is designed around &amp;lt;math&amp;gt;f_0 = 50 \text{ Hz}&amp;lt;/math&amp;gt;, and its bandwidth is controlled by the quality factor &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;, which is expressed as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;Q = \frac{f_0}{\Delta f}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In transfer-function form, the notch stage is written as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;H_{N}(z)=\frac{B_{N}(z)}{A_{N}(z)}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the implemented program, a large quality factor is chosen so that the notch remains narrow, allowing effective rejection of the 50 Hz interference while minimizing distortion of neighboring useful spectral components. This is particularly important for sEMG because the interference frequency lies directly inside the physiological band of interest.&lt;br /&gt;
&lt;br /&gt;
Following the filtering stages, further signal conditioning is performed to obtain a representation that is more directly related to muscle activation intensity. The filtered sEMG waveform is first &#039;&#039;&#039;full-wave rectified&#039;&#039;&#039;, which converts the bipolar oscillatory signal into a unipolar signal by taking its absolute value.  Rectification does not remove noise by itself; instead, it transforms the signal into a form that is more suitable for amplitude-based analysis because both positive and negative deflections contribute positively to the activation measure.&lt;br /&gt;
&lt;br /&gt;
After rectification, the signal envelope is extracted to provide a smooth estimate of muscle activation level over time. In a general formulation, the envelope can be described as the &#039;&#039;&#039;low-pass filtered&#039;&#039;&#039; version of the rectified signal, namely &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y_{\mathrm{env}}[n] = \mathrm{LPF}\bigl(y_{\mathrm{rect}}[n]\bigr)&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the present code implementation, this operation is realized by short-time averaging over a finite window, which is equivalent to a moving-average low-pass smoothing of the rectified waveform. The corresponding expression is &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y_{\mathrm{env}}[n] = \frac{1}{N}\sum_{k=0}^{N-1} |x[n-k]|&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; is the window length in samples. With a window duration of approximately 200 ms, this envelope extraction method provides a stable and physiologically meaningful representation of muscle activation intensity, making it suitable for tasks such as force estimation, fatigue analysis, and motor-control studies.&lt;br /&gt;
&lt;br /&gt;
An important feature of the present &#039;&#039;&#039;implementation&#039;&#039;&#039; is that the entire filtering process is performed &#039;&#039;&#039;in real time&#039;&#039;&#039;, sample by sample, rather than by offline block processing. For this reason, IIR filters are preferred over FIR filters, since they can achieve comparable filtering performance with lower order, lower computational cost, and shorter delay. These properties are especially valuable in embedded systems, serial data streaming, and other low-latency experimental applications. However, unlike memoryless operations, an IIR filter depends not only on the current input but also on previous inputs and previous outputs. Its discrete-time behavior can therefore be represented by the recursive difference equation &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y[n] = \sum_{k=0}^{M} b_k x[n-k] - \sum_{k=1}^{N} a_k y[n-k]&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This equation makes clear that internal filter states must be preserved continuously during streaming operation. If the state variables were reinitialized for every incoming sample or data segment, artificial transients would appear and the output would no longer remain continuous.&lt;br /&gt;
&lt;br /&gt;
In the Python implementation, this state continuity is maintained using the internal initial-condition mechanism provided by SciPy, such as &amp;lt;code&amp;gt;lfilter_zi&amp;lt;/code&amp;gt;, together with recursive state updates during each filtering call. As a result, each newly acquired sample is passed first through the band-pass filter and then through the notch filter, while the internal states of both filters are updated after every step. This state-preserving sample-by-sample design ensures that the processing chain remains causal, continuous, and suitable for real-time display or downstream analysis without requiring storage of the entire signal segment.&lt;br /&gt;
&lt;br /&gt;
Overall, this signal-conditioning scheme provides an experimentally practical solution for real-time sEMG processing. The fourth-order Butterworth band-pass filter confines the signal to the main physiological band of interest, the 50 Hz notch filter removes narrow-band power-line contamination, and the subsequent rectification and envelope extraction generate a smooth amplitude descriptor of muscle activity. Combined with state-preserved streaming IIR implementation, this approach achieves a good balance between signal fidelity, computational efficiency, and real-time applicability in biomedical and physical experiment settings.&lt;br /&gt;
&lt;br /&gt;
== Data Processing ==&lt;br /&gt;
&lt;br /&gt;
The objective of data processing is to convert raw surface electromyography (sEMG) recordings into stable, quantitative, and comparable indicators of muscle activity. Since EMG signals are low in amplitude, highly variable over time, and easily contaminated by noise, a dedicated processing pipeline is necessary before any experimental interpretation can be performed.&lt;br /&gt;
&lt;br /&gt;
In this project, the data processing workflow includes time normalization, signal pre-processing, sliding-window feature extraction, noise-floor estimation, and automatic contraction detection. The processed outputs are then used for subsequent experimental evaluation, including rest-versus-contraction discrimination, signal-to-noise ratio analysis, and repeatability assessment.&lt;br /&gt;
&lt;br /&gt;
=== Input Data and Time Normalization ===&lt;br /&gt;
&lt;br /&gt;
The acquired EMG data are read from CSV files containing two columns: time and filtered sEMG amplitude. In the MATLAB implementation, the time vector is normalized so that each recording starts from zero:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t = t_{all} - t_{all}(1)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This normalization is important because it removes the influence of absolute recording timestamps and makes different trials directly comparable on the same time axis.&lt;br /&gt;
&lt;br /&gt;
In addition, the signal type is automatically identified from the filename as either dynamic or rest. This design allows the same program to process both contraction recordings and resting recordings with different downstream analysis logic.&lt;br /&gt;
&lt;br /&gt;
=== Signal Pre-processing ===&lt;br /&gt;
&lt;br /&gt;
Raw EMG signals cannot be analyzed directly because they usually contain DC offset, low-frequency drift, motion artifacts, and residual high-frequency interference. Therefore, several pre-processing steps are applied before feature extraction.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(1) Baseline Removal&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The first step is DC offset removal:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
x_{dc}(t) = x(t) - \frac{1}{N}\sum_{i=1}^{N}x(i)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This operation centers the signal around zero. It is necessary because an uncorrected baseline would bias amplitude-based metrics and reduce the reliability of later envelope and feature calculations.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(2) Band-pass Filtering &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
After baseline correction, a fourth-order Butterworth band-pass filter is applied with a passband of 20–150 Hz.&lt;br /&gt;
&lt;br /&gt;
This step is introduced for two reasons:&lt;br /&gt;
&lt;br /&gt;
* The low-frequency cutoff at 20 Hz suppresses baseline drift and motion artifacts.&lt;br /&gt;
* The high-frequency cutoff at 150 Hz reduces unwanted high-frequency noise while preserving the main energy band of the recorded sEMG in this project.&lt;br /&gt;
&lt;br /&gt;
Compared with processing the raw waveform directly, band-pass filtering makes the subsequent time-domain features more stable and more physiologically meaningful.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(3) Full-wave Rectification&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The filtered EMG signal is bipolar, meaning that positive and negative phases coexist due to motor unit action potentials. If these positive and negative components are averaged directly, they may cancel each other out. To avoid this, full-wave rectification is performed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
x_{rect}(t) = |x_{filt}(t)|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This transforms the signal into a unipolar representation, so that all muscle activity contributes positively to the extracted features.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(4) Envelope Extraction &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Although the rectified signal reflects signal magnitude, it still fluctuates rapidly. To obtain a smoother representation of muscle activation level, an envelope is extracted using a moving average with a 100 ms window.&lt;br /&gt;
&lt;br /&gt;
Envelope extraction is important because contraction detection should reflect the overall activation trend rather than instantaneous spikes. A smoothed envelope is therefore more robust for identifying active and inactive muscle states.&lt;br /&gt;
&lt;br /&gt;
=== Sliding Window Design ===&lt;br /&gt;
&lt;br /&gt;
To quantify how muscle activity changes with time, the filtered signal is divided into overlapping short-time segments using a sliding window method.&lt;br /&gt;
&lt;br /&gt;
The window parameters are:&lt;br /&gt;
&lt;br /&gt;
* Window length: 250 ms&lt;br /&gt;
* Step size: 50 ms&lt;br /&gt;
&lt;br /&gt;
These values are chosen as a trade-off between temporal resolution and feature stability.&lt;br /&gt;
&lt;br /&gt;
A longer window improves statistical robustness because more samples are included in each calculation. However, if the window is too long, short contractions or rapid changes may be blurred. A smaller step size increases temporal continuity between adjacent feature points and makes the feature curves smoother in time. Therefore, the 250 ms / 50 ms design provides a practical balance between smoothing and time localization.&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt;-th segment, the feature time is defined as the mean time of that segment:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t_k = \frac{1}{N}\sum_{i=s_k}^{e_k} t(i)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;s_k&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;e_k&amp;lt;/math&amp;gt; denote the start and end indices of the window.&lt;br /&gt;
&lt;br /&gt;
=== Feature Extraction ===&lt;br /&gt;
&lt;br /&gt;
Within each sliding window, three time-domain features are extracted: RMS, iEMG, and MAV. These features are widely used in EMG analysis because they are simple, computationally efficient, and directly related to muscle activation intensity.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(1) Root Mean Square (RMS)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
RMS = \sqrt{\frac{1}{N}\sum_{i=1}^{N}x_i^2}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
RMS reflects the effective power of the EMG signal and is one of the most common indicators of contraction strength. It is sensitive to both amplitude and energy, making it especially useful for comparing rest and active states.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(2) Integrated EMG (iEMG)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
iEMG = \sum_{i=1}^{N}|x_i|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
iEMG describes the cumulative electrical activity within a window. It is often interpreted as a measure of total muscle effort over that time segment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(3) Mean Absolute Value (MAV)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
MAV = \frac{1}{N}\sum_{i=1}^{N}|x_i|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
MAV is an amplitude descriptor similar to iEMG, but normalized by the number of samples. It provides an efficient estimate of average signal level and is less computationally intensive than some other features.&lt;br /&gt;
&lt;br /&gt;
These three features are used together because they provide complementary descriptions of EMG intensity. RMS emphasizes signal energy, iEMG emphasizes cumulative activation, and MAV reflects average amplitude.&lt;br /&gt;
&lt;br /&gt;
=== Peak-value Extraction ===&lt;br /&gt;
&lt;br /&gt;
In addition to continuous feature curves, several key peak values are extracted from the processed signal:&lt;br /&gt;
&lt;br /&gt;
* maximum and minimum of the filtered EMG waveform&lt;br /&gt;
* peak of the envelope&lt;br /&gt;
* peak RMS&lt;br /&gt;
* peak iEMG&lt;br /&gt;
* peak MAV&lt;br /&gt;
&lt;br /&gt;
These peak values provide concise descriptors of the strongest activity observed in each recording. They are useful for quick comparison across trials and subjects.&lt;br /&gt;
&lt;br /&gt;
=== Noise Floor Estimation ===&lt;br /&gt;
&lt;br /&gt;
To evaluate signal quality, the noise floor is estimated from a reference resting interval. In the present implementation, the first 3 seconds of the recording are used as the default rest reference:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t \in [0,\min(3,t_{end})]&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this segment, three noise descriptors are computed:&lt;br /&gt;
&lt;br /&gt;
* Noise RMS&lt;br /&gt;
* Noise standard deviation&lt;br /&gt;
* Noise peak-to-peak amplitude&lt;br /&gt;
&lt;br /&gt;
Noise-floor estimation is important because EMG amplitude alone is not sufficient to judge recording quality. A large signal is only meaningful if it is sufficiently higher than the baseline noise level. Therefore, the noise floor serves as the reference for later SNR calculation and for designing contraction thresholds.&lt;br /&gt;
&lt;br /&gt;
=== Global Signal Metrics ===&lt;br /&gt;
&lt;br /&gt;
For each recording, three global metrics are also computed over the entire filtered signal:&lt;br /&gt;
&lt;br /&gt;
* Global RMS&lt;br /&gt;
* Global MAV&lt;br /&gt;
* Global iEMG&lt;br /&gt;
&lt;br /&gt;
These global descriptors summarize the overall signal level of the full recording and are later used in group-level comparisons.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Contraction Detection ===&lt;br /&gt;
&lt;br /&gt;
For dynamic recordings, an automatic contraction detection algorithm is used to identify repeated active segments. This is one of the key parts of the data processing pipeline, because it transforms a continuous EMG trace into discrete contraction events that can be counted and compared.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(1) Threshold Design&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The detection threshold is designed adaptively rather than using a fixed value. Two candidate thresholds are first calculated:&lt;br /&gt;
&lt;br /&gt;
* an envelope-based threshold derived from the global envelope mean and standard deviation&lt;br /&gt;
* a rest-reference threshold derived from the mean and standard deviation of the resting reference amplitude&lt;br /&gt;
&lt;br /&gt;
The final threshold is taken as the larger of the two after additional scaling. This strategy improves robustness because it combines the global activation level of the signal with the baseline noise characteristics of the individual recording.&lt;br /&gt;
&lt;br /&gt;
This adaptive threshold design is preferable to a manually fixed threshold because EMG amplitude can vary strongly between subjects, muscles, and recording sessions.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(2) Initial Segmentation&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
After thresholding the envelope, the signal is classified into active and inactive regions:&lt;br /&gt;
&lt;br /&gt;
* active: envelope above threshold&lt;br /&gt;
* inactive: envelope below threshold&lt;br /&gt;
&lt;br /&gt;
The rising and falling edges of the binary activity vector are then used to determine the start and end points of each candidate contraction segment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(3) Removal of Short Segments&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Very short active regions are often caused by noise fluctuations rather than true muscle contractions. Therefore, segments shorter than 0.20 s are discarded.&lt;br /&gt;
&lt;br /&gt;
This step prevents false positive detections and increases the physiological relevance of the segmentation results.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(4) Merging of Adjacent Segments &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If two neighboring active segments are separated by a very short gap, they are merged when the gap is less than 0.15 s.&lt;br /&gt;
&lt;br /&gt;
This operation is necessary because a single real contraction may be temporarily interrupted by a brief drop in the envelope caused by local fluctuation. Without merging, one contraction could be incorrectly counted as multiple repetitions.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(5) Repetition-level Metrics &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
For each detected contraction segment, two repetition-level metrics are extracted:&lt;br /&gt;
&lt;br /&gt;
* peak RMS of that contraction&lt;br /&gt;
* mean RMS of that contraction&lt;br /&gt;
&lt;br /&gt;
These metrics quantify both the strongest activation within each repetition and the average activation level over the repetition duration.&lt;br /&gt;
&lt;br /&gt;
=== Repeatability Analysis ===&lt;br /&gt;
&lt;br /&gt;
When multiple valid contractions are detected, repeatability is evaluated using the coefficient of variation (CV):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
CV = \frac{\sigma}{\mu}\times 100\%&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt; is the standard deviation and &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is the mean value across repetitions.&lt;br /&gt;
&lt;br /&gt;
Two CV values are computed:&lt;br /&gt;
&lt;br /&gt;
* CV of repetition peak RMS&lt;br /&gt;
* CV of repetition mean RMS&lt;br /&gt;
&lt;br /&gt;
A lower CV indicates better repeatability, meaning that repeated contractions produce more consistent EMG responses.&lt;br /&gt;
&lt;br /&gt;
=== Signal-to-Noise Ratio (SNR) ===&lt;br /&gt;
&lt;br /&gt;
In this project, the signal-to-noise ratio (SNR) is defined based on the ratio between contraction and rest activity:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
SNR_{dB} = 20\log_{10}\left(\frac{RMS_{contraction}}{RMS_{rest}}\right)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This definition is adopted because it directly reflects the system’s ability to distinguish active muscle contraction from baseline noise.&lt;br /&gt;
&lt;br /&gt;
Compared with global SNR definitions, this formulation is more relevant for practical EMG applications such as activity detection and classification.&lt;br /&gt;
&lt;br /&gt;
=== Rest-versus-Contraction Window Comparison ===&lt;br /&gt;
&lt;br /&gt;
To further distinguish inactive and active states, all sliding windows are divided into two groups:&lt;br /&gt;
&lt;br /&gt;
* rest windows: windows with envelope clearly below the threshold&lt;br /&gt;
* contraction windows: windows with envelope above the threshold&lt;br /&gt;
&lt;br /&gt;
The RMS values of these two groups are then compared statistically.&lt;br /&gt;
&lt;br /&gt;
This comparison is important because a practical EMG system should not only detect signal presence, but also clearly separate rest from contraction in a quantitative way. If the two RMS distributions are well separated, it indicates that the system has good discriminative capability.&lt;br /&gt;
&lt;br /&gt;
=== Output Data Structure ===&lt;br /&gt;
&lt;br /&gt;
The processed outputs are organized into structured data for experimental analysis:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(1) Time-series outputs&#039;&#039;&#039;&lt;br /&gt;
* Filtered EMG signal  &lt;br /&gt;
* Rectified signal  &lt;br /&gt;
* Envelope  &lt;br /&gt;
* RMS(t), iEMG(t), MAV(t)  &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(2) Recording-level outputs&#039;&#039;&#039; &lt;br /&gt;
* RMS (rest)  &lt;br /&gt;
* RMS (contraction)  &lt;br /&gt;
* iEMG  &lt;br /&gt;
* Noise metrics  &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(3) Dynamic-signal outputs &#039;&#039;&#039;&lt;br /&gt;
* Detected contractions  &lt;br /&gt;
* Repetition count  &lt;br /&gt;
* Peak RMS per repetition  &lt;br /&gt;
* Mean RMS per repetition  &lt;br /&gt;
* Coefficient of variation (CV)  &lt;br /&gt;
* Signal-to-noise ratio (SNR)  &lt;br /&gt;
&lt;br /&gt;
All extracted features are designed to directly support the evaluation of noise level, signal quality, activity discrimination, and repeatability in the subsequent experimental analysis.&lt;br /&gt;
&lt;br /&gt;
== Experimental Results ==&lt;br /&gt;
&lt;br /&gt;
This section presents representative results of the EMG acquisition and data processing pipeline under both dynamic (muscle contraction) and resting conditions.&lt;br /&gt;
&lt;br /&gt;
=== Representative Dynamic Signal Analysis ===&lt;br /&gt;
&lt;br /&gt;
[[File:Dynamic_Figure1.png|thumb|800px|center|Figure 5.1: Processed EMG signal under dynamic contraction, including filtered signal, rectified signal with envelope, and extracted features (RMS, iEMG, MAV).]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.1 shows the processed EMG signal during repeated muscle contractions.&lt;br /&gt;
&lt;br /&gt;
The filtered EMG waveform exhibits clear burst-like patterns corresponding to periodic contractions. The signal amplitude reaches a maximum of approximately 0.45, while the baseline remains centered around zero, indicating effective baseline removal and filtering.&lt;br /&gt;
&lt;br /&gt;
After rectification and envelope extraction, the contraction periods become clearly distinguishable. The envelope provides a smooth representation of muscle activation, with a peak value of approximately 0.145.&lt;br /&gt;
&lt;br /&gt;
The extracted time-domain features (RMS, iEMG, MAV) further quantify the signal. Among these, iEMG shows the strongest dynamic variation, indicating high sensitivity to contraction intensity.&lt;br /&gt;
&lt;br /&gt;
=== Noise Floor and Rest Reference ===&lt;br /&gt;
&lt;br /&gt;
[[File:Dynamic_Figure2.png|thumb|800px|center|Figure 5.2: Noise estimation, rest vs contraction comparison, automatic contraction detection, and repetition analysis.]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (top-left) shows the resting reference segment used for noise estimation.&lt;br /&gt;
&lt;br /&gt;
The signal remains centered around zero with small fluctuations. The noise characteristics are:&lt;br /&gt;
&lt;br /&gt;
* Noise RMS ≈ 0.0046  &lt;br /&gt;
* Standard deviation ≈ 0.0046  &lt;br /&gt;
* Peak-to-peak amplitude ≈ 0.071  &lt;br /&gt;
&lt;br /&gt;
This indicates a low noise floor and stable measurement conditions.&lt;br /&gt;
&lt;br /&gt;
=== Rest vs Contraction Discrimination ===&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (top-right) compares RMS values between rest and contraction states.&lt;br /&gt;
&lt;br /&gt;
The two distributions are clearly separated:&lt;br /&gt;
&lt;br /&gt;
* Rest mean RMS ≈ 0.0053  &lt;br /&gt;
* Contraction mean RMS ≈ 0.1064  &lt;br /&gt;
&lt;br /&gt;
This corresponds to an approximate 20× increase, demonstrating strong discriminability between inactive and active muscle states.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Contraction Detection ===&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (bottom-left) illustrates automatic detection based on the envelope signal.&lt;br /&gt;
&lt;br /&gt;
A threshold of approximately 0.040 is applied, resulting in stable segmentation of contraction periods.&lt;br /&gt;
&lt;br /&gt;
A total of 12 repetitions are detected, with good alignment to visible signal peaks.&lt;br /&gt;
&lt;br /&gt;
=== Repeatability Analysis ===&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (bottom-right) shows the peak RMS value of each detected contraction.&lt;br /&gt;
&lt;br /&gt;
The results indicate:&lt;br /&gt;
&lt;br /&gt;
* Mean peak RMS ≈ 0.1355  &lt;br /&gt;
* Standard deviation ≈ 0.0173  &lt;br /&gt;
* CV ≈ 12.77%  &lt;br /&gt;
* SNR ≈ 21.26 dB  &lt;br /&gt;
&lt;br /&gt;
This indicates acceptable repeatability and good signal quality.&lt;br /&gt;
&lt;br /&gt;
=== Representative Rest Signal Analysis ===&lt;br /&gt;
&lt;br /&gt;
[[File:Rest_Figure1.png|thumb|800px|center|Figure 5.3: Processed EMG signal under rest condition, showing low amplitude and absence of contraction patterns.]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.3 shows the EMG signal under resting conditions.&lt;br /&gt;
&lt;br /&gt;
The signal remains within a narrow amplitude range (approximately ±0.04) and shows no burst-like structures. The envelope remains close to zero, confirming the absence of muscle activity.&lt;br /&gt;
&lt;br /&gt;
The extracted features remain low:&lt;br /&gt;
&lt;br /&gt;
* RMS ≈ 0.007  &lt;br /&gt;
* MAV ≈ 0.005  &lt;br /&gt;
* iEMG remains stable  &lt;br /&gt;
&lt;br /&gt;
This confirms that no false activation is detected.&lt;br /&gt;
&lt;br /&gt;
=== Frequency-domain Characteristics ===&lt;br /&gt;
&lt;br /&gt;
[[File:Rest_Figure2.png|thumb|800px|center|Figure 5.4: Frequency-domain analysis and statistical characteristics of rest signal.]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.4 shows the frequency-domain characteristics of the resting signal.&lt;br /&gt;
&lt;br /&gt;
The power spectral density (PSD) indicates low overall signal energy without dominant peaks, confirming that the signal mainly consists of noise.&lt;br /&gt;
&lt;br /&gt;
=== Summary of Single-recording Performance ===&lt;br /&gt;
&lt;br /&gt;
From the representative results:&lt;br /&gt;
&lt;br /&gt;
* EMG signals are effectively extracted and denoised  &lt;br /&gt;
* Contraction events are clearly identifiable  &lt;br /&gt;
* Rest and contraction states are well separated  &lt;br /&gt;
* Automatic detection is stable and accurate  &lt;br /&gt;
* Repeatability is acceptable  &lt;br /&gt;
* No false activation occurs under rest conditions  &lt;br /&gt;
&lt;br /&gt;
=== Consistency Across Multiple Recordings ===&lt;br /&gt;
&lt;br /&gt;
The same data processing pipeline was applied to multiple recordings from different subjects and trials.&lt;br /&gt;
&lt;br /&gt;
Across all datasets, consistent patterns were observed:&lt;br /&gt;
&lt;br /&gt;
* Dynamic signals exhibit clear burst-like structures corresponding to repeated muscle contractions  &lt;br /&gt;
* Rest signals remain low in amplitude without distinct activation patterns  &lt;br /&gt;
* RMS values under contraction are consistently higher than those under rest  &lt;br /&gt;
* The automatic detection algorithm reliably identifies contraction segments  &lt;br /&gt;
&lt;br /&gt;
Although quantitative values (e.g., RMS, SNR, CV) vary across recordings due to differences in electrode contact, muscle activation strength, and individual conditions, the overall trends remain consistent.&lt;br /&gt;
&lt;br /&gt;
These results demonstrate the robustness and general applicability of the proposed signal processing method.&lt;br /&gt;
&lt;br /&gt;
== Multi-subject Analysis ==&lt;br /&gt;
=== System Evaluation ===&lt;br /&gt;
&lt;br /&gt;
This section evaluates the performance of the EMG acquisition system in terms of noise level, signal quality, activity discrimination, and repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Noise Floor Analysis ====&lt;br /&gt;
&lt;br /&gt;
The noise floor was evaluated using rest-state recordings, characterized by RMS noise, standard deviation, and peak-to-peak amplitude.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039; shows the lowest noise level (RMS ≈ 0.0046), indicating stable electrode contact and minimal interference.  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039; exhibits moderate noise (RMS ≈ 0.0080), likely influenced by motion artifacts or electrode–skin impedance variation.  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039; shows relatively higher noise (RMS ≈ 0.0126), suggesting increased baseline fluctuation.  &lt;br /&gt;
&lt;br /&gt;
Overall, the system maintains a low noise floor across subjects, although the quality depends on experimental conditions such as electrode contact and environmental interference.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Signal-to-Noise Ratio (SNR) ====&lt;br /&gt;
&lt;br /&gt;
The signal-to-noise ratio (SNR) is defined as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{SNR (dB)} = 20 \log_{10} \left( \frac{\mathrm{RMS}_{\mathrm{contraction}}}{\mathrm{RMS}_{\mathrm{rest}}} \right)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The measured SNR values are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: 21.26 dB → good signal quality  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: 13.52 dB → moderate and usable  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: 6.66 dB → low signal clarity  &lt;br /&gt;
&lt;br /&gt;
General interpretation:&lt;br /&gt;
&lt;br /&gt;
* &amp;gt;20 dB → good  &lt;br /&gt;
* 10–20 dB → usable  &lt;br /&gt;
* &amp;lt;10 dB → poor  &lt;br /&gt;
&lt;br /&gt;
These results show that the system can achieve reliable signal acquisition, although performance varies across subjects.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
====  Rest vs Contraction Discrimination ====&lt;br /&gt;
&lt;br /&gt;
A clear distinction between rest and contraction states is observed based on RMS values.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: 0.0053 → 0.1064 (≈20× increase)  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: 0.0079 → 0.0283 (≈3.6× increase)  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: 0.0141 → 0.0646 (≈4.6× increase)  &lt;br /&gt;
&lt;br /&gt;
This demonstrates that the system is capable of separating muscle activity from baseline noise.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Conclusion:&#039;&#039;  &lt;br /&gt;
The system can be used for basic muscle activity detection and simple classification tasks based on RMS features.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Repeatability of Repeated Contractions ====&lt;br /&gt;
&lt;br /&gt;
Repeatability is evaluated using the coefficient of variation (CV) of peak RMS values across repetitions.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! CV Range !! Evaluation&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt; 10% || Excellent&lt;br /&gt;
|-&lt;br /&gt;
| 10–20% || Acceptable&lt;br /&gt;
|-&lt;br /&gt;
| &amp;gt; 20% || Poor&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Results:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: CV = 12.77% → Acceptable  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: CV = 24.77% → Poor  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: CV = 10.60% → Acceptable  &lt;br /&gt;
&lt;br /&gt;
Although WANG&#039;s signal is detectable, its contraction amplitude varies significantly across repetitions, resulting in poor repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
=== Overall System Performance ===&lt;br /&gt;
&lt;br /&gt;
The system demonstrates the following performance characteristics:&lt;br /&gt;
&lt;br /&gt;
* Reliable detection of muscle activity across all subjects  &lt;br /&gt;
* Clear separation between rest and contraction states  &lt;br /&gt;
* Moderate to high signal quality depending on subject conditions  &lt;br /&gt;
* Repeatability ranging from acceptable to poor due to user-dependent factors  &lt;br /&gt;
&lt;br /&gt;
Overall, the designed EMG acquisition system is capable of stable signal acquisition and feature extraction, with performance primarily influenced by electrode contact quality, skin impedance, and motion consistency.&lt;br /&gt;
&lt;br /&gt;
===== Summary of Quantitative Metrics =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Subject !! RMS (Rest) !! RMS (Contraction) !! Separation Ratio !! iEMG (max) !! Noise RMS !! SNR (dB) !! CV (%) !! Evaluation&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;LIU&#039;&#039;&#039; || 0.0053 || 0.1064 || &#039;&#039;&#039;20.1×&#039;&#039;&#039; || 12.72 || 0.0046 || &#039;&#039;&#039;21.26&#039;&#039;&#039; || 12.77 || Strong signal, good quality&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;WANG&#039;&#039;&#039; || 0.0079 || 0.0283 || 3.57× || 11.10 || 0.0080 || 13.52 || &#039;&#039;&#039;24.77&#039;&#039;&#039; || Usable signal, poor repeatability&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ZHONG&#039;&#039;&#039; || 0.0141 || 0.0646 || 4.58× || 6.70 || 0.0126 || 6.66 || 10.60 || Acceptable performance&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Summary:&#039;&#039; Subject LIU shows the best overall performance, WANG provides usable but less stable signals, and ZHONG demonstrates moderate signal quality with good repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Activation Intensity =====&lt;br /&gt;
&lt;br /&gt;
Among the three subjects, &#039;&#039;&#039;LIU exhibits the strongest muscle activation&#039;&#039;&#039;, as indicated by the highest contraction RMS and iEMG values. ZHONG shows moderate activation, while WANG demonstrates comparable iEMG but lower RMS consistency.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Signal Quality =====&lt;br /&gt;
&lt;br /&gt;
Signal quality is evaluated based on SNR and noise level:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039; achieves the highest SNR and lowest noise → best signal quality  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039; shows moderate SNR → usable but less robust  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039; has the lowest SNR → weakest signal clarity  &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Repeatability =====&lt;br /&gt;
&lt;br /&gt;
Repeatability is evaluated using the coefficient of variation (CV):&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;ZHONG (10.60%)&#039;&#039;&#039; → most stable  &lt;br /&gt;
* &#039;&#039;&#039;LIU (12.77%)&#039;&#039;&#039; → acceptable  &lt;br /&gt;
* &#039;&#039;&#039;WANG (24.77%)&#039;&#039;&#039; → poor  &lt;br /&gt;
&lt;br /&gt;
This indicates that WANG’s contraction strength varies significantly between repetitions.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Engineering Interpretation of Inter-subject Differences =====&lt;br /&gt;
&lt;br /&gt;
The observed differences are mainly attributed to engineering and experimental factors rather than physiological differences.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Electrode contact quality&#039;&#039;&#039;  &lt;br /&gt;
  Variations in electrode placement, pressure, and gel contact affect signal amplitude and stability.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Skin impedance&#039;&#039;&#039;  &lt;br /&gt;
  Differences in skin condition (hydration, oil, hair) influence electrode–skin impedance, affecting noise level and signal coupling.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Muscle control consistency&#039;&#039;&#039;  &lt;br /&gt;
  Variations in contraction strength and timing affect repeatability and CV.&lt;br /&gt;
&lt;br /&gt;
Therefore, the variation across subjects reflects practical acquisition conditions rather than intrinsic system limitations.&lt;/div&gt;</summary>
		<author><name>Wang Jingyi</name></author>
	</entry>
	<entry>
		<id>https://pc5271.org/index.php?title=Surface_EMG_Sensor_for_Muscle_Activity_Measurement:_AFE_Design_and_Signal_Processing&amp;diff=1362</id>
		<title>Surface EMG Sensor for Muscle Activity Measurement: AFE Design and Signal Processing</title>
		<link rel="alternate" type="text/html" href="https://pc5271.org/index.php?title=Surface_EMG_Sensor_for_Muscle_Activity_Measurement:_AFE_Design_and_Signal_Processing&amp;diff=1362"/>
		<updated>2026-04-23T07:41:24Z</updated>

		<summary type="html">&lt;p&gt;Wang Jingyi: /* Signal Conditioning and Filtering */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Background and Theory==&lt;br /&gt;
&lt;br /&gt;
=== Surface EMG Signals ===&lt;br /&gt;
Surface electromyography (sEMG) refers to the bioelectrical signals detected on the skin surface during muscle contraction. These signals originate from the electrical activity of muscle fibers and provide a non-invasive way to monitor muscle activation. Compared with invasive EMG methods, sEMG is easier to apply, safer for repeated measurements, and more suitable for real-time monitoring. Therefore, it has been widely used in areas such as rehabilitation, motion analysis, human–machine interaction, and physiological monitoring.&lt;br /&gt;
&lt;br /&gt;
=== Characteristics of EMG Signals ===&lt;br /&gt;
EMG signals are generally weak, time-varying, and stochastic in nature. Their waveforms are typically bipolar, fluctuating around zero with both positive and negative components. The amplitude and frequency content of EMG signals depend on factors such as muscle contraction level, electrode placement, skin condition, and individual physiological differences. In practice, the useful frequency components of sEMG are mainly concentrated in a limited low-to-mid frequency range. Because of their low amplitude and variability, EMG signals usually require further conditioning before reliable interpretation and feature extraction can be performed.&lt;br /&gt;
&lt;br /&gt;
=== Bioelectrical Signal Acquisition Principles ===&lt;br /&gt;
The acquisition of bioelectrical signals is based on measuring the small potential difference on the skin surface using electrodes, then converting it into a processable electrical signal through amplification and digitization. For sEMG measurement, electrode placement and skin–electrode contact quality are especially important, since they directly affect signal amplitude and stability. In addition, the front-end acquisition circuit must provide sufficient sensitivity and good interference rejection, so that the recorded signal reflects actual muscle activity rather than environmental disturbance or poor contact conditions.&lt;br /&gt;
&lt;br /&gt;
=== Noise Sources in EMG (50 Hz, motion artifacts) ===&lt;br /&gt;
In practical EMG recording, the measured signal is easily contaminated by different types of noise. Two of the most common sources are power-line interference and motion artifacts. Power-line interference usually appears as a narrow-band component at 50 Hz in the local electrical environment, while motion artifacts are mainly caused by electrode movement, cable disturbance, or variations in the electrode–skin impedance, and are often concentrated in the low-frequency range. In addition, electronic noise from the acquisition hardware may also affect the recording quality. These unwanted components can reduce signal clarity and make muscle activity analysis less reliable, so they must be considered in the design of the signal processing pipeline.&lt;br /&gt;
[[File:background_theory_figure1.1_emg_noise_sources.png|center|thumb|700px|&#039;&#039;&#039;Figure 1.1.&#039;&#039;&#039; Principle of surface EMG acquisition.]]&lt;br /&gt;
&lt;br /&gt;
==System Architecture==&lt;br /&gt;
=== Total Structure Design ===&lt;br /&gt;
&lt;br /&gt;
For clarity，the proposed physiological signal acquisition system mainly consists of two core parts：the analog front－end （AFE）and the ADC board．The AFE is responsible for the preliminary conditioning of weak bioelectrical signals，including amplification，filtering，interference suppression，and level shifting，so that the analog waveform can be converted into a stable and measurable form．The ADC board then performs high－resolution digitization of the conditioned signal and transfers the sampled data to the host computer for subsequent display，storage，and analysis．Therefore，the overall system forms a complete signal－acquisition chain from weak physiological input to digital output．&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_1.jpg|thumb|center|800px|Figure 2.1. Overall system architecture of the proposed physiological signal acquisition platform，including the AFE and ADC modules．]]&lt;br /&gt;
&lt;br /&gt;
=== sEMG AFE Design ===&lt;br /&gt;
&lt;br /&gt;
To collect the weak bioelectric potential signals of the human body，an analog front－end（AFE）suitable sEMG measurements was designed．The module is powered by an external 5 V supply，and the complete circuit includes a first－ stage instrumentation amplifier based on INA128（Texas Instruments，Dallas，TX，USA），a band－pass filter，a 50 Hz notch filter，a second－order amplification and level shifting stage，a driver electrode circuit，a precise 1.5 V reference source，and a -5 V voltage generation module for powering the operational amplifiers．&lt;br /&gt;
&lt;br /&gt;
==== First－order Amplifier ====&lt;br /&gt;
&lt;br /&gt;
The input bioelectric signal is first acquired in differential form and applied to the INA128 instrumentation amplifier，which provides high input impedance，high common－mode rejection，and moderate initial gain for sEMG acquisition．This stage enlarges the weak physiological signal before filtering while reducing the risk of premature saturation caused by electrode offset or motion－induced disturbance，thereby preparing a more stable signal for the subsequent conditioning stages．&lt;br /&gt;
&lt;br /&gt;
==== Bandpass Filter ====&lt;br /&gt;
&lt;br /&gt;
After the instrumentation amplifier，the signal passes through a second－order active band－pass filter，as shown in Figure 2．2． This stage suppresses baseline drift and high－frequency noise outside the useful sEMG range，so that the low－frequency envelope information of sEMG can be preserved before further amplification．&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_2.jpg|thumb|center|800px|Figure 2.2. Schematic diagram of the active band-pass filter used in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the band-pass stage used to retain the main physiological signal band while suppressing unwanted lowand high-frequency components.&lt;br /&gt;
&lt;br /&gt;
==== Notch Filter ====&lt;br /&gt;
&lt;br /&gt;
To reduce power-line interference, a dedicated 50 Hz notch filter is introduced after the band-pass stage, as shown in Figure 2.3. This filter attenuates the mains-frequency component that commonly contaminates weak bioelectric measurements, thereby improving the signal-to-noise ratio of sEMG signals before the final amplification stage.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_3.jpg|thumb|center|800px|Figure 2.3. Schematic diagram of the 50 Hz notch filter used in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the circuit used to attenuate 50 Hz mains interference in the analog front end.&lt;br /&gt;
&lt;br /&gt;
==== Second-order Amplifier &amp;amp; Level Shifter ====&lt;br /&gt;
&lt;br /&gt;
After filtering, the signal enters the second-stage amplification and level-shifting circuit shown in Figure 2.4. In this stage, the filtered signal is further amplified to improve amplitude utilization and then shifted by a 1.5 V reference so that the output becomes a stable unipolar signal suitable for ADC sampling, while preserving linear operation and providing sufficient output swing margin.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_4.jpg|thumb|center|800px|Figure 2.4. Schematic diagram of the second-stage amplifier and level-shifting circuit in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows how the conditioned signal is further amplified and shifted to a suitable DC level before digitization.&lt;br /&gt;
&lt;br /&gt;
==== Power Module and Drive-electrode Circuit ====&lt;br /&gt;
&lt;br /&gt;
The AFE is powered by a 5 V supply and also integrates a 1.5 V precision reference, a -5 V generation circuit, and a driveelectrode circuit. These supporting modules provide the required supply rails and reference level for analog signal conditioning, while the drive-electrode circuit feeds back common-mode voltage to the body to suppress interference at the source. As a result, the complete AFE can support sEMG acquisition with adequate gain, filtering, and noise-reduction performance in a compact hardware structure.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_5.jpg|thumb|center|800px|Figure 2.5. Physical picture of the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the fabricated sEMG analog front-end hardware used in the system.&lt;br /&gt;
&lt;br /&gt;
Figure 2.5 presents the practical hardware implementation of the proposed sEMG AFE. It integrates amplification, filtering, level shifting, and driven-reference functions in a compact circuit for weak bioelectrical signal acquisition.&lt;br /&gt;
&lt;br /&gt;
=== ADS1256-based ADC Board ===&lt;br /&gt;
&lt;br /&gt;
To digitize the conditioned weak physiological signals with sufficient resolution and low noise, this project developed a dedicated ADC board based on the ADS1256 analog-to-digital converter (Texas Instruments, Dallas, TX, USA) and the STM32F103C8T6 microcontroller (STMicroelectronics, Geneva, Switzerland). The overall design objective of this board was not merely to realize analog-to-digital conversion, but to provide a complete hardware interface between the analog front-end and the digital processing unit, including precision reference generation, clocking, input protection and filtering, serial communication, power regulation, and MCU-based acquisition control. The ADS1256 was selected because it is a&lt;br /&gt;
&lt;br /&gt;
very low-noise 24-bit delta-sigma converter with a programmable gain amplifier (PGA), flexible input multiplexer, programmable digital filter, and SPI-compatible serial interface, which makes it well suited for weak low-frequency physiological signals after analog conditioning. The STM32F103C8T6 was used as the local controller because it provides a 32-bit Cortex-M3 core, up to 72 MHz system clock, SPI, USART, USB, and standard SWD debugging support in a compact and low-cost platform.&lt;br /&gt;
&lt;br /&gt;
==== ADC Core Architecture and Design Rationale ====&lt;br /&gt;
&lt;br /&gt;
The ADS1256 was selected as the core ADC because it provides high-resolution, low-noise delta-sigma conversion with an input multiplexer, programmable gain amplifier, and digital filter, which are suitable for weak and low-frequency physiological signals. As shown in Figure 2.6, this architecture emphasizes resolution and noise performance rather than high conversion bandwidth, making it appropriate for sEMG signal digitization after analog conditioning.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_6.jpg|thumb|center|800px|Figure 2.6. Internal functional structure of the ADS1256 analog-to-digital converter.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the main internal blocks of the ADS1256, including the multiplexer, PGA, modulator, and digital filter.&lt;br /&gt;
&lt;br /&gt;
==== Analog Front-End Interface, Reference, and Clocking ====&lt;br /&gt;
&lt;br /&gt;
The ADS1256 analog inputs are connected to the external header through a passive input-conditioning network that helps suppress high-frequency interference and improve input stability. In addition, the board includes a dedicated precision reference and clocking circuits so that the ADC can perform stable and accurate conversion. Together, these circuits provide a reliable analog interface and timing basis for high-resolution digitization of weak physiological signals.&lt;br /&gt;
&lt;br /&gt;
==== SPI Interface between ADS1256 and STM32F103C8T6 ====&lt;br /&gt;
&lt;br /&gt;
Communication between the ADS1256 and the STM32F103C8T6 is implemented through an SPI-compatible interface, with dedicated lines for chip select, serial clock, input/output data, data-ready notification, and hardware reset. This connection allows the MCU to configure the ADC, read conversion results in synchrony with DRDY, and maintain efficient and reliable acquisition control for multi-channel physiological measurements.&lt;br /&gt;
&lt;br /&gt;
==== Power Supply and On-board Regulation ====&lt;br /&gt;
&lt;br /&gt;
The ADC board uses a USB Type-B connector as the main power input and includes protection, voltage regulation, and local decoupling circuits to provide a stable supply for both the MCU and ADC-related hardware. In addition, analog ground and digital ground are separated in the PCB layout to reduce digital noise coupling into the analog path, which is particularly important for weak physiological signal acquisition.&lt;br /&gt;
&lt;br /&gt;
==== Basic Peripheral Circuits of the STM32F103C8T6 ====&lt;br /&gt;
&lt;br /&gt;
The STM32F103C8T6 serves as the local controller of the ADC board and is supported by several basic peripheral circuits, including an external crystal oscillator, reset network, BOOT0 configuration, SWD programming/debugging header, and a CH340N USB-to-UART bridge. These circuits ensure stable MCU operation, convenient firmware downloading and debugging, and reliable data transmission from the board to the host computer for real-time display and storage.&lt;br /&gt;
&lt;br /&gt;
==== Hardware-level Working Principle of the ADC Board ====&lt;br /&gt;
&lt;br /&gt;
In operation, the conditioned analog signal from the AFE enters the ADS1256 through the input header, is digitized with high resolution under the control of the local precision reference and clock, and is then read by the STM32 through the SPI interface. The MCU subsequently forwards the sampled data to the host computer through the serial communication link, so that the entire board functions as a compact digital acquisition backend connecting weak physiological analog signals to later software processing, display, and storage.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_7.jpg|thumb|center|800px|Figure 2.7. Photograph of the fabricated ADS1256-based ADC board developed in this project and the definitions of some key pins.]]&lt;br /&gt;
&lt;br /&gt;
Figure 2.7 shows the ADC board fabricated for this project. It integrates the ADS1256 conversion core, STM32 control circuit, power-conditioning circuits, and communication interfaces on a compact PCB for physiological signal digitization.&lt;br /&gt;
&lt;br /&gt;
= Experimental Setup =&lt;br /&gt;
&lt;br /&gt;
== Experimental Demonstration ==&lt;br /&gt;
&lt;br /&gt;
The experimental setup and data acquisition process are demonstrated in the video below.&lt;br /&gt;
&lt;br /&gt;
[https://www.youtube.com/watch?v=xxxx Click here to watch the full demonstration]&lt;br /&gt;
&lt;br /&gt;
The video illustrates the complete measurement procedure, including electrode placement, muscle activation, and real-time EMG signal visualization.&lt;br /&gt;
&lt;br /&gt;
---&lt;br /&gt;
&lt;br /&gt;
== Experimental Procedure ==&lt;br /&gt;
&lt;br /&gt;
Surface EMG signals were acquired using disposable electrodes placed on the forearm muscles responsible for wrist extension. Three electrodes were attached along the muscle region to capture differential EMG signals.&lt;br /&gt;
&lt;br /&gt;
The experimental movement consists of making a fist while extending the wrist backward. This action activates the forearm extensor muscles beneath the electrodes, producing measurable EMG signals.&lt;br /&gt;
&lt;br /&gt;
---&lt;br /&gt;
&lt;br /&gt;
== Data Acquisition Protocol ==&lt;br /&gt;
&lt;br /&gt;
Each subject performed repeated contraction–relaxation cycles under controlled conditions:&lt;br /&gt;
&lt;br /&gt;
* Number of subjects: 3  &lt;br /&gt;
* Number of trials per subject: 3  &lt;br /&gt;
* Duration of each trial: 30 seconds  &lt;br /&gt;
&lt;br /&gt;
During each trial, subjects were instructed to periodically contract and relax the muscle to generate clear dynamic EMG signals, while also maintaining a stable resting state between contractions.&lt;br /&gt;
&lt;br /&gt;
---&lt;br /&gt;
&lt;br /&gt;
== System and Measurement Conditions ==&lt;br /&gt;
&lt;br /&gt;
The EMG signals were recorded and visualized in real time using a data acquisition system connected to a computer. The sampling rate was set to 400 Hz.&lt;br /&gt;
&lt;br /&gt;
To ensure consistency across measurements:&lt;br /&gt;
&lt;br /&gt;
* Electrode placement was kept consistent for all subjects  &lt;br /&gt;
* The same movement protocol was followed  &lt;br /&gt;
* Measurements were conducted under similar environmental conditions  &lt;br /&gt;
&lt;br /&gt;
---&lt;br /&gt;
&lt;br /&gt;
== Summary ==&lt;br /&gt;
&lt;br /&gt;
This experimental setup enables reliable acquisition of both resting and dynamic EMG signals, providing a consistent dataset for subsequent signal processing and performance evaluation.&lt;br /&gt;
== Signal Conditioning and Filtering ==&lt;br /&gt;
Although the AFE already performs preliminary band-pass filtering and 50 Hz interference suppression in the analog domain, the digitized sEMG signal may still contain residual noise due to component tolerances, electrode-contact variation, and environmental interference. Therefore, an additional digital filtering stage is implemented in software as a complementary post-processing step to improve signal quality and to provide a more stable input for rectification, envelope extraction, and subsequent analysis. In this sense, the software filtering is not a simple repetition of the analog filtering, but a refinement and compensation for non-ideal front-end behavior.&lt;br /&gt;
&lt;br /&gt;
Surface electromyographic (sEMG) signals are highly susceptible to several sources of contamination during acquisition. In practical measurements, the dominant disturbances usually include low-frequency motion artifacts caused by electrode movement and electrode–skin impedance variation, narrow-band power-line interference centered at 50 Hz, and broadband high-frequency electronic noise introduced by the acquisition hardware. These unwanted components degrade the quality of the recorded signal and may significantly affect the reliability of subsequent feature extraction, parameter estimation, and muscle activity interpretation. For this reason, an effective signal-conditioning procedure is necessary before any higher-level analysis is performed.&lt;br /&gt;
&lt;br /&gt;
In the present implementation, the filtering strategy follows the principle of restricting the signal bandwidth first and then removing the remaining narrow-band interference in a targeted manner. Accordingly, the raw sEMG signal is first processed by a fourth-order Butterworth IIR band-pass filter and then by a 50 Hz notch filter. This processing sequence is illustrated in the flowchart below, where the signal passes through band-pass filtering, notch filtering, full-wave rectification, and envelope extraction before producing the final processed output.&lt;br /&gt;
&lt;br /&gt;
[[File:flowchart.png|thumb|center|500px|Flowchart of the real-time sEMG signal conditioning pipeline.]]&lt;br /&gt;
&lt;br /&gt;
The rationale of this order is that the &#039;&#039;&#039;band-pass stage&#039;&#039;&#039; first confines the signal to the main spectral region of interest for sEMG, thereby attenuating motion artifacts at very low frequencies and suppressing high-frequency noise components outside the physiological band. After this spectral preconditioning, the notch stage can more effectively suppress the residual 50 Hz power-line interference that lies inside the useful sEMG band. In transfer-function form, the band-pass filter may be written as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;H_{BP}(z)=\frac{B_{BP}(z)}{A_{BP}(z)}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where the effective passband is selected as &amp;lt;math&amp;gt;20 \leq f \leq 160 \text{ Hz}&amp;lt;/math&amp;gt;. This frequency interval is consistent with the dominant spectral content of surface EMG: the lower cutoff near 20 Hz reduces motion artifacts and unstable low-frequency fluctuations, whereas the upper cutoff near 160 Hz removes high-frequency electronic noise while preserving the main energy-bearing components of the muscle signal. The use of a Butterworth structure is appropriate here because it provides a smooth monotonic passband response without ripple, which helps preserve signal morphology in real-time applications.&lt;br /&gt;
&lt;br /&gt;
After band limitation, a &#039;&#039;&#039;notch filter&#039;&#039;&#039; centered at the power-line frequency is applied to suppress interference that cannot be removed by the band-pass stage alone. The notch filter is designed around &amp;lt;math&amp;gt;f_0 = 50 \text{ Hz}&amp;lt;/math&amp;gt;, and its bandwidth is controlled by the quality factor &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;, which is expressed as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;Q = \frac{f_0}{\Delta f}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In transfer-function form, the notch stage is written as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;H_{N}(z)=\frac{B_{N}(z)}{A_{N}(z)}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the implemented program, a large quality factor is chosen so that the notch remains narrow, allowing effective rejection of the 50 Hz interference while minimizing distortion of neighboring useful spectral components. This is particularly important for sEMG because the interference frequency lies directly inside the physiological band of interest.&lt;br /&gt;
&lt;br /&gt;
Following the filtering stages, further signal conditioning is performed to obtain a representation that is more directly related to muscle activation intensity. The filtered sEMG waveform is first &#039;&#039;&#039;full-wave rectified&#039;&#039;&#039;, which converts the bipolar oscillatory signal into a unipolar signal by taking its absolute value.  Rectification does not remove noise by itself; instead, it transforms the signal into a form that is more suitable for amplitude-based analysis because both positive and negative deflections contribute positively to the activation measure.&lt;br /&gt;
&lt;br /&gt;
After rectification, the signal envelope is extracted to provide a smooth estimate of muscle activation level over time. In a general formulation, the envelope can be described as the &#039;&#039;&#039;low-pass filtered&#039;&#039;&#039; version of the rectified signal, namely &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y_{\mathrm{env}}[n] = \mathrm{LPF}\bigl(y_{\mathrm{rect}}[n]\bigr)&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the present code implementation, this operation is realized by short-time averaging over a finite window, which is equivalent to a moving-average low-pass smoothing of the rectified waveform. The corresponding expression is &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y_{\mathrm{env}}[n] = \frac{1}{N}\sum_{k=0}^{N-1} |x[n-k]|&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; is the window length in samples. With a window duration of approximately 200 ms, this envelope extraction method provides a stable and physiologically meaningful representation of muscle activation intensity, making it suitable for tasks such as force estimation, fatigue analysis, and motor-control studies.&lt;br /&gt;
&lt;br /&gt;
An important feature of the present &#039;&#039;&#039;implementation&#039;&#039;&#039; is that the entire filtering process is performed &#039;&#039;&#039;in real time&#039;&#039;&#039;, sample by sample, rather than by offline block processing. For this reason, IIR filters are preferred over FIR filters, since they can achieve comparable filtering performance with lower order, lower computational cost, and shorter delay. These properties are especially valuable in embedded systems, serial data streaming, and other low-latency experimental applications. However, unlike memoryless operations, an IIR filter depends not only on the current input but also on previous inputs and previous outputs. Its discrete-time behavior can therefore be represented by the recursive difference equation &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y[n] = \sum_{k=0}^{M} b_k x[n-k] - \sum_{k=1}^{N} a_k y[n-k]&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This equation makes clear that internal filter states must be preserved continuously during streaming operation. If the state variables were reinitialized for every incoming sample or data segment, artificial transients would appear and the output would no longer remain continuous.&lt;br /&gt;
&lt;br /&gt;
In the Python implementation, this state continuity is maintained using the internal initial-condition mechanism provided by SciPy, such as &amp;lt;code&amp;gt;lfilter_zi&amp;lt;/code&amp;gt;, together with recursive state updates during each filtering call. As a result, each newly acquired sample is passed first through the band-pass filter and then through the notch filter, while the internal states of both filters are updated after every step. This state-preserving sample-by-sample design ensures that the processing chain remains causal, continuous, and suitable for real-time display or downstream analysis without requiring storage of the entire signal segment.&lt;br /&gt;
&lt;br /&gt;
Overall, this signal-conditioning scheme provides an experimentally practical solution for real-time sEMG processing. The fourth-order Butterworth band-pass filter confines the signal to the main physiological band of interest, the 50 Hz notch filter removes narrow-band power-line contamination, and the subsequent rectification and envelope extraction generate a smooth amplitude descriptor of muscle activity. Combined with state-preserved streaming IIR implementation, this approach achieves a good balance between signal fidelity, computational efficiency, and real-time applicability in biomedical and physical experiment settings.&lt;br /&gt;
&lt;br /&gt;
== Data Processing ==&lt;br /&gt;
&lt;br /&gt;
The objective of data processing is to convert raw surface electromyography (sEMG) recordings into stable, quantitative, and comparable indicators of muscle activity. Since EMG signals are low in amplitude, highly variable over time, and easily contaminated by noise, a dedicated processing pipeline is necessary before any experimental interpretation can be performed.&lt;br /&gt;
&lt;br /&gt;
In this project, the data processing workflow includes time normalization, signal pre-processing, sliding-window feature extraction, noise-floor estimation, and automatic contraction detection. The processed outputs are then used for subsequent experimental evaluation, including rest-versus-contraction discrimination, signal-to-noise ratio analysis, and repeatability assessment.&lt;br /&gt;
&lt;br /&gt;
=== Input Data and Time Normalization ===&lt;br /&gt;
&lt;br /&gt;
The acquired EMG data are read from CSV files containing two columns: time and filtered sEMG amplitude. In the MATLAB implementation, the time vector is normalized so that each recording starts from zero:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t = t_{all} - t_{all}(1)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This normalization is important because it removes the influence of absolute recording timestamps and makes different trials directly comparable on the same time axis.&lt;br /&gt;
&lt;br /&gt;
In addition, the signal type is automatically identified from the filename as either dynamic or rest. This design allows the same program to process both contraction recordings and resting recordings with different downstream analysis logic.&lt;br /&gt;
&lt;br /&gt;
=== Signal Pre-processing ===&lt;br /&gt;
&lt;br /&gt;
Raw EMG signals cannot be analyzed directly because they usually contain DC offset, low-frequency drift, motion artifacts, and residual high-frequency interference. Therefore, several pre-processing steps are applied before feature extraction.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(1) Baseline Removal&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The first step is DC offset removal:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
x_{dc}(t) = x(t) - \frac{1}{N}\sum_{i=1}^{N}x(i)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This operation centers the signal around zero. It is necessary because an uncorrected baseline would bias amplitude-based metrics and reduce the reliability of later envelope and feature calculations.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(2) Band-pass Filtering &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
After baseline correction, a fourth-order Butterworth band-pass filter is applied with a passband of 20–150 Hz.&lt;br /&gt;
&lt;br /&gt;
This step is introduced for two reasons:&lt;br /&gt;
&lt;br /&gt;
* The low-frequency cutoff at 20 Hz suppresses baseline drift and motion artifacts.&lt;br /&gt;
* The high-frequency cutoff at 150 Hz reduces unwanted high-frequency noise while preserving the main energy band of the recorded sEMG in this project.&lt;br /&gt;
&lt;br /&gt;
Compared with processing the raw waveform directly, band-pass filtering makes the subsequent time-domain features more stable and more physiologically meaningful.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(3) Full-wave Rectification&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The filtered EMG signal is bipolar, meaning that positive and negative phases coexist due to motor unit action potentials. If these positive and negative components are averaged directly, they may cancel each other out. To avoid this, full-wave rectification is performed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
x_{rect}(t) = |x_{filt}(t)|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This transforms the signal into a unipolar representation, so that all muscle activity contributes positively to the extracted features.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(4) Envelope Extraction &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Although the rectified signal reflects signal magnitude, it still fluctuates rapidly. To obtain a smoother representation of muscle activation level, an envelope is extracted using a moving average with a 100 ms window.&lt;br /&gt;
&lt;br /&gt;
Envelope extraction is important because contraction detection should reflect the overall activation trend rather than instantaneous spikes. A smoothed envelope is therefore more robust for identifying active and inactive muscle states.&lt;br /&gt;
&lt;br /&gt;
=== Sliding Window Design ===&lt;br /&gt;
&lt;br /&gt;
To quantify how muscle activity changes with time, the filtered signal is divided into overlapping short-time segments using a sliding window method.&lt;br /&gt;
&lt;br /&gt;
The window parameters are:&lt;br /&gt;
&lt;br /&gt;
* Window length: 250 ms&lt;br /&gt;
* Step size: 50 ms&lt;br /&gt;
&lt;br /&gt;
These values are chosen as a trade-off between temporal resolution and feature stability.&lt;br /&gt;
&lt;br /&gt;
A longer window improves statistical robustness because more samples are included in each calculation. However, if the window is too long, short contractions or rapid changes may be blurred. A smaller step size increases temporal continuity between adjacent feature points and makes the feature curves smoother in time. Therefore, the 250 ms / 50 ms design provides a practical balance between smoothing and time localization.&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt;-th segment, the feature time is defined as the mean time of that segment:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t_k = \frac{1}{N}\sum_{i=s_k}^{e_k} t(i)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;s_k&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;e_k&amp;lt;/math&amp;gt; denote the start and end indices of the window.&lt;br /&gt;
&lt;br /&gt;
=== Feature Extraction ===&lt;br /&gt;
&lt;br /&gt;
Within each sliding window, three time-domain features are extracted: RMS, iEMG, and MAV. These features are widely used in EMG analysis because they are simple, computationally efficient, and directly related to muscle activation intensity.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(1) Root Mean Square (RMS)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
RMS = \sqrt{\frac{1}{N}\sum_{i=1}^{N}x_i^2}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
RMS reflects the effective power of the EMG signal and is one of the most common indicators of contraction strength. It is sensitive to both amplitude and energy, making it especially useful for comparing rest and active states.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(2) Integrated EMG (iEMG)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
iEMG = \sum_{i=1}^{N}|x_i|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
iEMG describes the cumulative electrical activity within a window. It is often interpreted as a measure of total muscle effort over that time segment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(3) Mean Absolute Value (MAV)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
MAV = \frac{1}{N}\sum_{i=1}^{N}|x_i|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
MAV is an amplitude descriptor similar to iEMG, but normalized by the number of samples. It provides an efficient estimate of average signal level and is less computationally intensive than some other features.&lt;br /&gt;
&lt;br /&gt;
These three features are used together because they provide complementary descriptions of EMG intensity. RMS emphasizes signal energy, iEMG emphasizes cumulative activation, and MAV reflects average amplitude.&lt;br /&gt;
&lt;br /&gt;
=== Peak-value Extraction ===&lt;br /&gt;
&lt;br /&gt;
In addition to continuous feature curves, several key peak values are extracted from the processed signal:&lt;br /&gt;
&lt;br /&gt;
* maximum and minimum of the filtered EMG waveform&lt;br /&gt;
* peak of the envelope&lt;br /&gt;
* peak RMS&lt;br /&gt;
* peak iEMG&lt;br /&gt;
* peak MAV&lt;br /&gt;
&lt;br /&gt;
These peak values provide concise descriptors of the strongest activity observed in each recording. They are useful for quick comparison across trials and subjects.&lt;br /&gt;
&lt;br /&gt;
=== Noise Floor Estimation ===&lt;br /&gt;
&lt;br /&gt;
To evaluate signal quality, the noise floor is estimated from a reference resting interval. In the present implementation, the first 3 seconds of the recording are used as the default rest reference:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t \in [0,\min(3,t_{end})]&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this segment, three noise descriptors are computed:&lt;br /&gt;
&lt;br /&gt;
* Noise RMS&lt;br /&gt;
* Noise standard deviation&lt;br /&gt;
* Noise peak-to-peak amplitude&lt;br /&gt;
&lt;br /&gt;
Noise-floor estimation is important because EMG amplitude alone is not sufficient to judge recording quality. A large signal is only meaningful if it is sufficiently higher than the baseline noise level. Therefore, the noise floor serves as the reference for later SNR calculation and for designing contraction thresholds.&lt;br /&gt;
&lt;br /&gt;
=== Global Signal Metrics ===&lt;br /&gt;
&lt;br /&gt;
For each recording, three global metrics are also computed over the entire filtered signal:&lt;br /&gt;
&lt;br /&gt;
* Global RMS&lt;br /&gt;
* Global MAV&lt;br /&gt;
* Global iEMG&lt;br /&gt;
&lt;br /&gt;
These global descriptors summarize the overall signal level of the full recording and are later used in group-level comparisons.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Contraction Detection ===&lt;br /&gt;
&lt;br /&gt;
For dynamic recordings, an automatic contraction detection algorithm is used to identify repeated active segments. This is one of the key parts of the data processing pipeline, because it transforms a continuous EMG trace into discrete contraction events that can be counted and compared.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(1) Threshold Design&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The detection threshold is designed adaptively rather than using a fixed value. Two candidate thresholds are first calculated:&lt;br /&gt;
&lt;br /&gt;
* an envelope-based threshold derived from the global envelope mean and standard deviation&lt;br /&gt;
* a rest-reference threshold derived from the mean and standard deviation of the resting reference amplitude&lt;br /&gt;
&lt;br /&gt;
The final threshold is taken as the larger of the two after additional scaling. This strategy improves robustness because it combines the global activation level of the signal with the baseline noise characteristics of the individual recording.&lt;br /&gt;
&lt;br /&gt;
This adaptive threshold design is preferable to a manually fixed threshold because EMG amplitude can vary strongly between subjects, muscles, and recording sessions.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(2) Initial Segmentation&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
After thresholding the envelope, the signal is classified into active and inactive regions:&lt;br /&gt;
&lt;br /&gt;
* active: envelope above threshold&lt;br /&gt;
* inactive: envelope below threshold&lt;br /&gt;
&lt;br /&gt;
The rising and falling edges of the binary activity vector are then used to determine the start and end points of each candidate contraction segment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(3) Removal of Short Segments&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Very short active regions are often caused by noise fluctuations rather than true muscle contractions. Therefore, segments shorter than 0.20 s are discarded.&lt;br /&gt;
&lt;br /&gt;
This step prevents false positive detections and increases the physiological relevance of the segmentation results.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(4) Merging of Adjacent Segments &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If two neighboring active segments are separated by a very short gap, they are merged when the gap is less than 0.15 s.&lt;br /&gt;
&lt;br /&gt;
This operation is necessary because a single real contraction may be temporarily interrupted by a brief drop in the envelope caused by local fluctuation. Without merging, one contraction could be incorrectly counted as multiple repetitions.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(5) Repetition-level Metrics &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
For each detected contraction segment, two repetition-level metrics are extracted:&lt;br /&gt;
&lt;br /&gt;
* peak RMS of that contraction&lt;br /&gt;
* mean RMS of that contraction&lt;br /&gt;
&lt;br /&gt;
These metrics quantify both the strongest activation within each repetition and the average activation level over the repetition duration.&lt;br /&gt;
&lt;br /&gt;
=== Repeatability Analysis ===&lt;br /&gt;
&lt;br /&gt;
When multiple valid contractions are detected, repeatability is evaluated using the coefficient of variation (CV):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
CV = \frac{\sigma}{\mu}\times 100\%&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt; is the standard deviation and &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is the mean value across repetitions.&lt;br /&gt;
&lt;br /&gt;
Two CV values are computed:&lt;br /&gt;
&lt;br /&gt;
* CV of repetition peak RMS&lt;br /&gt;
* CV of repetition mean RMS&lt;br /&gt;
&lt;br /&gt;
A lower CV indicates better repeatability, meaning that repeated contractions produce more consistent EMG responses.&lt;br /&gt;
&lt;br /&gt;
=== Signal-to-Noise Ratio (SNR) ===&lt;br /&gt;
&lt;br /&gt;
In this project, the signal-to-noise ratio (SNR) is defined based on the ratio between contraction and rest activity:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
SNR_{dB} = 20\log_{10}\left(\frac{RMS_{contraction}}{RMS_{rest}}\right)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This definition is adopted because it directly reflects the system’s ability to distinguish active muscle contraction from baseline noise.&lt;br /&gt;
&lt;br /&gt;
Compared with global SNR definitions, this formulation is more relevant for practical EMG applications such as activity detection and classification.&lt;br /&gt;
&lt;br /&gt;
=== Rest-versus-Contraction Window Comparison ===&lt;br /&gt;
&lt;br /&gt;
To further distinguish inactive and active states, all sliding windows are divided into two groups:&lt;br /&gt;
&lt;br /&gt;
* rest windows: windows with envelope clearly below the threshold&lt;br /&gt;
* contraction windows: windows with envelope above the threshold&lt;br /&gt;
&lt;br /&gt;
The RMS values of these two groups are then compared statistically.&lt;br /&gt;
&lt;br /&gt;
This comparison is important because a practical EMG system should not only detect signal presence, but also clearly separate rest from contraction in a quantitative way. If the two RMS distributions are well separated, it indicates that the system has good discriminative capability.&lt;br /&gt;
&lt;br /&gt;
=== Output Data Structure ===&lt;br /&gt;
&lt;br /&gt;
The processed outputs are organized into structured data for experimental analysis:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(1) Time-series outputs&#039;&#039;&#039;&lt;br /&gt;
* Filtered EMG signal  &lt;br /&gt;
* Rectified signal  &lt;br /&gt;
* Envelope  &lt;br /&gt;
* RMS(t), iEMG(t), MAV(t)  &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(2) Recording-level outputs&#039;&#039;&#039; &lt;br /&gt;
* RMS (rest)  &lt;br /&gt;
* RMS (contraction)  &lt;br /&gt;
* iEMG  &lt;br /&gt;
* Noise metrics  &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(3) Dynamic-signal outputs &#039;&#039;&#039;&lt;br /&gt;
* Detected contractions  &lt;br /&gt;
* Repetition count  &lt;br /&gt;
* Peak RMS per repetition  &lt;br /&gt;
* Mean RMS per repetition  &lt;br /&gt;
* Coefficient of variation (CV)  &lt;br /&gt;
* Signal-to-noise ratio (SNR)  &lt;br /&gt;
&lt;br /&gt;
All extracted features are designed to directly support the evaluation of noise level, signal quality, activity discrimination, and repeatability in the subsequent experimental analysis.&lt;br /&gt;
&lt;br /&gt;
== Experimental Results ==&lt;br /&gt;
&lt;br /&gt;
This section presents representative results of the EMG acquisition and data processing pipeline under both dynamic (muscle contraction) and resting conditions.&lt;br /&gt;
&lt;br /&gt;
=== Representative Dynamic Signal Analysis ===&lt;br /&gt;
&lt;br /&gt;
[[File:Dynamic_Figure1.png|thumb|800px|center|Figure 5.1: Processed EMG signal under dynamic contraction, including filtered signal, rectified signal with envelope, and extracted features (RMS, iEMG, MAV).]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.1 shows the processed EMG signal during repeated muscle contractions.&lt;br /&gt;
&lt;br /&gt;
The filtered EMG waveform exhibits clear burst-like patterns corresponding to periodic contractions. The signal amplitude reaches a maximum of approximately 0.45, while the baseline remains centered around zero, indicating effective baseline removal and filtering.&lt;br /&gt;
&lt;br /&gt;
After rectification and envelope extraction, the contraction periods become clearly distinguishable. The envelope provides a smooth representation of muscle activation, with a peak value of approximately 0.145.&lt;br /&gt;
&lt;br /&gt;
The extracted time-domain features (RMS, iEMG, MAV) further quantify the signal. Among these, iEMG shows the strongest dynamic variation, indicating high sensitivity to contraction intensity.&lt;br /&gt;
&lt;br /&gt;
=== Noise Floor and Rest Reference ===&lt;br /&gt;
&lt;br /&gt;
[[File:Dynamic_Figure2.png|thumb|800px|center|Figure 5.2: Noise estimation, rest vs contraction comparison, automatic contraction detection, and repetition analysis.]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (top-left) shows the resting reference segment used for noise estimation.&lt;br /&gt;
&lt;br /&gt;
The signal remains centered around zero with small fluctuations. The noise characteristics are:&lt;br /&gt;
&lt;br /&gt;
* Noise RMS ≈ 0.0046  &lt;br /&gt;
* Standard deviation ≈ 0.0046  &lt;br /&gt;
* Peak-to-peak amplitude ≈ 0.071  &lt;br /&gt;
&lt;br /&gt;
This indicates a low noise floor and stable measurement conditions.&lt;br /&gt;
&lt;br /&gt;
=== Rest vs Contraction Discrimination ===&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (top-right) compares RMS values between rest and contraction states.&lt;br /&gt;
&lt;br /&gt;
The two distributions are clearly separated:&lt;br /&gt;
&lt;br /&gt;
* Rest mean RMS ≈ 0.0053  &lt;br /&gt;
* Contraction mean RMS ≈ 0.1064  &lt;br /&gt;
&lt;br /&gt;
This corresponds to an approximate 20× increase, demonstrating strong discriminability between inactive and active muscle states.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Contraction Detection ===&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (bottom-left) illustrates automatic detection based on the envelope signal.&lt;br /&gt;
&lt;br /&gt;
A threshold of approximately 0.040 is applied, resulting in stable segmentation of contraction periods.&lt;br /&gt;
&lt;br /&gt;
A total of 12 repetitions are detected, with good alignment to visible signal peaks.&lt;br /&gt;
&lt;br /&gt;
=== Repeatability Analysis ===&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (bottom-right) shows the peak RMS value of each detected contraction.&lt;br /&gt;
&lt;br /&gt;
The results indicate:&lt;br /&gt;
&lt;br /&gt;
* Mean peak RMS ≈ 0.1355  &lt;br /&gt;
* Standard deviation ≈ 0.0173  &lt;br /&gt;
* CV ≈ 12.77%  &lt;br /&gt;
* SNR ≈ 21.26 dB  &lt;br /&gt;
&lt;br /&gt;
This indicates acceptable repeatability and good signal quality.&lt;br /&gt;
&lt;br /&gt;
=== Representative Rest Signal Analysis ===&lt;br /&gt;
&lt;br /&gt;
[[File:Rest_Figure1.png|thumb|800px|center|Figure 5.3: Processed EMG signal under rest condition, showing low amplitude and absence of contraction patterns.]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.3 shows the EMG signal under resting conditions.&lt;br /&gt;
&lt;br /&gt;
The signal remains within a narrow amplitude range (approximately ±0.04) and shows no burst-like structures. The envelope remains close to zero, confirming the absence of muscle activity.&lt;br /&gt;
&lt;br /&gt;
The extracted features remain low:&lt;br /&gt;
&lt;br /&gt;
* RMS ≈ 0.007  &lt;br /&gt;
* MAV ≈ 0.005  &lt;br /&gt;
* iEMG remains stable  &lt;br /&gt;
&lt;br /&gt;
This confirms that no false activation is detected.&lt;br /&gt;
&lt;br /&gt;
=== Frequency-domain Characteristics ===&lt;br /&gt;
&lt;br /&gt;
[[File:Rest_Figure2.png|thumb|800px|center|Figure 5.4: Frequency-domain analysis and statistical characteristics of rest signal.]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.4 shows the frequency-domain characteristics of the resting signal.&lt;br /&gt;
&lt;br /&gt;
The power spectral density (PSD) indicates low overall signal energy without dominant peaks, confirming that the signal mainly consists of noise.&lt;br /&gt;
&lt;br /&gt;
=== Summary of Single-recording Performance ===&lt;br /&gt;
&lt;br /&gt;
From the representative results:&lt;br /&gt;
&lt;br /&gt;
* EMG signals are effectively extracted and denoised  &lt;br /&gt;
* Contraction events are clearly identifiable  &lt;br /&gt;
* Rest and contraction states are well separated  &lt;br /&gt;
* Automatic detection is stable and accurate  &lt;br /&gt;
* Repeatability is acceptable  &lt;br /&gt;
* No false activation occurs under rest conditions  &lt;br /&gt;
&lt;br /&gt;
=== Consistency Across Multiple Recordings ===&lt;br /&gt;
&lt;br /&gt;
The same data processing pipeline was applied to multiple recordings from different subjects and trials.&lt;br /&gt;
&lt;br /&gt;
Across all datasets, consistent patterns were observed:&lt;br /&gt;
&lt;br /&gt;
* Dynamic signals exhibit clear burst-like structures corresponding to repeated muscle contractions  &lt;br /&gt;
* Rest signals remain low in amplitude without distinct activation patterns  &lt;br /&gt;
* RMS values under contraction are consistently higher than those under rest  &lt;br /&gt;
* The automatic detection algorithm reliably identifies contraction segments  &lt;br /&gt;
&lt;br /&gt;
Although quantitative values (e.g., RMS, SNR, CV) vary across recordings due to differences in electrode contact, muscle activation strength, and individual conditions, the overall trends remain consistent.&lt;br /&gt;
&lt;br /&gt;
These results demonstrate the robustness and general applicability of the proposed signal processing method.&lt;br /&gt;
&lt;br /&gt;
== Multi-subject Analysis ==&lt;br /&gt;
=== System Evaluation ===&lt;br /&gt;
&lt;br /&gt;
This section evaluates the performance of the EMG acquisition system in terms of noise level, signal quality, activity discrimination, and repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Noise Floor Analysis ====&lt;br /&gt;
&lt;br /&gt;
The noise floor was evaluated using rest-state recordings, characterized by RMS noise, standard deviation, and peak-to-peak amplitude.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039; shows the lowest noise level (RMS ≈ 0.0046), indicating stable electrode contact and minimal interference.  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039; exhibits moderate noise (RMS ≈ 0.0080), likely influenced by motion artifacts or electrode–skin impedance variation.  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039; shows relatively higher noise (RMS ≈ 0.0126), suggesting increased baseline fluctuation.  &lt;br /&gt;
&lt;br /&gt;
Overall, the system maintains a low noise floor across subjects, although the quality depends on experimental conditions such as electrode contact and environmental interference.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Signal-to-Noise Ratio (SNR) ====&lt;br /&gt;
&lt;br /&gt;
The signal-to-noise ratio (SNR) is defined as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{SNR (dB)} = 20 \log_{10} \left( \frac{\mathrm{RMS}_{\mathrm{contraction}}}{\mathrm{RMS}_{\mathrm{rest}}} \right)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The measured SNR values are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: 21.26 dB → good signal quality  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: 13.52 dB → moderate and usable  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: 6.66 dB → low signal clarity  &lt;br /&gt;
&lt;br /&gt;
General interpretation:&lt;br /&gt;
&lt;br /&gt;
* &amp;gt;20 dB → good  &lt;br /&gt;
* 10–20 dB → usable  &lt;br /&gt;
* &amp;lt;10 dB → poor  &lt;br /&gt;
&lt;br /&gt;
These results show that the system can achieve reliable signal acquisition, although performance varies across subjects.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
====  Rest vs Contraction Discrimination ====&lt;br /&gt;
&lt;br /&gt;
A clear distinction between rest and contraction states is observed based on RMS values.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: 0.0053 → 0.1064 (≈20× increase)  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: 0.0079 → 0.0283 (≈3.6× increase)  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: 0.0141 → 0.0646 (≈4.6× increase)  &lt;br /&gt;
&lt;br /&gt;
This demonstrates that the system is capable of separating muscle activity from baseline noise.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Conclusion:&#039;&#039;  &lt;br /&gt;
The system can be used for basic muscle activity detection and simple classification tasks based on RMS features.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Repeatability of Repeated Contractions ====&lt;br /&gt;
&lt;br /&gt;
Repeatability is evaluated using the coefficient of variation (CV) of peak RMS values across repetitions.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! CV Range !! Evaluation&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt; 10% || Excellent&lt;br /&gt;
|-&lt;br /&gt;
| 10–20% || Acceptable&lt;br /&gt;
|-&lt;br /&gt;
| &amp;gt; 20% || Poor&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Results:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: CV = 12.77% → Acceptable  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: CV = 24.77% → Poor  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: CV = 10.60% → Acceptable  &lt;br /&gt;
&lt;br /&gt;
Although WANG&#039;s signal is detectable, its contraction amplitude varies significantly across repetitions, resulting in poor repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
=== Overall System Performance ===&lt;br /&gt;
&lt;br /&gt;
The system demonstrates the following performance characteristics:&lt;br /&gt;
&lt;br /&gt;
* Reliable detection of muscle activity across all subjects  &lt;br /&gt;
* Clear separation between rest and contraction states  &lt;br /&gt;
* Moderate to high signal quality depending on subject conditions  &lt;br /&gt;
* Repeatability ranging from acceptable to poor due to user-dependent factors  &lt;br /&gt;
&lt;br /&gt;
Overall, the designed EMG acquisition system is capable of stable signal acquisition and feature extraction, with performance primarily influenced by electrode contact quality, skin impedance, and motion consistency.&lt;br /&gt;
&lt;br /&gt;
===== Summary of Quantitative Metrics =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Subject !! RMS (Rest) !! RMS (Contraction) !! Separation Ratio !! iEMG (max) !! Noise RMS !! SNR (dB) !! CV (%) !! Evaluation&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;LIU&#039;&#039;&#039; || 0.0053 || 0.1064 || &#039;&#039;&#039;20.1×&#039;&#039;&#039; || 12.72 || 0.0046 || &#039;&#039;&#039;21.26&#039;&#039;&#039; || 12.77 || Strong signal, good quality&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;WANG&#039;&#039;&#039; || 0.0079 || 0.0283 || 3.57× || 11.10 || 0.0080 || 13.52 || &#039;&#039;&#039;24.77&#039;&#039;&#039; || Usable signal, poor repeatability&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ZHONG&#039;&#039;&#039; || 0.0141 || 0.0646 || 4.58× || 6.70 || 0.0126 || 6.66 || 10.60 || Acceptable performance&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Summary:&#039;&#039; Subject LIU shows the best overall performance, WANG provides usable but less stable signals, and ZHONG demonstrates moderate signal quality with good repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Activation Intensity =====&lt;br /&gt;
&lt;br /&gt;
Among the three subjects, &#039;&#039;&#039;LIU exhibits the strongest muscle activation&#039;&#039;&#039;, as indicated by the highest contraction RMS and iEMG values. ZHONG shows moderate activation, while WANG demonstrates comparable iEMG but lower RMS consistency.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Signal Quality =====&lt;br /&gt;
&lt;br /&gt;
Signal quality is evaluated based on SNR and noise level:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039; achieves the highest SNR and lowest noise → best signal quality  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039; shows moderate SNR → usable but less robust  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039; has the lowest SNR → weakest signal clarity  &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Repeatability =====&lt;br /&gt;
&lt;br /&gt;
Repeatability is evaluated using the coefficient of variation (CV):&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;ZHONG (10.60%)&#039;&#039;&#039; → most stable  &lt;br /&gt;
* &#039;&#039;&#039;LIU (12.77%)&#039;&#039;&#039; → acceptable  &lt;br /&gt;
* &#039;&#039;&#039;WANG (24.77%)&#039;&#039;&#039; → poor  &lt;br /&gt;
&lt;br /&gt;
This indicates that WANG’s contraction strength varies significantly between repetitions.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Engineering Interpretation of Inter-subject Differences =====&lt;br /&gt;
&lt;br /&gt;
The observed differences are mainly attributed to engineering and experimental factors rather than physiological differences.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Electrode contact quality&#039;&#039;&#039;  &lt;br /&gt;
  Variations in electrode placement, pressure, and gel contact affect signal amplitude and stability.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Skin impedance&#039;&#039;&#039;  &lt;br /&gt;
  Differences in skin condition (hydration, oil, hair) influence electrode–skin impedance, affecting noise level and signal coupling.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Muscle control consistency&#039;&#039;&#039;  &lt;br /&gt;
  Variations in contraction strength and timing affect repeatability and CV.&lt;br /&gt;
&lt;br /&gt;
Therefore, the variation across subjects reflects practical acquisition conditions rather than intrinsic system limitations.&lt;/div&gt;</summary>
		<author><name>Wang Jingyi</name></author>
	</entry>
	<entry>
		<id>https://pc5271.org/index.php?title=Surface_EMG_Sensor_for_Muscle_Activity_Measurement:_AFE_Design_and_Signal_Processing&amp;diff=1361</id>
		<title>Surface EMG Sensor for Muscle Activity Measurement: AFE Design and Signal Processing</title>
		<link rel="alternate" type="text/html" href="https://pc5271.org/index.php?title=Surface_EMG_Sensor_for_Muscle_Activity_Measurement:_AFE_Design_and_Signal_Processing&amp;diff=1361"/>
		<updated>2026-04-23T07:09:39Z</updated>

		<summary type="html">&lt;p&gt;Wang Jingyi: /* Data Processing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Background and Theory==&lt;br /&gt;
&lt;br /&gt;
=== Surface EMG Signals ===&lt;br /&gt;
Surface electromyography (sEMG) refers to the bioelectrical signals detected on the skin surface during muscle contraction. These signals originate from the electrical activity of muscle fibers and provide a non-invasive way to monitor muscle activation. Compared with invasive EMG methods, sEMG is easier to apply, safer for repeated measurements, and more suitable for real-time monitoring. Therefore, it has been widely used in areas such as rehabilitation, motion analysis, human–machine interaction, and physiological monitoring.&lt;br /&gt;
&lt;br /&gt;
=== Characteristics of EMG Signals ===&lt;br /&gt;
EMG signals are generally weak, time-varying, and stochastic in nature. Their waveforms are typically bipolar, fluctuating around zero with both positive and negative components. The amplitude and frequency content of EMG signals depend on factors such as muscle contraction level, electrode placement, skin condition, and individual physiological differences. In practice, the useful frequency components of sEMG are mainly concentrated in a limited low-to-mid frequency range. Because of their low amplitude and variability, EMG signals usually require further conditioning before reliable interpretation and feature extraction can be performed.&lt;br /&gt;
&lt;br /&gt;
=== Bioelectrical Signal Acquisition Principles ===&lt;br /&gt;
The acquisition of bioelectrical signals is based on measuring the small potential difference on the skin surface using electrodes, then converting it into a processable electrical signal through amplification and digitization. For sEMG measurement, electrode placement and skin–electrode contact quality are especially important, since they directly affect signal amplitude and stability. In addition, the front-end acquisition circuit must provide sufficient sensitivity and good interference rejection, so that the recorded signal reflects actual muscle activity rather than environmental disturbance or poor contact conditions.&lt;br /&gt;
&lt;br /&gt;
=== Noise Sources in EMG (50 Hz, motion artifacts) ===&lt;br /&gt;
In practical EMG recording, the measured signal is easily contaminated by different types of noise. Two of the most common sources are power-line interference and motion artifacts. Power-line interference usually appears as a narrow-band component at 50 Hz in the local electrical environment, while motion artifacts are mainly caused by electrode movement, cable disturbance, or variations in the electrode–skin impedance, and are often concentrated in the low-frequency range. In addition, electronic noise from the acquisition hardware may also affect the recording quality. These unwanted components can reduce signal clarity and make muscle activity analysis less reliable, so they must be considered in the design of the signal processing pipeline.&lt;br /&gt;
[[File:background_theory_figure1.1_emg_noise_sources.png|center|thumb|700px|&#039;&#039;&#039;Figure 1.1.&#039;&#039;&#039; Principle of surface EMG acquisition.]]&lt;br /&gt;
&lt;br /&gt;
==System Architecture==&lt;br /&gt;
=== Total Structure Design ===&lt;br /&gt;
&lt;br /&gt;
For clarity，the proposed physiological signal acquisition system mainly consists of two core parts：the analog front－end （AFE）and the ADC board．The AFE is responsible for the preliminary conditioning of weak bioelectrical signals，including amplification，filtering，interference suppression，and level shifting，so that the analog waveform can be converted into a stable and measurable form．The ADC board then performs high－resolution digitization of the conditioned signal and transfers the sampled data to the host computer for subsequent display，storage，and analysis．Therefore，the overall system forms a complete signal－acquisition chain from weak physiological input to digital output．&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_1.jpg|thumb|center|800px|Figure 2.1. Overall system architecture of the proposed physiological signal acquisition platform，including the AFE and ADC modules．]]&lt;br /&gt;
&lt;br /&gt;
=== sEMG AFE Design ===&lt;br /&gt;
&lt;br /&gt;
To collect the weak bioelectric potential signals of the human body，an analog front－end（AFE）suitable sEMG measurements was designed．The module is powered by an external 5 V supply，and the complete circuit includes a first－ stage instrumentation amplifier based on INA128（Texas Instruments，Dallas，TX，USA），a band－pass filter，a 50 Hz notch filter，a second－order amplification and level shifting stage，a driver electrode circuit，a precise 1.5 V reference source，and a -5 V voltage generation module for powering the operational amplifiers．&lt;br /&gt;
&lt;br /&gt;
==== First－order Amplifier ====&lt;br /&gt;
&lt;br /&gt;
The input bioelectric signal is first acquired in differential form and applied to the INA128 instrumentation amplifier，which provides high input impedance，high common－mode rejection，and moderate initial gain for sEMG acquisition．This stage enlarges the weak physiological signal before filtering while reducing the risk of premature saturation caused by electrode offset or motion－induced disturbance，thereby preparing a more stable signal for the subsequent conditioning stages．&lt;br /&gt;
&lt;br /&gt;
==== Bandpass Filter ====&lt;br /&gt;
&lt;br /&gt;
After the instrumentation amplifier，the signal passes through a second－order active band－pass filter，as shown in Figure 2．2． This stage suppresses baseline drift and high－frequency noise outside the useful sEMG range，so that the low－frequency envelope information of sEMG can be preserved before further amplification．&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_2.jpg|thumb|center|800px|Figure 2.2. Schematic diagram of the active band-pass filter used in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the band-pass stage used to retain the main physiological signal band while suppressing unwanted lowand high-frequency components.&lt;br /&gt;
&lt;br /&gt;
==== Notch Filter ====&lt;br /&gt;
&lt;br /&gt;
To reduce power-line interference, a dedicated 50 Hz notch filter is introduced after the band-pass stage, as shown in Figure 2.3. This filter attenuates the mains-frequency component that commonly contaminates weak bioelectric measurements, thereby improving the signal-to-noise ratio of sEMG signals before the final amplification stage.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_3.jpg|thumb|center|800px|Figure 2.3. Schematic diagram of the 50 Hz notch filter used in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the circuit used to attenuate 50 Hz mains interference in the analog front end.&lt;br /&gt;
&lt;br /&gt;
==== Second-order Amplifier &amp;amp; Level Shifter ====&lt;br /&gt;
&lt;br /&gt;
After filtering, the signal enters the second-stage amplification and level-shifting circuit shown in Figure 2.4. In this stage, the filtered signal is further amplified to improve amplitude utilization and then shifted by a 1.5 V reference so that the output becomes a stable unipolar signal suitable for ADC sampling, while preserving linear operation and providing sufficient output swing margin.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_4.jpg|thumb|center|800px|Figure 2.4. Schematic diagram of the second-stage amplifier and level-shifting circuit in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows how the conditioned signal is further amplified and shifted to a suitable DC level before digitization.&lt;br /&gt;
&lt;br /&gt;
==== Power Module and Drive-electrode Circuit ====&lt;br /&gt;
&lt;br /&gt;
The AFE is powered by a 5 V supply and also integrates a 1.5 V precision reference, a -5 V generation circuit, and a driveelectrode circuit. These supporting modules provide the required supply rails and reference level for analog signal conditioning, while the drive-electrode circuit feeds back common-mode voltage to the body to suppress interference at the source. As a result, the complete AFE can support sEMG acquisition with adequate gain, filtering, and noise-reduction performance in a compact hardware structure.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_5.jpg|thumb|center|800px|Figure 2.5. Physical picture of the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the fabricated sEMG analog front-end hardware used in the system.&lt;br /&gt;
&lt;br /&gt;
Figure 2.5 presents the practical hardware implementation of the proposed sEMG AFE. It integrates amplification, filtering, level shifting, and driven-reference functions in a compact circuit for weak bioelectrical signal acquisition.&lt;br /&gt;
&lt;br /&gt;
=== ADS1256-based ADC Board ===&lt;br /&gt;
&lt;br /&gt;
To digitize the conditioned weak physiological signals with sufficient resolution and low noise, this project developed a dedicated ADC board based on the ADS1256 analog-to-digital converter (Texas Instruments, Dallas, TX, USA) and the STM32F103C8T6 microcontroller (STMicroelectronics, Geneva, Switzerland). The overall design objective of this board was not merely to realize analog-to-digital conversion, but to provide a complete hardware interface between the analog front-end and the digital processing unit, including precision reference generation, clocking, input protection and filtering, serial communication, power regulation, and MCU-based acquisition control. The ADS1256 was selected because it is a&lt;br /&gt;
&lt;br /&gt;
very low-noise 24-bit delta-sigma converter with a programmable gain amplifier (PGA), flexible input multiplexer, programmable digital filter, and SPI-compatible serial interface, which makes it well suited for weak low-frequency physiological signals after analog conditioning. The STM32F103C8T6 was used as the local controller because it provides a 32-bit Cortex-M3 core, up to 72 MHz system clock, SPI, USART, USB, and standard SWD debugging support in a compact and low-cost platform.&lt;br /&gt;
&lt;br /&gt;
==== ADC Core Architecture and Design Rationale ====&lt;br /&gt;
&lt;br /&gt;
The ADS1256 was selected as the core ADC because it provides high-resolution, low-noise delta-sigma conversion with an input multiplexer, programmable gain amplifier, and digital filter, which are suitable for weak and low-frequency physiological signals. As shown in Figure 2.6, this architecture emphasizes resolution and noise performance rather than high conversion bandwidth, making it appropriate for sEMG signal digitization after analog conditioning.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_6.jpg|thumb|center|800px|Figure 2.6. Internal functional structure of the ADS1256 analog-to-digital converter.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the main internal blocks of the ADS1256, including the multiplexer, PGA, modulator, and digital filter.&lt;br /&gt;
&lt;br /&gt;
==== Analog Front-End Interface, Reference, and Clocking ====&lt;br /&gt;
&lt;br /&gt;
The ADS1256 analog inputs are connected to the external header through a passive input-conditioning network that helps suppress high-frequency interference and improve input stability. In addition, the board includes a dedicated precision reference and clocking circuits so that the ADC can perform stable and accurate conversion. Together, these circuits provide a reliable analog interface and timing basis for high-resolution digitization of weak physiological signals.&lt;br /&gt;
&lt;br /&gt;
==== SPI Interface between ADS1256 and STM32F103C8T6 ====&lt;br /&gt;
&lt;br /&gt;
Communication between the ADS1256 and the STM32F103C8T6 is implemented through an SPI-compatible interface, with dedicated lines for chip select, serial clock, input/output data, data-ready notification, and hardware reset. This connection allows the MCU to configure the ADC, read conversion results in synchrony with DRDY, and maintain efficient and reliable acquisition control for multi-channel physiological measurements.&lt;br /&gt;
&lt;br /&gt;
==== Power Supply and On-board Regulation ====&lt;br /&gt;
&lt;br /&gt;
The ADC board uses a USB Type-B connector as the main power input and includes protection, voltage regulation, and local decoupling circuits to provide a stable supply for both the MCU and ADC-related hardware. In addition, analog ground and digital ground are separated in the PCB layout to reduce digital noise coupling into the analog path, which is particularly important for weak physiological signal acquisition.&lt;br /&gt;
&lt;br /&gt;
==== Basic Peripheral Circuits of the STM32F103C8T6 ====&lt;br /&gt;
&lt;br /&gt;
The STM32F103C8T6 serves as the local controller of the ADC board and is supported by several basic peripheral circuits, including an external crystal oscillator, reset network, BOOT0 configuration, SWD programming/debugging header, and a CH340N USB-to-UART bridge. These circuits ensure stable MCU operation, convenient firmware downloading and debugging, and reliable data transmission from the board to the host computer for real-time display and storage.&lt;br /&gt;
&lt;br /&gt;
==== Hardware-level Working Principle of the ADC Board ====&lt;br /&gt;
&lt;br /&gt;
In operation, the conditioned analog signal from the AFE enters the ADS1256 through the input header, is digitized with high resolution under the control of the local precision reference and clock, and is then read by the STM32 through the SPI interface. The MCU subsequently forwards the sampled data to the host computer through the serial communication link, so that the entire board functions as a compact digital acquisition backend connecting weak physiological analog signals to later software processing, display, and storage.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_7.jpg|thumb|center|800px|Figure 2.7. Photograph of the fabricated ADS1256-based ADC board developed in this project and the definitions of some key pins.]]&lt;br /&gt;
&lt;br /&gt;
Figure 2.7 shows the ADC board fabricated for this project. It integrates the ADS1256 conversion core, STM32 control circuit, power-conditioning circuits, and communication interfaces on a compact PCB for physiological signal digitization.&lt;br /&gt;
&lt;br /&gt;
== Signal Conditioning and Filtering ==&lt;br /&gt;
Although the AFE already performs preliminary band-pass filtering and 50 Hz interference suppression in the analog domain, the digitized sEMG signal may still contain residual noise due to component tolerances, electrode-contact variation, and environmental interference. Therefore, an additional digital filtering stage is implemented in software as a complementary post-processing step to improve signal quality and to provide a more stable input for rectification, envelope extraction, and subsequent analysis. In this sense, the software filtering is not a simple repetition of the analog filtering, but a refinement and compensation for non-ideal front-end behavior.&lt;br /&gt;
&lt;br /&gt;
Surface electromyographic (sEMG) signals are highly susceptible to several sources of contamination during acquisition. In practical measurements, the dominant disturbances usually include low-frequency motion artifacts caused by electrode movement and electrode–skin impedance variation, narrow-band power-line interference centered at 50 Hz, and broadband high-frequency electronic noise introduced by the acquisition hardware. These unwanted components degrade the quality of the recorded signal and may significantly affect the reliability of subsequent feature extraction, parameter estimation, and muscle activity interpretation. For this reason, an effective signal-conditioning procedure is necessary before any higher-level analysis is performed.&lt;br /&gt;
&lt;br /&gt;
In the present implementation, the filtering strategy follows the principle of restricting the signal bandwidth first and then removing the remaining narrow-band interference in a targeted manner. Accordingly, the raw sEMG signal is first processed by a fourth-order Butterworth IIR band-pass filter and then by a 50 Hz notch filter. This processing sequence is illustrated in the flowchart below, where the signal passes through band-pass filtering, notch filtering, full-wave rectification, and envelope extraction before producing the final processed output.&lt;br /&gt;
&lt;br /&gt;
[[File:flowchart.png|thumb|center|500px|Flowchart of the real-time sEMG signal conditioning pipeline.]]&lt;br /&gt;
&lt;br /&gt;
The rationale of this order is that the &#039;&#039;&#039;band-pass stage&#039;&#039;&#039; first confines the signal to the main spectral region of interest for sEMG, thereby attenuating motion artifacts at very low frequencies and suppressing high-frequency noise components outside the physiological band. After this spectral preconditioning, the notch stage can more effectively suppress the residual 50 Hz power-line interference that lies inside the useful sEMG band. In transfer-function form, the band-pass filter may be written as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;H_{BP}(z)=\frac{B_{BP}(z)}{A_{BP}(z)}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where the effective passband is selected as &amp;lt;math&amp;gt;20 \leq f \leq 160 \text{ Hz}&amp;lt;/math&amp;gt;. This frequency interval is consistent with the dominant spectral content of surface EMG: the lower cutoff near 20 Hz reduces motion artifacts and unstable low-frequency fluctuations, whereas the upper cutoff near 160 Hz removes high-frequency electronic noise while preserving the main energy-bearing components of the muscle signal. The use of a Butterworth structure is appropriate here because it provides a smooth monotonic passband response without ripple, which helps preserve signal morphology in real-time applications.&lt;br /&gt;
&lt;br /&gt;
After band limitation, a &#039;&#039;&#039;notch filter&#039;&#039;&#039; centered at the power-line frequency is applied to suppress interference that cannot be removed by the band-pass stage alone. The notch filter is designed around &amp;lt;math&amp;gt;f_0 = 50 \text{ Hz}&amp;lt;/math&amp;gt;, and its bandwidth is controlled by the quality factor &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;, which is expressed as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;Q = \frac{f_0}{\Delta f}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In transfer-function form, the notch stage is written as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;H_{N}(z)=\frac{B_{N}(z)}{A_{N}(z)}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the implemented program, a large quality factor is chosen so that the notch remains narrow, allowing effective rejection of the 50 Hz interference while minimizing distortion of neighboring useful spectral components. This is particularly important for sEMG because the interference frequency lies directly inside the physiological band of interest.&lt;br /&gt;
&lt;br /&gt;
Following the filtering stages, further signal conditioning is performed to obtain a representation that is more directly related to muscle activation intensity. The filtered sEMG waveform is first &#039;&#039;&#039;full-wave rectified&#039;&#039;&#039;, which converts the bipolar oscillatory signal into a unipolar signal by taking its absolute value.  Rectification does not remove noise by itself; instead, it transforms the signal into a form that is more suitable for amplitude-based analysis because both positive and negative deflections contribute positively to the activation measure.&lt;br /&gt;
&lt;br /&gt;
After rectification, the signal envelope is extracted to provide a smooth estimate of muscle activation level over time. In a general formulation, the envelope can be described as the &#039;&#039;&#039;low-pass filtered&#039;&#039;&#039; version of the rectified signal, namely &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y_{\mathrm{env}}[n] = \mathrm{LPF}\bigl(y_{\mathrm{rect}}[n]\bigr)&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the present code implementation, this operation is realized by short-time averaging over a finite window, which is equivalent to a moving-average low-pass smoothing of the rectified waveform. The corresponding expression is &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y_{\mathrm{env}}[n] = \frac{1}{N}\sum_{k=0}^{N-1} |x[n-k]|&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; is the window length in samples. With a window duration of approximately 200 ms, this envelope extraction method provides a stable and physiologically meaningful representation of muscle activation intensity, making it suitable for tasks such as force estimation, fatigue analysis, and motor-control studies.&lt;br /&gt;
&lt;br /&gt;
An important feature of the present &#039;&#039;&#039;implementation&#039;&#039;&#039; is that the entire filtering process is performed &#039;&#039;&#039;in real time&#039;&#039;&#039;, sample by sample, rather than by offline block processing. For this reason, IIR filters are preferred over FIR filters, since they can achieve comparable filtering performance with lower order, lower computational cost, and shorter delay. These properties are especially valuable in embedded systems, serial data streaming, and other low-latency experimental applications. However, unlike memoryless operations, an IIR filter depends not only on the current input but also on previous inputs and previous outputs. Its discrete-time behavior can therefore be represented by the recursive difference equation &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y[n] = \sum_{k=0}^{M} b_k x[n-k] - \sum_{k=1}^{N} a_k y[n-k]&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This equation makes clear that internal filter states must be preserved continuously during streaming operation. If the state variables were reinitialized for every incoming sample or data segment, artificial transients would appear and the output would no longer remain continuous.&lt;br /&gt;
&lt;br /&gt;
In the Python implementation, this state continuity is maintained using the internal initial-condition mechanism provided by SciPy, such as &amp;lt;code&amp;gt;lfilter_zi&amp;lt;/code&amp;gt;, together with recursive state updates during each filtering call. As a result, each newly acquired sample is passed first through the band-pass filter and then through the notch filter, while the internal states of both filters are updated after every step. This state-preserving sample-by-sample design ensures that the processing chain remains causal, continuous, and suitable for real-time display or downstream analysis without requiring storage of the entire signal segment.&lt;br /&gt;
&lt;br /&gt;
Overall, this signal-conditioning scheme provides an experimentally practical solution for real-time sEMG processing. The fourth-order Butterworth band-pass filter confines the signal to the main physiological band of interest, the 50 Hz notch filter removes narrow-band power-line contamination, and the subsequent rectification and envelope extraction generate a smooth amplitude descriptor of muscle activity. Combined with state-preserved streaming IIR implementation, this approach achieves a good balance between signal fidelity, computational efficiency, and real-time applicability in biomedical and physical experiment settings.&lt;br /&gt;
&lt;br /&gt;
== Data Processing ==&lt;br /&gt;
&lt;br /&gt;
The objective of data processing is to convert raw surface electromyography (sEMG) recordings into stable, quantitative, and comparable indicators of muscle activity. Since EMG signals are low in amplitude, highly variable over time, and easily contaminated by noise, a dedicated processing pipeline is necessary before any experimental interpretation can be performed.&lt;br /&gt;
&lt;br /&gt;
In this project, the data processing workflow includes time normalization, signal pre-processing, sliding-window feature extraction, noise-floor estimation, and automatic contraction detection. The processed outputs are then used for subsequent experimental evaluation, including rest-versus-contraction discrimination, signal-to-noise ratio analysis, and repeatability assessment.&lt;br /&gt;
&lt;br /&gt;
=== Input Data and Time Normalization ===&lt;br /&gt;
&lt;br /&gt;
The acquired EMG data are read from CSV files containing two columns: time and filtered sEMG amplitude. In the MATLAB implementation, the time vector is normalized so that each recording starts from zero:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t = t_{all} - t_{all}(1)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This normalization is important because it removes the influence of absolute recording timestamps and makes different trials directly comparable on the same time axis.&lt;br /&gt;
&lt;br /&gt;
In addition, the signal type is automatically identified from the filename as either dynamic or rest. This design allows the same program to process both contraction recordings and resting recordings with different downstream analysis logic.&lt;br /&gt;
&lt;br /&gt;
=== Signal Pre-processing ===&lt;br /&gt;
&lt;br /&gt;
Raw EMG signals cannot be analyzed directly because they usually contain DC offset, low-frequency drift, motion artifacts, and residual high-frequency interference. Therefore, several pre-processing steps are applied before feature extraction.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(1) Baseline Removal&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The first step is DC offset removal:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
x_{dc}(t) = x(t) - \frac{1}{N}\sum_{i=1}^{N}x(i)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This operation centers the signal around zero. It is necessary because an uncorrected baseline would bias amplitude-based metrics and reduce the reliability of later envelope and feature calculations.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(2) Band-pass Filtering &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
After baseline correction, a fourth-order Butterworth band-pass filter is applied with a passband of 20–150 Hz.&lt;br /&gt;
&lt;br /&gt;
This step is introduced for two reasons:&lt;br /&gt;
&lt;br /&gt;
* The low-frequency cutoff at 20 Hz suppresses baseline drift and motion artifacts.&lt;br /&gt;
* The high-frequency cutoff at 150 Hz reduces unwanted high-frequency noise while preserving the main energy band of the recorded sEMG in this project.&lt;br /&gt;
&lt;br /&gt;
Compared with processing the raw waveform directly, band-pass filtering makes the subsequent time-domain features more stable and more physiologically meaningful.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(3) Full-wave Rectification&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The filtered EMG signal is bipolar, meaning that positive and negative phases coexist due to motor unit action potentials. If these positive and negative components are averaged directly, they may cancel each other out. To avoid this, full-wave rectification is performed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
x_{rect}(t) = |x_{filt}(t)|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This transforms the signal into a unipolar representation, so that all muscle activity contributes positively to the extracted features.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(4) Envelope Extraction &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Although the rectified signal reflects signal magnitude, it still fluctuates rapidly. To obtain a smoother representation of muscle activation level, an envelope is extracted using a moving average with a 100 ms window.&lt;br /&gt;
&lt;br /&gt;
Envelope extraction is important because contraction detection should reflect the overall activation trend rather than instantaneous spikes. A smoothed envelope is therefore more robust for identifying active and inactive muscle states.&lt;br /&gt;
&lt;br /&gt;
=== Sliding Window Design ===&lt;br /&gt;
&lt;br /&gt;
To quantify how muscle activity changes with time, the filtered signal is divided into overlapping short-time segments using a sliding window method.&lt;br /&gt;
&lt;br /&gt;
The window parameters are:&lt;br /&gt;
&lt;br /&gt;
* Window length: 250 ms&lt;br /&gt;
* Step size: 50 ms&lt;br /&gt;
&lt;br /&gt;
These values are chosen as a trade-off between temporal resolution and feature stability.&lt;br /&gt;
&lt;br /&gt;
A longer window improves statistical robustness because more samples are included in each calculation. However, if the window is too long, short contractions or rapid changes may be blurred. A smaller step size increases temporal continuity between adjacent feature points and makes the feature curves smoother in time. Therefore, the 250 ms / 50 ms design provides a practical balance between smoothing and time localization.&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt;-th segment, the feature time is defined as the mean time of that segment:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t_k = \frac{1}{N}\sum_{i=s_k}^{e_k} t(i)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;s_k&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;e_k&amp;lt;/math&amp;gt; denote the start and end indices of the window.&lt;br /&gt;
&lt;br /&gt;
=== Feature Extraction ===&lt;br /&gt;
&lt;br /&gt;
Within each sliding window, three time-domain features are extracted: RMS, iEMG, and MAV. These features are widely used in EMG analysis because they are simple, computationally efficient, and directly related to muscle activation intensity.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(1) Root Mean Square (RMS)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
RMS = \sqrt{\frac{1}{N}\sum_{i=1}^{N}x_i^2}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
RMS reflects the effective power of the EMG signal and is one of the most common indicators of contraction strength. It is sensitive to both amplitude and energy, making it especially useful for comparing rest and active states.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(2) Integrated EMG (iEMG)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
iEMG = \sum_{i=1}^{N}|x_i|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
iEMG describes the cumulative electrical activity within a window. It is often interpreted as a measure of total muscle effort over that time segment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(3) Mean Absolute Value (MAV)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
MAV = \frac{1}{N}\sum_{i=1}^{N}|x_i|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
MAV is an amplitude descriptor similar to iEMG, but normalized by the number of samples. It provides an efficient estimate of average signal level and is less computationally intensive than some other features.&lt;br /&gt;
&lt;br /&gt;
These three features are used together because they provide complementary descriptions of EMG intensity. RMS emphasizes signal energy, iEMG emphasizes cumulative activation, and MAV reflects average amplitude.&lt;br /&gt;
&lt;br /&gt;
=== Peak-value Extraction ===&lt;br /&gt;
&lt;br /&gt;
In addition to continuous feature curves, several key peak values are extracted from the processed signal:&lt;br /&gt;
&lt;br /&gt;
* maximum and minimum of the filtered EMG waveform&lt;br /&gt;
* peak of the envelope&lt;br /&gt;
* peak RMS&lt;br /&gt;
* peak iEMG&lt;br /&gt;
* peak MAV&lt;br /&gt;
&lt;br /&gt;
These peak values provide concise descriptors of the strongest activity observed in each recording. They are useful for quick comparison across trials and subjects.&lt;br /&gt;
&lt;br /&gt;
=== Noise Floor Estimation ===&lt;br /&gt;
&lt;br /&gt;
To evaluate signal quality, the noise floor is estimated from a reference resting interval. In the present implementation, the first 3 seconds of the recording are used as the default rest reference:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t \in [0,\min(3,t_{end})]&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this segment, three noise descriptors are computed:&lt;br /&gt;
&lt;br /&gt;
* Noise RMS&lt;br /&gt;
* Noise standard deviation&lt;br /&gt;
* Noise peak-to-peak amplitude&lt;br /&gt;
&lt;br /&gt;
Noise-floor estimation is important because EMG amplitude alone is not sufficient to judge recording quality. A large signal is only meaningful if it is sufficiently higher than the baseline noise level. Therefore, the noise floor serves as the reference for later SNR calculation and for designing contraction thresholds.&lt;br /&gt;
&lt;br /&gt;
=== Global Signal Metrics ===&lt;br /&gt;
&lt;br /&gt;
For each recording, three global metrics are also computed over the entire filtered signal:&lt;br /&gt;
&lt;br /&gt;
* Global RMS&lt;br /&gt;
* Global MAV&lt;br /&gt;
* Global iEMG&lt;br /&gt;
&lt;br /&gt;
These global descriptors summarize the overall signal level of the full recording and are later used in group-level comparisons.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Contraction Detection ===&lt;br /&gt;
&lt;br /&gt;
For dynamic recordings, an automatic contraction detection algorithm is used to identify repeated active segments. This is one of the key parts of the data processing pipeline, because it transforms a continuous EMG trace into discrete contraction events that can be counted and compared.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(1) Threshold Design&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The detection threshold is designed adaptively rather than using a fixed value. Two candidate thresholds are first calculated:&lt;br /&gt;
&lt;br /&gt;
* an envelope-based threshold derived from the global envelope mean and standard deviation&lt;br /&gt;
* a rest-reference threshold derived from the mean and standard deviation of the resting reference amplitude&lt;br /&gt;
&lt;br /&gt;
The final threshold is taken as the larger of the two after additional scaling. This strategy improves robustness because it combines the global activation level of the signal with the baseline noise characteristics of the individual recording.&lt;br /&gt;
&lt;br /&gt;
This adaptive threshold design is preferable to a manually fixed threshold because EMG amplitude can vary strongly between subjects, muscles, and recording sessions.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(2) Initial Segmentation&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
After thresholding the envelope, the signal is classified into active and inactive regions:&lt;br /&gt;
&lt;br /&gt;
* active: envelope above threshold&lt;br /&gt;
* inactive: envelope below threshold&lt;br /&gt;
&lt;br /&gt;
The rising and falling edges of the binary activity vector are then used to determine the start and end points of each candidate contraction segment.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(3) Removal of Short Segments&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Very short active regions are often caused by noise fluctuations rather than true muscle contractions. Therefore, segments shorter than 0.20 s are discarded.&lt;br /&gt;
&lt;br /&gt;
This step prevents false positive detections and increases the physiological relevance of the segmentation results.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(4) Merging of Adjacent Segments &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If two neighboring active segments are separated by a very short gap, they are merged when the gap is less than 0.15 s.&lt;br /&gt;
&lt;br /&gt;
This operation is necessary because a single real contraction may be temporarily interrupted by a brief drop in the envelope caused by local fluctuation. Without merging, one contraction could be incorrectly counted as multiple repetitions.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(5) Repetition-level Metrics &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
For each detected contraction segment, two repetition-level metrics are extracted:&lt;br /&gt;
&lt;br /&gt;
* peak RMS of that contraction&lt;br /&gt;
* mean RMS of that contraction&lt;br /&gt;
&lt;br /&gt;
These metrics quantify both the strongest activation within each repetition and the average activation level over the repetition duration.&lt;br /&gt;
&lt;br /&gt;
=== Repeatability Analysis ===&lt;br /&gt;
&lt;br /&gt;
When multiple valid contractions are detected, repeatability is evaluated using the coefficient of variation (CV):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
CV = \frac{\sigma}{\mu}\times 100\%&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt; is the standard deviation and &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is the mean value across repetitions.&lt;br /&gt;
&lt;br /&gt;
Two CV values are computed:&lt;br /&gt;
&lt;br /&gt;
* CV of repetition peak RMS&lt;br /&gt;
* CV of repetition mean RMS&lt;br /&gt;
&lt;br /&gt;
A lower CV indicates better repeatability, meaning that repeated contractions produce more consistent EMG responses.&lt;br /&gt;
&lt;br /&gt;
=== Signal-to-Noise Ratio (SNR) ===&lt;br /&gt;
&lt;br /&gt;
In this project, the signal-to-noise ratio (SNR) is defined based on the ratio between contraction and rest activity:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
SNR_{dB} = 20\log_{10}\left(\frac{RMS_{contraction}}{RMS_{rest}}\right)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This definition is adopted because it directly reflects the system’s ability to distinguish active muscle contraction from baseline noise.&lt;br /&gt;
&lt;br /&gt;
Compared with global SNR definitions, this formulation is more relevant for practical EMG applications such as activity detection and classification.&lt;br /&gt;
&lt;br /&gt;
=== Rest-versus-Contraction Window Comparison ===&lt;br /&gt;
&lt;br /&gt;
To further distinguish inactive and active states, all sliding windows are divided into two groups:&lt;br /&gt;
&lt;br /&gt;
* rest windows: windows with envelope clearly below the threshold&lt;br /&gt;
* contraction windows: windows with envelope above the threshold&lt;br /&gt;
&lt;br /&gt;
The RMS values of these two groups are then compared statistically.&lt;br /&gt;
&lt;br /&gt;
This comparison is important because a practical EMG system should not only detect signal presence, but also clearly separate rest from contraction in a quantitative way. If the two RMS distributions are well separated, it indicates that the system has good discriminative capability.&lt;br /&gt;
&lt;br /&gt;
=== Output Data Structure ===&lt;br /&gt;
&lt;br /&gt;
The processed outputs are organized into structured data for experimental analysis:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(1) Time-series outputs&#039;&#039;&#039;&lt;br /&gt;
* Filtered EMG signal  &lt;br /&gt;
* Rectified signal  &lt;br /&gt;
* Envelope  &lt;br /&gt;
* RMS(t), iEMG(t), MAV(t)  &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(2) Recording-level outputs&#039;&#039;&#039; &lt;br /&gt;
* RMS (rest)  &lt;br /&gt;
* RMS (contraction)  &lt;br /&gt;
* iEMG  &lt;br /&gt;
* Noise metrics  &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(3) Dynamic-signal outputs &#039;&#039;&#039;&lt;br /&gt;
* Detected contractions  &lt;br /&gt;
* Repetition count  &lt;br /&gt;
* Peak RMS per repetition  &lt;br /&gt;
* Mean RMS per repetition  &lt;br /&gt;
* Coefficient of variation (CV)  &lt;br /&gt;
* Signal-to-noise ratio (SNR)  &lt;br /&gt;
&lt;br /&gt;
All extracted features are designed to directly support the evaluation of noise level, signal quality, activity discrimination, and repeatability in the subsequent experimental analysis.&lt;br /&gt;
&lt;br /&gt;
== Experimental Results ==&lt;br /&gt;
&lt;br /&gt;
This section presents representative results of the EMG acquisition and data processing pipeline under both dynamic (muscle contraction) and resting conditions.&lt;br /&gt;
&lt;br /&gt;
=== Representative Dynamic Signal Analysis ===&lt;br /&gt;
&lt;br /&gt;
[[File:Dynamic_Figure1.png|thumb|800px|center|Figure 5.1: Processed EMG signal under dynamic contraction, including filtered signal, rectified signal with envelope, and extracted features (RMS, iEMG, MAV).]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.1 shows the processed EMG signal during repeated muscle contractions.&lt;br /&gt;
&lt;br /&gt;
The filtered EMG waveform exhibits clear burst-like patterns corresponding to periodic contractions. The signal amplitude reaches a maximum of approximately 0.45, while the baseline remains centered around zero, indicating effective baseline removal and filtering.&lt;br /&gt;
&lt;br /&gt;
After rectification and envelope extraction, the contraction periods become clearly distinguishable. The envelope provides a smooth representation of muscle activation, with a peak value of approximately 0.145.&lt;br /&gt;
&lt;br /&gt;
The extracted time-domain features (RMS, iEMG, MAV) further quantify the signal. Among these, iEMG shows the strongest dynamic variation, indicating high sensitivity to contraction intensity.&lt;br /&gt;
&lt;br /&gt;
=== Noise Floor and Rest Reference ===&lt;br /&gt;
&lt;br /&gt;
[[File:Dynamic_Figure2.png|thumb|800px|center|Figure 5.2: Noise estimation, rest vs contraction comparison, automatic contraction detection, and repetition analysis.]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (top-left) shows the resting reference segment used for noise estimation.&lt;br /&gt;
&lt;br /&gt;
The signal remains centered around zero with small fluctuations. The noise characteristics are:&lt;br /&gt;
&lt;br /&gt;
* Noise RMS ≈ 0.0046  &lt;br /&gt;
* Standard deviation ≈ 0.0046  &lt;br /&gt;
* Peak-to-peak amplitude ≈ 0.071  &lt;br /&gt;
&lt;br /&gt;
This indicates a low noise floor and stable measurement conditions.&lt;br /&gt;
&lt;br /&gt;
=== Rest vs Contraction Discrimination ===&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (top-right) compares RMS values between rest and contraction states.&lt;br /&gt;
&lt;br /&gt;
The two distributions are clearly separated:&lt;br /&gt;
&lt;br /&gt;
* Rest mean RMS ≈ 0.0053  &lt;br /&gt;
* Contraction mean RMS ≈ 0.1064  &lt;br /&gt;
&lt;br /&gt;
This corresponds to an approximate 20× increase, demonstrating strong discriminability between inactive and active muscle states.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Contraction Detection ===&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (bottom-left) illustrates automatic detection based on the envelope signal.&lt;br /&gt;
&lt;br /&gt;
A threshold of approximately 0.040 is applied, resulting in stable segmentation of contraction periods.&lt;br /&gt;
&lt;br /&gt;
A total of 12 repetitions are detected, with good alignment to visible signal peaks.&lt;br /&gt;
&lt;br /&gt;
=== Repeatability Analysis ===&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (bottom-right) shows the peak RMS value of each detected contraction.&lt;br /&gt;
&lt;br /&gt;
The results indicate:&lt;br /&gt;
&lt;br /&gt;
* Mean peak RMS ≈ 0.1355  &lt;br /&gt;
* Standard deviation ≈ 0.0173  &lt;br /&gt;
* CV ≈ 12.77%  &lt;br /&gt;
* SNR ≈ 21.26 dB  &lt;br /&gt;
&lt;br /&gt;
This indicates acceptable repeatability and good signal quality.&lt;br /&gt;
&lt;br /&gt;
=== Representative Rest Signal Analysis ===&lt;br /&gt;
&lt;br /&gt;
[[File:Rest_Figure1.png|thumb|800px|center|Figure 5.3: Processed EMG signal under rest condition, showing low amplitude and absence of contraction patterns.]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.3 shows the EMG signal under resting conditions.&lt;br /&gt;
&lt;br /&gt;
The signal remains within a narrow amplitude range (approximately ±0.04) and shows no burst-like structures. The envelope remains close to zero, confirming the absence of muscle activity.&lt;br /&gt;
&lt;br /&gt;
The extracted features remain low:&lt;br /&gt;
&lt;br /&gt;
* RMS ≈ 0.007  &lt;br /&gt;
* MAV ≈ 0.005  &lt;br /&gt;
* iEMG remains stable  &lt;br /&gt;
&lt;br /&gt;
This confirms that no false activation is detected.&lt;br /&gt;
&lt;br /&gt;
=== Frequency-domain Characteristics ===&lt;br /&gt;
&lt;br /&gt;
[[File:Rest_Figure2.png|thumb|800px|center|Figure 5.4: Frequency-domain analysis and statistical characteristics of rest signal.]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.4 shows the frequency-domain characteristics of the resting signal.&lt;br /&gt;
&lt;br /&gt;
The power spectral density (PSD) indicates low overall signal energy without dominant peaks, confirming that the signal mainly consists of noise.&lt;br /&gt;
&lt;br /&gt;
=== Summary of Single-recording Performance ===&lt;br /&gt;
&lt;br /&gt;
From the representative results:&lt;br /&gt;
&lt;br /&gt;
* EMG signals are effectively extracted and denoised  &lt;br /&gt;
* Contraction events are clearly identifiable  &lt;br /&gt;
* Rest and contraction states are well separated  &lt;br /&gt;
* Automatic detection is stable and accurate  &lt;br /&gt;
* Repeatability is acceptable  &lt;br /&gt;
* No false activation occurs under rest conditions  &lt;br /&gt;
&lt;br /&gt;
=== Consistency Across Multiple Recordings ===&lt;br /&gt;
&lt;br /&gt;
The same data processing pipeline was applied to multiple recordings from different subjects and trials.&lt;br /&gt;
&lt;br /&gt;
Across all datasets, consistent patterns were observed:&lt;br /&gt;
&lt;br /&gt;
* Dynamic signals exhibit clear burst-like structures corresponding to repeated muscle contractions  &lt;br /&gt;
* Rest signals remain low in amplitude without distinct activation patterns  &lt;br /&gt;
* RMS values under contraction are consistently higher than those under rest  &lt;br /&gt;
* The automatic detection algorithm reliably identifies contraction segments  &lt;br /&gt;
&lt;br /&gt;
Although quantitative values (e.g., RMS, SNR, CV) vary across recordings due to differences in electrode contact, muscle activation strength, and individual conditions, the overall trends remain consistent.&lt;br /&gt;
&lt;br /&gt;
These results demonstrate the robustness and general applicability of the proposed signal processing method.&lt;br /&gt;
&lt;br /&gt;
== Multi-subject Analysis ==&lt;br /&gt;
=== System Evaluation ===&lt;br /&gt;
&lt;br /&gt;
This section evaluates the performance of the EMG acquisition system in terms of noise level, signal quality, activity discrimination, and repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Noise Floor Analysis ====&lt;br /&gt;
&lt;br /&gt;
The noise floor was evaluated using rest-state recordings, characterized by RMS noise, standard deviation, and peak-to-peak amplitude.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039; shows the lowest noise level (RMS ≈ 0.0046), indicating stable electrode contact and minimal interference.  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039; exhibits moderate noise (RMS ≈ 0.0080), likely influenced by motion artifacts or electrode–skin impedance variation.  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039; shows relatively higher noise (RMS ≈ 0.0126), suggesting increased baseline fluctuation.  &lt;br /&gt;
&lt;br /&gt;
Overall, the system maintains a low noise floor across subjects, although the quality depends on experimental conditions such as electrode contact and environmental interference.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Signal-to-Noise Ratio (SNR) ====&lt;br /&gt;
&lt;br /&gt;
The signal-to-noise ratio (SNR) is defined as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{SNR (dB)} = 20 \log_{10} \left( \frac{\mathrm{RMS}_{\mathrm{contraction}}}{\mathrm{RMS}_{\mathrm{rest}}} \right)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The measured SNR values are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: 21.26 dB → good signal quality  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: 13.52 dB → moderate and usable  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: 6.66 dB → low signal clarity  &lt;br /&gt;
&lt;br /&gt;
General interpretation:&lt;br /&gt;
&lt;br /&gt;
* &amp;gt;20 dB → good  &lt;br /&gt;
* 10–20 dB → usable  &lt;br /&gt;
* &amp;lt;10 dB → poor  &lt;br /&gt;
&lt;br /&gt;
These results show that the system can achieve reliable signal acquisition, although performance varies across subjects.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
====  Rest vs Contraction Discrimination ====&lt;br /&gt;
&lt;br /&gt;
A clear distinction between rest and contraction states is observed based on RMS values.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: 0.0053 → 0.1064 (≈20× increase)  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: 0.0079 → 0.0283 (≈3.6× increase)  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: 0.0141 → 0.0646 (≈4.6× increase)  &lt;br /&gt;
&lt;br /&gt;
This demonstrates that the system is capable of separating muscle activity from baseline noise.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Conclusion:&#039;&#039;  &lt;br /&gt;
The system can be used for basic muscle activity detection and simple classification tasks based on RMS features.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Repeatability of Repeated Contractions ====&lt;br /&gt;
&lt;br /&gt;
Repeatability is evaluated using the coefficient of variation (CV) of peak RMS values across repetitions.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! CV Range !! Evaluation&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt; 10% || Excellent&lt;br /&gt;
|-&lt;br /&gt;
| 10–20% || Acceptable&lt;br /&gt;
|-&lt;br /&gt;
| &amp;gt; 20% || Poor&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Results:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: CV = 12.77% → Acceptable  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: CV = 24.77% → Poor  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: CV = 10.60% → Acceptable  &lt;br /&gt;
&lt;br /&gt;
Although WANG&#039;s signal is detectable, its contraction amplitude varies significantly across repetitions, resulting in poor repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
=== Overall System Performance ===&lt;br /&gt;
&lt;br /&gt;
The system demonstrates the following performance characteristics:&lt;br /&gt;
&lt;br /&gt;
* Reliable detection of muscle activity across all subjects  &lt;br /&gt;
* Clear separation between rest and contraction states  &lt;br /&gt;
* Moderate to high signal quality depending on subject conditions  &lt;br /&gt;
* Repeatability ranging from acceptable to poor due to user-dependent factors  &lt;br /&gt;
&lt;br /&gt;
Overall, the designed EMG acquisition system is capable of stable signal acquisition and feature extraction, with performance primarily influenced by electrode contact quality, skin impedance, and motion consistency.&lt;br /&gt;
&lt;br /&gt;
===== Summary of Quantitative Metrics =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Subject !! RMS (Rest) !! RMS (Contraction) !! Separation Ratio !! iEMG (max) !! Noise RMS !! SNR (dB) !! CV (%) !! Evaluation&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;LIU&#039;&#039;&#039; || 0.0053 || 0.1064 || &#039;&#039;&#039;20.1×&#039;&#039;&#039; || 12.72 || 0.0046 || &#039;&#039;&#039;21.26&#039;&#039;&#039; || 12.77 || Strong signal, good quality&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;WANG&#039;&#039;&#039; || 0.0079 || 0.0283 || 3.57× || 11.10 || 0.0080 || 13.52 || &#039;&#039;&#039;24.77&#039;&#039;&#039; || Usable signal, poor repeatability&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ZHONG&#039;&#039;&#039; || 0.0141 || 0.0646 || 4.58× || 6.70 || 0.0126 || 6.66 || 10.60 || Acceptable performance&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Summary:&#039;&#039; Subject LIU shows the best overall performance, WANG provides usable but less stable signals, and ZHONG demonstrates moderate signal quality with good repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Activation Intensity =====&lt;br /&gt;
&lt;br /&gt;
Among the three subjects, &#039;&#039;&#039;LIU exhibits the strongest muscle activation&#039;&#039;&#039;, as indicated by the highest contraction RMS and iEMG values. ZHONG shows moderate activation, while WANG demonstrates comparable iEMG but lower RMS consistency.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Signal Quality =====&lt;br /&gt;
&lt;br /&gt;
Signal quality is evaluated based on SNR and noise level:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039; achieves the highest SNR and lowest noise → best signal quality  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039; shows moderate SNR → usable but less robust  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039; has the lowest SNR → weakest signal clarity  &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Repeatability =====&lt;br /&gt;
&lt;br /&gt;
Repeatability is evaluated using the coefficient of variation (CV):&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;ZHONG (10.60%)&#039;&#039;&#039; → most stable  &lt;br /&gt;
* &#039;&#039;&#039;LIU (12.77%)&#039;&#039;&#039; → acceptable  &lt;br /&gt;
* &#039;&#039;&#039;WANG (24.77%)&#039;&#039;&#039; → poor  &lt;br /&gt;
&lt;br /&gt;
This indicates that WANG’s contraction strength varies significantly between repetitions.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Engineering Interpretation of Inter-subject Differences =====&lt;br /&gt;
&lt;br /&gt;
The observed differences are mainly attributed to engineering and experimental factors rather than physiological differences.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Electrode contact quality&#039;&#039;&#039;  &lt;br /&gt;
  Variations in electrode placement, pressure, and gel contact affect signal amplitude and stability.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Skin impedance&#039;&#039;&#039;  &lt;br /&gt;
  Differences in skin condition (hydration, oil, hair) influence electrode–skin impedance, affecting noise level and signal coupling.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Muscle control consistency&#039;&#039;&#039;  &lt;br /&gt;
  Variations in contraction strength and timing affect repeatability and CV.&lt;br /&gt;
&lt;br /&gt;
Therefore, the variation across subjects reflects practical acquisition conditions rather than intrinsic system limitations.&lt;/div&gt;</summary>
		<author><name>Wang Jingyi</name></author>
	</entry>
	<entry>
		<id>https://pc5271.org/index.php?title=Surface_EMG_Sensor_for_Muscle_Activity_Measurement:_AFE_Design_and_Signal_Processing&amp;diff=1360</id>
		<title>Surface EMG Sensor for Muscle Activity Measurement: AFE Design and Signal Processing</title>
		<link rel="alternate" type="text/html" href="https://pc5271.org/index.php?title=Surface_EMG_Sensor_for_Muscle_Activity_Measurement:_AFE_Design_and_Signal_Processing&amp;diff=1360"/>
		<updated>2026-04-23T06:46:57Z</updated>

		<summary type="html">&lt;p&gt;Wang Jingyi: /* Frequency-domain Characteristics */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Background and Theory==&lt;br /&gt;
&lt;br /&gt;
=== Surface EMG Signals ===&lt;br /&gt;
Surface electromyography (sEMG) refers to the bioelectrical signals detected on the skin surface during muscle contraction. These signals originate from the electrical activity of muscle fibers and provide a non-invasive way to monitor muscle activation. Compared with invasive EMG methods, sEMG is easier to apply, safer for repeated measurements, and more suitable for real-time monitoring. Therefore, it has been widely used in areas such as rehabilitation, motion analysis, human–machine interaction, and physiological monitoring.&lt;br /&gt;
&lt;br /&gt;
=== Characteristics of EMG Signals ===&lt;br /&gt;
EMG signals are generally weak, time-varying, and stochastic in nature. Their waveforms are typically bipolar, fluctuating around zero with both positive and negative components. The amplitude and frequency content of EMG signals depend on factors such as muscle contraction level, electrode placement, skin condition, and individual physiological differences. In practice, the useful frequency components of sEMG are mainly concentrated in a limited low-to-mid frequency range. Because of their low amplitude and variability, EMG signals usually require further conditioning before reliable interpretation and feature extraction can be performed.&lt;br /&gt;
&lt;br /&gt;
=== Bioelectrical Signal Acquisition Principles ===&lt;br /&gt;
The acquisition of bioelectrical signals is based on measuring the small potential difference on the skin surface using electrodes, then converting it into a processable electrical signal through amplification and digitization. For sEMG measurement, electrode placement and skin–electrode contact quality are especially important, since they directly affect signal amplitude and stability. In addition, the front-end acquisition circuit must provide sufficient sensitivity and good interference rejection, so that the recorded signal reflects actual muscle activity rather than environmental disturbance or poor contact conditions.&lt;br /&gt;
&lt;br /&gt;
=== Noise Sources in EMG (50 Hz, motion artifacts) ===&lt;br /&gt;
In practical EMG recording, the measured signal is easily contaminated by different types of noise. Two of the most common sources are power-line interference and motion artifacts. Power-line interference usually appears as a narrow-band component at 50 Hz in the local electrical environment, while motion artifacts are mainly caused by electrode movement, cable disturbance, or variations in the electrode–skin impedance, and are often concentrated in the low-frequency range. In addition, electronic noise from the acquisition hardware may also affect the recording quality. These unwanted components can reduce signal clarity and make muscle activity analysis less reliable, so they must be considered in the design of the signal processing pipeline.&lt;br /&gt;
[[File:background_theory_figure1.1_emg_noise_sources.png|center|thumb|700px|&#039;&#039;&#039;Figure 1.1.&#039;&#039;&#039; Principle of surface EMG acquisition.]]&lt;br /&gt;
&lt;br /&gt;
==System Architecture==&lt;br /&gt;
=== Total Structure Design ===&lt;br /&gt;
&lt;br /&gt;
For clarity，the proposed physiological signal acquisition system mainly consists of two core parts：the analog front－end （AFE）and the ADC board．The AFE is responsible for the preliminary conditioning of weak bioelectrical signals，including amplification，filtering，interference suppression，and level shifting，so that the analog waveform can be converted into a stable and measurable form．The ADC board then performs high－resolution digitization of the conditioned signal and transfers the sampled data to the host computer for subsequent display，storage，and analysis．Therefore，the overall system forms a complete signal－acquisition chain from weak physiological input to digital output．&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_1.jpg|thumb|center|800px|Figure 2.1. Overall system architecture of the proposed physiological signal acquisition platform，including the AFE and ADC modules．]]&lt;br /&gt;
&lt;br /&gt;
=== sEMG AFE Design ===&lt;br /&gt;
&lt;br /&gt;
To collect the weak bioelectric potential signals of the human body，an analog front－end（AFE）suitable sEMG measurements was designed．The module is powered by an external 5 V supply，and the complete circuit includes a first－ stage instrumentation amplifier based on INA128（Texas Instruments，Dallas，TX，USA），a band－pass filter，a 50 Hz notch filter，a second－order amplification and level shifting stage，a driver electrode circuit，a precise 1.5 V reference source，and a -5 V voltage generation module for powering the operational amplifiers．&lt;br /&gt;
&lt;br /&gt;
==== First－order Amplifier ====&lt;br /&gt;
&lt;br /&gt;
The input bioelectric signal is first acquired in differential form and applied to the INA128 instrumentation amplifier，which provides high input impedance，high common－mode rejection，and moderate initial gain for sEMG acquisition．This stage enlarges the weak physiological signal before filtering while reducing the risk of premature saturation caused by electrode offset or motion－induced disturbance，thereby preparing a more stable signal for the subsequent conditioning stages．&lt;br /&gt;
&lt;br /&gt;
==== Bandpass Filter ====&lt;br /&gt;
&lt;br /&gt;
After the instrumentation amplifier，the signal passes through a second－order active band－pass filter，as shown in Figure 2．2． This stage suppresses baseline drift and high－frequency noise outside the useful sEMG range，so that the low－frequency envelope information of sEMG can be preserved before further amplification．&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_2.jpg|thumb|center|800px|Figure 2.2. Schematic diagram of the active band-pass filter used in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the band-pass stage used to retain the main physiological signal band while suppressing unwanted lowand high-frequency components.&lt;br /&gt;
&lt;br /&gt;
==== Notch Filter ====&lt;br /&gt;
&lt;br /&gt;
To reduce power-line interference, a dedicated 50 Hz notch filter is introduced after the band-pass stage, as shown in Figure 2.3. This filter attenuates the mains-frequency component that commonly contaminates weak bioelectric measurements, thereby improving the signal-to-noise ratio of sEMG signals before the final amplification stage.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_3.jpg|thumb|center|800px|Figure 2.3. Schematic diagram of the 50 Hz notch filter used in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the circuit used to attenuate 50 Hz mains interference in the analog front end.&lt;br /&gt;
&lt;br /&gt;
==== Second-order Amplifier &amp;amp; Level Shifter ====&lt;br /&gt;
&lt;br /&gt;
After filtering, the signal enters the second-stage amplification and level-shifting circuit shown in Figure 2.4. In this stage, the filtered signal is further amplified to improve amplitude utilization and then shifted by a 1.5 V reference so that the output becomes a stable unipolar signal suitable for ADC sampling, while preserving linear operation and providing sufficient output swing margin.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_4.jpg|thumb|center|800px|Figure 2.4. Schematic diagram of the second-stage amplifier and level-shifting circuit in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows how the conditioned signal is further amplified and shifted to a suitable DC level before digitization.&lt;br /&gt;
&lt;br /&gt;
==== Power Module and Drive-electrode Circuit ====&lt;br /&gt;
&lt;br /&gt;
The AFE is powered by a 5 V supply and also integrates a 1.5 V precision reference, a -5 V generation circuit, and a driveelectrode circuit. These supporting modules provide the required supply rails and reference level for analog signal conditioning, while the drive-electrode circuit feeds back common-mode voltage to the body to suppress interference at the source. As a result, the complete AFE can support sEMG acquisition with adequate gain, filtering, and noise-reduction performance in a compact hardware structure.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_5.jpg|thumb|center|800px|Figure 2.5. Physical picture of the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the fabricated sEMG analog front-end hardware used in the system.&lt;br /&gt;
&lt;br /&gt;
Figure 2.5 presents the practical hardware implementation of the proposed sEMG AFE. It integrates amplification, filtering, level shifting, and driven-reference functions in a compact circuit for weak bioelectrical signal acquisition.&lt;br /&gt;
&lt;br /&gt;
=== ADS1256-based ADC Board ===&lt;br /&gt;
&lt;br /&gt;
To digitize the conditioned weak physiological signals with sufficient resolution and low noise, this project developed a dedicated ADC board based on the ADS1256 analog-to-digital converter (Texas Instruments, Dallas, TX, USA) and the STM32F103C8T6 microcontroller (STMicroelectronics, Geneva, Switzerland). The overall design objective of this board was not merely to realize analog-to-digital conversion, but to provide a complete hardware interface between the analog front-end and the digital processing unit, including precision reference generation, clocking, input protection and filtering, serial communication, power regulation, and MCU-based acquisition control. The ADS1256 was selected because it is a&lt;br /&gt;
&lt;br /&gt;
very low-noise 24-bit delta-sigma converter with a programmable gain amplifier (PGA), flexible input multiplexer, programmable digital filter, and SPI-compatible serial interface, which makes it well suited for weak low-frequency physiological signals after analog conditioning. The STM32F103C8T6 was used as the local controller because it provides a 32-bit Cortex-M3 core, up to 72 MHz system clock, SPI, USART, USB, and standard SWD debugging support in a compact and low-cost platform.&lt;br /&gt;
&lt;br /&gt;
==== ADC Core Architecture and Design Rationale ====&lt;br /&gt;
&lt;br /&gt;
The ADS1256 was selected as the core ADC because it provides high-resolution, low-noise delta-sigma conversion with an input multiplexer, programmable gain amplifier, and digital filter, which are suitable for weak and low-frequency physiological signals. As shown in Figure 2.6, this architecture emphasizes resolution and noise performance rather than high conversion bandwidth, making it appropriate for sEMG signal digitization after analog conditioning.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_6.jpg|thumb|center|800px|Figure 2.6. Internal functional structure of the ADS1256 analog-to-digital converter.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the main internal blocks of the ADS1256, including the multiplexer, PGA, modulator, and digital filter.&lt;br /&gt;
&lt;br /&gt;
==== Analog Front-End Interface, Reference, and Clocking ====&lt;br /&gt;
&lt;br /&gt;
The ADS1256 analog inputs are connected to the external header through a passive input-conditioning network that helps suppress high-frequency interference and improve input stability. In addition, the board includes a dedicated precision reference and clocking circuits so that the ADC can perform stable and accurate conversion. Together, these circuits provide a reliable analog interface and timing basis for high-resolution digitization of weak physiological signals.&lt;br /&gt;
&lt;br /&gt;
==== SPI Interface between ADS1256 and STM32F103C8T6 ====&lt;br /&gt;
&lt;br /&gt;
Communication between the ADS1256 and the STM32F103C8T6 is implemented through an SPI-compatible interface, with dedicated lines for chip select, serial clock, input/output data, data-ready notification, and hardware reset. This connection allows the MCU to configure the ADC, read conversion results in synchrony with DRDY, and maintain efficient and reliable acquisition control for multi-channel physiological measurements.&lt;br /&gt;
&lt;br /&gt;
==== Power Supply and On-board Regulation ====&lt;br /&gt;
&lt;br /&gt;
The ADC board uses a USB Type-B connector as the main power input and includes protection, voltage regulation, and local decoupling circuits to provide a stable supply for both the MCU and ADC-related hardware. In addition, analog ground and digital ground are separated in the PCB layout to reduce digital noise coupling into the analog path, which is particularly important for weak physiological signal acquisition.&lt;br /&gt;
&lt;br /&gt;
==== Basic Peripheral Circuits of the STM32F103C8T6 ====&lt;br /&gt;
&lt;br /&gt;
The STM32F103C8T6 serves as the local controller of the ADC board and is supported by several basic peripheral circuits, including an external crystal oscillator, reset network, BOOT0 configuration, SWD programming/debugging header, and a CH340N USB-to-UART bridge. These circuits ensure stable MCU operation, convenient firmware downloading and debugging, and reliable data transmission from the board to the host computer for real-time display and storage.&lt;br /&gt;
&lt;br /&gt;
==== Hardware-level Working Principle of the ADC Board ====&lt;br /&gt;
&lt;br /&gt;
In operation, the conditioned analog signal from the AFE enters the ADS1256 through the input header, is digitized with high resolution under the control of the local precision reference and clock, and is then read by the STM32 through the SPI interface. The MCU subsequently forwards the sampled data to the host computer through the serial communication link, so that the entire board functions as a compact digital acquisition backend connecting weak physiological analog signals to later software processing, display, and storage.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_7.jpg|thumb|center|800px|Figure 2.7. Photograph of the fabricated ADS1256-based ADC board developed in this project and the definitions of some key pins.]]&lt;br /&gt;
&lt;br /&gt;
Figure 2.7 shows the ADC board fabricated for this project. It integrates the ADS1256 conversion core, STM32 control circuit, power-conditioning circuits, and communication interfaces on a compact PCB for physiological signal digitization.&lt;br /&gt;
&lt;br /&gt;
== Signal Conditioning and Filtering ==&lt;br /&gt;
Although the AFE already performs preliminary band-pass filtering and 50 Hz interference suppression in the analog domain, the digitized sEMG signal may still contain residual noise due to component tolerances, electrode-contact variation, and environmental interference. Therefore, an additional digital filtering stage is implemented in software as a complementary post-processing step to improve signal quality and to provide a more stable input for rectification, envelope extraction, and subsequent analysis. In this sense, the software filtering is not a simple repetition of the analog filtering, but a refinement and compensation for non-ideal front-end behavior.&lt;br /&gt;
&lt;br /&gt;
Surface electromyographic (sEMG) signals are highly susceptible to several sources of contamination during acquisition. In practical measurements, the dominant disturbances usually include low-frequency motion artifacts caused by electrode movement and electrode–skin impedance variation, narrow-band power-line interference centered at 50 Hz, and broadband high-frequency electronic noise introduced by the acquisition hardware. These unwanted components degrade the quality of the recorded signal and may significantly affect the reliability of subsequent feature extraction, parameter estimation, and muscle activity interpretation. For this reason, an effective signal-conditioning procedure is necessary before any higher-level analysis is performed.&lt;br /&gt;
&lt;br /&gt;
In the present implementation, the filtering strategy follows the principle of restricting the signal bandwidth first and then removing the remaining narrow-band interference in a targeted manner. Accordingly, the raw sEMG signal is first processed by a fourth-order Butterworth IIR band-pass filter and then by a 50 Hz notch filter. This processing sequence is illustrated in the flowchart below, where the signal passes through band-pass filtering, notch filtering, full-wave rectification, and envelope extraction before producing the final processed output.&lt;br /&gt;
&lt;br /&gt;
[[File:flowchart.png|thumb|center|500px|Flowchart of the real-time sEMG signal conditioning pipeline.]]&lt;br /&gt;
&lt;br /&gt;
The rationale of this order is that the &#039;&#039;&#039;band-pass stage&#039;&#039;&#039; first confines the signal to the main spectral region of interest for sEMG, thereby attenuating motion artifacts at very low frequencies and suppressing high-frequency noise components outside the physiological band. After this spectral preconditioning, the notch stage can more effectively suppress the residual 50 Hz power-line interference that lies inside the useful sEMG band. In transfer-function form, the band-pass filter may be written as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;H_{BP}(z)=\frac{B_{BP}(z)}{A_{BP}(z)}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where the effective passband is selected as &amp;lt;math&amp;gt;20 \leq f \leq 160 \text{ Hz}&amp;lt;/math&amp;gt;. This frequency interval is consistent with the dominant spectral content of surface EMG: the lower cutoff near 20 Hz reduces motion artifacts and unstable low-frequency fluctuations, whereas the upper cutoff near 160 Hz removes high-frequency electronic noise while preserving the main energy-bearing components of the muscle signal. The use of a Butterworth structure is appropriate here because it provides a smooth monotonic passband response without ripple, which helps preserve signal morphology in real-time applications.&lt;br /&gt;
&lt;br /&gt;
After band limitation, a &#039;&#039;&#039;notch filter&#039;&#039;&#039; centered at the power-line frequency is applied to suppress interference that cannot be removed by the band-pass stage alone. The notch filter is designed around &amp;lt;math&amp;gt;f_0 = 50 \text{ Hz}&amp;lt;/math&amp;gt;, and its bandwidth is controlled by the quality factor &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;, which is expressed as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;Q = \frac{f_0}{\Delta f}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In transfer-function form, the notch stage is written as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;H_{N}(z)=\frac{B_{N}(z)}{A_{N}(z)}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the implemented program, a large quality factor is chosen so that the notch remains narrow, allowing effective rejection of the 50 Hz interference while minimizing distortion of neighboring useful spectral components. This is particularly important for sEMG because the interference frequency lies directly inside the physiological band of interest.&lt;br /&gt;
&lt;br /&gt;
Following the filtering stages, further signal conditioning is performed to obtain a representation that is more directly related to muscle activation intensity. The filtered sEMG waveform is first &#039;&#039;&#039;full-wave rectified&#039;&#039;&#039;, which converts the bipolar oscillatory signal into a unipolar signal by taking its absolute value.  Rectification does not remove noise by itself; instead, it transforms the signal into a form that is more suitable for amplitude-based analysis because both positive and negative deflections contribute positively to the activation measure.&lt;br /&gt;
&lt;br /&gt;
After rectification, the signal envelope is extracted to provide a smooth estimate of muscle activation level over time. In a general formulation, the envelope can be described as the &#039;&#039;&#039;low-pass filtered&#039;&#039;&#039; version of the rectified signal, namely &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y_{\mathrm{env}}[n] = \mathrm{LPF}\bigl(y_{\mathrm{rect}}[n]\bigr)&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the present code implementation, this operation is realized by short-time averaging over a finite window, which is equivalent to a moving-average low-pass smoothing of the rectified waveform. The corresponding expression is &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y_{\mathrm{env}}[n] = \frac{1}{N}\sum_{k=0}^{N-1} |x[n-k]|&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; is the window length in samples. With a window duration of approximately 200 ms, this envelope extraction method provides a stable and physiologically meaningful representation of muscle activation intensity, making it suitable for tasks such as force estimation, fatigue analysis, and motor-control studies.&lt;br /&gt;
&lt;br /&gt;
An important feature of the present &#039;&#039;&#039;implementation&#039;&#039;&#039; is that the entire filtering process is performed &#039;&#039;&#039;in real time&#039;&#039;&#039;, sample by sample, rather than by offline block processing. For this reason, IIR filters are preferred over FIR filters, since they can achieve comparable filtering performance with lower order, lower computational cost, and shorter delay. These properties are especially valuable in embedded systems, serial data streaming, and other low-latency experimental applications. However, unlike memoryless operations, an IIR filter depends not only on the current input but also on previous inputs and previous outputs. Its discrete-time behavior can therefore be represented by the recursive difference equation &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y[n] = \sum_{k=0}^{M} b_k x[n-k] - \sum_{k=1}^{N} a_k y[n-k]&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This equation makes clear that internal filter states must be preserved continuously during streaming operation. If the state variables were reinitialized for every incoming sample or data segment, artificial transients would appear and the output would no longer remain continuous.&lt;br /&gt;
&lt;br /&gt;
In the Python implementation, this state continuity is maintained using the internal initial-condition mechanism provided by SciPy, such as &amp;lt;code&amp;gt;lfilter_zi&amp;lt;/code&amp;gt;, together with recursive state updates during each filtering call. As a result, each newly acquired sample is passed first through the band-pass filter and then through the notch filter, while the internal states of both filters are updated after every step. This state-preserving sample-by-sample design ensures that the processing chain remains causal, continuous, and suitable for real-time display or downstream analysis without requiring storage of the entire signal segment.&lt;br /&gt;
&lt;br /&gt;
Overall, this signal-conditioning scheme provides an experimentally practical solution for real-time sEMG processing. The fourth-order Butterworth band-pass filter confines the signal to the main physiological band of interest, the 50 Hz notch filter removes narrow-band power-line contamination, and the subsequent rectification and envelope extraction generate a smooth amplitude descriptor of muscle activity. Combined with state-preserved streaming IIR implementation, this approach achieves a good balance between signal fidelity, computational efficiency, and real-time applicability in biomedical and physical experiment settings.&lt;br /&gt;
&lt;br /&gt;
== Data Processing ==&lt;br /&gt;
&lt;br /&gt;
The objective of data processing is to convert raw surface electromyography (sEMG) recordings into stable, quantitative, and comparable indicators of muscle activity. Since EMG signals are low in amplitude, highly variable over time, and easily contaminated by noise, a dedicated processing pipeline is necessary before any experimental interpretation can be performed.&lt;br /&gt;
&lt;br /&gt;
In this project, the data processing workflow includes time normalization, signal pre-processing, sliding-window feature extraction, noise-floor estimation, and automatic contraction detection. The processed outputs are then used for subsequent experimental evaluation, including rest-versus-contraction discrimination, signal-to-noise ratio analysis, and repeatability assessment.&lt;br /&gt;
&lt;br /&gt;
=== Input Data and Time Normalization ===&lt;br /&gt;
&lt;br /&gt;
The acquired EMG data are read from CSV files containing two columns: time and filtered sEMG amplitude. In the MATLAB implementation, the time vector is normalized so that each recording starts from zero:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t = t_{all} - t_{all}(1)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This normalization is important because it removes the influence of absolute recording timestamps and makes different trials directly comparable on the same time axis.&lt;br /&gt;
&lt;br /&gt;
In addition, the signal type is automatically identified from the filename as either dynamic or rest. This design allows the same program to process both contraction recordings and resting recordings with different downstream analysis logic.&lt;br /&gt;
&lt;br /&gt;
=== Signal Pre-processing ===&lt;br /&gt;
&lt;br /&gt;
Raw EMG signals cannot be analyzed directly because they usually contain DC offset, low-frequency drift, motion artifacts, and residual high-frequency interference. Therefore, several pre-processing steps are applied before feature extraction.&lt;br /&gt;
&lt;br /&gt;
==== Baseline Removal ====&lt;br /&gt;
&lt;br /&gt;
The first step is DC offset removal:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
x_{dc}(t) = x(t) - \frac{1}{N}\sum_{i=1}^{N}x(i)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This operation centers the signal around zero. It is necessary because an uncorrected baseline would bias amplitude-based metrics and reduce the reliability of later envelope and feature calculations.&lt;br /&gt;
&lt;br /&gt;
==== Band-pass Filtering ====&lt;br /&gt;
&lt;br /&gt;
After baseline correction, a fourth-order Butterworth band-pass filter is applied with a passband of 20–150 Hz.&lt;br /&gt;
&lt;br /&gt;
This step is introduced for two reasons:&lt;br /&gt;
&lt;br /&gt;
* The low-frequency cutoff at 20 Hz suppresses baseline drift and motion artifacts.&lt;br /&gt;
* The high-frequency cutoff at 150 Hz reduces unwanted high-frequency noise while preserving the main energy band of the recorded sEMG in this project.&lt;br /&gt;
&lt;br /&gt;
Compared with processing the raw waveform directly, band-pass filtering makes the subsequent time-domain features more stable and more physiologically meaningful.&lt;br /&gt;
&lt;br /&gt;
==== Full-wave Rectification ====&lt;br /&gt;
&lt;br /&gt;
The filtered EMG signal is bipolar, meaning that positive and negative phases coexist due to motor unit action potentials. If these positive and negative components are averaged directly, they may cancel each other out. To avoid this, full-wave rectification is performed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
x_{rect}(t) = |x_{filt}(t)|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This transforms the signal into a unipolar representation, so that all muscle activity contributes positively to the extracted features.&lt;br /&gt;
&lt;br /&gt;
==== Envelope Extraction ====&lt;br /&gt;
&lt;br /&gt;
Although the rectified signal reflects signal magnitude, it still fluctuates rapidly. To obtain a smoother representation of muscle activation level, an envelope is extracted using a moving average with a 100 ms window.&lt;br /&gt;
&lt;br /&gt;
Envelope extraction is important because contraction detection should reflect the overall activation trend rather than instantaneous spikes. A smoothed envelope is therefore more robust for identifying active and inactive muscle states.&lt;br /&gt;
&lt;br /&gt;
=== Sliding Window Design ===&lt;br /&gt;
&lt;br /&gt;
To quantify how muscle activity changes with time, the filtered signal is divided into overlapping short-time segments using a sliding window method.&lt;br /&gt;
&lt;br /&gt;
The window parameters are:&lt;br /&gt;
&lt;br /&gt;
* Window length: 250 ms&lt;br /&gt;
* Step size: 50 ms&lt;br /&gt;
&lt;br /&gt;
These values are chosen as a trade-off between temporal resolution and feature stability.&lt;br /&gt;
&lt;br /&gt;
A longer window improves statistical robustness because more samples are included in each calculation. However, if the window is too long, short contractions or rapid changes may be blurred. A smaller step size increases temporal continuity between adjacent feature points and makes the feature curves smoother in time. Therefore, the 250 ms / 50 ms design provides a practical balance between smoothing and time localization.&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt;-th segment, the feature time is defined as the mean time of that segment:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t_k = \frac{1}{N}\sum_{i=s_k}^{e_k} t(i)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;s_k&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;e_k&amp;lt;/math&amp;gt; denote the start and end indices of the window.&lt;br /&gt;
&lt;br /&gt;
=== Feature Extraction ===&lt;br /&gt;
&lt;br /&gt;
Within each sliding window, three time-domain features are extracted: RMS, iEMG, and MAV. These features are widely used in EMG analysis because they are simple, computationally efficient, and directly related to muscle activation intensity.&lt;br /&gt;
&lt;br /&gt;
==== Root Mean Square (RMS) ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
RMS = \sqrt{\frac{1}{N}\sum_{i=1}^{N}x_i^2}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
RMS reflects the effective power of the EMG signal and is one of the most common indicators of contraction strength. It is sensitive to both amplitude and energy, making it especially useful for comparing rest and active states.&lt;br /&gt;
&lt;br /&gt;
==== Integrated EMG (iEMG) ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
iEMG = \sum_{i=1}^{N}|x_i|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
iEMG describes the cumulative electrical activity within a window. It is often interpreted as a measure of total muscle effort over that time segment.&lt;br /&gt;
&lt;br /&gt;
==== Mean Absolute Value (MAV) ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
MAV = \frac{1}{N}\sum_{i=1}^{N}|x_i|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
MAV is an amplitude descriptor similar to iEMG, but normalized by the number of samples. It provides an efficient estimate of average signal level and is less computationally intensive than some other features.&lt;br /&gt;
&lt;br /&gt;
These three features are used together because they provide complementary descriptions of EMG intensity. RMS emphasizes signal energy, iEMG emphasizes cumulative activation, and MAV reflects average amplitude.&lt;br /&gt;
&lt;br /&gt;
=== Peak-value Extraction ===&lt;br /&gt;
&lt;br /&gt;
In addition to continuous feature curves, several key peak values are extracted from the processed signal:&lt;br /&gt;
&lt;br /&gt;
* maximum and minimum of the filtered EMG waveform&lt;br /&gt;
* peak of the envelope&lt;br /&gt;
* peak RMS&lt;br /&gt;
* peak iEMG&lt;br /&gt;
* peak MAV&lt;br /&gt;
&lt;br /&gt;
These peak values provide concise descriptors of the strongest activity observed in each recording. They are useful for quick comparison across trials and subjects.&lt;br /&gt;
&lt;br /&gt;
=== Noise Floor Estimation ===&lt;br /&gt;
&lt;br /&gt;
To evaluate signal quality, the noise floor is estimated from a reference resting interval. In the present implementation, the first 3 seconds of the recording are used as the default rest reference:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t \in [0,\min(3,t_{end})]&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this segment, three noise descriptors are computed:&lt;br /&gt;
&lt;br /&gt;
* Noise RMS&lt;br /&gt;
* Noise standard deviation&lt;br /&gt;
* Noise peak-to-peak amplitude&lt;br /&gt;
&lt;br /&gt;
Noise-floor estimation is important because EMG amplitude alone is not sufficient to judge recording quality. A large signal is only meaningful if it is sufficiently higher than the baseline noise level. Therefore, the noise floor serves as the reference for later SNR calculation and for designing contraction thresholds.&lt;br /&gt;
&lt;br /&gt;
=== Global Signal Metrics ===&lt;br /&gt;
&lt;br /&gt;
For each recording, three global metrics are also computed over the entire filtered signal:&lt;br /&gt;
&lt;br /&gt;
* Global RMS&lt;br /&gt;
* Global MAV&lt;br /&gt;
* Global iEMG&lt;br /&gt;
&lt;br /&gt;
These global descriptors summarize the overall signal level of the full recording and are later used in group-level comparisons.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Contraction Detection ===&lt;br /&gt;
&lt;br /&gt;
For dynamic recordings, an automatic contraction detection algorithm is used to identify repeated active segments. This is one of the key parts of the data processing pipeline, because it transforms a continuous EMG trace into discrete contraction events that can be counted and compared.&lt;br /&gt;
&lt;br /&gt;
==== Threshold Design ====&lt;br /&gt;
&lt;br /&gt;
The detection threshold is designed adaptively rather than using a fixed value. Two candidate thresholds are first calculated:&lt;br /&gt;
&lt;br /&gt;
* an envelope-based threshold derived from the global envelope mean and standard deviation&lt;br /&gt;
* a rest-reference threshold derived from the mean and standard deviation of the resting reference amplitude&lt;br /&gt;
&lt;br /&gt;
The final threshold is taken as the larger of the two after additional scaling. This strategy improves robustness because it combines the global activation level of the signal with the baseline noise characteristics of the individual recording.&lt;br /&gt;
&lt;br /&gt;
This adaptive threshold design is preferable to a manually fixed threshold because EMG amplitude can vary strongly between subjects, muscles, and recording sessions.&lt;br /&gt;
&lt;br /&gt;
==== Initial Segmentation ====&lt;br /&gt;
&lt;br /&gt;
After thresholding the envelope, the signal is classified into active and inactive regions:&lt;br /&gt;
&lt;br /&gt;
* active: envelope above threshold&lt;br /&gt;
* inactive: envelope below threshold&lt;br /&gt;
&lt;br /&gt;
The rising and falling edges of the binary activity vector are then used to determine the start and end points of each candidate contraction segment.&lt;br /&gt;
&lt;br /&gt;
==== Removal of Short Segments ====&lt;br /&gt;
&lt;br /&gt;
Very short active regions are often caused by noise fluctuations rather than true muscle contractions. Therefore, segments shorter than 0.20 s are discarded.&lt;br /&gt;
&lt;br /&gt;
This step prevents false positive detections and increases the physiological relevance of the segmentation results.&lt;br /&gt;
&lt;br /&gt;
==== Merging of Adjacent Segments ====&lt;br /&gt;
&lt;br /&gt;
If two neighboring active segments are separated by a very short gap, they are merged when the gap is less than 0.15 s.&lt;br /&gt;
&lt;br /&gt;
This operation is necessary because a single real contraction may be temporarily interrupted by a brief drop in the envelope caused by local fluctuation. Without merging, one contraction could be incorrectly counted as multiple repetitions.&lt;br /&gt;
&lt;br /&gt;
==== Repetition-level Metrics ====&lt;br /&gt;
&lt;br /&gt;
For each detected contraction segment, two repetition-level metrics are extracted:&lt;br /&gt;
&lt;br /&gt;
* peak RMS of that contraction&lt;br /&gt;
* mean RMS of that contraction&lt;br /&gt;
&lt;br /&gt;
These metrics quantify both the strongest activation within each repetition and the average activation level over the repetition duration.&lt;br /&gt;
&lt;br /&gt;
=== Repeatability Analysis ===&lt;br /&gt;
&lt;br /&gt;
When multiple valid contractions are detected, repeatability is evaluated using the coefficient of variation (CV):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
CV = \frac{\sigma}{\mu}\times 100\%&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt; is the standard deviation and &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is the mean value across repetitions.&lt;br /&gt;
&lt;br /&gt;
Two CV values are computed:&lt;br /&gt;
&lt;br /&gt;
* CV of repetition peak RMS&lt;br /&gt;
* CV of repetition mean RMS&lt;br /&gt;
&lt;br /&gt;
A lower CV indicates better repeatability, meaning that repeated contractions produce more consistent EMG responses.&lt;br /&gt;
&lt;br /&gt;
=== Signal-to-Noise Ratio (SNR) ===&lt;br /&gt;
&lt;br /&gt;
In this project, the signal-to-noise ratio (SNR) is defined based on the ratio between contraction and rest activity:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
SNR_{dB} = 20\log_{10}\left(\frac{RMS_{contraction}}{RMS_{rest}}\right)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This definition is adopted because it directly reflects the system’s ability to distinguish active muscle contraction from baseline noise.&lt;br /&gt;
&lt;br /&gt;
Compared with global SNR definitions, this formulation is more relevant for practical EMG applications such as activity detection and classification.&lt;br /&gt;
&lt;br /&gt;
=== Rest-versus-Contraction Window Comparison ===&lt;br /&gt;
&lt;br /&gt;
To further distinguish inactive and active states, all sliding windows are divided into two groups:&lt;br /&gt;
&lt;br /&gt;
* rest windows: windows with envelope clearly below the threshold&lt;br /&gt;
* contraction windows: windows with envelope above the threshold&lt;br /&gt;
&lt;br /&gt;
The RMS values of these two groups are then compared statistically.&lt;br /&gt;
&lt;br /&gt;
This comparison is important because a practical EMG system should not only detect signal presence, but also clearly separate rest from contraction in a quantitative way. If the two RMS distributions are well separated, it indicates that the system has good discriminative capability.&lt;br /&gt;
&lt;br /&gt;
=== Output Data Structure ===&lt;br /&gt;
&lt;br /&gt;
The processed outputs are organized into structured data for experimental analysis:&lt;br /&gt;
&lt;br /&gt;
==== Time-series outputs ====&lt;br /&gt;
* Filtered EMG signal  &lt;br /&gt;
* Rectified signal  &lt;br /&gt;
* Envelope  &lt;br /&gt;
* RMS(t), iEMG(t), MAV(t)  &lt;br /&gt;
&lt;br /&gt;
==== Recording-level outputs ====&lt;br /&gt;
* RMS (rest)  &lt;br /&gt;
* RMS (contraction)  &lt;br /&gt;
* iEMG  &lt;br /&gt;
* Noise metrics  &lt;br /&gt;
&lt;br /&gt;
==== Dynamic-signal outputs ====&lt;br /&gt;
* Detected contractions  &lt;br /&gt;
* Repetition count  &lt;br /&gt;
* Peak RMS per repetition  &lt;br /&gt;
* Mean RMS per repetition  &lt;br /&gt;
* Coefficient of variation (CV)  &lt;br /&gt;
* Signal-to-noise ratio (SNR)  &lt;br /&gt;
&lt;br /&gt;
All extracted features are designed to directly support the evaluation of noise level, signal quality, activity discrimination, and repeatability in the subsequent experimental analysis.&lt;br /&gt;
&lt;br /&gt;
== Experimental Results ==&lt;br /&gt;
&lt;br /&gt;
This section presents representative results of the EMG acquisition and data processing pipeline under both dynamic (muscle contraction) and resting conditions.&lt;br /&gt;
&lt;br /&gt;
=== Representative Dynamic Signal Analysis ===&lt;br /&gt;
&lt;br /&gt;
[[File:Dynamic_Figure1.png|thumb|800px|center|Figure 5.1: Processed EMG signal under dynamic contraction, including filtered signal, rectified signal with envelope, and extracted features (RMS, iEMG, MAV).]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.1 shows the processed EMG signal during repeated muscle contractions.&lt;br /&gt;
&lt;br /&gt;
The filtered EMG waveform exhibits clear burst-like patterns corresponding to periodic contractions. The signal amplitude reaches a maximum of approximately 0.45, while the baseline remains centered around zero, indicating effective baseline removal and filtering.&lt;br /&gt;
&lt;br /&gt;
After rectification and envelope extraction, the contraction periods become clearly distinguishable. The envelope provides a smooth representation of muscle activation, with a peak value of approximately 0.145.&lt;br /&gt;
&lt;br /&gt;
The extracted time-domain features (RMS, iEMG, MAV) further quantify the signal. Among these, iEMG shows the strongest dynamic variation, indicating high sensitivity to contraction intensity.&lt;br /&gt;
&lt;br /&gt;
=== Noise Floor and Rest Reference ===&lt;br /&gt;
&lt;br /&gt;
[[File:Dynamic_Figure2.png|thumb|800px|center|Figure 5.2: Noise estimation, rest vs contraction comparison, automatic contraction detection, and repetition analysis.]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (top-left) shows the resting reference segment used for noise estimation.&lt;br /&gt;
&lt;br /&gt;
The signal remains centered around zero with small fluctuations. The noise characteristics are:&lt;br /&gt;
&lt;br /&gt;
* Noise RMS ≈ 0.0046  &lt;br /&gt;
* Standard deviation ≈ 0.0046  &lt;br /&gt;
* Peak-to-peak amplitude ≈ 0.071  &lt;br /&gt;
&lt;br /&gt;
This indicates a low noise floor and stable measurement conditions.&lt;br /&gt;
&lt;br /&gt;
=== Rest vs Contraction Discrimination ===&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (top-right) compares RMS values between rest and contraction states.&lt;br /&gt;
&lt;br /&gt;
The two distributions are clearly separated:&lt;br /&gt;
&lt;br /&gt;
* Rest mean RMS ≈ 0.0053  &lt;br /&gt;
* Contraction mean RMS ≈ 0.1064  &lt;br /&gt;
&lt;br /&gt;
This corresponds to an approximate 20× increase, demonstrating strong discriminability between inactive and active muscle states.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Contraction Detection ===&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (bottom-left) illustrates automatic detection based on the envelope signal.&lt;br /&gt;
&lt;br /&gt;
A threshold of approximately 0.040 is applied, resulting in stable segmentation of contraction periods.&lt;br /&gt;
&lt;br /&gt;
A total of 12 repetitions are detected, with good alignment to visible signal peaks.&lt;br /&gt;
&lt;br /&gt;
=== Repeatability Analysis ===&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (bottom-right) shows the peak RMS value of each detected contraction.&lt;br /&gt;
&lt;br /&gt;
The results indicate:&lt;br /&gt;
&lt;br /&gt;
* Mean peak RMS ≈ 0.1355  &lt;br /&gt;
* Standard deviation ≈ 0.0173  &lt;br /&gt;
* CV ≈ 12.77%  &lt;br /&gt;
* SNR ≈ 21.26 dB  &lt;br /&gt;
&lt;br /&gt;
This indicates acceptable repeatability and good signal quality.&lt;br /&gt;
&lt;br /&gt;
=== Representative Rest Signal Analysis ===&lt;br /&gt;
&lt;br /&gt;
[[File:Rest_Figure1.png|thumb|800px|center|Figure 5.3: Processed EMG signal under rest condition, showing low amplitude and absence of contraction patterns.]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.3 shows the EMG signal under resting conditions.&lt;br /&gt;
&lt;br /&gt;
The signal remains within a narrow amplitude range (approximately ±0.04) and shows no burst-like structures. The envelope remains close to zero, confirming the absence of muscle activity.&lt;br /&gt;
&lt;br /&gt;
The extracted features remain low:&lt;br /&gt;
&lt;br /&gt;
* RMS ≈ 0.007  &lt;br /&gt;
* MAV ≈ 0.005  &lt;br /&gt;
* iEMG remains stable  &lt;br /&gt;
&lt;br /&gt;
This confirms that no false activation is detected.&lt;br /&gt;
&lt;br /&gt;
=== Frequency-domain Characteristics ===&lt;br /&gt;
&lt;br /&gt;
[[File:Rest_Figure2.png|thumb|800px|center|Figure 5.4: Frequency-domain analysis and statistical characteristics of rest signal.]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.4 shows the frequency-domain characteristics of the resting signal.&lt;br /&gt;
&lt;br /&gt;
The power spectral density (PSD) indicates low overall signal energy without dominant peaks, confirming that the signal mainly consists of noise.&lt;br /&gt;
&lt;br /&gt;
=== Summary of Single-recording Performance ===&lt;br /&gt;
&lt;br /&gt;
From the representative results:&lt;br /&gt;
&lt;br /&gt;
* EMG signals are effectively extracted and denoised  &lt;br /&gt;
* Contraction events are clearly identifiable  &lt;br /&gt;
* Rest and contraction states are well separated  &lt;br /&gt;
* Automatic detection is stable and accurate  &lt;br /&gt;
* Repeatability is acceptable  &lt;br /&gt;
* No false activation occurs under rest conditions  &lt;br /&gt;
&lt;br /&gt;
=== Consistency Across Multiple Recordings ===&lt;br /&gt;
&lt;br /&gt;
The same data processing pipeline was applied to multiple recordings from different subjects and trials.&lt;br /&gt;
&lt;br /&gt;
Across all datasets, consistent patterns were observed:&lt;br /&gt;
&lt;br /&gt;
* Dynamic signals exhibit clear burst-like structures corresponding to repeated muscle contractions  &lt;br /&gt;
* Rest signals remain low in amplitude without distinct activation patterns  &lt;br /&gt;
* RMS values under contraction are consistently higher than those under rest  &lt;br /&gt;
* The automatic detection algorithm reliably identifies contraction segments  &lt;br /&gt;
&lt;br /&gt;
Although quantitative values (e.g., RMS, SNR, CV) vary across recordings due to differences in electrode contact, muscle activation strength, and individual conditions, the overall trends remain consistent.&lt;br /&gt;
&lt;br /&gt;
These results demonstrate the robustness and general applicability of the proposed signal processing method.&lt;br /&gt;
&lt;br /&gt;
== Multi-subject Analysis ==&lt;br /&gt;
=== System Evaluation ===&lt;br /&gt;
&lt;br /&gt;
This section evaluates the performance of the EMG acquisition system in terms of noise level, signal quality, activity discrimination, and repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Noise Floor Analysis ====&lt;br /&gt;
&lt;br /&gt;
The noise floor was evaluated using rest-state recordings, characterized by RMS noise, standard deviation, and peak-to-peak amplitude.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039; shows the lowest noise level (RMS ≈ 0.0046), indicating stable electrode contact and minimal interference.  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039; exhibits moderate noise (RMS ≈ 0.0080), likely influenced by motion artifacts or electrode–skin impedance variation.  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039; shows relatively higher noise (RMS ≈ 0.0126), suggesting increased baseline fluctuation.  &lt;br /&gt;
&lt;br /&gt;
Overall, the system maintains a low noise floor across subjects, although the quality depends on experimental conditions such as electrode contact and environmental interference.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Signal-to-Noise Ratio (SNR) ====&lt;br /&gt;
&lt;br /&gt;
The signal-to-noise ratio (SNR) is defined as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{SNR (dB)} = 20 \log_{10} \left( \frac{\mathrm{RMS}_{\mathrm{contraction}}}{\mathrm{RMS}_{\mathrm{rest}}} \right)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The measured SNR values are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: 21.26 dB → good signal quality  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: 13.52 dB → moderate and usable  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: 6.66 dB → low signal clarity  &lt;br /&gt;
&lt;br /&gt;
General interpretation:&lt;br /&gt;
&lt;br /&gt;
* &amp;gt;20 dB → good  &lt;br /&gt;
* 10–20 dB → usable  &lt;br /&gt;
* &amp;lt;10 dB → poor  &lt;br /&gt;
&lt;br /&gt;
These results show that the system can achieve reliable signal acquisition, although performance varies across subjects.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
====  Rest vs Contraction Discrimination ====&lt;br /&gt;
&lt;br /&gt;
A clear distinction between rest and contraction states is observed based on RMS values.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: 0.0053 → 0.1064 (≈20× increase)  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: 0.0079 → 0.0283 (≈3.6× increase)  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: 0.0141 → 0.0646 (≈4.6× increase)  &lt;br /&gt;
&lt;br /&gt;
This demonstrates that the system is capable of separating muscle activity from baseline noise.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Conclusion:&#039;&#039;  &lt;br /&gt;
The system can be used for basic muscle activity detection and simple classification tasks based on RMS features.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Repeatability of Repeated Contractions ====&lt;br /&gt;
&lt;br /&gt;
Repeatability is evaluated using the coefficient of variation (CV) of peak RMS values across repetitions.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! CV Range !! Evaluation&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt; 10% || Excellent&lt;br /&gt;
|-&lt;br /&gt;
| 10–20% || Acceptable&lt;br /&gt;
|-&lt;br /&gt;
| &amp;gt; 20% || Poor&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Results:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: CV = 12.77% → Acceptable  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: CV = 24.77% → Poor  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: CV = 10.60% → Acceptable  &lt;br /&gt;
&lt;br /&gt;
Although WANG&#039;s signal is detectable, its contraction amplitude varies significantly across repetitions, resulting in poor repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
=== Overall System Performance ===&lt;br /&gt;
&lt;br /&gt;
The system demonstrates the following performance characteristics:&lt;br /&gt;
&lt;br /&gt;
* Reliable detection of muscle activity across all subjects  &lt;br /&gt;
* Clear separation between rest and contraction states  &lt;br /&gt;
* Moderate to high signal quality depending on subject conditions  &lt;br /&gt;
* Repeatability ranging from acceptable to poor due to user-dependent factors  &lt;br /&gt;
&lt;br /&gt;
Overall, the designed EMG acquisition system is capable of stable signal acquisition and feature extraction, with performance primarily influenced by electrode contact quality, skin impedance, and motion consistency.&lt;br /&gt;
&lt;br /&gt;
===== Summary of Quantitative Metrics =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Subject !! RMS (Rest) !! RMS (Contraction) !! Separation Ratio !! iEMG (max) !! Noise RMS !! SNR (dB) !! CV (%) !! Evaluation&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;LIU&#039;&#039;&#039; || 0.0053 || 0.1064 || &#039;&#039;&#039;20.1×&#039;&#039;&#039; || 12.72 || 0.0046 || &#039;&#039;&#039;21.26&#039;&#039;&#039; || 12.77 || Strong signal, good quality&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;WANG&#039;&#039;&#039; || 0.0079 || 0.0283 || 3.57× || 11.10 || 0.0080 || 13.52 || &#039;&#039;&#039;24.77&#039;&#039;&#039; || Usable signal, poor repeatability&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ZHONG&#039;&#039;&#039; || 0.0141 || 0.0646 || 4.58× || 6.70 || 0.0126 || 6.66 || 10.60 || Acceptable performance&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Summary:&#039;&#039; Subject LIU shows the best overall performance, WANG provides usable but less stable signals, and ZHONG demonstrates moderate signal quality with good repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Activation Intensity =====&lt;br /&gt;
&lt;br /&gt;
Among the three subjects, &#039;&#039;&#039;LIU exhibits the strongest muscle activation&#039;&#039;&#039;, as indicated by the highest contraction RMS and iEMG values. ZHONG shows moderate activation, while WANG demonstrates comparable iEMG but lower RMS consistency.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Signal Quality =====&lt;br /&gt;
&lt;br /&gt;
Signal quality is evaluated based on SNR and noise level:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039; achieves the highest SNR and lowest noise → best signal quality  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039; shows moderate SNR → usable but less robust  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039; has the lowest SNR → weakest signal clarity  &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Repeatability =====&lt;br /&gt;
&lt;br /&gt;
Repeatability is evaluated using the coefficient of variation (CV):&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;ZHONG (10.60%)&#039;&#039;&#039; → most stable  &lt;br /&gt;
* &#039;&#039;&#039;LIU (12.77%)&#039;&#039;&#039; → acceptable  &lt;br /&gt;
* &#039;&#039;&#039;WANG (24.77%)&#039;&#039;&#039; → poor  &lt;br /&gt;
&lt;br /&gt;
This indicates that WANG’s contraction strength varies significantly between repetitions.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Engineering Interpretation of Inter-subject Differences =====&lt;br /&gt;
&lt;br /&gt;
The observed differences are mainly attributed to engineering and experimental factors rather than physiological differences.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Electrode contact quality&#039;&#039;&#039;  &lt;br /&gt;
  Variations in electrode placement, pressure, and gel contact affect signal amplitude and stability.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Skin impedance&#039;&#039;&#039;  &lt;br /&gt;
  Differences in skin condition (hydration, oil, hair) influence electrode–skin impedance, affecting noise level and signal coupling.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Muscle control consistency&#039;&#039;&#039;  &lt;br /&gt;
  Variations in contraction strength and timing affect repeatability and CV.&lt;br /&gt;
&lt;br /&gt;
Therefore, the variation across subjects reflects practical acquisition conditions rather than intrinsic system limitations.&lt;/div&gt;</summary>
		<author><name>Wang Jingyi</name></author>
	</entry>
	<entry>
		<id>https://pc5271.org/index.php?title=Surface_EMG_Sensor_for_Muscle_Activity_Measurement:_AFE_Design_and_Signal_Processing&amp;diff=1359</id>
		<title>Surface EMG Sensor for Muscle Activity Measurement: AFE Design and Signal Processing</title>
		<link rel="alternate" type="text/html" href="https://pc5271.org/index.php?title=Surface_EMG_Sensor_for_Muscle_Activity_Measurement:_AFE_Design_and_Signal_Processing&amp;diff=1359"/>
		<updated>2026-04-23T06:46:37Z</updated>

		<summary type="html">&lt;p&gt;Wang Jingyi: /* Representative Rest Signal Analysis */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Background and Theory==&lt;br /&gt;
&lt;br /&gt;
=== Surface EMG Signals ===&lt;br /&gt;
Surface electromyography (sEMG) refers to the bioelectrical signals detected on the skin surface during muscle contraction. These signals originate from the electrical activity of muscle fibers and provide a non-invasive way to monitor muscle activation. Compared with invasive EMG methods, sEMG is easier to apply, safer for repeated measurements, and more suitable for real-time monitoring. Therefore, it has been widely used in areas such as rehabilitation, motion analysis, human–machine interaction, and physiological monitoring.&lt;br /&gt;
&lt;br /&gt;
=== Characteristics of EMG Signals ===&lt;br /&gt;
EMG signals are generally weak, time-varying, and stochastic in nature. Their waveforms are typically bipolar, fluctuating around zero with both positive and negative components. The amplitude and frequency content of EMG signals depend on factors such as muscle contraction level, electrode placement, skin condition, and individual physiological differences. In practice, the useful frequency components of sEMG are mainly concentrated in a limited low-to-mid frequency range. Because of their low amplitude and variability, EMG signals usually require further conditioning before reliable interpretation and feature extraction can be performed.&lt;br /&gt;
&lt;br /&gt;
=== Bioelectrical Signal Acquisition Principles ===&lt;br /&gt;
The acquisition of bioelectrical signals is based on measuring the small potential difference on the skin surface using electrodes, then converting it into a processable electrical signal through amplification and digitization. For sEMG measurement, electrode placement and skin–electrode contact quality are especially important, since they directly affect signal amplitude and stability. In addition, the front-end acquisition circuit must provide sufficient sensitivity and good interference rejection, so that the recorded signal reflects actual muscle activity rather than environmental disturbance or poor contact conditions.&lt;br /&gt;
&lt;br /&gt;
=== Noise Sources in EMG (50 Hz, motion artifacts) ===&lt;br /&gt;
In practical EMG recording, the measured signal is easily contaminated by different types of noise. Two of the most common sources are power-line interference and motion artifacts. Power-line interference usually appears as a narrow-band component at 50 Hz in the local electrical environment, while motion artifacts are mainly caused by electrode movement, cable disturbance, or variations in the electrode–skin impedance, and are often concentrated in the low-frequency range. In addition, electronic noise from the acquisition hardware may also affect the recording quality. These unwanted components can reduce signal clarity and make muscle activity analysis less reliable, so they must be considered in the design of the signal processing pipeline.&lt;br /&gt;
[[File:background_theory_figure1.1_emg_noise_sources.png|center|thumb|700px|&#039;&#039;&#039;Figure 1.1.&#039;&#039;&#039; Principle of surface EMG acquisition.]]&lt;br /&gt;
&lt;br /&gt;
==System Architecture==&lt;br /&gt;
=== Total Structure Design ===&lt;br /&gt;
&lt;br /&gt;
For clarity，the proposed physiological signal acquisition system mainly consists of two core parts：the analog front－end （AFE）and the ADC board．The AFE is responsible for the preliminary conditioning of weak bioelectrical signals，including amplification，filtering，interference suppression，and level shifting，so that the analog waveform can be converted into a stable and measurable form．The ADC board then performs high－resolution digitization of the conditioned signal and transfers the sampled data to the host computer for subsequent display，storage，and analysis．Therefore，the overall system forms a complete signal－acquisition chain from weak physiological input to digital output．&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_1.jpg|thumb|center|800px|Figure 2.1. Overall system architecture of the proposed physiological signal acquisition platform，including the AFE and ADC modules．]]&lt;br /&gt;
&lt;br /&gt;
=== sEMG AFE Design ===&lt;br /&gt;
&lt;br /&gt;
To collect the weak bioelectric potential signals of the human body，an analog front－end（AFE）suitable sEMG measurements was designed．The module is powered by an external 5 V supply，and the complete circuit includes a first－ stage instrumentation amplifier based on INA128（Texas Instruments，Dallas，TX，USA），a band－pass filter，a 50 Hz notch filter，a second－order amplification and level shifting stage，a driver electrode circuit，a precise 1.5 V reference source，and a -5 V voltage generation module for powering the operational amplifiers．&lt;br /&gt;
&lt;br /&gt;
==== First－order Amplifier ====&lt;br /&gt;
&lt;br /&gt;
The input bioelectric signal is first acquired in differential form and applied to the INA128 instrumentation amplifier，which provides high input impedance，high common－mode rejection，and moderate initial gain for sEMG acquisition．This stage enlarges the weak physiological signal before filtering while reducing the risk of premature saturation caused by electrode offset or motion－induced disturbance，thereby preparing a more stable signal for the subsequent conditioning stages．&lt;br /&gt;
&lt;br /&gt;
==== Bandpass Filter ====&lt;br /&gt;
&lt;br /&gt;
After the instrumentation amplifier，the signal passes through a second－order active band－pass filter，as shown in Figure 2．2． This stage suppresses baseline drift and high－frequency noise outside the useful sEMG range，so that the low－frequency envelope information of sEMG can be preserved before further amplification．&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_2.jpg|thumb|center|800px|Figure 2.2. Schematic diagram of the active band-pass filter used in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the band-pass stage used to retain the main physiological signal band while suppressing unwanted lowand high-frequency components.&lt;br /&gt;
&lt;br /&gt;
==== Notch Filter ====&lt;br /&gt;
&lt;br /&gt;
To reduce power-line interference, a dedicated 50 Hz notch filter is introduced after the band-pass stage, as shown in Figure 2.3. This filter attenuates the mains-frequency component that commonly contaminates weak bioelectric measurements, thereby improving the signal-to-noise ratio of sEMG signals before the final amplification stage.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_3.jpg|thumb|center|800px|Figure 2.3. Schematic diagram of the 50 Hz notch filter used in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the circuit used to attenuate 50 Hz mains interference in the analog front end.&lt;br /&gt;
&lt;br /&gt;
==== Second-order Amplifier &amp;amp; Level Shifter ====&lt;br /&gt;
&lt;br /&gt;
After filtering, the signal enters the second-stage amplification and level-shifting circuit shown in Figure 2.4. In this stage, the filtered signal is further amplified to improve amplitude utilization and then shifted by a 1.5 V reference so that the output becomes a stable unipolar signal suitable for ADC sampling, while preserving linear operation and providing sufficient output swing margin.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_4.jpg|thumb|center|800px|Figure 2.4. Schematic diagram of the second-stage amplifier and level-shifting circuit in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows how the conditioned signal is further amplified and shifted to a suitable DC level before digitization.&lt;br /&gt;
&lt;br /&gt;
==== Power Module and Drive-electrode Circuit ====&lt;br /&gt;
&lt;br /&gt;
The AFE is powered by a 5 V supply and also integrates a 1.5 V precision reference, a -5 V generation circuit, and a driveelectrode circuit. These supporting modules provide the required supply rails and reference level for analog signal conditioning, while the drive-electrode circuit feeds back common-mode voltage to the body to suppress interference at the source. As a result, the complete AFE can support sEMG acquisition with adequate gain, filtering, and noise-reduction performance in a compact hardware structure.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_5.jpg|thumb|center|800px|Figure 2.5. Physical picture of the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the fabricated sEMG analog front-end hardware used in the system.&lt;br /&gt;
&lt;br /&gt;
Figure 2.5 presents the practical hardware implementation of the proposed sEMG AFE. It integrates amplification, filtering, level shifting, and driven-reference functions in a compact circuit for weak bioelectrical signal acquisition.&lt;br /&gt;
&lt;br /&gt;
=== ADS1256-based ADC Board ===&lt;br /&gt;
&lt;br /&gt;
To digitize the conditioned weak physiological signals with sufficient resolution and low noise, this project developed a dedicated ADC board based on the ADS1256 analog-to-digital converter (Texas Instruments, Dallas, TX, USA) and the STM32F103C8T6 microcontroller (STMicroelectronics, Geneva, Switzerland). The overall design objective of this board was not merely to realize analog-to-digital conversion, but to provide a complete hardware interface between the analog front-end and the digital processing unit, including precision reference generation, clocking, input protection and filtering, serial communication, power regulation, and MCU-based acquisition control. The ADS1256 was selected because it is a&lt;br /&gt;
&lt;br /&gt;
very low-noise 24-bit delta-sigma converter with a programmable gain amplifier (PGA), flexible input multiplexer, programmable digital filter, and SPI-compatible serial interface, which makes it well suited for weak low-frequency physiological signals after analog conditioning. The STM32F103C8T6 was used as the local controller because it provides a 32-bit Cortex-M3 core, up to 72 MHz system clock, SPI, USART, USB, and standard SWD debugging support in a compact and low-cost platform.&lt;br /&gt;
&lt;br /&gt;
==== ADC Core Architecture and Design Rationale ====&lt;br /&gt;
&lt;br /&gt;
The ADS1256 was selected as the core ADC because it provides high-resolution, low-noise delta-sigma conversion with an input multiplexer, programmable gain amplifier, and digital filter, which are suitable for weak and low-frequency physiological signals. As shown in Figure 2.6, this architecture emphasizes resolution and noise performance rather than high conversion bandwidth, making it appropriate for sEMG signal digitization after analog conditioning.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_6.jpg|thumb|center|800px|Figure 2.6. Internal functional structure of the ADS1256 analog-to-digital converter.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the main internal blocks of the ADS1256, including the multiplexer, PGA, modulator, and digital filter.&lt;br /&gt;
&lt;br /&gt;
==== Analog Front-End Interface, Reference, and Clocking ====&lt;br /&gt;
&lt;br /&gt;
The ADS1256 analog inputs are connected to the external header through a passive input-conditioning network that helps suppress high-frequency interference and improve input stability. In addition, the board includes a dedicated precision reference and clocking circuits so that the ADC can perform stable and accurate conversion. Together, these circuits provide a reliable analog interface and timing basis for high-resolution digitization of weak physiological signals.&lt;br /&gt;
&lt;br /&gt;
==== SPI Interface between ADS1256 and STM32F103C8T6 ====&lt;br /&gt;
&lt;br /&gt;
Communication between the ADS1256 and the STM32F103C8T6 is implemented through an SPI-compatible interface, with dedicated lines for chip select, serial clock, input/output data, data-ready notification, and hardware reset. This connection allows the MCU to configure the ADC, read conversion results in synchrony with DRDY, and maintain efficient and reliable acquisition control for multi-channel physiological measurements.&lt;br /&gt;
&lt;br /&gt;
==== Power Supply and On-board Regulation ====&lt;br /&gt;
&lt;br /&gt;
The ADC board uses a USB Type-B connector as the main power input and includes protection, voltage regulation, and local decoupling circuits to provide a stable supply for both the MCU and ADC-related hardware. In addition, analog ground and digital ground are separated in the PCB layout to reduce digital noise coupling into the analog path, which is particularly important for weak physiological signal acquisition.&lt;br /&gt;
&lt;br /&gt;
==== Basic Peripheral Circuits of the STM32F103C8T6 ====&lt;br /&gt;
&lt;br /&gt;
The STM32F103C8T6 serves as the local controller of the ADC board and is supported by several basic peripheral circuits, including an external crystal oscillator, reset network, BOOT0 configuration, SWD programming/debugging header, and a CH340N USB-to-UART bridge. These circuits ensure stable MCU operation, convenient firmware downloading and debugging, and reliable data transmission from the board to the host computer for real-time display and storage.&lt;br /&gt;
&lt;br /&gt;
==== Hardware-level Working Principle of the ADC Board ====&lt;br /&gt;
&lt;br /&gt;
In operation, the conditioned analog signal from the AFE enters the ADS1256 through the input header, is digitized with high resolution under the control of the local precision reference and clock, and is then read by the STM32 through the SPI interface. The MCU subsequently forwards the sampled data to the host computer through the serial communication link, so that the entire board functions as a compact digital acquisition backend connecting weak physiological analog signals to later software processing, display, and storage.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_7.jpg|thumb|center|800px|Figure 2.7. Photograph of the fabricated ADS1256-based ADC board developed in this project and the definitions of some key pins.]]&lt;br /&gt;
&lt;br /&gt;
Figure 2.7 shows the ADC board fabricated for this project. It integrates the ADS1256 conversion core, STM32 control circuit, power-conditioning circuits, and communication interfaces on a compact PCB for physiological signal digitization.&lt;br /&gt;
&lt;br /&gt;
== Signal Conditioning and Filtering ==&lt;br /&gt;
Although the AFE already performs preliminary band-pass filtering and 50 Hz interference suppression in the analog domain, the digitized sEMG signal may still contain residual noise due to component tolerances, electrode-contact variation, and environmental interference. Therefore, an additional digital filtering stage is implemented in software as a complementary post-processing step to improve signal quality and to provide a more stable input for rectification, envelope extraction, and subsequent analysis. In this sense, the software filtering is not a simple repetition of the analog filtering, but a refinement and compensation for non-ideal front-end behavior.&lt;br /&gt;
&lt;br /&gt;
Surface electromyographic (sEMG) signals are highly susceptible to several sources of contamination during acquisition. In practical measurements, the dominant disturbances usually include low-frequency motion artifacts caused by electrode movement and electrode–skin impedance variation, narrow-band power-line interference centered at 50 Hz, and broadband high-frequency electronic noise introduced by the acquisition hardware. These unwanted components degrade the quality of the recorded signal and may significantly affect the reliability of subsequent feature extraction, parameter estimation, and muscle activity interpretation. For this reason, an effective signal-conditioning procedure is necessary before any higher-level analysis is performed.&lt;br /&gt;
&lt;br /&gt;
In the present implementation, the filtering strategy follows the principle of restricting the signal bandwidth first and then removing the remaining narrow-band interference in a targeted manner. Accordingly, the raw sEMG signal is first processed by a fourth-order Butterworth IIR band-pass filter and then by a 50 Hz notch filter. This processing sequence is illustrated in the flowchart below, where the signal passes through band-pass filtering, notch filtering, full-wave rectification, and envelope extraction before producing the final processed output.&lt;br /&gt;
&lt;br /&gt;
[[File:flowchart.png|thumb|center|500px|Flowchart of the real-time sEMG signal conditioning pipeline.]]&lt;br /&gt;
&lt;br /&gt;
The rationale of this order is that the &#039;&#039;&#039;band-pass stage&#039;&#039;&#039; first confines the signal to the main spectral region of interest for sEMG, thereby attenuating motion artifacts at very low frequencies and suppressing high-frequency noise components outside the physiological band. After this spectral preconditioning, the notch stage can more effectively suppress the residual 50 Hz power-line interference that lies inside the useful sEMG band. In transfer-function form, the band-pass filter may be written as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;H_{BP}(z)=\frac{B_{BP}(z)}{A_{BP}(z)}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where the effective passband is selected as &amp;lt;math&amp;gt;20 \leq f \leq 160 \text{ Hz}&amp;lt;/math&amp;gt;. This frequency interval is consistent with the dominant spectral content of surface EMG: the lower cutoff near 20 Hz reduces motion artifacts and unstable low-frequency fluctuations, whereas the upper cutoff near 160 Hz removes high-frequency electronic noise while preserving the main energy-bearing components of the muscle signal. The use of a Butterworth structure is appropriate here because it provides a smooth monotonic passband response without ripple, which helps preserve signal morphology in real-time applications.&lt;br /&gt;
&lt;br /&gt;
After band limitation, a &#039;&#039;&#039;notch filter&#039;&#039;&#039; centered at the power-line frequency is applied to suppress interference that cannot be removed by the band-pass stage alone. The notch filter is designed around &amp;lt;math&amp;gt;f_0 = 50 \text{ Hz}&amp;lt;/math&amp;gt;, and its bandwidth is controlled by the quality factor &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;, which is expressed as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;Q = \frac{f_0}{\Delta f}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In transfer-function form, the notch stage is written as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;H_{N}(z)=\frac{B_{N}(z)}{A_{N}(z)}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the implemented program, a large quality factor is chosen so that the notch remains narrow, allowing effective rejection of the 50 Hz interference while minimizing distortion of neighboring useful spectral components. This is particularly important for sEMG because the interference frequency lies directly inside the physiological band of interest.&lt;br /&gt;
&lt;br /&gt;
Following the filtering stages, further signal conditioning is performed to obtain a representation that is more directly related to muscle activation intensity. The filtered sEMG waveform is first &#039;&#039;&#039;full-wave rectified&#039;&#039;&#039;, which converts the bipolar oscillatory signal into a unipolar signal by taking its absolute value.  Rectification does not remove noise by itself; instead, it transforms the signal into a form that is more suitable for amplitude-based analysis because both positive and negative deflections contribute positively to the activation measure.&lt;br /&gt;
&lt;br /&gt;
After rectification, the signal envelope is extracted to provide a smooth estimate of muscle activation level over time. In a general formulation, the envelope can be described as the &#039;&#039;&#039;low-pass filtered&#039;&#039;&#039; version of the rectified signal, namely &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y_{\mathrm{env}}[n] = \mathrm{LPF}\bigl(y_{\mathrm{rect}}[n]\bigr)&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the present code implementation, this operation is realized by short-time averaging over a finite window, which is equivalent to a moving-average low-pass smoothing of the rectified waveform. The corresponding expression is &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y_{\mathrm{env}}[n] = \frac{1}{N}\sum_{k=0}^{N-1} |x[n-k]|&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; is the window length in samples. With a window duration of approximately 200 ms, this envelope extraction method provides a stable and physiologically meaningful representation of muscle activation intensity, making it suitable for tasks such as force estimation, fatigue analysis, and motor-control studies.&lt;br /&gt;
&lt;br /&gt;
An important feature of the present &#039;&#039;&#039;implementation&#039;&#039;&#039; is that the entire filtering process is performed &#039;&#039;&#039;in real time&#039;&#039;&#039;, sample by sample, rather than by offline block processing. For this reason, IIR filters are preferred over FIR filters, since they can achieve comparable filtering performance with lower order, lower computational cost, and shorter delay. These properties are especially valuable in embedded systems, serial data streaming, and other low-latency experimental applications. However, unlike memoryless operations, an IIR filter depends not only on the current input but also on previous inputs and previous outputs. Its discrete-time behavior can therefore be represented by the recursive difference equation &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y[n] = \sum_{k=0}^{M} b_k x[n-k] - \sum_{k=1}^{N} a_k y[n-k]&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This equation makes clear that internal filter states must be preserved continuously during streaming operation. If the state variables were reinitialized for every incoming sample or data segment, artificial transients would appear and the output would no longer remain continuous.&lt;br /&gt;
&lt;br /&gt;
In the Python implementation, this state continuity is maintained using the internal initial-condition mechanism provided by SciPy, such as &amp;lt;code&amp;gt;lfilter_zi&amp;lt;/code&amp;gt;, together with recursive state updates during each filtering call. As a result, each newly acquired sample is passed first through the band-pass filter and then through the notch filter, while the internal states of both filters are updated after every step. This state-preserving sample-by-sample design ensures that the processing chain remains causal, continuous, and suitable for real-time display or downstream analysis without requiring storage of the entire signal segment.&lt;br /&gt;
&lt;br /&gt;
Overall, this signal-conditioning scheme provides an experimentally practical solution for real-time sEMG processing. The fourth-order Butterworth band-pass filter confines the signal to the main physiological band of interest, the 50 Hz notch filter removes narrow-band power-line contamination, and the subsequent rectification and envelope extraction generate a smooth amplitude descriptor of muscle activity. Combined with state-preserved streaming IIR implementation, this approach achieves a good balance between signal fidelity, computational efficiency, and real-time applicability in biomedical and physical experiment settings.&lt;br /&gt;
&lt;br /&gt;
== Data Processing ==&lt;br /&gt;
&lt;br /&gt;
The objective of data processing is to convert raw surface electromyography (sEMG) recordings into stable, quantitative, and comparable indicators of muscle activity. Since EMG signals are low in amplitude, highly variable over time, and easily contaminated by noise, a dedicated processing pipeline is necessary before any experimental interpretation can be performed.&lt;br /&gt;
&lt;br /&gt;
In this project, the data processing workflow includes time normalization, signal pre-processing, sliding-window feature extraction, noise-floor estimation, and automatic contraction detection. The processed outputs are then used for subsequent experimental evaluation, including rest-versus-contraction discrimination, signal-to-noise ratio analysis, and repeatability assessment.&lt;br /&gt;
&lt;br /&gt;
=== Input Data and Time Normalization ===&lt;br /&gt;
&lt;br /&gt;
The acquired EMG data are read from CSV files containing two columns: time and filtered sEMG amplitude. In the MATLAB implementation, the time vector is normalized so that each recording starts from zero:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t = t_{all} - t_{all}(1)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This normalization is important because it removes the influence of absolute recording timestamps and makes different trials directly comparable on the same time axis.&lt;br /&gt;
&lt;br /&gt;
In addition, the signal type is automatically identified from the filename as either dynamic or rest. This design allows the same program to process both contraction recordings and resting recordings with different downstream analysis logic.&lt;br /&gt;
&lt;br /&gt;
=== Signal Pre-processing ===&lt;br /&gt;
&lt;br /&gt;
Raw EMG signals cannot be analyzed directly because they usually contain DC offset, low-frequency drift, motion artifacts, and residual high-frequency interference. Therefore, several pre-processing steps are applied before feature extraction.&lt;br /&gt;
&lt;br /&gt;
==== Baseline Removal ====&lt;br /&gt;
&lt;br /&gt;
The first step is DC offset removal:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
x_{dc}(t) = x(t) - \frac{1}{N}\sum_{i=1}^{N}x(i)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This operation centers the signal around zero. It is necessary because an uncorrected baseline would bias amplitude-based metrics and reduce the reliability of later envelope and feature calculations.&lt;br /&gt;
&lt;br /&gt;
==== Band-pass Filtering ====&lt;br /&gt;
&lt;br /&gt;
After baseline correction, a fourth-order Butterworth band-pass filter is applied with a passband of 20–150 Hz.&lt;br /&gt;
&lt;br /&gt;
This step is introduced for two reasons:&lt;br /&gt;
&lt;br /&gt;
* The low-frequency cutoff at 20 Hz suppresses baseline drift and motion artifacts.&lt;br /&gt;
* The high-frequency cutoff at 150 Hz reduces unwanted high-frequency noise while preserving the main energy band of the recorded sEMG in this project.&lt;br /&gt;
&lt;br /&gt;
Compared with processing the raw waveform directly, band-pass filtering makes the subsequent time-domain features more stable and more physiologically meaningful.&lt;br /&gt;
&lt;br /&gt;
==== Full-wave Rectification ====&lt;br /&gt;
&lt;br /&gt;
The filtered EMG signal is bipolar, meaning that positive and negative phases coexist due to motor unit action potentials. If these positive and negative components are averaged directly, they may cancel each other out. To avoid this, full-wave rectification is performed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
x_{rect}(t) = |x_{filt}(t)|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This transforms the signal into a unipolar representation, so that all muscle activity contributes positively to the extracted features.&lt;br /&gt;
&lt;br /&gt;
==== Envelope Extraction ====&lt;br /&gt;
&lt;br /&gt;
Although the rectified signal reflects signal magnitude, it still fluctuates rapidly. To obtain a smoother representation of muscle activation level, an envelope is extracted using a moving average with a 100 ms window.&lt;br /&gt;
&lt;br /&gt;
Envelope extraction is important because contraction detection should reflect the overall activation trend rather than instantaneous spikes. A smoothed envelope is therefore more robust for identifying active and inactive muscle states.&lt;br /&gt;
&lt;br /&gt;
=== Sliding Window Design ===&lt;br /&gt;
&lt;br /&gt;
To quantify how muscle activity changes with time, the filtered signal is divided into overlapping short-time segments using a sliding window method.&lt;br /&gt;
&lt;br /&gt;
The window parameters are:&lt;br /&gt;
&lt;br /&gt;
* Window length: 250 ms&lt;br /&gt;
* Step size: 50 ms&lt;br /&gt;
&lt;br /&gt;
These values are chosen as a trade-off between temporal resolution and feature stability.&lt;br /&gt;
&lt;br /&gt;
A longer window improves statistical robustness because more samples are included in each calculation. However, if the window is too long, short contractions or rapid changes may be blurred. A smaller step size increases temporal continuity between adjacent feature points and makes the feature curves smoother in time. Therefore, the 250 ms / 50 ms design provides a practical balance between smoothing and time localization.&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt;-th segment, the feature time is defined as the mean time of that segment:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t_k = \frac{1}{N}\sum_{i=s_k}^{e_k} t(i)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;s_k&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;e_k&amp;lt;/math&amp;gt; denote the start and end indices of the window.&lt;br /&gt;
&lt;br /&gt;
=== Feature Extraction ===&lt;br /&gt;
&lt;br /&gt;
Within each sliding window, three time-domain features are extracted: RMS, iEMG, and MAV. These features are widely used in EMG analysis because they are simple, computationally efficient, and directly related to muscle activation intensity.&lt;br /&gt;
&lt;br /&gt;
==== Root Mean Square (RMS) ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
RMS = \sqrt{\frac{1}{N}\sum_{i=1}^{N}x_i^2}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
RMS reflects the effective power of the EMG signal and is one of the most common indicators of contraction strength. It is sensitive to both amplitude and energy, making it especially useful for comparing rest and active states.&lt;br /&gt;
&lt;br /&gt;
==== Integrated EMG (iEMG) ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
iEMG = \sum_{i=1}^{N}|x_i|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
iEMG describes the cumulative electrical activity within a window. It is often interpreted as a measure of total muscle effort over that time segment.&lt;br /&gt;
&lt;br /&gt;
==== Mean Absolute Value (MAV) ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
MAV = \frac{1}{N}\sum_{i=1}^{N}|x_i|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
MAV is an amplitude descriptor similar to iEMG, but normalized by the number of samples. It provides an efficient estimate of average signal level and is less computationally intensive than some other features.&lt;br /&gt;
&lt;br /&gt;
These three features are used together because they provide complementary descriptions of EMG intensity. RMS emphasizes signal energy, iEMG emphasizes cumulative activation, and MAV reflects average amplitude.&lt;br /&gt;
&lt;br /&gt;
=== Peak-value Extraction ===&lt;br /&gt;
&lt;br /&gt;
In addition to continuous feature curves, several key peak values are extracted from the processed signal:&lt;br /&gt;
&lt;br /&gt;
* maximum and minimum of the filtered EMG waveform&lt;br /&gt;
* peak of the envelope&lt;br /&gt;
* peak RMS&lt;br /&gt;
* peak iEMG&lt;br /&gt;
* peak MAV&lt;br /&gt;
&lt;br /&gt;
These peak values provide concise descriptors of the strongest activity observed in each recording. They are useful for quick comparison across trials and subjects.&lt;br /&gt;
&lt;br /&gt;
=== Noise Floor Estimation ===&lt;br /&gt;
&lt;br /&gt;
To evaluate signal quality, the noise floor is estimated from a reference resting interval. In the present implementation, the first 3 seconds of the recording are used as the default rest reference:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t \in [0,\min(3,t_{end})]&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this segment, three noise descriptors are computed:&lt;br /&gt;
&lt;br /&gt;
* Noise RMS&lt;br /&gt;
* Noise standard deviation&lt;br /&gt;
* Noise peak-to-peak amplitude&lt;br /&gt;
&lt;br /&gt;
Noise-floor estimation is important because EMG amplitude alone is not sufficient to judge recording quality. A large signal is only meaningful if it is sufficiently higher than the baseline noise level. Therefore, the noise floor serves as the reference for later SNR calculation and for designing contraction thresholds.&lt;br /&gt;
&lt;br /&gt;
=== Global Signal Metrics ===&lt;br /&gt;
&lt;br /&gt;
For each recording, three global metrics are also computed over the entire filtered signal:&lt;br /&gt;
&lt;br /&gt;
* Global RMS&lt;br /&gt;
* Global MAV&lt;br /&gt;
* Global iEMG&lt;br /&gt;
&lt;br /&gt;
These global descriptors summarize the overall signal level of the full recording and are later used in group-level comparisons.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Contraction Detection ===&lt;br /&gt;
&lt;br /&gt;
For dynamic recordings, an automatic contraction detection algorithm is used to identify repeated active segments. This is one of the key parts of the data processing pipeline, because it transforms a continuous EMG trace into discrete contraction events that can be counted and compared.&lt;br /&gt;
&lt;br /&gt;
==== Threshold Design ====&lt;br /&gt;
&lt;br /&gt;
The detection threshold is designed adaptively rather than using a fixed value. Two candidate thresholds are first calculated:&lt;br /&gt;
&lt;br /&gt;
* an envelope-based threshold derived from the global envelope mean and standard deviation&lt;br /&gt;
* a rest-reference threshold derived from the mean and standard deviation of the resting reference amplitude&lt;br /&gt;
&lt;br /&gt;
The final threshold is taken as the larger of the two after additional scaling. This strategy improves robustness because it combines the global activation level of the signal with the baseline noise characteristics of the individual recording.&lt;br /&gt;
&lt;br /&gt;
This adaptive threshold design is preferable to a manually fixed threshold because EMG amplitude can vary strongly between subjects, muscles, and recording sessions.&lt;br /&gt;
&lt;br /&gt;
==== Initial Segmentation ====&lt;br /&gt;
&lt;br /&gt;
After thresholding the envelope, the signal is classified into active and inactive regions:&lt;br /&gt;
&lt;br /&gt;
* active: envelope above threshold&lt;br /&gt;
* inactive: envelope below threshold&lt;br /&gt;
&lt;br /&gt;
The rising and falling edges of the binary activity vector are then used to determine the start and end points of each candidate contraction segment.&lt;br /&gt;
&lt;br /&gt;
==== Removal of Short Segments ====&lt;br /&gt;
&lt;br /&gt;
Very short active regions are often caused by noise fluctuations rather than true muscle contractions. Therefore, segments shorter than 0.20 s are discarded.&lt;br /&gt;
&lt;br /&gt;
This step prevents false positive detections and increases the physiological relevance of the segmentation results.&lt;br /&gt;
&lt;br /&gt;
==== Merging of Adjacent Segments ====&lt;br /&gt;
&lt;br /&gt;
If two neighboring active segments are separated by a very short gap, they are merged when the gap is less than 0.15 s.&lt;br /&gt;
&lt;br /&gt;
This operation is necessary because a single real contraction may be temporarily interrupted by a brief drop in the envelope caused by local fluctuation. Without merging, one contraction could be incorrectly counted as multiple repetitions.&lt;br /&gt;
&lt;br /&gt;
==== Repetition-level Metrics ====&lt;br /&gt;
&lt;br /&gt;
For each detected contraction segment, two repetition-level metrics are extracted:&lt;br /&gt;
&lt;br /&gt;
* peak RMS of that contraction&lt;br /&gt;
* mean RMS of that contraction&lt;br /&gt;
&lt;br /&gt;
These metrics quantify both the strongest activation within each repetition and the average activation level over the repetition duration.&lt;br /&gt;
&lt;br /&gt;
=== Repeatability Analysis ===&lt;br /&gt;
&lt;br /&gt;
When multiple valid contractions are detected, repeatability is evaluated using the coefficient of variation (CV):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
CV = \frac{\sigma}{\mu}\times 100\%&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt; is the standard deviation and &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is the mean value across repetitions.&lt;br /&gt;
&lt;br /&gt;
Two CV values are computed:&lt;br /&gt;
&lt;br /&gt;
* CV of repetition peak RMS&lt;br /&gt;
* CV of repetition mean RMS&lt;br /&gt;
&lt;br /&gt;
A lower CV indicates better repeatability, meaning that repeated contractions produce more consistent EMG responses.&lt;br /&gt;
&lt;br /&gt;
=== Signal-to-Noise Ratio (SNR) ===&lt;br /&gt;
&lt;br /&gt;
In this project, the signal-to-noise ratio (SNR) is defined based on the ratio between contraction and rest activity:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
SNR_{dB} = 20\log_{10}\left(\frac{RMS_{contraction}}{RMS_{rest}}\right)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This definition is adopted because it directly reflects the system’s ability to distinguish active muscle contraction from baseline noise.&lt;br /&gt;
&lt;br /&gt;
Compared with global SNR definitions, this formulation is more relevant for practical EMG applications such as activity detection and classification.&lt;br /&gt;
&lt;br /&gt;
=== Rest-versus-Contraction Window Comparison ===&lt;br /&gt;
&lt;br /&gt;
To further distinguish inactive and active states, all sliding windows are divided into two groups:&lt;br /&gt;
&lt;br /&gt;
* rest windows: windows with envelope clearly below the threshold&lt;br /&gt;
* contraction windows: windows with envelope above the threshold&lt;br /&gt;
&lt;br /&gt;
The RMS values of these two groups are then compared statistically.&lt;br /&gt;
&lt;br /&gt;
This comparison is important because a practical EMG system should not only detect signal presence, but also clearly separate rest from contraction in a quantitative way. If the two RMS distributions are well separated, it indicates that the system has good discriminative capability.&lt;br /&gt;
&lt;br /&gt;
=== Output Data Structure ===&lt;br /&gt;
&lt;br /&gt;
The processed outputs are organized into structured data for experimental analysis:&lt;br /&gt;
&lt;br /&gt;
==== Time-series outputs ====&lt;br /&gt;
* Filtered EMG signal  &lt;br /&gt;
* Rectified signal  &lt;br /&gt;
* Envelope  &lt;br /&gt;
* RMS(t), iEMG(t), MAV(t)  &lt;br /&gt;
&lt;br /&gt;
==== Recording-level outputs ====&lt;br /&gt;
* RMS (rest)  &lt;br /&gt;
* RMS (contraction)  &lt;br /&gt;
* iEMG  &lt;br /&gt;
* Noise metrics  &lt;br /&gt;
&lt;br /&gt;
==== Dynamic-signal outputs ====&lt;br /&gt;
* Detected contractions  &lt;br /&gt;
* Repetition count  &lt;br /&gt;
* Peak RMS per repetition  &lt;br /&gt;
* Mean RMS per repetition  &lt;br /&gt;
* Coefficient of variation (CV)  &lt;br /&gt;
* Signal-to-noise ratio (SNR)  &lt;br /&gt;
&lt;br /&gt;
All extracted features are designed to directly support the evaluation of noise level, signal quality, activity discrimination, and repeatability in the subsequent experimental analysis.&lt;br /&gt;
&lt;br /&gt;
== Experimental Results ==&lt;br /&gt;
&lt;br /&gt;
This section presents representative results of the EMG acquisition and data processing pipeline under both dynamic (muscle contraction) and resting conditions.&lt;br /&gt;
&lt;br /&gt;
=== Representative Dynamic Signal Analysis ===&lt;br /&gt;
&lt;br /&gt;
[[File:Dynamic_Figure1.png|thumb|800px|center|Figure 5.1: Processed EMG signal under dynamic contraction, including filtered signal, rectified signal with envelope, and extracted features (RMS, iEMG, MAV).]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.1 shows the processed EMG signal during repeated muscle contractions.&lt;br /&gt;
&lt;br /&gt;
The filtered EMG waveform exhibits clear burst-like patterns corresponding to periodic contractions. The signal amplitude reaches a maximum of approximately 0.45, while the baseline remains centered around zero, indicating effective baseline removal and filtering.&lt;br /&gt;
&lt;br /&gt;
After rectification and envelope extraction, the contraction periods become clearly distinguishable. The envelope provides a smooth representation of muscle activation, with a peak value of approximately 0.145.&lt;br /&gt;
&lt;br /&gt;
The extracted time-domain features (RMS, iEMG, MAV) further quantify the signal. Among these, iEMG shows the strongest dynamic variation, indicating high sensitivity to contraction intensity.&lt;br /&gt;
&lt;br /&gt;
=== Noise Floor and Rest Reference ===&lt;br /&gt;
&lt;br /&gt;
[[File:Dynamic_Figure2.png|thumb|800px|center|Figure 5.2: Noise estimation, rest vs contraction comparison, automatic contraction detection, and repetition analysis.]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (top-left) shows the resting reference segment used for noise estimation.&lt;br /&gt;
&lt;br /&gt;
The signal remains centered around zero with small fluctuations. The noise characteristics are:&lt;br /&gt;
&lt;br /&gt;
* Noise RMS ≈ 0.0046  &lt;br /&gt;
* Standard deviation ≈ 0.0046  &lt;br /&gt;
* Peak-to-peak amplitude ≈ 0.071  &lt;br /&gt;
&lt;br /&gt;
This indicates a low noise floor and stable measurement conditions.&lt;br /&gt;
&lt;br /&gt;
=== Rest vs Contraction Discrimination ===&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (top-right) compares RMS values between rest and contraction states.&lt;br /&gt;
&lt;br /&gt;
The two distributions are clearly separated:&lt;br /&gt;
&lt;br /&gt;
* Rest mean RMS ≈ 0.0053  &lt;br /&gt;
* Contraction mean RMS ≈ 0.1064  &lt;br /&gt;
&lt;br /&gt;
This corresponds to an approximate 20× increase, demonstrating strong discriminability between inactive and active muscle states.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Contraction Detection ===&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (bottom-left) illustrates automatic detection based on the envelope signal.&lt;br /&gt;
&lt;br /&gt;
A threshold of approximately 0.040 is applied, resulting in stable segmentation of contraction periods.&lt;br /&gt;
&lt;br /&gt;
A total of 12 repetitions are detected, with good alignment to visible signal peaks.&lt;br /&gt;
&lt;br /&gt;
=== Repeatability Analysis ===&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (bottom-right) shows the peak RMS value of each detected contraction.&lt;br /&gt;
&lt;br /&gt;
The results indicate:&lt;br /&gt;
&lt;br /&gt;
* Mean peak RMS ≈ 0.1355  &lt;br /&gt;
* Standard deviation ≈ 0.0173  &lt;br /&gt;
* CV ≈ 12.77%  &lt;br /&gt;
* SNR ≈ 21.26 dB  &lt;br /&gt;
&lt;br /&gt;
This indicates acceptable repeatability and good signal quality.&lt;br /&gt;
&lt;br /&gt;
=== Representative Rest Signal Analysis ===&lt;br /&gt;
&lt;br /&gt;
[[File:Rest_Figure1.png|thumb|800px|center|Figure 5.3: Processed EMG signal under rest condition, showing low amplitude and absence of contraction patterns.]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.3 shows the EMG signal under resting conditions.&lt;br /&gt;
&lt;br /&gt;
The signal remains within a narrow amplitude range (approximately ±0.04) and shows no burst-like structures. The envelope remains close to zero, confirming the absence of muscle activity.&lt;br /&gt;
&lt;br /&gt;
The extracted features remain low:&lt;br /&gt;
&lt;br /&gt;
* RMS ≈ 0.007  &lt;br /&gt;
* MAV ≈ 0.005  &lt;br /&gt;
* iEMG remains stable  &lt;br /&gt;
&lt;br /&gt;
This confirms that no false activation is detected.&lt;br /&gt;
&lt;br /&gt;
=== Frequency-domain Characteristics ===&lt;br /&gt;
&lt;br /&gt;
[[File:Rest_Figure2.png|800px|center|Figure 4: Frequency-domain analysis and statistical characteristics of rest signal.]]&lt;br /&gt;
&lt;br /&gt;
Figure 4 shows the frequency-domain characteristics of the resting signal.&lt;br /&gt;
&lt;br /&gt;
The power spectral density (PSD) indicates low overall signal energy without dominant peaks, confirming that the signal mainly consists of noise.&lt;br /&gt;
&lt;br /&gt;
=== Summary of Single-recording Performance ===&lt;br /&gt;
&lt;br /&gt;
From the representative results:&lt;br /&gt;
&lt;br /&gt;
* EMG signals are effectively extracted and denoised  &lt;br /&gt;
* Contraction events are clearly identifiable  &lt;br /&gt;
* Rest and contraction states are well separated  &lt;br /&gt;
* Automatic detection is stable and accurate  &lt;br /&gt;
* Repeatability is acceptable  &lt;br /&gt;
* No false activation occurs under rest conditions  &lt;br /&gt;
&lt;br /&gt;
=== Consistency Across Multiple Recordings ===&lt;br /&gt;
&lt;br /&gt;
The same data processing pipeline was applied to multiple recordings from different subjects and trials.&lt;br /&gt;
&lt;br /&gt;
Across all datasets, consistent patterns were observed:&lt;br /&gt;
&lt;br /&gt;
* Dynamic signals exhibit clear burst-like structures corresponding to repeated muscle contractions  &lt;br /&gt;
* Rest signals remain low in amplitude without distinct activation patterns  &lt;br /&gt;
* RMS values under contraction are consistently higher than those under rest  &lt;br /&gt;
* The automatic detection algorithm reliably identifies contraction segments  &lt;br /&gt;
&lt;br /&gt;
Although quantitative values (e.g., RMS, SNR, CV) vary across recordings due to differences in electrode contact, muscle activation strength, and individual conditions, the overall trends remain consistent.&lt;br /&gt;
&lt;br /&gt;
These results demonstrate the robustness and general applicability of the proposed signal processing method.&lt;br /&gt;
&lt;br /&gt;
== Multi-subject Analysis ==&lt;br /&gt;
=== System Evaluation ===&lt;br /&gt;
&lt;br /&gt;
This section evaluates the performance of the EMG acquisition system in terms of noise level, signal quality, activity discrimination, and repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Noise Floor Analysis ====&lt;br /&gt;
&lt;br /&gt;
The noise floor was evaluated using rest-state recordings, characterized by RMS noise, standard deviation, and peak-to-peak amplitude.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039; shows the lowest noise level (RMS ≈ 0.0046), indicating stable electrode contact and minimal interference.  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039; exhibits moderate noise (RMS ≈ 0.0080), likely influenced by motion artifacts or electrode–skin impedance variation.  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039; shows relatively higher noise (RMS ≈ 0.0126), suggesting increased baseline fluctuation.  &lt;br /&gt;
&lt;br /&gt;
Overall, the system maintains a low noise floor across subjects, although the quality depends on experimental conditions such as electrode contact and environmental interference.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Signal-to-Noise Ratio (SNR) ====&lt;br /&gt;
&lt;br /&gt;
The signal-to-noise ratio (SNR) is defined as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{SNR (dB)} = 20 \log_{10} \left( \frac{\mathrm{RMS}_{\mathrm{contraction}}}{\mathrm{RMS}_{\mathrm{rest}}} \right)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The measured SNR values are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: 21.26 dB → good signal quality  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: 13.52 dB → moderate and usable  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: 6.66 dB → low signal clarity  &lt;br /&gt;
&lt;br /&gt;
General interpretation:&lt;br /&gt;
&lt;br /&gt;
* &amp;gt;20 dB → good  &lt;br /&gt;
* 10–20 dB → usable  &lt;br /&gt;
* &amp;lt;10 dB → poor  &lt;br /&gt;
&lt;br /&gt;
These results show that the system can achieve reliable signal acquisition, although performance varies across subjects.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
====  Rest vs Contraction Discrimination ====&lt;br /&gt;
&lt;br /&gt;
A clear distinction between rest and contraction states is observed based on RMS values.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: 0.0053 → 0.1064 (≈20× increase)  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: 0.0079 → 0.0283 (≈3.6× increase)  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: 0.0141 → 0.0646 (≈4.6× increase)  &lt;br /&gt;
&lt;br /&gt;
This demonstrates that the system is capable of separating muscle activity from baseline noise.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Conclusion:&#039;&#039;  &lt;br /&gt;
The system can be used for basic muscle activity detection and simple classification tasks based on RMS features.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Repeatability of Repeated Contractions ====&lt;br /&gt;
&lt;br /&gt;
Repeatability is evaluated using the coefficient of variation (CV) of peak RMS values across repetitions.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! CV Range !! Evaluation&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt; 10% || Excellent&lt;br /&gt;
|-&lt;br /&gt;
| 10–20% || Acceptable&lt;br /&gt;
|-&lt;br /&gt;
| &amp;gt; 20% || Poor&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Results:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: CV = 12.77% → Acceptable  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: CV = 24.77% → Poor  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: CV = 10.60% → Acceptable  &lt;br /&gt;
&lt;br /&gt;
Although WANG&#039;s signal is detectable, its contraction amplitude varies significantly across repetitions, resulting in poor repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
=== Overall System Performance ===&lt;br /&gt;
&lt;br /&gt;
The system demonstrates the following performance characteristics:&lt;br /&gt;
&lt;br /&gt;
* Reliable detection of muscle activity across all subjects  &lt;br /&gt;
* Clear separation between rest and contraction states  &lt;br /&gt;
* Moderate to high signal quality depending on subject conditions  &lt;br /&gt;
* Repeatability ranging from acceptable to poor due to user-dependent factors  &lt;br /&gt;
&lt;br /&gt;
Overall, the designed EMG acquisition system is capable of stable signal acquisition and feature extraction, with performance primarily influenced by electrode contact quality, skin impedance, and motion consistency.&lt;br /&gt;
&lt;br /&gt;
===== Summary of Quantitative Metrics =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Subject !! RMS (Rest) !! RMS (Contraction) !! Separation Ratio !! iEMG (max) !! Noise RMS !! SNR (dB) !! CV (%) !! Evaluation&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;LIU&#039;&#039;&#039; || 0.0053 || 0.1064 || &#039;&#039;&#039;20.1×&#039;&#039;&#039; || 12.72 || 0.0046 || &#039;&#039;&#039;21.26&#039;&#039;&#039; || 12.77 || Strong signal, good quality&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;WANG&#039;&#039;&#039; || 0.0079 || 0.0283 || 3.57× || 11.10 || 0.0080 || 13.52 || &#039;&#039;&#039;24.77&#039;&#039;&#039; || Usable signal, poor repeatability&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ZHONG&#039;&#039;&#039; || 0.0141 || 0.0646 || 4.58× || 6.70 || 0.0126 || 6.66 || 10.60 || Acceptable performance&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Summary:&#039;&#039; Subject LIU shows the best overall performance, WANG provides usable but less stable signals, and ZHONG demonstrates moderate signal quality with good repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Activation Intensity =====&lt;br /&gt;
&lt;br /&gt;
Among the three subjects, &#039;&#039;&#039;LIU exhibits the strongest muscle activation&#039;&#039;&#039;, as indicated by the highest contraction RMS and iEMG values. ZHONG shows moderate activation, while WANG demonstrates comparable iEMG but lower RMS consistency.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Signal Quality =====&lt;br /&gt;
&lt;br /&gt;
Signal quality is evaluated based on SNR and noise level:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039; achieves the highest SNR and lowest noise → best signal quality  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039; shows moderate SNR → usable but less robust  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039; has the lowest SNR → weakest signal clarity  &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Repeatability =====&lt;br /&gt;
&lt;br /&gt;
Repeatability is evaluated using the coefficient of variation (CV):&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;ZHONG (10.60%)&#039;&#039;&#039; → most stable  &lt;br /&gt;
* &#039;&#039;&#039;LIU (12.77%)&#039;&#039;&#039; → acceptable  &lt;br /&gt;
* &#039;&#039;&#039;WANG (24.77%)&#039;&#039;&#039; → poor  &lt;br /&gt;
&lt;br /&gt;
This indicates that WANG’s contraction strength varies significantly between repetitions.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Engineering Interpretation of Inter-subject Differences =====&lt;br /&gt;
&lt;br /&gt;
The observed differences are mainly attributed to engineering and experimental factors rather than physiological differences.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Electrode contact quality&#039;&#039;&#039;  &lt;br /&gt;
  Variations in electrode placement, pressure, and gel contact affect signal amplitude and stability.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Skin impedance&#039;&#039;&#039;  &lt;br /&gt;
  Differences in skin condition (hydration, oil, hair) influence electrode–skin impedance, affecting noise level and signal coupling.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Muscle control consistency&#039;&#039;&#039;  &lt;br /&gt;
  Variations in contraction strength and timing affect repeatability and CV.&lt;br /&gt;
&lt;br /&gt;
Therefore, the variation across subjects reflects practical acquisition conditions rather than intrinsic system limitations.&lt;/div&gt;</summary>
		<author><name>Wang Jingyi</name></author>
	</entry>
	<entry>
		<id>https://pc5271.org/index.php?title=Surface_EMG_Sensor_for_Muscle_Activity_Measurement:_AFE_Design_and_Signal_Processing&amp;diff=1358</id>
		<title>Surface EMG Sensor for Muscle Activity Measurement: AFE Design and Signal Processing</title>
		<link rel="alternate" type="text/html" href="https://pc5271.org/index.php?title=Surface_EMG_Sensor_for_Muscle_Activity_Measurement:_AFE_Design_and_Signal_Processing&amp;diff=1358"/>
		<updated>2026-04-23T06:46:07Z</updated>

		<summary type="html">&lt;p&gt;Wang Jingyi: /* Repeatability Analysis */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Background and Theory==&lt;br /&gt;
&lt;br /&gt;
=== Surface EMG Signals ===&lt;br /&gt;
Surface electromyography (sEMG) refers to the bioelectrical signals detected on the skin surface during muscle contraction. These signals originate from the electrical activity of muscle fibers and provide a non-invasive way to monitor muscle activation. Compared with invasive EMG methods, sEMG is easier to apply, safer for repeated measurements, and more suitable for real-time monitoring. Therefore, it has been widely used in areas such as rehabilitation, motion analysis, human–machine interaction, and physiological monitoring.&lt;br /&gt;
&lt;br /&gt;
=== Characteristics of EMG Signals ===&lt;br /&gt;
EMG signals are generally weak, time-varying, and stochastic in nature. Their waveforms are typically bipolar, fluctuating around zero with both positive and negative components. The amplitude and frequency content of EMG signals depend on factors such as muscle contraction level, electrode placement, skin condition, and individual physiological differences. In practice, the useful frequency components of sEMG are mainly concentrated in a limited low-to-mid frequency range. Because of their low amplitude and variability, EMG signals usually require further conditioning before reliable interpretation and feature extraction can be performed.&lt;br /&gt;
&lt;br /&gt;
=== Bioelectrical Signal Acquisition Principles ===&lt;br /&gt;
The acquisition of bioelectrical signals is based on measuring the small potential difference on the skin surface using electrodes, then converting it into a processable electrical signal through amplification and digitization. For sEMG measurement, electrode placement and skin–electrode contact quality are especially important, since they directly affect signal amplitude and stability. In addition, the front-end acquisition circuit must provide sufficient sensitivity and good interference rejection, so that the recorded signal reflects actual muscle activity rather than environmental disturbance or poor contact conditions.&lt;br /&gt;
&lt;br /&gt;
=== Noise Sources in EMG (50 Hz, motion artifacts) ===&lt;br /&gt;
In practical EMG recording, the measured signal is easily contaminated by different types of noise. Two of the most common sources are power-line interference and motion artifacts. Power-line interference usually appears as a narrow-band component at 50 Hz in the local electrical environment, while motion artifacts are mainly caused by electrode movement, cable disturbance, or variations in the electrode–skin impedance, and are often concentrated in the low-frequency range. In addition, electronic noise from the acquisition hardware may also affect the recording quality. These unwanted components can reduce signal clarity and make muscle activity analysis less reliable, so they must be considered in the design of the signal processing pipeline.&lt;br /&gt;
[[File:background_theory_figure1.1_emg_noise_sources.png|center|thumb|700px|&#039;&#039;&#039;Figure 1.1.&#039;&#039;&#039; Principle of surface EMG acquisition.]]&lt;br /&gt;
&lt;br /&gt;
==System Architecture==&lt;br /&gt;
=== Total Structure Design ===&lt;br /&gt;
&lt;br /&gt;
For clarity，the proposed physiological signal acquisition system mainly consists of two core parts：the analog front－end （AFE）and the ADC board．The AFE is responsible for the preliminary conditioning of weak bioelectrical signals，including amplification，filtering，interference suppression，and level shifting，so that the analog waveform can be converted into a stable and measurable form．The ADC board then performs high－resolution digitization of the conditioned signal and transfers the sampled data to the host computer for subsequent display，storage，and analysis．Therefore，the overall system forms a complete signal－acquisition chain from weak physiological input to digital output．&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_1.jpg|thumb|center|800px|Figure 2.1. Overall system architecture of the proposed physiological signal acquisition platform，including the AFE and ADC modules．]]&lt;br /&gt;
&lt;br /&gt;
=== sEMG AFE Design ===&lt;br /&gt;
&lt;br /&gt;
To collect the weak bioelectric potential signals of the human body，an analog front－end（AFE）suitable sEMG measurements was designed．The module is powered by an external 5 V supply，and the complete circuit includes a first－ stage instrumentation amplifier based on INA128（Texas Instruments，Dallas，TX，USA），a band－pass filter，a 50 Hz notch filter，a second－order amplification and level shifting stage，a driver electrode circuit，a precise 1.5 V reference source，and a -5 V voltage generation module for powering the operational amplifiers．&lt;br /&gt;
&lt;br /&gt;
==== First－order Amplifier ====&lt;br /&gt;
&lt;br /&gt;
The input bioelectric signal is first acquired in differential form and applied to the INA128 instrumentation amplifier，which provides high input impedance，high common－mode rejection，and moderate initial gain for sEMG acquisition．This stage enlarges the weak physiological signal before filtering while reducing the risk of premature saturation caused by electrode offset or motion－induced disturbance，thereby preparing a more stable signal for the subsequent conditioning stages．&lt;br /&gt;
&lt;br /&gt;
==== Bandpass Filter ====&lt;br /&gt;
&lt;br /&gt;
After the instrumentation amplifier，the signal passes through a second－order active band－pass filter，as shown in Figure 2．2． This stage suppresses baseline drift and high－frequency noise outside the useful sEMG range，so that the low－frequency envelope information of sEMG can be preserved before further amplification．&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_2.jpg|thumb|center|800px|Figure 2.2. Schematic diagram of the active band-pass filter used in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the band-pass stage used to retain the main physiological signal band while suppressing unwanted lowand high-frequency components.&lt;br /&gt;
&lt;br /&gt;
==== Notch Filter ====&lt;br /&gt;
&lt;br /&gt;
To reduce power-line interference, a dedicated 50 Hz notch filter is introduced after the band-pass stage, as shown in Figure 2.3. This filter attenuates the mains-frequency component that commonly contaminates weak bioelectric measurements, thereby improving the signal-to-noise ratio of sEMG signals before the final amplification stage.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_3.jpg|thumb|center|800px|Figure 2.3. Schematic diagram of the 50 Hz notch filter used in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the circuit used to attenuate 50 Hz mains interference in the analog front end.&lt;br /&gt;
&lt;br /&gt;
==== Second-order Amplifier &amp;amp; Level Shifter ====&lt;br /&gt;
&lt;br /&gt;
After filtering, the signal enters the second-stage amplification and level-shifting circuit shown in Figure 2.4. In this stage, the filtered signal is further amplified to improve amplitude utilization and then shifted by a 1.5 V reference so that the output becomes a stable unipolar signal suitable for ADC sampling, while preserving linear operation and providing sufficient output swing margin.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_4.jpg|thumb|center|800px|Figure 2.4. Schematic diagram of the second-stage amplifier and level-shifting circuit in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows how the conditioned signal is further amplified and shifted to a suitable DC level before digitization.&lt;br /&gt;
&lt;br /&gt;
==== Power Module and Drive-electrode Circuit ====&lt;br /&gt;
&lt;br /&gt;
The AFE is powered by a 5 V supply and also integrates a 1.5 V precision reference, a -5 V generation circuit, and a driveelectrode circuit. These supporting modules provide the required supply rails and reference level for analog signal conditioning, while the drive-electrode circuit feeds back common-mode voltage to the body to suppress interference at the source. As a result, the complete AFE can support sEMG acquisition with adequate gain, filtering, and noise-reduction performance in a compact hardware structure.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_5.jpg|thumb|center|800px|Figure 2.5. Physical picture of the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the fabricated sEMG analog front-end hardware used in the system.&lt;br /&gt;
&lt;br /&gt;
Figure 2.5 presents the practical hardware implementation of the proposed sEMG AFE. It integrates amplification, filtering, level shifting, and driven-reference functions in a compact circuit for weak bioelectrical signal acquisition.&lt;br /&gt;
&lt;br /&gt;
=== ADS1256-based ADC Board ===&lt;br /&gt;
&lt;br /&gt;
To digitize the conditioned weak physiological signals with sufficient resolution and low noise, this project developed a dedicated ADC board based on the ADS1256 analog-to-digital converter (Texas Instruments, Dallas, TX, USA) and the STM32F103C8T6 microcontroller (STMicroelectronics, Geneva, Switzerland). The overall design objective of this board was not merely to realize analog-to-digital conversion, but to provide a complete hardware interface between the analog front-end and the digital processing unit, including precision reference generation, clocking, input protection and filtering, serial communication, power regulation, and MCU-based acquisition control. The ADS1256 was selected because it is a&lt;br /&gt;
&lt;br /&gt;
very low-noise 24-bit delta-sigma converter with a programmable gain amplifier (PGA), flexible input multiplexer, programmable digital filter, and SPI-compatible serial interface, which makes it well suited for weak low-frequency physiological signals after analog conditioning. The STM32F103C8T6 was used as the local controller because it provides a 32-bit Cortex-M3 core, up to 72 MHz system clock, SPI, USART, USB, and standard SWD debugging support in a compact and low-cost platform.&lt;br /&gt;
&lt;br /&gt;
==== ADC Core Architecture and Design Rationale ====&lt;br /&gt;
&lt;br /&gt;
The ADS1256 was selected as the core ADC because it provides high-resolution, low-noise delta-sigma conversion with an input multiplexer, programmable gain amplifier, and digital filter, which are suitable for weak and low-frequency physiological signals. As shown in Figure 2.6, this architecture emphasizes resolution and noise performance rather than high conversion bandwidth, making it appropriate for sEMG signal digitization after analog conditioning.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_6.jpg|thumb|center|800px|Figure 2.6. Internal functional structure of the ADS1256 analog-to-digital converter.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the main internal blocks of the ADS1256, including the multiplexer, PGA, modulator, and digital filter.&lt;br /&gt;
&lt;br /&gt;
==== Analog Front-End Interface, Reference, and Clocking ====&lt;br /&gt;
&lt;br /&gt;
The ADS1256 analog inputs are connected to the external header through a passive input-conditioning network that helps suppress high-frequency interference and improve input stability. In addition, the board includes a dedicated precision reference and clocking circuits so that the ADC can perform stable and accurate conversion. Together, these circuits provide a reliable analog interface and timing basis for high-resolution digitization of weak physiological signals.&lt;br /&gt;
&lt;br /&gt;
==== SPI Interface between ADS1256 and STM32F103C8T6 ====&lt;br /&gt;
&lt;br /&gt;
Communication between the ADS1256 and the STM32F103C8T6 is implemented through an SPI-compatible interface, with dedicated lines for chip select, serial clock, input/output data, data-ready notification, and hardware reset. This connection allows the MCU to configure the ADC, read conversion results in synchrony with DRDY, and maintain efficient and reliable acquisition control for multi-channel physiological measurements.&lt;br /&gt;
&lt;br /&gt;
==== Power Supply and On-board Regulation ====&lt;br /&gt;
&lt;br /&gt;
The ADC board uses a USB Type-B connector as the main power input and includes protection, voltage regulation, and local decoupling circuits to provide a stable supply for both the MCU and ADC-related hardware. In addition, analog ground and digital ground are separated in the PCB layout to reduce digital noise coupling into the analog path, which is particularly important for weak physiological signal acquisition.&lt;br /&gt;
&lt;br /&gt;
==== Basic Peripheral Circuits of the STM32F103C8T6 ====&lt;br /&gt;
&lt;br /&gt;
The STM32F103C8T6 serves as the local controller of the ADC board and is supported by several basic peripheral circuits, including an external crystal oscillator, reset network, BOOT0 configuration, SWD programming/debugging header, and a CH340N USB-to-UART bridge. These circuits ensure stable MCU operation, convenient firmware downloading and debugging, and reliable data transmission from the board to the host computer for real-time display and storage.&lt;br /&gt;
&lt;br /&gt;
==== Hardware-level Working Principle of the ADC Board ====&lt;br /&gt;
&lt;br /&gt;
In operation, the conditioned analog signal from the AFE enters the ADS1256 through the input header, is digitized with high resolution under the control of the local precision reference and clock, and is then read by the STM32 through the SPI interface. The MCU subsequently forwards the sampled data to the host computer through the serial communication link, so that the entire board functions as a compact digital acquisition backend connecting weak physiological analog signals to later software processing, display, and storage.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_7.jpg|thumb|center|800px|Figure 2.7. Photograph of the fabricated ADS1256-based ADC board developed in this project and the definitions of some key pins.]]&lt;br /&gt;
&lt;br /&gt;
Figure 2.7 shows the ADC board fabricated for this project. It integrates the ADS1256 conversion core, STM32 control circuit, power-conditioning circuits, and communication interfaces on a compact PCB for physiological signal digitization.&lt;br /&gt;
&lt;br /&gt;
== Signal Conditioning and Filtering ==&lt;br /&gt;
Although the AFE already performs preliminary band-pass filtering and 50 Hz interference suppression in the analog domain, the digitized sEMG signal may still contain residual noise due to component tolerances, electrode-contact variation, and environmental interference. Therefore, an additional digital filtering stage is implemented in software as a complementary post-processing step to improve signal quality and to provide a more stable input for rectification, envelope extraction, and subsequent analysis. In this sense, the software filtering is not a simple repetition of the analog filtering, but a refinement and compensation for non-ideal front-end behavior.&lt;br /&gt;
&lt;br /&gt;
Surface electromyographic (sEMG) signals are highly susceptible to several sources of contamination during acquisition. In practical measurements, the dominant disturbances usually include low-frequency motion artifacts caused by electrode movement and electrode–skin impedance variation, narrow-band power-line interference centered at 50 Hz, and broadband high-frequency electronic noise introduced by the acquisition hardware. These unwanted components degrade the quality of the recorded signal and may significantly affect the reliability of subsequent feature extraction, parameter estimation, and muscle activity interpretation. For this reason, an effective signal-conditioning procedure is necessary before any higher-level analysis is performed.&lt;br /&gt;
&lt;br /&gt;
In the present implementation, the filtering strategy follows the principle of restricting the signal bandwidth first and then removing the remaining narrow-band interference in a targeted manner. Accordingly, the raw sEMG signal is first processed by a fourth-order Butterworth IIR band-pass filter and then by a 50 Hz notch filter. This processing sequence is illustrated in the flowchart below, where the signal passes through band-pass filtering, notch filtering, full-wave rectification, and envelope extraction before producing the final processed output.&lt;br /&gt;
&lt;br /&gt;
[[File:flowchart.png|thumb|center|500px|Flowchart of the real-time sEMG signal conditioning pipeline.]]&lt;br /&gt;
&lt;br /&gt;
The rationale of this order is that the &#039;&#039;&#039;band-pass stage&#039;&#039;&#039; first confines the signal to the main spectral region of interest for sEMG, thereby attenuating motion artifacts at very low frequencies and suppressing high-frequency noise components outside the physiological band. After this spectral preconditioning, the notch stage can more effectively suppress the residual 50 Hz power-line interference that lies inside the useful sEMG band. In transfer-function form, the band-pass filter may be written as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;H_{BP}(z)=\frac{B_{BP}(z)}{A_{BP}(z)}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where the effective passband is selected as &amp;lt;math&amp;gt;20 \leq f \leq 160 \text{ Hz}&amp;lt;/math&amp;gt;. This frequency interval is consistent with the dominant spectral content of surface EMG: the lower cutoff near 20 Hz reduces motion artifacts and unstable low-frequency fluctuations, whereas the upper cutoff near 160 Hz removes high-frequency electronic noise while preserving the main energy-bearing components of the muscle signal. The use of a Butterworth structure is appropriate here because it provides a smooth monotonic passband response without ripple, which helps preserve signal morphology in real-time applications.&lt;br /&gt;
&lt;br /&gt;
After band limitation, a &#039;&#039;&#039;notch filter&#039;&#039;&#039; centered at the power-line frequency is applied to suppress interference that cannot be removed by the band-pass stage alone. The notch filter is designed around &amp;lt;math&amp;gt;f_0 = 50 \text{ Hz}&amp;lt;/math&amp;gt;, and its bandwidth is controlled by the quality factor &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;, which is expressed as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;Q = \frac{f_0}{\Delta f}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In transfer-function form, the notch stage is written as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;H_{N}(z)=\frac{B_{N}(z)}{A_{N}(z)}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the implemented program, a large quality factor is chosen so that the notch remains narrow, allowing effective rejection of the 50 Hz interference while minimizing distortion of neighboring useful spectral components. This is particularly important for sEMG because the interference frequency lies directly inside the physiological band of interest.&lt;br /&gt;
&lt;br /&gt;
Following the filtering stages, further signal conditioning is performed to obtain a representation that is more directly related to muscle activation intensity. The filtered sEMG waveform is first &#039;&#039;&#039;full-wave rectified&#039;&#039;&#039;, which converts the bipolar oscillatory signal into a unipolar signal by taking its absolute value.  Rectification does not remove noise by itself; instead, it transforms the signal into a form that is more suitable for amplitude-based analysis because both positive and negative deflections contribute positively to the activation measure.&lt;br /&gt;
&lt;br /&gt;
After rectification, the signal envelope is extracted to provide a smooth estimate of muscle activation level over time. In a general formulation, the envelope can be described as the &#039;&#039;&#039;low-pass filtered&#039;&#039;&#039; version of the rectified signal, namely &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y_{\mathrm{env}}[n] = \mathrm{LPF}\bigl(y_{\mathrm{rect}}[n]\bigr)&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the present code implementation, this operation is realized by short-time averaging over a finite window, which is equivalent to a moving-average low-pass smoothing of the rectified waveform. The corresponding expression is &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y_{\mathrm{env}}[n] = \frac{1}{N}\sum_{k=0}^{N-1} |x[n-k]|&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; is the window length in samples. With a window duration of approximately 200 ms, this envelope extraction method provides a stable and physiologically meaningful representation of muscle activation intensity, making it suitable for tasks such as force estimation, fatigue analysis, and motor-control studies.&lt;br /&gt;
&lt;br /&gt;
An important feature of the present &#039;&#039;&#039;implementation&#039;&#039;&#039; is that the entire filtering process is performed &#039;&#039;&#039;in real time&#039;&#039;&#039;, sample by sample, rather than by offline block processing. For this reason, IIR filters are preferred over FIR filters, since they can achieve comparable filtering performance with lower order, lower computational cost, and shorter delay. These properties are especially valuable in embedded systems, serial data streaming, and other low-latency experimental applications. However, unlike memoryless operations, an IIR filter depends not only on the current input but also on previous inputs and previous outputs. Its discrete-time behavior can therefore be represented by the recursive difference equation &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y[n] = \sum_{k=0}^{M} b_k x[n-k] - \sum_{k=1}^{N} a_k y[n-k]&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This equation makes clear that internal filter states must be preserved continuously during streaming operation. If the state variables were reinitialized for every incoming sample or data segment, artificial transients would appear and the output would no longer remain continuous.&lt;br /&gt;
&lt;br /&gt;
In the Python implementation, this state continuity is maintained using the internal initial-condition mechanism provided by SciPy, such as &amp;lt;code&amp;gt;lfilter_zi&amp;lt;/code&amp;gt;, together with recursive state updates during each filtering call. As a result, each newly acquired sample is passed first through the band-pass filter and then through the notch filter, while the internal states of both filters are updated after every step. This state-preserving sample-by-sample design ensures that the processing chain remains causal, continuous, and suitable for real-time display or downstream analysis without requiring storage of the entire signal segment.&lt;br /&gt;
&lt;br /&gt;
Overall, this signal-conditioning scheme provides an experimentally practical solution for real-time sEMG processing. The fourth-order Butterworth band-pass filter confines the signal to the main physiological band of interest, the 50 Hz notch filter removes narrow-band power-line contamination, and the subsequent rectification and envelope extraction generate a smooth amplitude descriptor of muscle activity. Combined with state-preserved streaming IIR implementation, this approach achieves a good balance between signal fidelity, computational efficiency, and real-time applicability in biomedical and physical experiment settings.&lt;br /&gt;
&lt;br /&gt;
== Data Processing ==&lt;br /&gt;
&lt;br /&gt;
The objective of data processing is to convert raw surface electromyography (sEMG) recordings into stable, quantitative, and comparable indicators of muscle activity. Since EMG signals are low in amplitude, highly variable over time, and easily contaminated by noise, a dedicated processing pipeline is necessary before any experimental interpretation can be performed.&lt;br /&gt;
&lt;br /&gt;
In this project, the data processing workflow includes time normalization, signal pre-processing, sliding-window feature extraction, noise-floor estimation, and automatic contraction detection. The processed outputs are then used for subsequent experimental evaluation, including rest-versus-contraction discrimination, signal-to-noise ratio analysis, and repeatability assessment.&lt;br /&gt;
&lt;br /&gt;
=== Input Data and Time Normalization ===&lt;br /&gt;
&lt;br /&gt;
The acquired EMG data are read from CSV files containing two columns: time and filtered sEMG amplitude. In the MATLAB implementation, the time vector is normalized so that each recording starts from zero:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t = t_{all} - t_{all}(1)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This normalization is important because it removes the influence of absolute recording timestamps and makes different trials directly comparable on the same time axis.&lt;br /&gt;
&lt;br /&gt;
In addition, the signal type is automatically identified from the filename as either dynamic or rest. This design allows the same program to process both contraction recordings and resting recordings with different downstream analysis logic.&lt;br /&gt;
&lt;br /&gt;
=== Signal Pre-processing ===&lt;br /&gt;
&lt;br /&gt;
Raw EMG signals cannot be analyzed directly because they usually contain DC offset, low-frequency drift, motion artifacts, and residual high-frequency interference. Therefore, several pre-processing steps are applied before feature extraction.&lt;br /&gt;
&lt;br /&gt;
==== Baseline Removal ====&lt;br /&gt;
&lt;br /&gt;
The first step is DC offset removal:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
x_{dc}(t) = x(t) - \frac{1}{N}\sum_{i=1}^{N}x(i)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This operation centers the signal around zero. It is necessary because an uncorrected baseline would bias amplitude-based metrics and reduce the reliability of later envelope and feature calculations.&lt;br /&gt;
&lt;br /&gt;
==== Band-pass Filtering ====&lt;br /&gt;
&lt;br /&gt;
After baseline correction, a fourth-order Butterworth band-pass filter is applied with a passband of 20–150 Hz.&lt;br /&gt;
&lt;br /&gt;
This step is introduced for two reasons:&lt;br /&gt;
&lt;br /&gt;
* The low-frequency cutoff at 20 Hz suppresses baseline drift and motion artifacts.&lt;br /&gt;
* The high-frequency cutoff at 150 Hz reduces unwanted high-frequency noise while preserving the main energy band of the recorded sEMG in this project.&lt;br /&gt;
&lt;br /&gt;
Compared with processing the raw waveform directly, band-pass filtering makes the subsequent time-domain features more stable and more physiologically meaningful.&lt;br /&gt;
&lt;br /&gt;
==== Full-wave Rectification ====&lt;br /&gt;
&lt;br /&gt;
The filtered EMG signal is bipolar, meaning that positive and negative phases coexist due to motor unit action potentials. If these positive and negative components are averaged directly, they may cancel each other out. To avoid this, full-wave rectification is performed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
x_{rect}(t) = |x_{filt}(t)|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This transforms the signal into a unipolar representation, so that all muscle activity contributes positively to the extracted features.&lt;br /&gt;
&lt;br /&gt;
==== Envelope Extraction ====&lt;br /&gt;
&lt;br /&gt;
Although the rectified signal reflects signal magnitude, it still fluctuates rapidly. To obtain a smoother representation of muscle activation level, an envelope is extracted using a moving average with a 100 ms window.&lt;br /&gt;
&lt;br /&gt;
Envelope extraction is important because contraction detection should reflect the overall activation trend rather than instantaneous spikes. A smoothed envelope is therefore more robust for identifying active and inactive muscle states.&lt;br /&gt;
&lt;br /&gt;
=== Sliding Window Design ===&lt;br /&gt;
&lt;br /&gt;
To quantify how muscle activity changes with time, the filtered signal is divided into overlapping short-time segments using a sliding window method.&lt;br /&gt;
&lt;br /&gt;
The window parameters are:&lt;br /&gt;
&lt;br /&gt;
* Window length: 250 ms&lt;br /&gt;
* Step size: 50 ms&lt;br /&gt;
&lt;br /&gt;
These values are chosen as a trade-off between temporal resolution and feature stability.&lt;br /&gt;
&lt;br /&gt;
A longer window improves statistical robustness because more samples are included in each calculation. However, if the window is too long, short contractions or rapid changes may be blurred. A smaller step size increases temporal continuity between adjacent feature points and makes the feature curves smoother in time. Therefore, the 250 ms / 50 ms design provides a practical balance between smoothing and time localization.&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt;-th segment, the feature time is defined as the mean time of that segment:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t_k = \frac{1}{N}\sum_{i=s_k}^{e_k} t(i)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;s_k&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;e_k&amp;lt;/math&amp;gt; denote the start and end indices of the window.&lt;br /&gt;
&lt;br /&gt;
=== Feature Extraction ===&lt;br /&gt;
&lt;br /&gt;
Within each sliding window, three time-domain features are extracted: RMS, iEMG, and MAV. These features are widely used in EMG analysis because they are simple, computationally efficient, and directly related to muscle activation intensity.&lt;br /&gt;
&lt;br /&gt;
==== Root Mean Square (RMS) ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
RMS = \sqrt{\frac{1}{N}\sum_{i=1}^{N}x_i^2}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
RMS reflects the effective power of the EMG signal and is one of the most common indicators of contraction strength. It is sensitive to both amplitude and energy, making it especially useful for comparing rest and active states.&lt;br /&gt;
&lt;br /&gt;
==== Integrated EMG (iEMG) ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
iEMG = \sum_{i=1}^{N}|x_i|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
iEMG describes the cumulative electrical activity within a window. It is often interpreted as a measure of total muscle effort over that time segment.&lt;br /&gt;
&lt;br /&gt;
==== Mean Absolute Value (MAV) ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
MAV = \frac{1}{N}\sum_{i=1}^{N}|x_i|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
MAV is an amplitude descriptor similar to iEMG, but normalized by the number of samples. It provides an efficient estimate of average signal level and is less computationally intensive than some other features.&lt;br /&gt;
&lt;br /&gt;
These three features are used together because they provide complementary descriptions of EMG intensity. RMS emphasizes signal energy, iEMG emphasizes cumulative activation, and MAV reflects average amplitude.&lt;br /&gt;
&lt;br /&gt;
=== Peak-value Extraction ===&lt;br /&gt;
&lt;br /&gt;
In addition to continuous feature curves, several key peak values are extracted from the processed signal:&lt;br /&gt;
&lt;br /&gt;
* maximum and minimum of the filtered EMG waveform&lt;br /&gt;
* peak of the envelope&lt;br /&gt;
* peak RMS&lt;br /&gt;
* peak iEMG&lt;br /&gt;
* peak MAV&lt;br /&gt;
&lt;br /&gt;
These peak values provide concise descriptors of the strongest activity observed in each recording. They are useful for quick comparison across trials and subjects.&lt;br /&gt;
&lt;br /&gt;
=== Noise Floor Estimation ===&lt;br /&gt;
&lt;br /&gt;
To evaluate signal quality, the noise floor is estimated from a reference resting interval. In the present implementation, the first 3 seconds of the recording are used as the default rest reference:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t \in [0,\min(3,t_{end})]&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this segment, three noise descriptors are computed:&lt;br /&gt;
&lt;br /&gt;
* Noise RMS&lt;br /&gt;
* Noise standard deviation&lt;br /&gt;
* Noise peak-to-peak amplitude&lt;br /&gt;
&lt;br /&gt;
Noise-floor estimation is important because EMG amplitude alone is not sufficient to judge recording quality. A large signal is only meaningful if it is sufficiently higher than the baseline noise level. Therefore, the noise floor serves as the reference for later SNR calculation and for designing contraction thresholds.&lt;br /&gt;
&lt;br /&gt;
=== Global Signal Metrics ===&lt;br /&gt;
&lt;br /&gt;
For each recording, three global metrics are also computed over the entire filtered signal:&lt;br /&gt;
&lt;br /&gt;
* Global RMS&lt;br /&gt;
* Global MAV&lt;br /&gt;
* Global iEMG&lt;br /&gt;
&lt;br /&gt;
These global descriptors summarize the overall signal level of the full recording and are later used in group-level comparisons.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Contraction Detection ===&lt;br /&gt;
&lt;br /&gt;
For dynamic recordings, an automatic contraction detection algorithm is used to identify repeated active segments. This is one of the key parts of the data processing pipeline, because it transforms a continuous EMG trace into discrete contraction events that can be counted and compared.&lt;br /&gt;
&lt;br /&gt;
==== Threshold Design ====&lt;br /&gt;
&lt;br /&gt;
The detection threshold is designed adaptively rather than using a fixed value. Two candidate thresholds are first calculated:&lt;br /&gt;
&lt;br /&gt;
* an envelope-based threshold derived from the global envelope mean and standard deviation&lt;br /&gt;
* a rest-reference threshold derived from the mean and standard deviation of the resting reference amplitude&lt;br /&gt;
&lt;br /&gt;
The final threshold is taken as the larger of the two after additional scaling. This strategy improves robustness because it combines the global activation level of the signal with the baseline noise characteristics of the individual recording.&lt;br /&gt;
&lt;br /&gt;
This adaptive threshold design is preferable to a manually fixed threshold because EMG amplitude can vary strongly between subjects, muscles, and recording sessions.&lt;br /&gt;
&lt;br /&gt;
==== Initial Segmentation ====&lt;br /&gt;
&lt;br /&gt;
After thresholding the envelope, the signal is classified into active and inactive regions:&lt;br /&gt;
&lt;br /&gt;
* active: envelope above threshold&lt;br /&gt;
* inactive: envelope below threshold&lt;br /&gt;
&lt;br /&gt;
The rising and falling edges of the binary activity vector are then used to determine the start and end points of each candidate contraction segment.&lt;br /&gt;
&lt;br /&gt;
==== Removal of Short Segments ====&lt;br /&gt;
&lt;br /&gt;
Very short active regions are often caused by noise fluctuations rather than true muscle contractions. Therefore, segments shorter than 0.20 s are discarded.&lt;br /&gt;
&lt;br /&gt;
This step prevents false positive detections and increases the physiological relevance of the segmentation results.&lt;br /&gt;
&lt;br /&gt;
==== Merging of Adjacent Segments ====&lt;br /&gt;
&lt;br /&gt;
If two neighboring active segments are separated by a very short gap, they are merged when the gap is less than 0.15 s.&lt;br /&gt;
&lt;br /&gt;
This operation is necessary because a single real contraction may be temporarily interrupted by a brief drop in the envelope caused by local fluctuation. Without merging, one contraction could be incorrectly counted as multiple repetitions.&lt;br /&gt;
&lt;br /&gt;
==== Repetition-level Metrics ====&lt;br /&gt;
&lt;br /&gt;
For each detected contraction segment, two repetition-level metrics are extracted:&lt;br /&gt;
&lt;br /&gt;
* peak RMS of that contraction&lt;br /&gt;
* mean RMS of that contraction&lt;br /&gt;
&lt;br /&gt;
These metrics quantify both the strongest activation within each repetition and the average activation level over the repetition duration.&lt;br /&gt;
&lt;br /&gt;
=== Repeatability Analysis ===&lt;br /&gt;
&lt;br /&gt;
When multiple valid contractions are detected, repeatability is evaluated using the coefficient of variation (CV):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
CV = \frac{\sigma}{\mu}\times 100\%&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt; is the standard deviation and &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is the mean value across repetitions.&lt;br /&gt;
&lt;br /&gt;
Two CV values are computed:&lt;br /&gt;
&lt;br /&gt;
* CV of repetition peak RMS&lt;br /&gt;
* CV of repetition mean RMS&lt;br /&gt;
&lt;br /&gt;
A lower CV indicates better repeatability, meaning that repeated contractions produce more consistent EMG responses.&lt;br /&gt;
&lt;br /&gt;
=== Signal-to-Noise Ratio (SNR) ===&lt;br /&gt;
&lt;br /&gt;
In this project, the signal-to-noise ratio (SNR) is defined based on the ratio between contraction and rest activity:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
SNR_{dB} = 20\log_{10}\left(\frac{RMS_{contraction}}{RMS_{rest}}\right)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This definition is adopted because it directly reflects the system’s ability to distinguish active muscle contraction from baseline noise.&lt;br /&gt;
&lt;br /&gt;
Compared with global SNR definitions, this formulation is more relevant for practical EMG applications such as activity detection and classification.&lt;br /&gt;
&lt;br /&gt;
=== Rest-versus-Contraction Window Comparison ===&lt;br /&gt;
&lt;br /&gt;
To further distinguish inactive and active states, all sliding windows are divided into two groups:&lt;br /&gt;
&lt;br /&gt;
* rest windows: windows with envelope clearly below the threshold&lt;br /&gt;
* contraction windows: windows with envelope above the threshold&lt;br /&gt;
&lt;br /&gt;
The RMS values of these two groups are then compared statistically.&lt;br /&gt;
&lt;br /&gt;
This comparison is important because a practical EMG system should not only detect signal presence, but also clearly separate rest from contraction in a quantitative way. If the two RMS distributions are well separated, it indicates that the system has good discriminative capability.&lt;br /&gt;
&lt;br /&gt;
=== Output Data Structure ===&lt;br /&gt;
&lt;br /&gt;
The processed outputs are organized into structured data for experimental analysis:&lt;br /&gt;
&lt;br /&gt;
==== Time-series outputs ====&lt;br /&gt;
* Filtered EMG signal  &lt;br /&gt;
* Rectified signal  &lt;br /&gt;
* Envelope  &lt;br /&gt;
* RMS(t), iEMG(t), MAV(t)  &lt;br /&gt;
&lt;br /&gt;
==== Recording-level outputs ====&lt;br /&gt;
* RMS (rest)  &lt;br /&gt;
* RMS (contraction)  &lt;br /&gt;
* iEMG  &lt;br /&gt;
* Noise metrics  &lt;br /&gt;
&lt;br /&gt;
==== Dynamic-signal outputs ====&lt;br /&gt;
* Detected contractions  &lt;br /&gt;
* Repetition count  &lt;br /&gt;
* Peak RMS per repetition  &lt;br /&gt;
* Mean RMS per repetition  &lt;br /&gt;
* Coefficient of variation (CV)  &lt;br /&gt;
* Signal-to-noise ratio (SNR)  &lt;br /&gt;
&lt;br /&gt;
All extracted features are designed to directly support the evaluation of noise level, signal quality, activity discrimination, and repeatability in the subsequent experimental analysis.&lt;br /&gt;
&lt;br /&gt;
== Experimental Results ==&lt;br /&gt;
&lt;br /&gt;
This section presents representative results of the EMG acquisition and data processing pipeline under both dynamic (muscle contraction) and resting conditions.&lt;br /&gt;
&lt;br /&gt;
=== Representative Dynamic Signal Analysis ===&lt;br /&gt;
&lt;br /&gt;
[[File:Dynamic_Figure1.png|thumb|800px|center|Figure 5.1: Processed EMG signal under dynamic contraction, including filtered signal, rectified signal with envelope, and extracted features (RMS, iEMG, MAV).]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.1 shows the processed EMG signal during repeated muscle contractions.&lt;br /&gt;
&lt;br /&gt;
The filtered EMG waveform exhibits clear burst-like patterns corresponding to periodic contractions. The signal amplitude reaches a maximum of approximately 0.45, while the baseline remains centered around zero, indicating effective baseline removal and filtering.&lt;br /&gt;
&lt;br /&gt;
After rectification and envelope extraction, the contraction periods become clearly distinguishable. The envelope provides a smooth representation of muscle activation, with a peak value of approximately 0.145.&lt;br /&gt;
&lt;br /&gt;
The extracted time-domain features (RMS, iEMG, MAV) further quantify the signal. Among these, iEMG shows the strongest dynamic variation, indicating high sensitivity to contraction intensity.&lt;br /&gt;
&lt;br /&gt;
=== Noise Floor and Rest Reference ===&lt;br /&gt;
&lt;br /&gt;
[[File:Dynamic_Figure2.png|thumb|800px|center|Figure 5.2: Noise estimation, rest vs contraction comparison, automatic contraction detection, and repetition analysis.]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (top-left) shows the resting reference segment used for noise estimation.&lt;br /&gt;
&lt;br /&gt;
The signal remains centered around zero with small fluctuations. The noise characteristics are:&lt;br /&gt;
&lt;br /&gt;
* Noise RMS ≈ 0.0046  &lt;br /&gt;
* Standard deviation ≈ 0.0046  &lt;br /&gt;
* Peak-to-peak amplitude ≈ 0.071  &lt;br /&gt;
&lt;br /&gt;
This indicates a low noise floor and stable measurement conditions.&lt;br /&gt;
&lt;br /&gt;
=== Rest vs Contraction Discrimination ===&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (top-right) compares RMS values between rest and contraction states.&lt;br /&gt;
&lt;br /&gt;
The two distributions are clearly separated:&lt;br /&gt;
&lt;br /&gt;
* Rest mean RMS ≈ 0.0053  &lt;br /&gt;
* Contraction mean RMS ≈ 0.1064  &lt;br /&gt;
&lt;br /&gt;
This corresponds to an approximate 20× increase, demonstrating strong discriminability between inactive and active muscle states.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Contraction Detection ===&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (bottom-left) illustrates automatic detection based on the envelope signal.&lt;br /&gt;
&lt;br /&gt;
A threshold of approximately 0.040 is applied, resulting in stable segmentation of contraction periods.&lt;br /&gt;
&lt;br /&gt;
A total of 12 repetitions are detected, with good alignment to visible signal peaks.&lt;br /&gt;
&lt;br /&gt;
=== Repeatability Analysis ===&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (bottom-right) shows the peak RMS value of each detected contraction.&lt;br /&gt;
&lt;br /&gt;
The results indicate:&lt;br /&gt;
&lt;br /&gt;
* Mean peak RMS ≈ 0.1355  &lt;br /&gt;
* Standard deviation ≈ 0.0173  &lt;br /&gt;
* CV ≈ 12.77%  &lt;br /&gt;
* SNR ≈ 21.26 dB  &lt;br /&gt;
&lt;br /&gt;
This indicates acceptable repeatability and good signal quality.&lt;br /&gt;
&lt;br /&gt;
=== Representative Rest Signal Analysis ===&lt;br /&gt;
&lt;br /&gt;
[[File:Rest_Figure1.png|800px|center|Figure 3: Processed EMG signal under rest condition, showing low amplitude and absence of contraction patterns.]]&lt;br /&gt;
&lt;br /&gt;
Figure 3 shows the EMG signal under resting conditions.&lt;br /&gt;
&lt;br /&gt;
The signal remains within a narrow amplitude range (approximately ±0.04) and shows no burst-like structures. The envelope remains close to zero, confirming the absence of muscle activity.&lt;br /&gt;
&lt;br /&gt;
The extracted features remain low:&lt;br /&gt;
&lt;br /&gt;
* RMS ≈ 0.007  &lt;br /&gt;
* MAV ≈ 0.005  &lt;br /&gt;
* iEMG remains stable  &lt;br /&gt;
&lt;br /&gt;
This confirms that no false activation is detected.&lt;br /&gt;
&lt;br /&gt;
=== Frequency-domain Characteristics ===&lt;br /&gt;
&lt;br /&gt;
[[File:Rest_Figure2.png|800px|center|Figure 4: Frequency-domain analysis and statistical characteristics of rest signal.]]&lt;br /&gt;
&lt;br /&gt;
Figure 4 shows the frequency-domain characteristics of the resting signal.&lt;br /&gt;
&lt;br /&gt;
The power spectral density (PSD) indicates low overall signal energy without dominant peaks, confirming that the signal mainly consists of noise.&lt;br /&gt;
&lt;br /&gt;
=== Summary of Single-recording Performance ===&lt;br /&gt;
&lt;br /&gt;
From the representative results:&lt;br /&gt;
&lt;br /&gt;
* EMG signals are effectively extracted and denoised  &lt;br /&gt;
* Contraction events are clearly identifiable  &lt;br /&gt;
* Rest and contraction states are well separated  &lt;br /&gt;
* Automatic detection is stable and accurate  &lt;br /&gt;
* Repeatability is acceptable  &lt;br /&gt;
* No false activation occurs under rest conditions  &lt;br /&gt;
&lt;br /&gt;
=== Consistency Across Multiple Recordings ===&lt;br /&gt;
&lt;br /&gt;
The same data processing pipeline was applied to multiple recordings from different subjects and trials.&lt;br /&gt;
&lt;br /&gt;
Across all datasets, consistent patterns were observed:&lt;br /&gt;
&lt;br /&gt;
* Dynamic signals exhibit clear burst-like structures corresponding to repeated muscle contractions  &lt;br /&gt;
* Rest signals remain low in amplitude without distinct activation patterns  &lt;br /&gt;
* RMS values under contraction are consistently higher than those under rest  &lt;br /&gt;
* The automatic detection algorithm reliably identifies contraction segments  &lt;br /&gt;
&lt;br /&gt;
Although quantitative values (e.g., RMS, SNR, CV) vary across recordings due to differences in electrode contact, muscle activation strength, and individual conditions, the overall trends remain consistent.&lt;br /&gt;
&lt;br /&gt;
These results demonstrate the robustness and general applicability of the proposed signal processing method.&lt;br /&gt;
&lt;br /&gt;
== Multi-subject Analysis ==&lt;br /&gt;
=== System Evaluation ===&lt;br /&gt;
&lt;br /&gt;
This section evaluates the performance of the EMG acquisition system in terms of noise level, signal quality, activity discrimination, and repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Noise Floor Analysis ====&lt;br /&gt;
&lt;br /&gt;
The noise floor was evaluated using rest-state recordings, characterized by RMS noise, standard deviation, and peak-to-peak amplitude.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039; shows the lowest noise level (RMS ≈ 0.0046), indicating stable electrode contact and minimal interference.  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039; exhibits moderate noise (RMS ≈ 0.0080), likely influenced by motion artifacts or electrode–skin impedance variation.  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039; shows relatively higher noise (RMS ≈ 0.0126), suggesting increased baseline fluctuation.  &lt;br /&gt;
&lt;br /&gt;
Overall, the system maintains a low noise floor across subjects, although the quality depends on experimental conditions such as electrode contact and environmental interference.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Signal-to-Noise Ratio (SNR) ====&lt;br /&gt;
&lt;br /&gt;
The signal-to-noise ratio (SNR) is defined as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{SNR (dB)} = 20 \log_{10} \left( \frac{\mathrm{RMS}_{\mathrm{contraction}}}{\mathrm{RMS}_{\mathrm{rest}}} \right)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The measured SNR values are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: 21.26 dB → good signal quality  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: 13.52 dB → moderate and usable  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: 6.66 dB → low signal clarity  &lt;br /&gt;
&lt;br /&gt;
General interpretation:&lt;br /&gt;
&lt;br /&gt;
* &amp;gt;20 dB → good  &lt;br /&gt;
* 10–20 dB → usable  &lt;br /&gt;
* &amp;lt;10 dB → poor  &lt;br /&gt;
&lt;br /&gt;
These results show that the system can achieve reliable signal acquisition, although performance varies across subjects.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
====  Rest vs Contraction Discrimination ====&lt;br /&gt;
&lt;br /&gt;
A clear distinction between rest and contraction states is observed based on RMS values.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: 0.0053 → 0.1064 (≈20× increase)  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: 0.0079 → 0.0283 (≈3.6× increase)  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: 0.0141 → 0.0646 (≈4.6× increase)  &lt;br /&gt;
&lt;br /&gt;
This demonstrates that the system is capable of separating muscle activity from baseline noise.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Conclusion:&#039;&#039;  &lt;br /&gt;
The system can be used for basic muscle activity detection and simple classification tasks based on RMS features.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Repeatability of Repeated Contractions ====&lt;br /&gt;
&lt;br /&gt;
Repeatability is evaluated using the coefficient of variation (CV) of peak RMS values across repetitions.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! CV Range !! Evaluation&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt; 10% || Excellent&lt;br /&gt;
|-&lt;br /&gt;
| 10–20% || Acceptable&lt;br /&gt;
|-&lt;br /&gt;
| &amp;gt; 20% || Poor&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Results:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: CV = 12.77% → Acceptable  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: CV = 24.77% → Poor  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: CV = 10.60% → Acceptable  &lt;br /&gt;
&lt;br /&gt;
Although WANG&#039;s signal is detectable, its contraction amplitude varies significantly across repetitions, resulting in poor repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
=== Overall System Performance ===&lt;br /&gt;
&lt;br /&gt;
The system demonstrates the following performance characteristics:&lt;br /&gt;
&lt;br /&gt;
* Reliable detection of muscle activity across all subjects  &lt;br /&gt;
* Clear separation between rest and contraction states  &lt;br /&gt;
* Moderate to high signal quality depending on subject conditions  &lt;br /&gt;
* Repeatability ranging from acceptable to poor due to user-dependent factors  &lt;br /&gt;
&lt;br /&gt;
Overall, the designed EMG acquisition system is capable of stable signal acquisition and feature extraction, with performance primarily influenced by electrode contact quality, skin impedance, and motion consistency.&lt;br /&gt;
&lt;br /&gt;
===== Summary of Quantitative Metrics =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Subject !! RMS (Rest) !! RMS (Contraction) !! Separation Ratio !! iEMG (max) !! Noise RMS !! SNR (dB) !! CV (%) !! Evaluation&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;LIU&#039;&#039;&#039; || 0.0053 || 0.1064 || &#039;&#039;&#039;20.1×&#039;&#039;&#039; || 12.72 || 0.0046 || &#039;&#039;&#039;21.26&#039;&#039;&#039; || 12.77 || Strong signal, good quality&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;WANG&#039;&#039;&#039; || 0.0079 || 0.0283 || 3.57× || 11.10 || 0.0080 || 13.52 || &#039;&#039;&#039;24.77&#039;&#039;&#039; || Usable signal, poor repeatability&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ZHONG&#039;&#039;&#039; || 0.0141 || 0.0646 || 4.58× || 6.70 || 0.0126 || 6.66 || 10.60 || Acceptable performance&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Summary:&#039;&#039; Subject LIU shows the best overall performance, WANG provides usable but less stable signals, and ZHONG demonstrates moderate signal quality with good repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Activation Intensity =====&lt;br /&gt;
&lt;br /&gt;
Among the three subjects, &#039;&#039;&#039;LIU exhibits the strongest muscle activation&#039;&#039;&#039;, as indicated by the highest contraction RMS and iEMG values. ZHONG shows moderate activation, while WANG demonstrates comparable iEMG but lower RMS consistency.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Signal Quality =====&lt;br /&gt;
&lt;br /&gt;
Signal quality is evaluated based on SNR and noise level:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039; achieves the highest SNR and lowest noise → best signal quality  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039; shows moderate SNR → usable but less robust  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039; has the lowest SNR → weakest signal clarity  &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Repeatability =====&lt;br /&gt;
&lt;br /&gt;
Repeatability is evaluated using the coefficient of variation (CV):&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;ZHONG (10.60%)&#039;&#039;&#039; → most stable  &lt;br /&gt;
* &#039;&#039;&#039;LIU (12.77%)&#039;&#039;&#039; → acceptable  &lt;br /&gt;
* &#039;&#039;&#039;WANG (24.77%)&#039;&#039;&#039; → poor  &lt;br /&gt;
&lt;br /&gt;
This indicates that WANG’s contraction strength varies significantly between repetitions.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Engineering Interpretation of Inter-subject Differences =====&lt;br /&gt;
&lt;br /&gt;
The observed differences are mainly attributed to engineering and experimental factors rather than physiological differences.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Electrode contact quality&#039;&#039;&#039;  &lt;br /&gt;
  Variations in electrode placement, pressure, and gel contact affect signal amplitude and stability.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Skin impedance&#039;&#039;&#039;  &lt;br /&gt;
  Differences in skin condition (hydration, oil, hair) influence electrode–skin impedance, affecting noise level and signal coupling.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Muscle control consistency&#039;&#039;&#039;  &lt;br /&gt;
  Variations in contraction strength and timing affect repeatability and CV.&lt;br /&gt;
&lt;br /&gt;
Therefore, the variation across subjects reflects practical acquisition conditions rather than intrinsic system limitations.&lt;/div&gt;</summary>
		<author><name>Wang Jingyi</name></author>
	</entry>
	<entry>
		<id>https://pc5271.org/index.php?title=Surface_EMG_Sensor_for_Muscle_Activity_Measurement:_AFE_Design_and_Signal_Processing&amp;diff=1357</id>
		<title>Surface EMG Sensor for Muscle Activity Measurement: AFE Design and Signal Processing</title>
		<link rel="alternate" type="text/html" href="https://pc5271.org/index.php?title=Surface_EMG_Sensor_for_Muscle_Activity_Measurement:_AFE_Design_and_Signal_Processing&amp;diff=1357"/>
		<updated>2026-04-23T06:45:50Z</updated>

		<summary type="html">&lt;p&gt;Wang Jingyi: /* Automatic Contraction Detection */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Background and Theory==&lt;br /&gt;
&lt;br /&gt;
=== Surface EMG Signals ===&lt;br /&gt;
Surface electromyography (sEMG) refers to the bioelectrical signals detected on the skin surface during muscle contraction. These signals originate from the electrical activity of muscle fibers and provide a non-invasive way to monitor muscle activation. Compared with invasive EMG methods, sEMG is easier to apply, safer for repeated measurements, and more suitable for real-time monitoring. Therefore, it has been widely used in areas such as rehabilitation, motion analysis, human–machine interaction, and physiological monitoring.&lt;br /&gt;
&lt;br /&gt;
=== Characteristics of EMG Signals ===&lt;br /&gt;
EMG signals are generally weak, time-varying, and stochastic in nature. Their waveforms are typically bipolar, fluctuating around zero with both positive and negative components. The amplitude and frequency content of EMG signals depend on factors such as muscle contraction level, electrode placement, skin condition, and individual physiological differences. In practice, the useful frequency components of sEMG are mainly concentrated in a limited low-to-mid frequency range. Because of their low amplitude and variability, EMG signals usually require further conditioning before reliable interpretation and feature extraction can be performed.&lt;br /&gt;
&lt;br /&gt;
=== Bioelectrical Signal Acquisition Principles ===&lt;br /&gt;
The acquisition of bioelectrical signals is based on measuring the small potential difference on the skin surface using electrodes, then converting it into a processable electrical signal through amplification and digitization. For sEMG measurement, electrode placement and skin–electrode contact quality are especially important, since they directly affect signal amplitude and stability. In addition, the front-end acquisition circuit must provide sufficient sensitivity and good interference rejection, so that the recorded signal reflects actual muscle activity rather than environmental disturbance or poor contact conditions.&lt;br /&gt;
&lt;br /&gt;
=== Noise Sources in EMG (50 Hz, motion artifacts) ===&lt;br /&gt;
In practical EMG recording, the measured signal is easily contaminated by different types of noise. Two of the most common sources are power-line interference and motion artifacts. Power-line interference usually appears as a narrow-band component at 50 Hz in the local electrical environment, while motion artifacts are mainly caused by electrode movement, cable disturbance, or variations in the electrode–skin impedance, and are often concentrated in the low-frequency range. In addition, electronic noise from the acquisition hardware may also affect the recording quality. These unwanted components can reduce signal clarity and make muscle activity analysis less reliable, so they must be considered in the design of the signal processing pipeline.&lt;br /&gt;
[[File:background_theory_figure1.1_emg_noise_sources.png|center|thumb|700px|&#039;&#039;&#039;Figure 1.1.&#039;&#039;&#039; Principle of surface EMG acquisition.]]&lt;br /&gt;
&lt;br /&gt;
==System Architecture==&lt;br /&gt;
=== Total Structure Design ===&lt;br /&gt;
&lt;br /&gt;
For clarity，the proposed physiological signal acquisition system mainly consists of two core parts：the analog front－end （AFE）and the ADC board．The AFE is responsible for the preliminary conditioning of weak bioelectrical signals，including amplification，filtering，interference suppression，and level shifting，so that the analog waveform can be converted into a stable and measurable form．The ADC board then performs high－resolution digitization of the conditioned signal and transfers the sampled data to the host computer for subsequent display，storage，and analysis．Therefore，the overall system forms a complete signal－acquisition chain from weak physiological input to digital output．&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_1.jpg|thumb|center|800px|Figure 2.1. Overall system architecture of the proposed physiological signal acquisition platform，including the AFE and ADC modules．]]&lt;br /&gt;
&lt;br /&gt;
=== sEMG AFE Design ===&lt;br /&gt;
&lt;br /&gt;
To collect the weak bioelectric potential signals of the human body，an analog front－end（AFE）suitable sEMG measurements was designed．The module is powered by an external 5 V supply，and the complete circuit includes a first－ stage instrumentation amplifier based on INA128（Texas Instruments，Dallas，TX，USA），a band－pass filter，a 50 Hz notch filter，a second－order amplification and level shifting stage，a driver electrode circuit，a precise 1.5 V reference source，and a -5 V voltage generation module for powering the operational amplifiers．&lt;br /&gt;
&lt;br /&gt;
==== First－order Amplifier ====&lt;br /&gt;
&lt;br /&gt;
The input bioelectric signal is first acquired in differential form and applied to the INA128 instrumentation amplifier，which provides high input impedance，high common－mode rejection，and moderate initial gain for sEMG acquisition．This stage enlarges the weak physiological signal before filtering while reducing the risk of premature saturation caused by electrode offset or motion－induced disturbance，thereby preparing a more stable signal for the subsequent conditioning stages．&lt;br /&gt;
&lt;br /&gt;
==== Bandpass Filter ====&lt;br /&gt;
&lt;br /&gt;
After the instrumentation amplifier，the signal passes through a second－order active band－pass filter，as shown in Figure 2．2． This stage suppresses baseline drift and high－frequency noise outside the useful sEMG range，so that the low－frequency envelope information of sEMG can be preserved before further amplification．&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_2.jpg|thumb|center|800px|Figure 2.2. Schematic diagram of the active band-pass filter used in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the band-pass stage used to retain the main physiological signal band while suppressing unwanted lowand high-frequency components.&lt;br /&gt;
&lt;br /&gt;
==== Notch Filter ====&lt;br /&gt;
&lt;br /&gt;
To reduce power-line interference, a dedicated 50 Hz notch filter is introduced after the band-pass stage, as shown in Figure 2.3. This filter attenuates the mains-frequency component that commonly contaminates weak bioelectric measurements, thereby improving the signal-to-noise ratio of sEMG signals before the final amplification stage.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_3.jpg|thumb|center|800px|Figure 2.3. Schematic diagram of the 50 Hz notch filter used in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the circuit used to attenuate 50 Hz mains interference in the analog front end.&lt;br /&gt;
&lt;br /&gt;
==== Second-order Amplifier &amp;amp; Level Shifter ====&lt;br /&gt;
&lt;br /&gt;
After filtering, the signal enters the second-stage amplification and level-shifting circuit shown in Figure 2.4. In this stage, the filtered signal is further amplified to improve amplitude utilization and then shifted by a 1.5 V reference so that the output becomes a stable unipolar signal suitable for ADC sampling, while preserving linear operation and providing sufficient output swing margin.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_4.jpg|thumb|center|800px|Figure 2.4. Schematic diagram of the second-stage amplifier and level-shifting circuit in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows how the conditioned signal is further amplified and shifted to a suitable DC level before digitization.&lt;br /&gt;
&lt;br /&gt;
==== Power Module and Drive-electrode Circuit ====&lt;br /&gt;
&lt;br /&gt;
The AFE is powered by a 5 V supply and also integrates a 1.5 V precision reference, a -5 V generation circuit, and a driveelectrode circuit. These supporting modules provide the required supply rails and reference level for analog signal conditioning, while the drive-electrode circuit feeds back common-mode voltage to the body to suppress interference at the source. As a result, the complete AFE can support sEMG acquisition with adequate gain, filtering, and noise-reduction performance in a compact hardware structure.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_5.jpg|thumb|center|800px|Figure 2.5. Physical picture of the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the fabricated sEMG analog front-end hardware used in the system.&lt;br /&gt;
&lt;br /&gt;
Figure 2.5 presents the practical hardware implementation of the proposed sEMG AFE. It integrates amplification, filtering, level shifting, and driven-reference functions in a compact circuit for weak bioelectrical signal acquisition.&lt;br /&gt;
&lt;br /&gt;
=== ADS1256-based ADC Board ===&lt;br /&gt;
&lt;br /&gt;
To digitize the conditioned weak physiological signals with sufficient resolution and low noise, this project developed a dedicated ADC board based on the ADS1256 analog-to-digital converter (Texas Instruments, Dallas, TX, USA) and the STM32F103C8T6 microcontroller (STMicroelectronics, Geneva, Switzerland). The overall design objective of this board was not merely to realize analog-to-digital conversion, but to provide a complete hardware interface between the analog front-end and the digital processing unit, including precision reference generation, clocking, input protection and filtering, serial communication, power regulation, and MCU-based acquisition control. The ADS1256 was selected because it is a&lt;br /&gt;
&lt;br /&gt;
very low-noise 24-bit delta-sigma converter with a programmable gain amplifier (PGA), flexible input multiplexer, programmable digital filter, and SPI-compatible serial interface, which makes it well suited for weak low-frequency physiological signals after analog conditioning. The STM32F103C8T6 was used as the local controller because it provides a 32-bit Cortex-M3 core, up to 72 MHz system clock, SPI, USART, USB, and standard SWD debugging support in a compact and low-cost platform.&lt;br /&gt;
&lt;br /&gt;
==== ADC Core Architecture and Design Rationale ====&lt;br /&gt;
&lt;br /&gt;
The ADS1256 was selected as the core ADC because it provides high-resolution, low-noise delta-sigma conversion with an input multiplexer, programmable gain amplifier, and digital filter, which are suitable for weak and low-frequency physiological signals. As shown in Figure 2.6, this architecture emphasizes resolution and noise performance rather than high conversion bandwidth, making it appropriate for sEMG signal digitization after analog conditioning.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_6.jpg|thumb|center|800px|Figure 2.6. Internal functional structure of the ADS1256 analog-to-digital converter.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the main internal blocks of the ADS1256, including the multiplexer, PGA, modulator, and digital filter.&lt;br /&gt;
&lt;br /&gt;
==== Analog Front-End Interface, Reference, and Clocking ====&lt;br /&gt;
&lt;br /&gt;
The ADS1256 analog inputs are connected to the external header through a passive input-conditioning network that helps suppress high-frequency interference and improve input stability. In addition, the board includes a dedicated precision reference and clocking circuits so that the ADC can perform stable and accurate conversion. Together, these circuits provide a reliable analog interface and timing basis for high-resolution digitization of weak physiological signals.&lt;br /&gt;
&lt;br /&gt;
==== SPI Interface between ADS1256 and STM32F103C8T6 ====&lt;br /&gt;
&lt;br /&gt;
Communication between the ADS1256 and the STM32F103C8T6 is implemented through an SPI-compatible interface, with dedicated lines for chip select, serial clock, input/output data, data-ready notification, and hardware reset. This connection allows the MCU to configure the ADC, read conversion results in synchrony with DRDY, and maintain efficient and reliable acquisition control for multi-channel physiological measurements.&lt;br /&gt;
&lt;br /&gt;
==== Power Supply and On-board Regulation ====&lt;br /&gt;
&lt;br /&gt;
The ADC board uses a USB Type-B connector as the main power input and includes protection, voltage regulation, and local decoupling circuits to provide a stable supply for both the MCU and ADC-related hardware. In addition, analog ground and digital ground are separated in the PCB layout to reduce digital noise coupling into the analog path, which is particularly important for weak physiological signal acquisition.&lt;br /&gt;
&lt;br /&gt;
==== Basic Peripheral Circuits of the STM32F103C8T6 ====&lt;br /&gt;
&lt;br /&gt;
The STM32F103C8T6 serves as the local controller of the ADC board and is supported by several basic peripheral circuits, including an external crystal oscillator, reset network, BOOT0 configuration, SWD programming/debugging header, and a CH340N USB-to-UART bridge. These circuits ensure stable MCU operation, convenient firmware downloading and debugging, and reliable data transmission from the board to the host computer for real-time display and storage.&lt;br /&gt;
&lt;br /&gt;
==== Hardware-level Working Principle of the ADC Board ====&lt;br /&gt;
&lt;br /&gt;
In operation, the conditioned analog signal from the AFE enters the ADS1256 through the input header, is digitized with high resolution under the control of the local precision reference and clock, and is then read by the STM32 through the SPI interface. The MCU subsequently forwards the sampled data to the host computer through the serial communication link, so that the entire board functions as a compact digital acquisition backend connecting weak physiological analog signals to later software processing, display, and storage.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_7.jpg|thumb|center|800px|Figure 2.7. Photograph of the fabricated ADS1256-based ADC board developed in this project and the definitions of some key pins.]]&lt;br /&gt;
&lt;br /&gt;
Figure 2.7 shows the ADC board fabricated for this project. It integrates the ADS1256 conversion core, STM32 control circuit, power-conditioning circuits, and communication interfaces on a compact PCB for physiological signal digitization.&lt;br /&gt;
&lt;br /&gt;
== Signal Conditioning and Filtering ==&lt;br /&gt;
Although the AFE already performs preliminary band-pass filtering and 50 Hz interference suppression in the analog domain, the digitized sEMG signal may still contain residual noise due to component tolerances, electrode-contact variation, and environmental interference. Therefore, an additional digital filtering stage is implemented in software as a complementary post-processing step to improve signal quality and to provide a more stable input for rectification, envelope extraction, and subsequent analysis. In this sense, the software filtering is not a simple repetition of the analog filtering, but a refinement and compensation for non-ideal front-end behavior.&lt;br /&gt;
&lt;br /&gt;
Surface electromyographic (sEMG) signals are highly susceptible to several sources of contamination during acquisition. In practical measurements, the dominant disturbances usually include low-frequency motion artifacts caused by electrode movement and electrode–skin impedance variation, narrow-band power-line interference centered at 50 Hz, and broadband high-frequency electronic noise introduced by the acquisition hardware. These unwanted components degrade the quality of the recorded signal and may significantly affect the reliability of subsequent feature extraction, parameter estimation, and muscle activity interpretation. For this reason, an effective signal-conditioning procedure is necessary before any higher-level analysis is performed.&lt;br /&gt;
&lt;br /&gt;
In the present implementation, the filtering strategy follows the principle of restricting the signal bandwidth first and then removing the remaining narrow-band interference in a targeted manner. Accordingly, the raw sEMG signal is first processed by a fourth-order Butterworth IIR band-pass filter and then by a 50 Hz notch filter. This processing sequence is illustrated in the flowchart below, where the signal passes through band-pass filtering, notch filtering, full-wave rectification, and envelope extraction before producing the final processed output.&lt;br /&gt;
&lt;br /&gt;
[[File:flowchart.png|thumb|center|500px|Flowchart of the real-time sEMG signal conditioning pipeline.]]&lt;br /&gt;
&lt;br /&gt;
The rationale of this order is that the &#039;&#039;&#039;band-pass stage&#039;&#039;&#039; first confines the signal to the main spectral region of interest for sEMG, thereby attenuating motion artifacts at very low frequencies and suppressing high-frequency noise components outside the physiological band. After this spectral preconditioning, the notch stage can more effectively suppress the residual 50 Hz power-line interference that lies inside the useful sEMG band. In transfer-function form, the band-pass filter may be written as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;H_{BP}(z)=\frac{B_{BP}(z)}{A_{BP}(z)}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where the effective passband is selected as &amp;lt;math&amp;gt;20 \leq f \leq 160 \text{ Hz}&amp;lt;/math&amp;gt;. This frequency interval is consistent with the dominant spectral content of surface EMG: the lower cutoff near 20 Hz reduces motion artifacts and unstable low-frequency fluctuations, whereas the upper cutoff near 160 Hz removes high-frequency electronic noise while preserving the main energy-bearing components of the muscle signal. The use of a Butterworth structure is appropriate here because it provides a smooth monotonic passband response without ripple, which helps preserve signal morphology in real-time applications.&lt;br /&gt;
&lt;br /&gt;
After band limitation, a &#039;&#039;&#039;notch filter&#039;&#039;&#039; centered at the power-line frequency is applied to suppress interference that cannot be removed by the band-pass stage alone. The notch filter is designed around &amp;lt;math&amp;gt;f_0 = 50 \text{ Hz}&amp;lt;/math&amp;gt;, and its bandwidth is controlled by the quality factor &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;, which is expressed as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;Q = \frac{f_0}{\Delta f}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In transfer-function form, the notch stage is written as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;H_{N}(z)=\frac{B_{N}(z)}{A_{N}(z)}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the implemented program, a large quality factor is chosen so that the notch remains narrow, allowing effective rejection of the 50 Hz interference while minimizing distortion of neighboring useful spectral components. This is particularly important for sEMG because the interference frequency lies directly inside the physiological band of interest.&lt;br /&gt;
&lt;br /&gt;
Following the filtering stages, further signal conditioning is performed to obtain a representation that is more directly related to muscle activation intensity. The filtered sEMG waveform is first &#039;&#039;&#039;full-wave rectified&#039;&#039;&#039;, which converts the bipolar oscillatory signal into a unipolar signal by taking its absolute value.  Rectification does not remove noise by itself; instead, it transforms the signal into a form that is more suitable for amplitude-based analysis because both positive and negative deflections contribute positively to the activation measure.&lt;br /&gt;
&lt;br /&gt;
After rectification, the signal envelope is extracted to provide a smooth estimate of muscle activation level over time. In a general formulation, the envelope can be described as the &#039;&#039;&#039;low-pass filtered&#039;&#039;&#039; version of the rectified signal, namely &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y_{\mathrm{env}}[n] = \mathrm{LPF}\bigl(y_{\mathrm{rect}}[n]\bigr)&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the present code implementation, this operation is realized by short-time averaging over a finite window, which is equivalent to a moving-average low-pass smoothing of the rectified waveform. The corresponding expression is &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y_{\mathrm{env}}[n] = \frac{1}{N}\sum_{k=0}^{N-1} |x[n-k]|&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; is the window length in samples. With a window duration of approximately 200 ms, this envelope extraction method provides a stable and physiologically meaningful representation of muscle activation intensity, making it suitable for tasks such as force estimation, fatigue analysis, and motor-control studies.&lt;br /&gt;
&lt;br /&gt;
An important feature of the present &#039;&#039;&#039;implementation&#039;&#039;&#039; is that the entire filtering process is performed &#039;&#039;&#039;in real time&#039;&#039;&#039;, sample by sample, rather than by offline block processing. For this reason, IIR filters are preferred over FIR filters, since they can achieve comparable filtering performance with lower order, lower computational cost, and shorter delay. These properties are especially valuable in embedded systems, serial data streaming, and other low-latency experimental applications. However, unlike memoryless operations, an IIR filter depends not only on the current input but also on previous inputs and previous outputs. Its discrete-time behavior can therefore be represented by the recursive difference equation &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y[n] = \sum_{k=0}^{M} b_k x[n-k] - \sum_{k=1}^{N} a_k y[n-k]&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This equation makes clear that internal filter states must be preserved continuously during streaming operation. If the state variables were reinitialized for every incoming sample or data segment, artificial transients would appear and the output would no longer remain continuous.&lt;br /&gt;
&lt;br /&gt;
In the Python implementation, this state continuity is maintained using the internal initial-condition mechanism provided by SciPy, such as &amp;lt;code&amp;gt;lfilter_zi&amp;lt;/code&amp;gt;, together with recursive state updates during each filtering call. As a result, each newly acquired sample is passed first through the band-pass filter and then through the notch filter, while the internal states of both filters are updated after every step. This state-preserving sample-by-sample design ensures that the processing chain remains causal, continuous, and suitable for real-time display or downstream analysis without requiring storage of the entire signal segment.&lt;br /&gt;
&lt;br /&gt;
Overall, this signal-conditioning scheme provides an experimentally practical solution for real-time sEMG processing. The fourth-order Butterworth band-pass filter confines the signal to the main physiological band of interest, the 50 Hz notch filter removes narrow-band power-line contamination, and the subsequent rectification and envelope extraction generate a smooth amplitude descriptor of muscle activity. Combined with state-preserved streaming IIR implementation, this approach achieves a good balance between signal fidelity, computational efficiency, and real-time applicability in biomedical and physical experiment settings.&lt;br /&gt;
&lt;br /&gt;
== Data Processing ==&lt;br /&gt;
&lt;br /&gt;
The objective of data processing is to convert raw surface electromyography (sEMG) recordings into stable, quantitative, and comparable indicators of muscle activity. Since EMG signals are low in amplitude, highly variable over time, and easily contaminated by noise, a dedicated processing pipeline is necessary before any experimental interpretation can be performed.&lt;br /&gt;
&lt;br /&gt;
In this project, the data processing workflow includes time normalization, signal pre-processing, sliding-window feature extraction, noise-floor estimation, and automatic contraction detection. The processed outputs are then used for subsequent experimental evaluation, including rest-versus-contraction discrimination, signal-to-noise ratio analysis, and repeatability assessment.&lt;br /&gt;
&lt;br /&gt;
=== Input Data and Time Normalization ===&lt;br /&gt;
&lt;br /&gt;
The acquired EMG data are read from CSV files containing two columns: time and filtered sEMG amplitude. In the MATLAB implementation, the time vector is normalized so that each recording starts from zero:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t = t_{all} - t_{all}(1)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This normalization is important because it removes the influence of absolute recording timestamps and makes different trials directly comparable on the same time axis.&lt;br /&gt;
&lt;br /&gt;
In addition, the signal type is automatically identified from the filename as either dynamic or rest. This design allows the same program to process both contraction recordings and resting recordings with different downstream analysis logic.&lt;br /&gt;
&lt;br /&gt;
=== Signal Pre-processing ===&lt;br /&gt;
&lt;br /&gt;
Raw EMG signals cannot be analyzed directly because they usually contain DC offset, low-frequency drift, motion artifacts, and residual high-frequency interference. Therefore, several pre-processing steps are applied before feature extraction.&lt;br /&gt;
&lt;br /&gt;
==== Baseline Removal ====&lt;br /&gt;
&lt;br /&gt;
The first step is DC offset removal:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
x_{dc}(t) = x(t) - \frac{1}{N}\sum_{i=1}^{N}x(i)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This operation centers the signal around zero. It is necessary because an uncorrected baseline would bias amplitude-based metrics and reduce the reliability of later envelope and feature calculations.&lt;br /&gt;
&lt;br /&gt;
==== Band-pass Filtering ====&lt;br /&gt;
&lt;br /&gt;
After baseline correction, a fourth-order Butterworth band-pass filter is applied with a passband of 20–150 Hz.&lt;br /&gt;
&lt;br /&gt;
This step is introduced for two reasons:&lt;br /&gt;
&lt;br /&gt;
* The low-frequency cutoff at 20 Hz suppresses baseline drift and motion artifacts.&lt;br /&gt;
* The high-frequency cutoff at 150 Hz reduces unwanted high-frequency noise while preserving the main energy band of the recorded sEMG in this project.&lt;br /&gt;
&lt;br /&gt;
Compared with processing the raw waveform directly, band-pass filtering makes the subsequent time-domain features more stable and more physiologically meaningful.&lt;br /&gt;
&lt;br /&gt;
==== Full-wave Rectification ====&lt;br /&gt;
&lt;br /&gt;
The filtered EMG signal is bipolar, meaning that positive and negative phases coexist due to motor unit action potentials. If these positive and negative components are averaged directly, they may cancel each other out. To avoid this, full-wave rectification is performed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
x_{rect}(t) = |x_{filt}(t)|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This transforms the signal into a unipolar representation, so that all muscle activity contributes positively to the extracted features.&lt;br /&gt;
&lt;br /&gt;
==== Envelope Extraction ====&lt;br /&gt;
&lt;br /&gt;
Although the rectified signal reflects signal magnitude, it still fluctuates rapidly. To obtain a smoother representation of muscle activation level, an envelope is extracted using a moving average with a 100 ms window.&lt;br /&gt;
&lt;br /&gt;
Envelope extraction is important because contraction detection should reflect the overall activation trend rather than instantaneous spikes. A smoothed envelope is therefore more robust for identifying active and inactive muscle states.&lt;br /&gt;
&lt;br /&gt;
=== Sliding Window Design ===&lt;br /&gt;
&lt;br /&gt;
To quantify how muscle activity changes with time, the filtered signal is divided into overlapping short-time segments using a sliding window method.&lt;br /&gt;
&lt;br /&gt;
The window parameters are:&lt;br /&gt;
&lt;br /&gt;
* Window length: 250 ms&lt;br /&gt;
* Step size: 50 ms&lt;br /&gt;
&lt;br /&gt;
These values are chosen as a trade-off between temporal resolution and feature stability.&lt;br /&gt;
&lt;br /&gt;
A longer window improves statistical robustness because more samples are included in each calculation. However, if the window is too long, short contractions or rapid changes may be blurred. A smaller step size increases temporal continuity between adjacent feature points and makes the feature curves smoother in time. Therefore, the 250 ms / 50 ms design provides a practical balance between smoothing and time localization.&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt;-th segment, the feature time is defined as the mean time of that segment:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t_k = \frac{1}{N}\sum_{i=s_k}^{e_k} t(i)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;s_k&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;e_k&amp;lt;/math&amp;gt; denote the start and end indices of the window.&lt;br /&gt;
&lt;br /&gt;
=== Feature Extraction ===&lt;br /&gt;
&lt;br /&gt;
Within each sliding window, three time-domain features are extracted: RMS, iEMG, and MAV. These features are widely used in EMG analysis because they are simple, computationally efficient, and directly related to muscle activation intensity.&lt;br /&gt;
&lt;br /&gt;
==== Root Mean Square (RMS) ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
RMS = \sqrt{\frac{1}{N}\sum_{i=1}^{N}x_i^2}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
RMS reflects the effective power of the EMG signal and is one of the most common indicators of contraction strength. It is sensitive to both amplitude and energy, making it especially useful for comparing rest and active states.&lt;br /&gt;
&lt;br /&gt;
==== Integrated EMG (iEMG) ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
iEMG = \sum_{i=1}^{N}|x_i|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
iEMG describes the cumulative electrical activity within a window. It is often interpreted as a measure of total muscle effort over that time segment.&lt;br /&gt;
&lt;br /&gt;
==== Mean Absolute Value (MAV) ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
MAV = \frac{1}{N}\sum_{i=1}^{N}|x_i|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
MAV is an amplitude descriptor similar to iEMG, but normalized by the number of samples. It provides an efficient estimate of average signal level and is less computationally intensive than some other features.&lt;br /&gt;
&lt;br /&gt;
These three features are used together because they provide complementary descriptions of EMG intensity. RMS emphasizes signal energy, iEMG emphasizes cumulative activation, and MAV reflects average amplitude.&lt;br /&gt;
&lt;br /&gt;
=== Peak-value Extraction ===&lt;br /&gt;
&lt;br /&gt;
In addition to continuous feature curves, several key peak values are extracted from the processed signal:&lt;br /&gt;
&lt;br /&gt;
* maximum and minimum of the filtered EMG waveform&lt;br /&gt;
* peak of the envelope&lt;br /&gt;
* peak RMS&lt;br /&gt;
* peak iEMG&lt;br /&gt;
* peak MAV&lt;br /&gt;
&lt;br /&gt;
These peak values provide concise descriptors of the strongest activity observed in each recording. They are useful for quick comparison across trials and subjects.&lt;br /&gt;
&lt;br /&gt;
=== Noise Floor Estimation ===&lt;br /&gt;
&lt;br /&gt;
To evaluate signal quality, the noise floor is estimated from a reference resting interval. In the present implementation, the first 3 seconds of the recording are used as the default rest reference:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t \in [0,\min(3,t_{end})]&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this segment, three noise descriptors are computed:&lt;br /&gt;
&lt;br /&gt;
* Noise RMS&lt;br /&gt;
* Noise standard deviation&lt;br /&gt;
* Noise peak-to-peak amplitude&lt;br /&gt;
&lt;br /&gt;
Noise-floor estimation is important because EMG amplitude alone is not sufficient to judge recording quality. A large signal is only meaningful if it is sufficiently higher than the baseline noise level. Therefore, the noise floor serves as the reference for later SNR calculation and for designing contraction thresholds.&lt;br /&gt;
&lt;br /&gt;
=== Global Signal Metrics ===&lt;br /&gt;
&lt;br /&gt;
For each recording, three global metrics are also computed over the entire filtered signal:&lt;br /&gt;
&lt;br /&gt;
* Global RMS&lt;br /&gt;
* Global MAV&lt;br /&gt;
* Global iEMG&lt;br /&gt;
&lt;br /&gt;
These global descriptors summarize the overall signal level of the full recording and are later used in group-level comparisons.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Contraction Detection ===&lt;br /&gt;
&lt;br /&gt;
For dynamic recordings, an automatic contraction detection algorithm is used to identify repeated active segments. This is one of the key parts of the data processing pipeline, because it transforms a continuous EMG trace into discrete contraction events that can be counted and compared.&lt;br /&gt;
&lt;br /&gt;
==== Threshold Design ====&lt;br /&gt;
&lt;br /&gt;
The detection threshold is designed adaptively rather than using a fixed value. Two candidate thresholds are first calculated:&lt;br /&gt;
&lt;br /&gt;
* an envelope-based threshold derived from the global envelope mean and standard deviation&lt;br /&gt;
* a rest-reference threshold derived from the mean and standard deviation of the resting reference amplitude&lt;br /&gt;
&lt;br /&gt;
The final threshold is taken as the larger of the two after additional scaling. This strategy improves robustness because it combines the global activation level of the signal with the baseline noise characteristics of the individual recording.&lt;br /&gt;
&lt;br /&gt;
This adaptive threshold design is preferable to a manually fixed threshold because EMG amplitude can vary strongly between subjects, muscles, and recording sessions.&lt;br /&gt;
&lt;br /&gt;
==== Initial Segmentation ====&lt;br /&gt;
&lt;br /&gt;
After thresholding the envelope, the signal is classified into active and inactive regions:&lt;br /&gt;
&lt;br /&gt;
* active: envelope above threshold&lt;br /&gt;
* inactive: envelope below threshold&lt;br /&gt;
&lt;br /&gt;
The rising and falling edges of the binary activity vector are then used to determine the start and end points of each candidate contraction segment.&lt;br /&gt;
&lt;br /&gt;
==== Removal of Short Segments ====&lt;br /&gt;
&lt;br /&gt;
Very short active regions are often caused by noise fluctuations rather than true muscle contractions. Therefore, segments shorter than 0.20 s are discarded.&lt;br /&gt;
&lt;br /&gt;
This step prevents false positive detections and increases the physiological relevance of the segmentation results.&lt;br /&gt;
&lt;br /&gt;
==== Merging of Adjacent Segments ====&lt;br /&gt;
&lt;br /&gt;
If two neighboring active segments are separated by a very short gap, they are merged when the gap is less than 0.15 s.&lt;br /&gt;
&lt;br /&gt;
This operation is necessary because a single real contraction may be temporarily interrupted by a brief drop in the envelope caused by local fluctuation. Without merging, one contraction could be incorrectly counted as multiple repetitions.&lt;br /&gt;
&lt;br /&gt;
==== Repetition-level Metrics ====&lt;br /&gt;
&lt;br /&gt;
For each detected contraction segment, two repetition-level metrics are extracted:&lt;br /&gt;
&lt;br /&gt;
* peak RMS of that contraction&lt;br /&gt;
* mean RMS of that contraction&lt;br /&gt;
&lt;br /&gt;
These metrics quantify both the strongest activation within each repetition and the average activation level over the repetition duration.&lt;br /&gt;
&lt;br /&gt;
=== Repeatability Analysis ===&lt;br /&gt;
&lt;br /&gt;
When multiple valid contractions are detected, repeatability is evaluated using the coefficient of variation (CV):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
CV = \frac{\sigma}{\mu}\times 100\%&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt; is the standard deviation and &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is the mean value across repetitions.&lt;br /&gt;
&lt;br /&gt;
Two CV values are computed:&lt;br /&gt;
&lt;br /&gt;
* CV of repetition peak RMS&lt;br /&gt;
* CV of repetition mean RMS&lt;br /&gt;
&lt;br /&gt;
A lower CV indicates better repeatability, meaning that repeated contractions produce more consistent EMG responses.&lt;br /&gt;
&lt;br /&gt;
=== Signal-to-Noise Ratio (SNR) ===&lt;br /&gt;
&lt;br /&gt;
In this project, the signal-to-noise ratio (SNR) is defined based on the ratio between contraction and rest activity:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
SNR_{dB} = 20\log_{10}\left(\frac{RMS_{contraction}}{RMS_{rest}}\right)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This definition is adopted because it directly reflects the system’s ability to distinguish active muscle contraction from baseline noise.&lt;br /&gt;
&lt;br /&gt;
Compared with global SNR definitions, this formulation is more relevant for practical EMG applications such as activity detection and classification.&lt;br /&gt;
&lt;br /&gt;
=== Rest-versus-Contraction Window Comparison ===&lt;br /&gt;
&lt;br /&gt;
To further distinguish inactive and active states, all sliding windows are divided into two groups:&lt;br /&gt;
&lt;br /&gt;
* rest windows: windows with envelope clearly below the threshold&lt;br /&gt;
* contraction windows: windows with envelope above the threshold&lt;br /&gt;
&lt;br /&gt;
The RMS values of these two groups are then compared statistically.&lt;br /&gt;
&lt;br /&gt;
This comparison is important because a practical EMG system should not only detect signal presence, but also clearly separate rest from contraction in a quantitative way. If the two RMS distributions are well separated, it indicates that the system has good discriminative capability.&lt;br /&gt;
&lt;br /&gt;
=== Output Data Structure ===&lt;br /&gt;
&lt;br /&gt;
The processed outputs are organized into structured data for experimental analysis:&lt;br /&gt;
&lt;br /&gt;
==== Time-series outputs ====&lt;br /&gt;
* Filtered EMG signal  &lt;br /&gt;
* Rectified signal  &lt;br /&gt;
* Envelope  &lt;br /&gt;
* RMS(t), iEMG(t), MAV(t)  &lt;br /&gt;
&lt;br /&gt;
==== Recording-level outputs ====&lt;br /&gt;
* RMS (rest)  &lt;br /&gt;
* RMS (contraction)  &lt;br /&gt;
* iEMG  &lt;br /&gt;
* Noise metrics  &lt;br /&gt;
&lt;br /&gt;
==== Dynamic-signal outputs ====&lt;br /&gt;
* Detected contractions  &lt;br /&gt;
* Repetition count  &lt;br /&gt;
* Peak RMS per repetition  &lt;br /&gt;
* Mean RMS per repetition  &lt;br /&gt;
* Coefficient of variation (CV)  &lt;br /&gt;
* Signal-to-noise ratio (SNR)  &lt;br /&gt;
&lt;br /&gt;
All extracted features are designed to directly support the evaluation of noise level, signal quality, activity discrimination, and repeatability in the subsequent experimental analysis.&lt;br /&gt;
&lt;br /&gt;
== Experimental Results ==&lt;br /&gt;
&lt;br /&gt;
This section presents representative results of the EMG acquisition and data processing pipeline under both dynamic (muscle contraction) and resting conditions.&lt;br /&gt;
&lt;br /&gt;
=== Representative Dynamic Signal Analysis ===&lt;br /&gt;
&lt;br /&gt;
[[File:Dynamic_Figure1.png|thumb|800px|center|Figure 5.1: Processed EMG signal under dynamic contraction, including filtered signal, rectified signal with envelope, and extracted features (RMS, iEMG, MAV).]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.1 shows the processed EMG signal during repeated muscle contractions.&lt;br /&gt;
&lt;br /&gt;
The filtered EMG waveform exhibits clear burst-like patterns corresponding to periodic contractions. The signal amplitude reaches a maximum of approximately 0.45, while the baseline remains centered around zero, indicating effective baseline removal and filtering.&lt;br /&gt;
&lt;br /&gt;
After rectification and envelope extraction, the contraction periods become clearly distinguishable. The envelope provides a smooth representation of muscle activation, with a peak value of approximately 0.145.&lt;br /&gt;
&lt;br /&gt;
The extracted time-domain features (RMS, iEMG, MAV) further quantify the signal. Among these, iEMG shows the strongest dynamic variation, indicating high sensitivity to contraction intensity.&lt;br /&gt;
&lt;br /&gt;
=== Noise Floor and Rest Reference ===&lt;br /&gt;
&lt;br /&gt;
[[File:Dynamic_Figure2.png|thumb|800px|center|Figure 5.2: Noise estimation, rest vs contraction comparison, automatic contraction detection, and repetition analysis.]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (top-left) shows the resting reference segment used for noise estimation.&lt;br /&gt;
&lt;br /&gt;
The signal remains centered around zero with small fluctuations. The noise characteristics are:&lt;br /&gt;
&lt;br /&gt;
* Noise RMS ≈ 0.0046  &lt;br /&gt;
* Standard deviation ≈ 0.0046  &lt;br /&gt;
* Peak-to-peak amplitude ≈ 0.071  &lt;br /&gt;
&lt;br /&gt;
This indicates a low noise floor and stable measurement conditions.&lt;br /&gt;
&lt;br /&gt;
=== Rest vs Contraction Discrimination ===&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (top-right) compares RMS values between rest and contraction states.&lt;br /&gt;
&lt;br /&gt;
The two distributions are clearly separated:&lt;br /&gt;
&lt;br /&gt;
* Rest mean RMS ≈ 0.0053  &lt;br /&gt;
* Contraction mean RMS ≈ 0.1064  &lt;br /&gt;
&lt;br /&gt;
This corresponds to an approximate 20× increase, demonstrating strong discriminability between inactive and active muscle states.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Contraction Detection ===&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (bottom-left) illustrates automatic detection based on the envelope signal.&lt;br /&gt;
&lt;br /&gt;
A threshold of approximately 0.040 is applied, resulting in stable segmentation of contraction periods.&lt;br /&gt;
&lt;br /&gt;
A total of 12 repetitions are detected, with good alignment to visible signal peaks.&lt;br /&gt;
&lt;br /&gt;
=== Repeatability Analysis ===&lt;br /&gt;
&lt;br /&gt;
Figure 2 (bottom-right) shows the peak RMS value of each detected contraction.&lt;br /&gt;
&lt;br /&gt;
The results indicate:&lt;br /&gt;
&lt;br /&gt;
* Mean peak RMS ≈ 0.1355  &lt;br /&gt;
* Standard deviation ≈ 0.0173  &lt;br /&gt;
* CV ≈ 12.77%  &lt;br /&gt;
* SNR ≈ 21.26 dB  &lt;br /&gt;
&lt;br /&gt;
This indicates acceptable repeatability and good signal quality.&lt;br /&gt;
&lt;br /&gt;
=== Representative Rest Signal Analysis ===&lt;br /&gt;
&lt;br /&gt;
[[File:Rest_Figure1.png|800px|center|Figure 3: Processed EMG signal under rest condition, showing low amplitude and absence of contraction patterns.]]&lt;br /&gt;
&lt;br /&gt;
Figure 3 shows the EMG signal under resting conditions.&lt;br /&gt;
&lt;br /&gt;
The signal remains within a narrow amplitude range (approximately ±0.04) and shows no burst-like structures. The envelope remains close to zero, confirming the absence of muscle activity.&lt;br /&gt;
&lt;br /&gt;
The extracted features remain low:&lt;br /&gt;
&lt;br /&gt;
* RMS ≈ 0.007  &lt;br /&gt;
* MAV ≈ 0.005  &lt;br /&gt;
* iEMG remains stable  &lt;br /&gt;
&lt;br /&gt;
This confirms that no false activation is detected.&lt;br /&gt;
&lt;br /&gt;
=== Frequency-domain Characteristics ===&lt;br /&gt;
&lt;br /&gt;
[[File:Rest_Figure2.png|800px|center|Figure 4: Frequency-domain analysis and statistical characteristics of rest signal.]]&lt;br /&gt;
&lt;br /&gt;
Figure 4 shows the frequency-domain characteristics of the resting signal.&lt;br /&gt;
&lt;br /&gt;
The power spectral density (PSD) indicates low overall signal energy without dominant peaks, confirming that the signal mainly consists of noise.&lt;br /&gt;
&lt;br /&gt;
=== Summary of Single-recording Performance ===&lt;br /&gt;
&lt;br /&gt;
From the representative results:&lt;br /&gt;
&lt;br /&gt;
* EMG signals are effectively extracted and denoised  &lt;br /&gt;
* Contraction events are clearly identifiable  &lt;br /&gt;
* Rest and contraction states are well separated  &lt;br /&gt;
* Automatic detection is stable and accurate  &lt;br /&gt;
* Repeatability is acceptable  &lt;br /&gt;
* No false activation occurs under rest conditions  &lt;br /&gt;
&lt;br /&gt;
=== Consistency Across Multiple Recordings ===&lt;br /&gt;
&lt;br /&gt;
The same data processing pipeline was applied to multiple recordings from different subjects and trials.&lt;br /&gt;
&lt;br /&gt;
Across all datasets, consistent patterns were observed:&lt;br /&gt;
&lt;br /&gt;
* Dynamic signals exhibit clear burst-like structures corresponding to repeated muscle contractions  &lt;br /&gt;
* Rest signals remain low in amplitude without distinct activation patterns  &lt;br /&gt;
* RMS values under contraction are consistently higher than those under rest  &lt;br /&gt;
* The automatic detection algorithm reliably identifies contraction segments  &lt;br /&gt;
&lt;br /&gt;
Although quantitative values (e.g., RMS, SNR, CV) vary across recordings due to differences in electrode contact, muscle activation strength, and individual conditions, the overall trends remain consistent.&lt;br /&gt;
&lt;br /&gt;
These results demonstrate the robustness and general applicability of the proposed signal processing method.&lt;br /&gt;
&lt;br /&gt;
== Multi-subject Analysis ==&lt;br /&gt;
=== System Evaluation ===&lt;br /&gt;
&lt;br /&gt;
This section evaluates the performance of the EMG acquisition system in terms of noise level, signal quality, activity discrimination, and repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Noise Floor Analysis ====&lt;br /&gt;
&lt;br /&gt;
The noise floor was evaluated using rest-state recordings, characterized by RMS noise, standard deviation, and peak-to-peak amplitude.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039; shows the lowest noise level (RMS ≈ 0.0046), indicating stable electrode contact and minimal interference.  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039; exhibits moderate noise (RMS ≈ 0.0080), likely influenced by motion artifacts or electrode–skin impedance variation.  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039; shows relatively higher noise (RMS ≈ 0.0126), suggesting increased baseline fluctuation.  &lt;br /&gt;
&lt;br /&gt;
Overall, the system maintains a low noise floor across subjects, although the quality depends on experimental conditions such as electrode contact and environmental interference.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Signal-to-Noise Ratio (SNR) ====&lt;br /&gt;
&lt;br /&gt;
The signal-to-noise ratio (SNR) is defined as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{SNR (dB)} = 20 \log_{10} \left( \frac{\mathrm{RMS}_{\mathrm{contraction}}}{\mathrm{RMS}_{\mathrm{rest}}} \right)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The measured SNR values are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: 21.26 dB → good signal quality  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: 13.52 dB → moderate and usable  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: 6.66 dB → low signal clarity  &lt;br /&gt;
&lt;br /&gt;
General interpretation:&lt;br /&gt;
&lt;br /&gt;
* &amp;gt;20 dB → good  &lt;br /&gt;
* 10–20 dB → usable  &lt;br /&gt;
* &amp;lt;10 dB → poor  &lt;br /&gt;
&lt;br /&gt;
These results show that the system can achieve reliable signal acquisition, although performance varies across subjects.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
====  Rest vs Contraction Discrimination ====&lt;br /&gt;
&lt;br /&gt;
A clear distinction between rest and contraction states is observed based on RMS values.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: 0.0053 → 0.1064 (≈20× increase)  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: 0.0079 → 0.0283 (≈3.6× increase)  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: 0.0141 → 0.0646 (≈4.6× increase)  &lt;br /&gt;
&lt;br /&gt;
This demonstrates that the system is capable of separating muscle activity from baseline noise.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Conclusion:&#039;&#039;  &lt;br /&gt;
The system can be used for basic muscle activity detection and simple classification tasks based on RMS features.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Repeatability of Repeated Contractions ====&lt;br /&gt;
&lt;br /&gt;
Repeatability is evaluated using the coefficient of variation (CV) of peak RMS values across repetitions.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! CV Range !! Evaluation&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt; 10% || Excellent&lt;br /&gt;
|-&lt;br /&gt;
| 10–20% || Acceptable&lt;br /&gt;
|-&lt;br /&gt;
| &amp;gt; 20% || Poor&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Results:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: CV = 12.77% → Acceptable  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: CV = 24.77% → Poor  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: CV = 10.60% → Acceptable  &lt;br /&gt;
&lt;br /&gt;
Although WANG&#039;s signal is detectable, its contraction amplitude varies significantly across repetitions, resulting in poor repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
=== Overall System Performance ===&lt;br /&gt;
&lt;br /&gt;
The system demonstrates the following performance characteristics:&lt;br /&gt;
&lt;br /&gt;
* Reliable detection of muscle activity across all subjects  &lt;br /&gt;
* Clear separation between rest and contraction states  &lt;br /&gt;
* Moderate to high signal quality depending on subject conditions  &lt;br /&gt;
* Repeatability ranging from acceptable to poor due to user-dependent factors  &lt;br /&gt;
&lt;br /&gt;
Overall, the designed EMG acquisition system is capable of stable signal acquisition and feature extraction, with performance primarily influenced by electrode contact quality, skin impedance, and motion consistency.&lt;br /&gt;
&lt;br /&gt;
===== Summary of Quantitative Metrics =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Subject !! RMS (Rest) !! RMS (Contraction) !! Separation Ratio !! iEMG (max) !! Noise RMS !! SNR (dB) !! CV (%) !! Evaluation&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;LIU&#039;&#039;&#039; || 0.0053 || 0.1064 || &#039;&#039;&#039;20.1×&#039;&#039;&#039; || 12.72 || 0.0046 || &#039;&#039;&#039;21.26&#039;&#039;&#039; || 12.77 || Strong signal, good quality&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;WANG&#039;&#039;&#039; || 0.0079 || 0.0283 || 3.57× || 11.10 || 0.0080 || 13.52 || &#039;&#039;&#039;24.77&#039;&#039;&#039; || Usable signal, poor repeatability&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ZHONG&#039;&#039;&#039; || 0.0141 || 0.0646 || 4.58× || 6.70 || 0.0126 || 6.66 || 10.60 || Acceptable performance&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Summary:&#039;&#039; Subject LIU shows the best overall performance, WANG provides usable but less stable signals, and ZHONG demonstrates moderate signal quality with good repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Activation Intensity =====&lt;br /&gt;
&lt;br /&gt;
Among the three subjects, &#039;&#039;&#039;LIU exhibits the strongest muscle activation&#039;&#039;&#039;, as indicated by the highest contraction RMS and iEMG values. ZHONG shows moderate activation, while WANG demonstrates comparable iEMG but lower RMS consistency.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Signal Quality =====&lt;br /&gt;
&lt;br /&gt;
Signal quality is evaluated based on SNR and noise level:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039; achieves the highest SNR and lowest noise → best signal quality  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039; shows moderate SNR → usable but less robust  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039; has the lowest SNR → weakest signal clarity  &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Repeatability =====&lt;br /&gt;
&lt;br /&gt;
Repeatability is evaluated using the coefficient of variation (CV):&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;ZHONG (10.60%)&#039;&#039;&#039; → most stable  &lt;br /&gt;
* &#039;&#039;&#039;LIU (12.77%)&#039;&#039;&#039; → acceptable  &lt;br /&gt;
* &#039;&#039;&#039;WANG (24.77%)&#039;&#039;&#039; → poor  &lt;br /&gt;
&lt;br /&gt;
This indicates that WANG’s contraction strength varies significantly between repetitions.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Engineering Interpretation of Inter-subject Differences =====&lt;br /&gt;
&lt;br /&gt;
The observed differences are mainly attributed to engineering and experimental factors rather than physiological differences.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Electrode contact quality&#039;&#039;&#039;  &lt;br /&gt;
  Variations in electrode placement, pressure, and gel contact affect signal amplitude and stability.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Skin impedance&#039;&#039;&#039;  &lt;br /&gt;
  Differences in skin condition (hydration, oil, hair) influence electrode–skin impedance, affecting noise level and signal coupling.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Muscle control consistency&#039;&#039;&#039;  &lt;br /&gt;
  Variations in contraction strength and timing affect repeatability and CV.&lt;br /&gt;
&lt;br /&gt;
Therefore, the variation across subjects reflects practical acquisition conditions rather than intrinsic system limitations.&lt;/div&gt;</summary>
		<author><name>Wang Jingyi</name></author>
	</entry>
	<entry>
		<id>https://pc5271.org/index.php?title=Surface_EMG_Sensor_for_Muscle_Activity_Measurement:_AFE_Design_and_Signal_Processing&amp;diff=1356</id>
		<title>Surface EMG Sensor for Muscle Activity Measurement: AFE Design and Signal Processing</title>
		<link rel="alternate" type="text/html" href="https://pc5271.org/index.php?title=Surface_EMG_Sensor_for_Muscle_Activity_Measurement:_AFE_Design_and_Signal_Processing&amp;diff=1356"/>
		<updated>2026-04-23T06:45:40Z</updated>

		<summary type="html">&lt;p&gt;Wang Jingyi: /* Rest vs Contraction Discrimination */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Background and Theory==&lt;br /&gt;
&lt;br /&gt;
=== Surface EMG Signals ===&lt;br /&gt;
Surface electromyography (sEMG) refers to the bioelectrical signals detected on the skin surface during muscle contraction. These signals originate from the electrical activity of muscle fibers and provide a non-invasive way to monitor muscle activation. Compared with invasive EMG methods, sEMG is easier to apply, safer for repeated measurements, and more suitable for real-time monitoring. Therefore, it has been widely used in areas such as rehabilitation, motion analysis, human–machine interaction, and physiological monitoring.&lt;br /&gt;
&lt;br /&gt;
=== Characteristics of EMG Signals ===&lt;br /&gt;
EMG signals are generally weak, time-varying, and stochastic in nature. Their waveforms are typically bipolar, fluctuating around zero with both positive and negative components. The amplitude and frequency content of EMG signals depend on factors such as muscle contraction level, electrode placement, skin condition, and individual physiological differences. In practice, the useful frequency components of sEMG are mainly concentrated in a limited low-to-mid frequency range. Because of their low amplitude and variability, EMG signals usually require further conditioning before reliable interpretation and feature extraction can be performed.&lt;br /&gt;
&lt;br /&gt;
=== Bioelectrical Signal Acquisition Principles ===&lt;br /&gt;
The acquisition of bioelectrical signals is based on measuring the small potential difference on the skin surface using electrodes, then converting it into a processable electrical signal through amplification and digitization. For sEMG measurement, electrode placement and skin–electrode contact quality are especially important, since they directly affect signal amplitude and stability. In addition, the front-end acquisition circuit must provide sufficient sensitivity and good interference rejection, so that the recorded signal reflects actual muscle activity rather than environmental disturbance or poor contact conditions.&lt;br /&gt;
&lt;br /&gt;
=== Noise Sources in EMG (50 Hz, motion artifacts) ===&lt;br /&gt;
In practical EMG recording, the measured signal is easily contaminated by different types of noise. Two of the most common sources are power-line interference and motion artifacts. Power-line interference usually appears as a narrow-band component at 50 Hz in the local electrical environment, while motion artifacts are mainly caused by electrode movement, cable disturbance, or variations in the electrode–skin impedance, and are often concentrated in the low-frequency range. In addition, electronic noise from the acquisition hardware may also affect the recording quality. These unwanted components can reduce signal clarity and make muscle activity analysis less reliable, so they must be considered in the design of the signal processing pipeline.&lt;br /&gt;
[[File:background_theory_figure1.1_emg_noise_sources.png|center|thumb|700px|&#039;&#039;&#039;Figure 1.1.&#039;&#039;&#039; Principle of surface EMG acquisition.]]&lt;br /&gt;
&lt;br /&gt;
==System Architecture==&lt;br /&gt;
=== Total Structure Design ===&lt;br /&gt;
&lt;br /&gt;
For clarity，the proposed physiological signal acquisition system mainly consists of two core parts：the analog front－end （AFE）and the ADC board．The AFE is responsible for the preliminary conditioning of weak bioelectrical signals，including amplification，filtering，interference suppression，and level shifting，so that the analog waveform can be converted into a stable and measurable form．The ADC board then performs high－resolution digitization of the conditioned signal and transfers the sampled data to the host computer for subsequent display，storage，and analysis．Therefore，the overall system forms a complete signal－acquisition chain from weak physiological input to digital output．&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_1.jpg|thumb|center|800px|Figure 2.1. Overall system architecture of the proposed physiological signal acquisition platform，including the AFE and ADC modules．]]&lt;br /&gt;
&lt;br /&gt;
=== sEMG AFE Design ===&lt;br /&gt;
&lt;br /&gt;
To collect the weak bioelectric potential signals of the human body，an analog front－end（AFE）suitable sEMG measurements was designed．The module is powered by an external 5 V supply，and the complete circuit includes a first－ stage instrumentation amplifier based on INA128（Texas Instruments，Dallas，TX，USA），a band－pass filter，a 50 Hz notch filter，a second－order amplification and level shifting stage，a driver electrode circuit，a precise 1.5 V reference source，and a -5 V voltage generation module for powering the operational amplifiers．&lt;br /&gt;
&lt;br /&gt;
==== First－order Amplifier ====&lt;br /&gt;
&lt;br /&gt;
The input bioelectric signal is first acquired in differential form and applied to the INA128 instrumentation amplifier，which provides high input impedance，high common－mode rejection，and moderate initial gain for sEMG acquisition．This stage enlarges the weak physiological signal before filtering while reducing the risk of premature saturation caused by electrode offset or motion－induced disturbance，thereby preparing a more stable signal for the subsequent conditioning stages．&lt;br /&gt;
&lt;br /&gt;
==== Bandpass Filter ====&lt;br /&gt;
&lt;br /&gt;
After the instrumentation amplifier，the signal passes through a second－order active band－pass filter，as shown in Figure 2．2． This stage suppresses baseline drift and high－frequency noise outside the useful sEMG range，so that the low－frequency envelope information of sEMG can be preserved before further amplification．&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_2.jpg|thumb|center|800px|Figure 2.2. Schematic diagram of the active band-pass filter used in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the band-pass stage used to retain the main physiological signal band while suppressing unwanted lowand high-frequency components.&lt;br /&gt;
&lt;br /&gt;
==== Notch Filter ====&lt;br /&gt;
&lt;br /&gt;
To reduce power-line interference, a dedicated 50 Hz notch filter is introduced after the band-pass stage, as shown in Figure 2.3. This filter attenuates the mains-frequency component that commonly contaminates weak bioelectric measurements, thereby improving the signal-to-noise ratio of sEMG signals before the final amplification stage.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_3.jpg|thumb|center|800px|Figure 2.3. Schematic diagram of the 50 Hz notch filter used in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the circuit used to attenuate 50 Hz mains interference in the analog front end.&lt;br /&gt;
&lt;br /&gt;
==== Second-order Amplifier &amp;amp; Level Shifter ====&lt;br /&gt;
&lt;br /&gt;
After filtering, the signal enters the second-stage amplification and level-shifting circuit shown in Figure 2.4. In this stage, the filtered signal is further amplified to improve amplitude utilization and then shifted by a 1.5 V reference so that the output becomes a stable unipolar signal suitable for ADC sampling, while preserving linear operation and providing sufficient output swing margin.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_4.jpg|thumb|center|800px|Figure 2.4. Schematic diagram of the second-stage amplifier and level-shifting circuit in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows how the conditioned signal is further amplified and shifted to a suitable DC level before digitization.&lt;br /&gt;
&lt;br /&gt;
==== Power Module and Drive-electrode Circuit ====&lt;br /&gt;
&lt;br /&gt;
The AFE is powered by a 5 V supply and also integrates a 1.5 V precision reference, a -5 V generation circuit, and a driveelectrode circuit. These supporting modules provide the required supply rails and reference level for analog signal conditioning, while the drive-electrode circuit feeds back common-mode voltage to the body to suppress interference at the source. As a result, the complete AFE can support sEMG acquisition with adequate gain, filtering, and noise-reduction performance in a compact hardware structure.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_5.jpg|thumb|center|800px|Figure 2.5. Physical picture of the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the fabricated sEMG analog front-end hardware used in the system.&lt;br /&gt;
&lt;br /&gt;
Figure 2.5 presents the practical hardware implementation of the proposed sEMG AFE. It integrates amplification, filtering, level shifting, and driven-reference functions in a compact circuit for weak bioelectrical signal acquisition.&lt;br /&gt;
&lt;br /&gt;
=== ADS1256-based ADC Board ===&lt;br /&gt;
&lt;br /&gt;
To digitize the conditioned weak physiological signals with sufficient resolution and low noise, this project developed a dedicated ADC board based on the ADS1256 analog-to-digital converter (Texas Instruments, Dallas, TX, USA) and the STM32F103C8T6 microcontroller (STMicroelectronics, Geneva, Switzerland). The overall design objective of this board was not merely to realize analog-to-digital conversion, but to provide a complete hardware interface between the analog front-end and the digital processing unit, including precision reference generation, clocking, input protection and filtering, serial communication, power regulation, and MCU-based acquisition control. The ADS1256 was selected because it is a&lt;br /&gt;
&lt;br /&gt;
very low-noise 24-bit delta-sigma converter with a programmable gain amplifier (PGA), flexible input multiplexer, programmable digital filter, and SPI-compatible serial interface, which makes it well suited for weak low-frequency physiological signals after analog conditioning. The STM32F103C8T6 was used as the local controller because it provides a 32-bit Cortex-M3 core, up to 72 MHz system clock, SPI, USART, USB, and standard SWD debugging support in a compact and low-cost platform.&lt;br /&gt;
&lt;br /&gt;
==== ADC Core Architecture and Design Rationale ====&lt;br /&gt;
&lt;br /&gt;
The ADS1256 was selected as the core ADC because it provides high-resolution, low-noise delta-sigma conversion with an input multiplexer, programmable gain amplifier, and digital filter, which are suitable for weak and low-frequency physiological signals. As shown in Figure 2.6, this architecture emphasizes resolution and noise performance rather than high conversion bandwidth, making it appropriate for sEMG signal digitization after analog conditioning.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_6.jpg|thumb|center|800px|Figure 2.6. Internal functional structure of the ADS1256 analog-to-digital converter.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the main internal blocks of the ADS1256, including the multiplexer, PGA, modulator, and digital filter.&lt;br /&gt;
&lt;br /&gt;
==== Analog Front-End Interface, Reference, and Clocking ====&lt;br /&gt;
&lt;br /&gt;
The ADS1256 analog inputs are connected to the external header through a passive input-conditioning network that helps suppress high-frequency interference and improve input stability. In addition, the board includes a dedicated precision reference and clocking circuits so that the ADC can perform stable and accurate conversion. Together, these circuits provide a reliable analog interface and timing basis for high-resolution digitization of weak physiological signals.&lt;br /&gt;
&lt;br /&gt;
==== SPI Interface between ADS1256 and STM32F103C8T6 ====&lt;br /&gt;
&lt;br /&gt;
Communication between the ADS1256 and the STM32F103C8T6 is implemented through an SPI-compatible interface, with dedicated lines for chip select, serial clock, input/output data, data-ready notification, and hardware reset. This connection allows the MCU to configure the ADC, read conversion results in synchrony with DRDY, and maintain efficient and reliable acquisition control for multi-channel physiological measurements.&lt;br /&gt;
&lt;br /&gt;
==== Power Supply and On-board Regulation ====&lt;br /&gt;
&lt;br /&gt;
The ADC board uses a USB Type-B connector as the main power input and includes protection, voltage regulation, and local decoupling circuits to provide a stable supply for both the MCU and ADC-related hardware. In addition, analog ground and digital ground are separated in the PCB layout to reduce digital noise coupling into the analog path, which is particularly important for weak physiological signal acquisition.&lt;br /&gt;
&lt;br /&gt;
==== Basic Peripheral Circuits of the STM32F103C8T6 ====&lt;br /&gt;
&lt;br /&gt;
The STM32F103C8T6 serves as the local controller of the ADC board and is supported by several basic peripheral circuits, including an external crystal oscillator, reset network, BOOT0 configuration, SWD programming/debugging header, and a CH340N USB-to-UART bridge. These circuits ensure stable MCU operation, convenient firmware downloading and debugging, and reliable data transmission from the board to the host computer for real-time display and storage.&lt;br /&gt;
&lt;br /&gt;
==== Hardware-level Working Principle of the ADC Board ====&lt;br /&gt;
&lt;br /&gt;
In operation, the conditioned analog signal from the AFE enters the ADS1256 through the input header, is digitized with high resolution under the control of the local precision reference and clock, and is then read by the STM32 through the SPI interface. The MCU subsequently forwards the sampled data to the host computer through the serial communication link, so that the entire board functions as a compact digital acquisition backend connecting weak physiological analog signals to later software processing, display, and storage.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_7.jpg|thumb|center|800px|Figure 2.7. Photograph of the fabricated ADS1256-based ADC board developed in this project and the definitions of some key pins.]]&lt;br /&gt;
&lt;br /&gt;
Figure 2.7 shows the ADC board fabricated for this project. It integrates the ADS1256 conversion core, STM32 control circuit, power-conditioning circuits, and communication interfaces on a compact PCB for physiological signal digitization.&lt;br /&gt;
&lt;br /&gt;
== Signal Conditioning and Filtering ==&lt;br /&gt;
Although the AFE already performs preliminary band-pass filtering and 50 Hz interference suppression in the analog domain, the digitized sEMG signal may still contain residual noise due to component tolerances, electrode-contact variation, and environmental interference. Therefore, an additional digital filtering stage is implemented in software as a complementary post-processing step to improve signal quality and to provide a more stable input for rectification, envelope extraction, and subsequent analysis. In this sense, the software filtering is not a simple repetition of the analog filtering, but a refinement and compensation for non-ideal front-end behavior.&lt;br /&gt;
&lt;br /&gt;
Surface electromyographic (sEMG) signals are highly susceptible to several sources of contamination during acquisition. In practical measurements, the dominant disturbances usually include low-frequency motion artifacts caused by electrode movement and electrode–skin impedance variation, narrow-band power-line interference centered at 50 Hz, and broadband high-frequency electronic noise introduced by the acquisition hardware. These unwanted components degrade the quality of the recorded signal and may significantly affect the reliability of subsequent feature extraction, parameter estimation, and muscle activity interpretation. For this reason, an effective signal-conditioning procedure is necessary before any higher-level analysis is performed.&lt;br /&gt;
&lt;br /&gt;
In the present implementation, the filtering strategy follows the principle of restricting the signal bandwidth first and then removing the remaining narrow-band interference in a targeted manner. Accordingly, the raw sEMG signal is first processed by a fourth-order Butterworth IIR band-pass filter and then by a 50 Hz notch filter. This processing sequence is illustrated in the flowchart below, where the signal passes through band-pass filtering, notch filtering, full-wave rectification, and envelope extraction before producing the final processed output.&lt;br /&gt;
&lt;br /&gt;
[[File:flowchart.png|thumb|center|500px|Flowchart of the real-time sEMG signal conditioning pipeline.]]&lt;br /&gt;
&lt;br /&gt;
The rationale of this order is that the &#039;&#039;&#039;band-pass stage&#039;&#039;&#039; first confines the signal to the main spectral region of interest for sEMG, thereby attenuating motion artifacts at very low frequencies and suppressing high-frequency noise components outside the physiological band. After this spectral preconditioning, the notch stage can more effectively suppress the residual 50 Hz power-line interference that lies inside the useful sEMG band. In transfer-function form, the band-pass filter may be written as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;H_{BP}(z)=\frac{B_{BP}(z)}{A_{BP}(z)}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where the effective passband is selected as &amp;lt;math&amp;gt;20 \leq f \leq 160 \text{ Hz}&amp;lt;/math&amp;gt;. This frequency interval is consistent with the dominant spectral content of surface EMG: the lower cutoff near 20 Hz reduces motion artifacts and unstable low-frequency fluctuations, whereas the upper cutoff near 160 Hz removes high-frequency electronic noise while preserving the main energy-bearing components of the muscle signal. The use of a Butterworth structure is appropriate here because it provides a smooth monotonic passband response without ripple, which helps preserve signal morphology in real-time applications.&lt;br /&gt;
&lt;br /&gt;
After band limitation, a &#039;&#039;&#039;notch filter&#039;&#039;&#039; centered at the power-line frequency is applied to suppress interference that cannot be removed by the band-pass stage alone. The notch filter is designed around &amp;lt;math&amp;gt;f_0 = 50 \text{ Hz}&amp;lt;/math&amp;gt;, and its bandwidth is controlled by the quality factor &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;, which is expressed as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;Q = \frac{f_0}{\Delta f}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In transfer-function form, the notch stage is written as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;H_{N}(z)=\frac{B_{N}(z)}{A_{N}(z)}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the implemented program, a large quality factor is chosen so that the notch remains narrow, allowing effective rejection of the 50 Hz interference while minimizing distortion of neighboring useful spectral components. This is particularly important for sEMG because the interference frequency lies directly inside the physiological band of interest.&lt;br /&gt;
&lt;br /&gt;
Following the filtering stages, further signal conditioning is performed to obtain a representation that is more directly related to muscle activation intensity. The filtered sEMG waveform is first &#039;&#039;&#039;full-wave rectified&#039;&#039;&#039;, which converts the bipolar oscillatory signal into a unipolar signal by taking its absolute value.  Rectification does not remove noise by itself; instead, it transforms the signal into a form that is more suitable for amplitude-based analysis because both positive and negative deflections contribute positively to the activation measure.&lt;br /&gt;
&lt;br /&gt;
After rectification, the signal envelope is extracted to provide a smooth estimate of muscle activation level over time. In a general formulation, the envelope can be described as the &#039;&#039;&#039;low-pass filtered&#039;&#039;&#039; version of the rectified signal, namely &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y_{\mathrm{env}}[n] = \mathrm{LPF}\bigl(y_{\mathrm{rect}}[n]\bigr)&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the present code implementation, this operation is realized by short-time averaging over a finite window, which is equivalent to a moving-average low-pass smoothing of the rectified waveform. The corresponding expression is &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y_{\mathrm{env}}[n] = \frac{1}{N}\sum_{k=0}^{N-1} |x[n-k]|&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; is the window length in samples. With a window duration of approximately 200 ms, this envelope extraction method provides a stable and physiologically meaningful representation of muscle activation intensity, making it suitable for tasks such as force estimation, fatigue analysis, and motor-control studies.&lt;br /&gt;
&lt;br /&gt;
An important feature of the present &#039;&#039;&#039;implementation&#039;&#039;&#039; is that the entire filtering process is performed &#039;&#039;&#039;in real time&#039;&#039;&#039;, sample by sample, rather than by offline block processing. For this reason, IIR filters are preferred over FIR filters, since they can achieve comparable filtering performance with lower order, lower computational cost, and shorter delay. These properties are especially valuable in embedded systems, serial data streaming, and other low-latency experimental applications. However, unlike memoryless operations, an IIR filter depends not only on the current input but also on previous inputs and previous outputs. Its discrete-time behavior can therefore be represented by the recursive difference equation &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y[n] = \sum_{k=0}^{M} b_k x[n-k] - \sum_{k=1}^{N} a_k y[n-k]&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This equation makes clear that internal filter states must be preserved continuously during streaming operation. If the state variables were reinitialized for every incoming sample or data segment, artificial transients would appear and the output would no longer remain continuous.&lt;br /&gt;
&lt;br /&gt;
In the Python implementation, this state continuity is maintained using the internal initial-condition mechanism provided by SciPy, such as &amp;lt;code&amp;gt;lfilter_zi&amp;lt;/code&amp;gt;, together with recursive state updates during each filtering call. As a result, each newly acquired sample is passed first through the band-pass filter and then through the notch filter, while the internal states of both filters are updated after every step. This state-preserving sample-by-sample design ensures that the processing chain remains causal, continuous, and suitable for real-time display or downstream analysis without requiring storage of the entire signal segment.&lt;br /&gt;
&lt;br /&gt;
Overall, this signal-conditioning scheme provides an experimentally practical solution for real-time sEMG processing. The fourth-order Butterworth band-pass filter confines the signal to the main physiological band of interest, the 50 Hz notch filter removes narrow-band power-line contamination, and the subsequent rectification and envelope extraction generate a smooth amplitude descriptor of muscle activity. Combined with state-preserved streaming IIR implementation, this approach achieves a good balance between signal fidelity, computational efficiency, and real-time applicability in biomedical and physical experiment settings.&lt;br /&gt;
&lt;br /&gt;
== Data Processing ==&lt;br /&gt;
&lt;br /&gt;
The objective of data processing is to convert raw surface electromyography (sEMG) recordings into stable, quantitative, and comparable indicators of muscle activity. Since EMG signals are low in amplitude, highly variable over time, and easily contaminated by noise, a dedicated processing pipeline is necessary before any experimental interpretation can be performed.&lt;br /&gt;
&lt;br /&gt;
In this project, the data processing workflow includes time normalization, signal pre-processing, sliding-window feature extraction, noise-floor estimation, and automatic contraction detection. The processed outputs are then used for subsequent experimental evaluation, including rest-versus-contraction discrimination, signal-to-noise ratio analysis, and repeatability assessment.&lt;br /&gt;
&lt;br /&gt;
=== Input Data and Time Normalization ===&lt;br /&gt;
&lt;br /&gt;
The acquired EMG data are read from CSV files containing two columns: time and filtered sEMG amplitude. In the MATLAB implementation, the time vector is normalized so that each recording starts from zero:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t = t_{all} - t_{all}(1)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This normalization is important because it removes the influence of absolute recording timestamps and makes different trials directly comparable on the same time axis.&lt;br /&gt;
&lt;br /&gt;
In addition, the signal type is automatically identified from the filename as either dynamic or rest. This design allows the same program to process both contraction recordings and resting recordings with different downstream analysis logic.&lt;br /&gt;
&lt;br /&gt;
=== Signal Pre-processing ===&lt;br /&gt;
&lt;br /&gt;
Raw EMG signals cannot be analyzed directly because they usually contain DC offset, low-frequency drift, motion artifacts, and residual high-frequency interference. Therefore, several pre-processing steps are applied before feature extraction.&lt;br /&gt;
&lt;br /&gt;
==== Baseline Removal ====&lt;br /&gt;
&lt;br /&gt;
The first step is DC offset removal:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
x_{dc}(t) = x(t) - \frac{1}{N}\sum_{i=1}^{N}x(i)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This operation centers the signal around zero. It is necessary because an uncorrected baseline would bias amplitude-based metrics and reduce the reliability of later envelope and feature calculations.&lt;br /&gt;
&lt;br /&gt;
==== Band-pass Filtering ====&lt;br /&gt;
&lt;br /&gt;
After baseline correction, a fourth-order Butterworth band-pass filter is applied with a passband of 20–150 Hz.&lt;br /&gt;
&lt;br /&gt;
This step is introduced for two reasons:&lt;br /&gt;
&lt;br /&gt;
* The low-frequency cutoff at 20 Hz suppresses baseline drift and motion artifacts.&lt;br /&gt;
* The high-frequency cutoff at 150 Hz reduces unwanted high-frequency noise while preserving the main energy band of the recorded sEMG in this project.&lt;br /&gt;
&lt;br /&gt;
Compared with processing the raw waveform directly, band-pass filtering makes the subsequent time-domain features more stable and more physiologically meaningful.&lt;br /&gt;
&lt;br /&gt;
==== Full-wave Rectification ====&lt;br /&gt;
&lt;br /&gt;
The filtered EMG signal is bipolar, meaning that positive and negative phases coexist due to motor unit action potentials. If these positive and negative components are averaged directly, they may cancel each other out. To avoid this, full-wave rectification is performed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
x_{rect}(t) = |x_{filt}(t)|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This transforms the signal into a unipolar representation, so that all muscle activity contributes positively to the extracted features.&lt;br /&gt;
&lt;br /&gt;
==== Envelope Extraction ====&lt;br /&gt;
&lt;br /&gt;
Although the rectified signal reflects signal magnitude, it still fluctuates rapidly. To obtain a smoother representation of muscle activation level, an envelope is extracted using a moving average with a 100 ms window.&lt;br /&gt;
&lt;br /&gt;
Envelope extraction is important because contraction detection should reflect the overall activation trend rather than instantaneous spikes. A smoothed envelope is therefore more robust for identifying active and inactive muscle states.&lt;br /&gt;
&lt;br /&gt;
=== Sliding Window Design ===&lt;br /&gt;
&lt;br /&gt;
To quantify how muscle activity changes with time, the filtered signal is divided into overlapping short-time segments using a sliding window method.&lt;br /&gt;
&lt;br /&gt;
The window parameters are:&lt;br /&gt;
&lt;br /&gt;
* Window length: 250 ms&lt;br /&gt;
* Step size: 50 ms&lt;br /&gt;
&lt;br /&gt;
These values are chosen as a trade-off between temporal resolution and feature stability.&lt;br /&gt;
&lt;br /&gt;
A longer window improves statistical robustness because more samples are included in each calculation. However, if the window is too long, short contractions or rapid changes may be blurred. A smaller step size increases temporal continuity between adjacent feature points and makes the feature curves smoother in time. Therefore, the 250 ms / 50 ms design provides a practical balance between smoothing and time localization.&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt;-th segment, the feature time is defined as the mean time of that segment:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t_k = \frac{1}{N}\sum_{i=s_k}^{e_k} t(i)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;s_k&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;e_k&amp;lt;/math&amp;gt; denote the start and end indices of the window.&lt;br /&gt;
&lt;br /&gt;
=== Feature Extraction ===&lt;br /&gt;
&lt;br /&gt;
Within each sliding window, three time-domain features are extracted: RMS, iEMG, and MAV. These features are widely used in EMG analysis because they are simple, computationally efficient, and directly related to muscle activation intensity.&lt;br /&gt;
&lt;br /&gt;
==== Root Mean Square (RMS) ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
RMS = \sqrt{\frac{1}{N}\sum_{i=1}^{N}x_i^2}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
RMS reflects the effective power of the EMG signal and is one of the most common indicators of contraction strength. It is sensitive to both amplitude and energy, making it especially useful for comparing rest and active states.&lt;br /&gt;
&lt;br /&gt;
==== Integrated EMG (iEMG) ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
iEMG = \sum_{i=1}^{N}|x_i|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
iEMG describes the cumulative electrical activity within a window. It is often interpreted as a measure of total muscle effort over that time segment.&lt;br /&gt;
&lt;br /&gt;
==== Mean Absolute Value (MAV) ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
MAV = \frac{1}{N}\sum_{i=1}^{N}|x_i|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
MAV is an amplitude descriptor similar to iEMG, but normalized by the number of samples. It provides an efficient estimate of average signal level and is less computationally intensive than some other features.&lt;br /&gt;
&lt;br /&gt;
These three features are used together because they provide complementary descriptions of EMG intensity. RMS emphasizes signal energy, iEMG emphasizes cumulative activation, and MAV reflects average amplitude.&lt;br /&gt;
&lt;br /&gt;
=== Peak-value Extraction ===&lt;br /&gt;
&lt;br /&gt;
In addition to continuous feature curves, several key peak values are extracted from the processed signal:&lt;br /&gt;
&lt;br /&gt;
* maximum and minimum of the filtered EMG waveform&lt;br /&gt;
* peak of the envelope&lt;br /&gt;
* peak RMS&lt;br /&gt;
* peak iEMG&lt;br /&gt;
* peak MAV&lt;br /&gt;
&lt;br /&gt;
These peak values provide concise descriptors of the strongest activity observed in each recording. They are useful for quick comparison across trials and subjects.&lt;br /&gt;
&lt;br /&gt;
=== Noise Floor Estimation ===&lt;br /&gt;
&lt;br /&gt;
To evaluate signal quality, the noise floor is estimated from a reference resting interval. In the present implementation, the first 3 seconds of the recording are used as the default rest reference:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t \in [0,\min(3,t_{end})]&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this segment, three noise descriptors are computed:&lt;br /&gt;
&lt;br /&gt;
* Noise RMS&lt;br /&gt;
* Noise standard deviation&lt;br /&gt;
* Noise peak-to-peak amplitude&lt;br /&gt;
&lt;br /&gt;
Noise-floor estimation is important because EMG amplitude alone is not sufficient to judge recording quality. A large signal is only meaningful if it is sufficiently higher than the baseline noise level. Therefore, the noise floor serves as the reference for later SNR calculation and for designing contraction thresholds.&lt;br /&gt;
&lt;br /&gt;
=== Global Signal Metrics ===&lt;br /&gt;
&lt;br /&gt;
For each recording, three global metrics are also computed over the entire filtered signal:&lt;br /&gt;
&lt;br /&gt;
* Global RMS&lt;br /&gt;
* Global MAV&lt;br /&gt;
* Global iEMG&lt;br /&gt;
&lt;br /&gt;
These global descriptors summarize the overall signal level of the full recording and are later used in group-level comparisons.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Contraction Detection ===&lt;br /&gt;
&lt;br /&gt;
For dynamic recordings, an automatic contraction detection algorithm is used to identify repeated active segments. This is one of the key parts of the data processing pipeline, because it transforms a continuous EMG trace into discrete contraction events that can be counted and compared.&lt;br /&gt;
&lt;br /&gt;
==== Threshold Design ====&lt;br /&gt;
&lt;br /&gt;
The detection threshold is designed adaptively rather than using a fixed value. Two candidate thresholds are first calculated:&lt;br /&gt;
&lt;br /&gt;
* an envelope-based threshold derived from the global envelope mean and standard deviation&lt;br /&gt;
* a rest-reference threshold derived from the mean and standard deviation of the resting reference amplitude&lt;br /&gt;
&lt;br /&gt;
The final threshold is taken as the larger of the two after additional scaling. This strategy improves robustness because it combines the global activation level of the signal with the baseline noise characteristics of the individual recording.&lt;br /&gt;
&lt;br /&gt;
This adaptive threshold design is preferable to a manually fixed threshold because EMG amplitude can vary strongly between subjects, muscles, and recording sessions.&lt;br /&gt;
&lt;br /&gt;
==== Initial Segmentation ====&lt;br /&gt;
&lt;br /&gt;
After thresholding the envelope, the signal is classified into active and inactive regions:&lt;br /&gt;
&lt;br /&gt;
* active: envelope above threshold&lt;br /&gt;
* inactive: envelope below threshold&lt;br /&gt;
&lt;br /&gt;
The rising and falling edges of the binary activity vector are then used to determine the start and end points of each candidate contraction segment.&lt;br /&gt;
&lt;br /&gt;
==== Removal of Short Segments ====&lt;br /&gt;
&lt;br /&gt;
Very short active regions are often caused by noise fluctuations rather than true muscle contractions. Therefore, segments shorter than 0.20 s are discarded.&lt;br /&gt;
&lt;br /&gt;
This step prevents false positive detections and increases the physiological relevance of the segmentation results.&lt;br /&gt;
&lt;br /&gt;
==== Merging of Adjacent Segments ====&lt;br /&gt;
&lt;br /&gt;
If two neighboring active segments are separated by a very short gap, they are merged when the gap is less than 0.15 s.&lt;br /&gt;
&lt;br /&gt;
This operation is necessary because a single real contraction may be temporarily interrupted by a brief drop in the envelope caused by local fluctuation. Without merging, one contraction could be incorrectly counted as multiple repetitions.&lt;br /&gt;
&lt;br /&gt;
==== Repetition-level Metrics ====&lt;br /&gt;
&lt;br /&gt;
For each detected contraction segment, two repetition-level metrics are extracted:&lt;br /&gt;
&lt;br /&gt;
* peak RMS of that contraction&lt;br /&gt;
* mean RMS of that contraction&lt;br /&gt;
&lt;br /&gt;
These metrics quantify both the strongest activation within each repetition and the average activation level over the repetition duration.&lt;br /&gt;
&lt;br /&gt;
=== Repeatability Analysis ===&lt;br /&gt;
&lt;br /&gt;
When multiple valid contractions are detected, repeatability is evaluated using the coefficient of variation (CV):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
CV = \frac{\sigma}{\mu}\times 100\%&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt; is the standard deviation and &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is the mean value across repetitions.&lt;br /&gt;
&lt;br /&gt;
Two CV values are computed:&lt;br /&gt;
&lt;br /&gt;
* CV of repetition peak RMS&lt;br /&gt;
* CV of repetition mean RMS&lt;br /&gt;
&lt;br /&gt;
A lower CV indicates better repeatability, meaning that repeated contractions produce more consistent EMG responses.&lt;br /&gt;
&lt;br /&gt;
=== Signal-to-Noise Ratio (SNR) ===&lt;br /&gt;
&lt;br /&gt;
In this project, the signal-to-noise ratio (SNR) is defined based on the ratio between contraction and rest activity:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
SNR_{dB} = 20\log_{10}\left(\frac{RMS_{contraction}}{RMS_{rest}}\right)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This definition is adopted because it directly reflects the system’s ability to distinguish active muscle contraction from baseline noise.&lt;br /&gt;
&lt;br /&gt;
Compared with global SNR definitions, this formulation is more relevant for practical EMG applications such as activity detection and classification.&lt;br /&gt;
&lt;br /&gt;
=== Rest-versus-Contraction Window Comparison ===&lt;br /&gt;
&lt;br /&gt;
To further distinguish inactive and active states, all sliding windows are divided into two groups:&lt;br /&gt;
&lt;br /&gt;
* rest windows: windows with envelope clearly below the threshold&lt;br /&gt;
* contraction windows: windows with envelope above the threshold&lt;br /&gt;
&lt;br /&gt;
The RMS values of these two groups are then compared statistically.&lt;br /&gt;
&lt;br /&gt;
This comparison is important because a practical EMG system should not only detect signal presence, but also clearly separate rest from contraction in a quantitative way. If the two RMS distributions are well separated, it indicates that the system has good discriminative capability.&lt;br /&gt;
&lt;br /&gt;
=== Output Data Structure ===&lt;br /&gt;
&lt;br /&gt;
The processed outputs are organized into structured data for experimental analysis:&lt;br /&gt;
&lt;br /&gt;
==== Time-series outputs ====&lt;br /&gt;
* Filtered EMG signal  &lt;br /&gt;
* Rectified signal  &lt;br /&gt;
* Envelope  &lt;br /&gt;
* RMS(t), iEMG(t), MAV(t)  &lt;br /&gt;
&lt;br /&gt;
==== Recording-level outputs ====&lt;br /&gt;
* RMS (rest)  &lt;br /&gt;
* RMS (contraction)  &lt;br /&gt;
* iEMG  &lt;br /&gt;
* Noise metrics  &lt;br /&gt;
&lt;br /&gt;
==== Dynamic-signal outputs ====&lt;br /&gt;
* Detected contractions  &lt;br /&gt;
* Repetition count  &lt;br /&gt;
* Peak RMS per repetition  &lt;br /&gt;
* Mean RMS per repetition  &lt;br /&gt;
* Coefficient of variation (CV)  &lt;br /&gt;
* Signal-to-noise ratio (SNR)  &lt;br /&gt;
&lt;br /&gt;
All extracted features are designed to directly support the evaluation of noise level, signal quality, activity discrimination, and repeatability in the subsequent experimental analysis.&lt;br /&gt;
&lt;br /&gt;
== Experimental Results ==&lt;br /&gt;
&lt;br /&gt;
This section presents representative results of the EMG acquisition and data processing pipeline under both dynamic (muscle contraction) and resting conditions.&lt;br /&gt;
&lt;br /&gt;
=== Representative Dynamic Signal Analysis ===&lt;br /&gt;
&lt;br /&gt;
[[File:Dynamic_Figure1.png|thumb|800px|center|Figure 5.1: Processed EMG signal under dynamic contraction, including filtered signal, rectified signal with envelope, and extracted features (RMS, iEMG, MAV).]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.1 shows the processed EMG signal during repeated muscle contractions.&lt;br /&gt;
&lt;br /&gt;
The filtered EMG waveform exhibits clear burst-like patterns corresponding to periodic contractions. The signal amplitude reaches a maximum of approximately 0.45, while the baseline remains centered around zero, indicating effective baseline removal and filtering.&lt;br /&gt;
&lt;br /&gt;
After rectification and envelope extraction, the contraction periods become clearly distinguishable. The envelope provides a smooth representation of muscle activation, with a peak value of approximately 0.145.&lt;br /&gt;
&lt;br /&gt;
The extracted time-domain features (RMS, iEMG, MAV) further quantify the signal. Among these, iEMG shows the strongest dynamic variation, indicating high sensitivity to contraction intensity.&lt;br /&gt;
&lt;br /&gt;
=== Noise Floor and Rest Reference ===&lt;br /&gt;
&lt;br /&gt;
[[File:Dynamic_Figure2.png|thumb|800px|center|Figure 5.2: Noise estimation, rest vs contraction comparison, automatic contraction detection, and repetition analysis.]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (top-left) shows the resting reference segment used for noise estimation.&lt;br /&gt;
&lt;br /&gt;
The signal remains centered around zero with small fluctuations. The noise characteristics are:&lt;br /&gt;
&lt;br /&gt;
* Noise RMS ≈ 0.0046  &lt;br /&gt;
* Standard deviation ≈ 0.0046  &lt;br /&gt;
* Peak-to-peak amplitude ≈ 0.071  &lt;br /&gt;
&lt;br /&gt;
This indicates a low noise floor and stable measurement conditions.&lt;br /&gt;
&lt;br /&gt;
=== Rest vs Contraction Discrimination ===&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (top-right) compares RMS values between rest and contraction states.&lt;br /&gt;
&lt;br /&gt;
The two distributions are clearly separated:&lt;br /&gt;
&lt;br /&gt;
* Rest mean RMS ≈ 0.0053  &lt;br /&gt;
* Contraction mean RMS ≈ 0.1064  &lt;br /&gt;
&lt;br /&gt;
This corresponds to an approximate 20× increase, demonstrating strong discriminability between inactive and active muscle states.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Contraction Detection ===&lt;br /&gt;
&lt;br /&gt;
Figure 2 (bottom-left) illustrates automatic detection based on the envelope signal.&lt;br /&gt;
&lt;br /&gt;
A threshold of approximately 0.040 is applied, resulting in stable segmentation of contraction periods.&lt;br /&gt;
&lt;br /&gt;
A total of 12 repetitions are detected, with good alignment to visible signal peaks.&lt;br /&gt;
&lt;br /&gt;
=== Repeatability Analysis ===&lt;br /&gt;
&lt;br /&gt;
Figure 2 (bottom-right) shows the peak RMS value of each detected contraction.&lt;br /&gt;
&lt;br /&gt;
The results indicate:&lt;br /&gt;
&lt;br /&gt;
* Mean peak RMS ≈ 0.1355  &lt;br /&gt;
* Standard deviation ≈ 0.0173  &lt;br /&gt;
* CV ≈ 12.77%  &lt;br /&gt;
* SNR ≈ 21.26 dB  &lt;br /&gt;
&lt;br /&gt;
This indicates acceptable repeatability and good signal quality.&lt;br /&gt;
&lt;br /&gt;
=== Representative Rest Signal Analysis ===&lt;br /&gt;
&lt;br /&gt;
[[File:Rest_Figure1.png|800px|center|Figure 3: Processed EMG signal under rest condition, showing low amplitude and absence of contraction patterns.]]&lt;br /&gt;
&lt;br /&gt;
Figure 3 shows the EMG signal under resting conditions.&lt;br /&gt;
&lt;br /&gt;
The signal remains within a narrow amplitude range (approximately ±0.04) and shows no burst-like structures. The envelope remains close to zero, confirming the absence of muscle activity.&lt;br /&gt;
&lt;br /&gt;
The extracted features remain low:&lt;br /&gt;
&lt;br /&gt;
* RMS ≈ 0.007  &lt;br /&gt;
* MAV ≈ 0.005  &lt;br /&gt;
* iEMG remains stable  &lt;br /&gt;
&lt;br /&gt;
This confirms that no false activation is detected.&lt;br /&gt;
&lt;br /&gt;
=== Frequency-domain Characteristics ===&lt;br /&gt;
&lt;br /&gt;
[[File:Rest_Figure2.png|800px|center|Figure 4: Frequency-domain analysis and statistical characteristics of rest signal.]]&lt;br /&gt;
&lt;br /&gt;
Figure 4 shows the frequency-domain characteristics of the resting signal.&lt;br /&gt;
&lt;br /&gt;
The power spectral density (PSD) indicates low overall signal energy without dominant peaks, confirming that the signal mainly consists of noise.&lt;br /&gt;
&lt;br /&gt;
=== Summary of Single-recording Performance ===&lt;br /&gt;
&lt;br /&gt;
From the representative results:&lt;br /&gt;
&lt;br /&gt;
* EMG signals are effectively extracted and denoised  &lt;br /&gt;
* Contraction events are clearly identifiable  &lt;br /&gt;
* Rest and contraction states are well separated  &lt;br /&gt;
* Automatic detection is stable and accurate  &lt;br /&gt;
* Repeatability is acceptable  &lt;br /&gt;
* No false activation occurs under rest conditions  &lt;br /&gt;
&lt;br /&gt;
=== Consistency Across Multiple Recordings ===&lt;br /&gt;
&lt;br /&gt;
The same data processing pipeline was applied to multiple recordings from different subjects and trials.&lt;br /&gt;
&lt;br /&gt;
Across all datasets, consistent patterns were observed:&lt;br /&gt;
&lt;br /&gt;
* Dynamic signals exhibit clear burst-like structures corresponding to repeated muscle contractions  &lt;br /&gt;
* Rest signals remain low in amplitude without distinct activation patterns  &lt;br /&gt;
* RMS values under contraction are consistently higher than those under rest  &lt;br /&gt;
* The automatic detection algorithm reliably identifies contraction segments  &lt;br /&gt;
&lt;br /&gt;
Although quantitative values (e.g., RMS, SNR, CV) vary across recordings due to differences in electrode contact, muscle activation strength, and individual conditions, the overall trends remain consistent.&lt;br /&gt;
&lt;br /&gt;
These results demonstrate the robustness and general applicability of the proposed signal processing method.&lt;br /&gt;
&lt;br /&gt;
== Multi-subject Analysis ==&lt;br /&gt;
=== System Evaluation ===&lt;br /&gt;
&lt;br /&gt;
This section evaluates the performance of the EMG acquisition system in terms of noise level, signal quality, activity discrimination, and repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Noise Floor Analysis ====&lt;br /&gt;
&lt;br /&gt;
The noise floor was evaluated using rest-state recordings, characterized by RMS noise, standard deviation, and peak-to-peak amplitude.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039; shows the lowest noise level (RMS ≈ 0.0046), indicating stable electrode contact and minimal interference.  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039; exhibits moderate noise (RMS ≈ 0.0080), likely influenced by motion artifacts or electrode–skin impedance variation.  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039; shows relatively higher noise (RMS ≈ 0.0126), suggesting increased baseline fluctuation.  &lt;br /&gt;
&lt;br /&gt;
Overall, the system maintains a low noise floor across subjects, although the quality depends on experimental conditions such as electrode contact and environmental interference.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Signal-to-Noise Ratio (SNR) ====&lt;br /&gt;
&lt;br /&gt;
The signal-to-noise ratio (SNR) is defined as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{SNR (dB)} = 20 \log_{10} \left( \frac{\mathrm{RMS}_{\mathrm{contraction}}}{\mathrm{RMS}_{\mathrm{rest}}} \right)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The measured SNR values are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: 21.26 dB → good signal quality  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: 13.52 dB → moderate and usable  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: 6.66 dB → low signal clarity  &lt;br /&gt;
&lt;br /&gt;
General interpretation:&lt;br /&gt;
&lt;br /&gt;
* &amp;gt;20 dB → good  &lt;br /&gt;
* 10–20 dB → usable  &lt;br /&gt;
* &amp;lt;10 dB → poor  &lt;br /&gt;
&lt;br /&gt;
These results show that the system can achieve reliable signal acquisition, although performance varies across subjects.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
====  Rest vs Contraction Discrimination ====&lt;br /&gt;
&lt;br /&gt;
A clear distinction between rest and contraction states is observed based on RMS values.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: 0.0053 → 0.1064 (≈20× increase)  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: 0.0079 → 0.0283 (≈3.6× increase)  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: 0.0141 → 0.0646 (≈4.6× increase)  &lt;br /&gt;
&lt;br /&gt;
This demonstrates that the system is capable of separating muscle activity from baseline noise.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Conclusion:&#039;&#039;  &lt;br /&gt;
The system can be used for basic muscle activity detection and simple classification tasks based on RMS features.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Repeatability of Repeated Contractions ====&lt;br /&gt;
&lt;br /&gt;
Repeatability is evaluated using the coefficient of variation (CV) of peak RMS values across repetitions.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! CV Range !! Evaluation&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt; 10% || Excellent&lt;br /&gt;
|-&lt;br /&gt;
| 10–20% || Acceptable&lt;br /&gt;
|-&lt;br /&gt;
| &amp;gt; 20% || Poor&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Results:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: CV = 12.77% → Acceptable  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: CV = 24.77% → Poor  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: CV = 10.60% → Acceptable  &lt;br /&gt;
&lt;br /&gt;
Although WANG&#039;s signal is detectable, its contraction amplitude varies significantly across repetitions, resulting in poor repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
=== Overall System Performance ===&lt;br /&gt;
&lt;br /&gt;
The system demonstrates the following performance characteristics:&lt;br /&gt;
&lt;br /&gt;
* Reliable detection of muscle activity across all subjects  &lt;br /&gt;
* Clear separation between rest and contraction states  &lt;br /&gt;
* Moderate to high signal quality depending on subject conditions  &lt;br /&gt;
* Repeatability ranging from acceptable to poor due to user-dependent factors  &lt;br /&gt;
&lt;br /&gt;
Overall, the designed EMG acquisition system is capable of stable signal acquisition and feature extraction, with performance primarily influenced by electrode contact quality, skin impedance, and motion consistency.&lt;br /&gt;
&lt;br /&gt;
===== Summary of Quantitative Metrics =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Subject !! RMS (Rest) !! RMS (Contraction) !! Separation Ratio !! iEMG (max) !! Noise RMS !! SNR (dB) !! CV (%) !! Evaluation&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;LIU&#039;&#039;&#039; || 0.0053 || 0.1064 || &#039;&#039;&#039;20.1×&#039;&#039;&#039; || 12.72 || 0.0046 || &#039;&#039;&#039;21.26&#039;&#039;&#039; || 12.77 || Strong signal, good quality&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;WANG&#039;&#039;&#039; || 0.0079 || 0.0283 || 3.57× || 11.10 || 0.0080 || 13.52 || &#039;&#039;&#039;24.77&#039;&#039;&#039; || Usable signal, poor repeatability&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ZHONG&#039;&#039;&#039; || 0.0141 || 0.0646 || 4.58× || 6.70 || 0.0126 || 6.66 || 10.60 || Acceptable performance&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Summary:&#039;&#039; Subject LIU shows the best overall performance, WANG provides usable but less stable signals, and ZHONG demonstrates moderate signal quality with good repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Activation Intensity =====&lt;br /&gt;
&lt;br /&gt;
Among the three subjects, &#039;&#039;&#039;LIU exhibits the strongest muscle activation&#039;&#039;&#039;, as indicated by the highest contraction RMS and iEMG values. ZHONG shows moderate activation, while WANG demonstrates comparable iEMG but lower RMS consistency.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Signal Quality =====&lt;br /&gt;
&lt;br /&gt;
Signal quality is evaluated based on SNR and noise level:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039; achieves the highest SNR and lowest noise → best signal quality  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039; shows moderate SNR → usable but less robust  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039; has the lowest SNR → weakest signal clarity  &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Repeatability =====&lt;br /&gt;
&lt;br /&gt;
Repeatability is evaluated using the coefficient of variation (CV):&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;ZHONG (10.60%)&#039;&#039;&#039; → most stable  &lt;br /&gt;
* &#039;&#039;&#039;LIU (12.77%)&#039;&#039;&#039; → acceptable  &lt;br /&gt;
* &#039;&#039;&#039;WANG (24.77%)&#039;&#039;&#039; → poor  &lt;br /&gt;
&lt;br /&gt;
This indicates that WANG’s contraction strength varies significantly between repetitions.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Engineering Interpretation of Inter-subject Differences =====&lt;br /&gt;
&lt;br /&gt;
The observed differences are mainly attributed to engineering and experimental factors rather than physiological differences.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Electrode contact quality&#039;&#039;&#039;  &lt;br /&gt;
  Variations in electrode placement, pressure, and gel contact affect signal amplitude and stability.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Skin impedance&#039;&#039;&#039;  &lt;br /&gt;
  Differences in skin condition (hydration, oil, hair) influence electrode–skin impedance, affecting noise level and signal coupling.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Muscle control consistency&#039;&#039;&#039;  &lt;br /&gt;
  Variations in contraction strength and timing affect repeatability and CV.&lt;br /&gt;
&lt;br /&gt;
Therefore, the variation across subjects reflects practical acquisition conditions rather than intrinsic system limitations.&lt;/div&gt;</summary>
		<author><name>Wang Jingyi</name></author>
	</entry>
	<entry>
		<id>https://pc5271.org/index.php?title=Surface_EMG_Sensor_for_Muscle_Activity_Measurement:_AFE_Design_and_Signal_Processing&amp;diff=1355</id>
		<title>Surface EMG Sensor for Muscle Activity Measurement: AFE Design and Signal Processing</title>
		<link rel="alternate" type="text/html" href="https://pc5271.org/index.php?title=Surface_EMG_Sensor_for_Muscle_Activity_Measurement:_AFE_Design_and_Signal_Processing&amp;diff=1355"/>
		<updated>2026-04-23T06:45:26Z</updated>

		<summary type="html">&lt;p&gt;Wang Jingyi: /* Noise Floor and Rest Reference */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Background and Theory==&lt;br /&gt;
&lt;br /&gt;
=== Surface EMG Signals ===&lt;br /&gt;
Surface electromyography (sEMG) refers to the bioelectrical signals detected on the skin surface during muscle contraction. These signals originate from the electrical activity of muscle fibers and provide a non-invasive way to monitor muscle activation. Compared with invasive EMG methods, sEMG is easier to apply, safer for repeated measurements, and more suitable for real-time monitoring. Therefore, it has been widely used in areas such as rehabilitation, motion analysis, human–machine interaction, and physiological monitoring.&lt;br /&gt;
&lt;br /&gt;
=== Characteristics of EMG Signals ===&lt;br /&gt;
EMG signals are generally weak, time-varying, and stochastic in nature. Their waveforms are typically bipolar, fluctuating around zero with both positive and negative components. The amplitude and frequency content of EMG signals depend on factors such as muscle contraction level, electrode placement, skin condition, and individual physiological differences. In practice, the useful frequency components of sEMG are mainly concentrated in a limited low-to-mid frequency range. Because of their low amplitude and variability, EMG signals usually require further conditioning before reliable interpretation and feature extraction can be performed.&lt;br /&gt;
&lt;br /&gt;
=== Bioelectrical Signal Acquisition Principles ===&lt;br /&gt;
The acquisition of bioelectrical signals is based on measuring the small potential difference on the skin surface using electrodes, then converting it into a processable electrical signal through amplification and digitization. For sEMG measurement, electrode placement and skin–electrode contact quality are especially important, since they directly affect signal amplitude and stability. In addition, the front-end acquisition circuit must provide sufficient sensitivity and good interference rejection, so that the recorded signal reflects actual muscle activity rather than environmental disturbance or poor contact conditions.&lt;br /&gt;
&lt;br /&gt;
=== Noise Sources in EMG (50 Hz, motion artifacts) ===&lt;br /&gt;
In practical EMG recording, the measured signal is easily contaminated by different types of noise. Two of the most common sources are power-line interference and motion artifacts. Power-line interference usually appears as a narrow-band component at 50 Hz in the local electrical environment, while motion artifacts are mainly caused by electrode movement, cable disturbance, or variations in the electrode–skin impedance, and are often concentrated in the low-frequency range. In addition, electronic noise from the acquisition hardware may also affect the recording quality. These unwanted components can reduce signal clarity and make muscle activity analysis less reliable, so they must be considered in the design of the signal processing pipeline.&lt;br /&gt;
[[File:background_theory_figure1.1_emg_noise_sources.png|center|thumb|700px|&#039;&#039;&#039;Figure 1.1.&#039;&#039;&#039; Principle of surface EMG acquisition.]]&lt;br /&gt;
&lt;br /&gt;
==System Architecture==&lt;br /&gt;
=== Total Structure Design ===&lt;br /&gt;
&lt;br /&gt;
For clarity，the proposed physiological signal acquisition system mainly consists of two core parts：the analog front－end （AFE）and the ADC board．The AFE is responsible for the preliminary conditioning of weak bioelectrical signals，including amplification，filtering，interference suppression，and level shifting，so that the analog waveform can be converted into a stable and measurable form．The ADC board then performs high－resolution digitization of the conditioned signal and transfers the sampled data to the host computer for subsequent display，storage，and analysis．Therefore，the overall system forms a complete signal－acquisition chain from weak physiological input to digital output．&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_1.jpg|thumb|center|800px|Figure 2.1. Overall system architecture of the proposed physiological signal acquisition platform，including the AFE and ADC modules．]]&lt;br /&gt;
&lt;br /&gt;
=== sEMG AFE Design ===&lt;br /&gt;
&lt;br /&gt;
To collect the weak bioelectric potential signals of the human body，an analog front－end（AFE）suitable sEMG measurements was designed．The module is powered by an external 5 V supply，and the complete circuit includes a first－ stage instrumentation amplifier based on INA128（Texas Instruments，Dallas，TX，USA），a band－pass filter，a 50 Hz notch filter，a second－order amplification and level shifting stage，a driver electrode circuit，a precise 1.5 V reference source，and a -5 V voltage generation module for powering the operational amplifiers．&lt;br /&gt;
&lt;br /&gt;
==== First－order Amplifier ====&lt;br /&gt;
&lt;br /&gt;
The input bioelectric signal is first acquired in differential form and applied to the INA128 instrumentation amplifier，which provides high input impedance，high common－mode rejection，and moderate initial gain for sEMG acquisition．This stage enlarges the weak physiological signal before filtering while reducing the risk of premature saturation caused by electrode offset or motion－induced disturbance，thereby preparing a more stable signal for the subsequent conditioning stages．&lt;br /&gt;
&lt;br /&gt;
==== Bandpass Filter ====&lt;br /&gt;
&lt;br /&gt;
After the instrumentation amplifier，the signal passes through a second－order active band－pass filter，as shown in Figure 2．2． This stage suppresses baseline drift and high－frequency noise outside the useful sEMG range，so that the low－frequency envelope information of sEMG can be preserved before further amplification．&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_2.jpg|thumb|center|800px|Figure 2.2. Schematic diagram of the active band-pass filter used in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the band-pass stage used to retain the main physiological signal band while suppressing unwanted lowand high-frequency components.&lt;br /&gt;
&lt;br /&gt;
==== Notch Filter ====&lt;br /&gt;
&lt;br /&gt;
To reduce power-line interference, a dedicated 50 Hz notch filter is introduced after the band-pass stage, as shown in Figure 2.3. This filter attenuates the mains-frequency component that commonly contaminates weak bioelectric measurements, thereby improving the signal-to-noise ratio of sEMG signals before the final amplification stage.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_3.jpg|thumb|center|800px|Figure 2.3. Schematic diagram of the 50 Hz notch filter used in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the circuit used to attenuate 50 Hz mains interference in the analog front end.&lt;br /&gt;
&lt;br /&gt;
==== Second-order Amplifier &amp;amp; Level Shifter ====&lt;br /&gt;
&lt;br /&gt;
After filtering, the signal enters the second-stage amplification and level-shifting circuit shown in Figure 2.4. In this stage, the filtered signal is further amplified to improve amplitude utilization and then shifted by a 1.5 V reference so that the output becomes a stable unipolar signal suitable for ADC sampling, while preserving linear operation and providing sufficient output swing margin.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_4.jpg|thumb|center|800px|Figure 2.4. Schematic diagram of the second-stage amplifier and level-shifting circuit in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows how the conditioned signal is further amplified and shifted to a suitable DC level before digitization.&lt;br /&gt;
&lt;br /&gt;
==== Power Module and Drive-electrode Circuit ====&lt;br /&gt;
&lt;br /&gt;
The AFE is powered by a 5 V supply and also integrates a 1.5 V precision reference, a -5 V generation circuit, and a driveelectrode circuit. These supporting modules provide the required supply rails and reference level for analog signal conditioning, while the drive-electrode circuit feeds back common-mode voltage to the body to suppress interference at the source. As a result, the complete AFE can support sEMG acquisition with adequate gain, filtering, and noise-reduction performance in a compact hardware structure.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_5.jpg|thumb|center|800px|Figure 2.5. Physical picture of the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the fabricated sEMG analog front-end hardware used in the system.&lt;br /&gt;
&lt;br /&gt;
Figure 2.5 presents the practical hardware implementation of the proposed sEMG AFE. It integrates amplification, filtering, level shifting, and driven-reference functions in a compact circuit for weak bioelectrical signal acquisition.&lt;br /&gt;
&lt;br /&gt;
=== ADS1256-based ADC Board ===&lt;br /&gt;
&lt;br /&gt;
To digitize the conditioned weak physiological signals with sufficient resolution and low noise, this project developed a dedicated ADC board based on the ADS1256 analog-to-digital converter (Texas Instruments, Dallas, TX, USA) and the STM32F103C8T6 microcontroller (STMicroelectronics, Geneva, Switzerland). The overall design objective of this board was not merely to realize analog-to-digital conversion, but to provide a complete hardware interface between the analog front-end and the digital processing unit, including precision reference generation, clocking, input protection and filtering, serial communication, power regulation, and MCU-based acquisition control. The ADS1256 was selected because it is a&lt;br /&gt;
&lt;br /&gt;
very low-noise 24-bit delta-sigma converter with a programmable gain amplifier (PGA), flexible input multiplexer, programmable digital filter, and SPI-compatible serial interface, which makes it well suited for weak low-frequency physiological signals after analog conditioning. The STM32F103C8T6 was used as the local controller because it provides a 32-bit Cortex-M3 core, up to 72 MHz system clock, SPI, USART, USB, and standard SWD debugging support in a compact and low-cost platform.&lt;br /&gt;
&lt;br /&gt;
==== ADC Core Architecture and Design Rationale ====&lt;br /&gt;
&lt;br /&gt;
The ADS1256 was selected as the core ADC because it provides high-resolution, low-noise delta-sigma conversion with an input multiplexer, programmable gain amplifier, and digital filter, which are suitable for weak and low-frequency physiological signals. As shown in Figure 2.6, this architecture emphasizes resolution and noise performance rather than high conversion bandwidth, making it appropriate for sEMG signal digitization after analog conditioning.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_6.jpg|thumb|center|800px|Figure 2.6. Internal functional structure of the ADS1256 analog-to-digital converter.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the main internal blocks of the ADS1256, including the multiplexer, PGA, modulator, and digital filter.&lt;br /&gt;
&lt;br /&gt;
==== Analog Front-End Interface, Reference, and Clocking ====&lt;br /&gt;
&lt;br /&gt;
The ADS1256 analog inputs are connected to the external header through a passive input-conditioning network that helps suppress high-frequency interference and improve input stability. In addition, the board includes a dedicated precision reference and clocking circuits so that the ADC can perform stable and accurate conversion. Together, these circuits provide a reliable analog interface and timing basis for high-resolution digitization of weak physiological signals.&lt;br /&gt;
&lt;br /&gt;
==== SPI Interface between ADS1256 and STM32F103C8T6 ====&lt;br /&gt;
&lt;br /&gt;
Communication between the ADS1256 and the STM32F103C8T6 is implemented through an SPI-compatible interface, with dedicated lines for chip select, serial clock, input/output data, data-ready notification, and hardware reset. This connection allows the MCU to configure the ADC, read conversion results in synchrony with DRDY, and maintain efficient and reliable acquisition control for multi-channel physiological measurements.&lt;br /&gt;
&lt;br /&gt;
==== Power Supply and On-board Regulation ====&lt;br /&gt;
&lt;br /&gt;
The ADC board uses a USB Type-B connector as the main power input and includes protection, voltage regulation, and local decoupling circuits to provide a stable supply for both the MCU and ADC-related hardware. In addition, analog ground and digital ground are separated in the PCB layout to reduce digital noise coupling into the analog path, which is particularly important for weak physiological signal acquisition.&lt;br /&gt;
&lt;br /&gt;
==== Basic Peripheral Circuits of the STM32F103C8T6 ====&lt;br /&gt;
&lt;br /&gt;
The STM32F103C8T6 serves as the local controller of the ADC board and is supported by several basic peripheral circuits, including an external crystal oscillator, reset network, BOOT0 configuration, SWD programming/debugging header, and a CH340N USB-to-UART bridge. These circuits ensure stable MCU operation, convenient firmware downloading and debugging, and reliable data transmission from the board to the host computer for real-time display and storage.&lt;br /&gt;
&lt;br /&gt;
==== Hardware-level Working Principle of the ADC Board ====&lt;br /&gt;
&lt;br /&gt;
In operation, the conditioned analog signal from the AFE enters the ADS1256 through the input header, is digitized with high resolution under the control of the local precision reference and clock, and is then read by the STM32 through the SPI interface. The MCU subsequently forwards the sampled data to the host computer through the serial communication link, so that the entire board functions as a compact digital acquisition backend connecting weak physiological analog signals to later software processing, display, and storage.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_7.jpg|thumb|center|800px|Figure 2.7. Photograph of the fabricated ADS1256-based ADC board developed in this project and the definitions of some key pins.]]&lt;br /&gt;
&lt;br /&gt;
Figure 2.7 shows the ADC board fabricated for this project. It integrates the ADS1256 conversion core, STM32 control circuit, power-conditioning circuits, and communication interfaces on a compact PCB for physiological signal digitization.&lt;br /&gt;
&lt;br /&gt;
== Signal Conditioning and Filtering ==&lt;br /&gt;
Although the AFE already performs preliminary band-pass filtering and 50 Hz interference suppression in the analog domain, the digitized sEMG signal may still contain residual noise due to component tolerances, electrode-contact variation, and environmental interference. Therefore, an additional digital filtering stage is implemented in software as a complementary post-processing step to improve signal quality and to provide a more stable input for rectification, envelope extraction, and subsequent analysis. In this sense, the software filtering is not a simple repetition of the analog filtering, but a refinement and compensation for non-ideal front-end behavior.&lt;br /&gt;
&lt;br /&gt;
Surface electromyographic (sEMG) signals are highly susceptible to several sources of contamination during acquisition. In practical measurements, the dominant disturbances usually include low-frequency motion artifacts caused by electrode movement and electrode–skin impedance variation, narrow-band power-line interference centered at 50 Hz, and broadband high-frequency electronic noise introduced by the acquisition hardware. These unwanted components degrade the quality of the recorded signal and may significantly affect the reliability of subsequent feature extraction, parameter estimation, and muscle activity interpretation. For this reason, an effective signal-conditioning procedure is necessary before any higher-level analysis is performed.&lt;br /&gt;
&lt;br /&gt;
In the present implementation, the filtering strategy follows the principle of restricting the signal bandwidth first and then removing the remaining narrow-band interference in a targeted manner. Accordingly, the raw sEMG signal is first processed by a fourth-order Butterworth IIR band-pass filter and then by a 50 Hz notch filter. This processing sequence is illustrated in the flowchart below, where the signal passes through band-pass filtering, notch filtering, full-wave rectification, and envelope extraction before producing the final processed output.&lt;br /&gt;
&lt;br /&gt;
[[File:flowchart.png|thumb|center|500px|Flowchart of the real-time sEMG signal conditioning pipeline.]]&lt;br /&gt;
&lt;br /&gt;
The rationale of this order is that the &#039;&#039;&#039;band-pass stage&#039;&#039;&#039; first confines the signal to the main spectral region of interest for sEMG, thereby attenuating motion artifacts at very low frequencies and suppressing high-frequency noise components outside the physiological band. After this spectral preconditioning, the notch stage can more effectively suppress the residual 50 Hz power-line interference that lies inside the useful sEMG band. In transfer-function form, the band-pass filter may be written as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;H_{BP}(z)=\frac{B_{BP}(z)}{A_{BP}(z)}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where the effective passband is selected as &amp;lt;math&amp;gt;20 \leq f \leq 160 \text{ Hz}&amp;lt;/math&amp;gt;. This frequency interval is consistent with the dominant spectral content of surface EMG: the lower cutoff near 20 Hz reduces motion artifacts and unstable low-frequency fluctuations, whereas the upper cutoff near 160 Hz removes high-frequency electronic noise while preserving the main energy-bearing components of the muscle signal. The use of a Butterworth structure is appropriate here because it provides a smooth monotonic passband response without ripple, which helps preserve signal morphology in real-time applications.&lt;br /&gt;
&lt;br /&gt;
After band limitation, a &#039;&#039;&#039;notch filter&#039;&#039;&#039; centered at the power-line frequency is applied to suppress interference that cannot be removed by the band-pass stage alone. The notch filter is designed around &amp;lt;math&amp;gt;f_0 = 50 \text{ Hz}&amp;lt;/math&amp;gt;, and its bandwidth is controlled by the quality factor &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;, which is expressed as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;Q = \frac{f_0}{\Delta f}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In transfer-function form, the notch stage is written as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;H_{N}(z)=\frac{B_{N}(z)}{A_{N}(z)}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the implemented program, a large quality factor is chosen so that the notch remains narrow, allowing effective rejection of the 50 Hz interference while minimizing distortion of neighboring useful spectral components. This is particularly important for sEMG because the interference frequency lies directly inside the physiological band of interest.&lt;br /&gt;
&lt;br /&gt;
Following the filtering stages, further signal conditioning is performed to obtain a representation that is more directly related to muscle activation intensity. The filtered sEMG waveform is first &#039;&#039;&#039;full-wave rectified&#039;&#039;&#039;, which converts the bipolar oscillatory signal into a unipolar signal by taking its absolute value.  Rectification does not remove noise by itself; instead, it transforms the signal into a form that is more suitable for amplitude-based analysis because both positive and negative deflections contribute positively to the activation measure.&lt;br /&gt;
&lt;br /&gt;
After rectification, the signal envelope is extracted to provide a smooth estimate of muscle activation level over time. In a general formulation, the envelope can be described as the &#039;&#039;&#039;low-pass filtered&#039;&#039;&#039; version of the rectified signal, namely &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y_{\mathrm{env}}[n] = \mathrm{LPF}\bigl(y_{\mathrm{rect}}[n]\bigr)&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the present code implementation, this operation is realized by short-time averaging over a finite window, which is equivalent to a moving-average low-pass smoothing of the rectified waveform. The corresponding expression is &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y_{\mathrm{env}}[n] = \frac{1}{N}\sum_{k=0}^{N-1} |x[n-k]|&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; is the window length in samples. With a window duration of approximately 200 ms, this envelope extraction method provides a stable and physiologically meaningful representation of muscle activation intensity, making it suitable for tasks such as force estimation, fatigue analysis, and motor-control studies.&lt;br /&gt;
&lt;br /&gt;
An important feature of the present &#039;&#039;&#039;implementation&#039;&#039;&#039; is that the entire filtering process is performed &#039;&#039;&#039;in real time&#039;&#039;&#039;, sample by sample, rather than by offline block processing. For this reason, IIR filters are preferred over FIR filters, since they can achieve comparable filtering performance with lower order, lower computational cost, and shorter delay. These properties are especially valuable in embedded systems, serial data streaming, and other low-latency experimental applications. However, unlike memoryless operations, an IIR filter depends not only on the current input but also on previous inputs and previous outputs. Its discrete-time behavior can therefore be represented by the recursive difference equation &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y[n] = \sum_{k=0}^{M} b_k x[n-k] - \sum_{k=1}^{N} a_k y[n-k]&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This equation makes clear that internal filter states must be preserved continuously during streaming operation. If the state variables were reinitialized for every incoming sample or data segment, artificial transients would appear and the output would no longer remain continuous.&lt;br /&gt;
&lt;br /&gt;
In the Python implementation, this state continuity is maintained using the internal initial-condition mechanism provided by SciPy, such as &amp;lt;code&amp;gt;lfilter_zi&amp;lt;/code&amp;gt;, together with recursive state updates during each filtering call. As a result, each newly acquired sample is passed first through the band-pass filter and then through the notch filter, while the internal states of both filters are updated after every step. This state-preserving sample-by-sample design ensures that the processing chain remains causal, continuous, and suitable for real-time display or downstream analysis without requiring storage of the entire signal segment.&lt;br /&gt;
&lt;br /&gt;
Overall, this signal-conditioning scheme provides an experimentally practical solution for real-time sEMG processing. The fourth-order Butterworth band-pass filter confines the signal to the main physiological band of interest, the 50 Hz notch filter removes narrow-band power-line contamination, and the subsequent rectification and envelope extraction generate a smooth amplitude descriptor of muscle activity. Combined with state-preserved streaming IIR implementation, this approach achieves a good balance between signal fidelity, computational efficiency, and real-time applicability in biomedical and physical experiment settings.&lt;br /&gt;
&lt;br /&gt;
== Data Processing ==&lt;br /&gt;
&lt;br /&gt;
The objective of data processing is to convert raw surface electromyography (sEMG) recordings into stable, quantitative, and comparable indicators of muscle activity. Since EMG signals are low in amplitude, highly variable over time, and easily contaminated by noise, a dedicated processing pipeline is necessary before any experimental interpretation can be performed.&lt;br /&gt;
&lt;br /&gt;
In this project, the data processing workflow includes time normalization, signal pre-processing, sliding-window feature extraction, noise-floor estimation, and automatic contraction detection. The processed outputs are then used for subsequent experimental evaluation, including rest-versus-contraction discrimination, signal-to-noise ratio analysis, and repeatability assessment.&lt;br /&gt;
&lt;br /&gt;
=== Input Data and Time Normalization ===&lt;br /&gt;
&lt;br /&gt;
The acquired EMG data are read from CSV files containing two columns: time and filtered sEMG amplitude. In the MATLAB implementation, the time vector is normalized so that each recording starts from zero:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t = t_{all} - t_{all}(1)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This normalization is important because it removes the influence of absolute recording timestamps and makes different trials directly comparable on the same time axis.&lt;br /&gt;
&lt;br /&gt;
In addition, the signal type is automatically identified from the filename as either dynamic or rest. This design allows the same program to process both contraction recordings and resting recordings with different downstream analysis logic.&lt;br /&gt;
&lt;br /&gt;
=== Signal Pre-processing ===&lt;br /&gt;
&lt;br /&gt;
Raw EMG signals cannot be analyzed directly because they usually contain DC offset, low-frequency drift, motion artifacts, and residual high-frequency interference. Therefore, several pre-processing steps are applied before feature extraction.&lt;br /&gt;
&lt;br /&gt;
==== Baseline Removal ====&lt;br /&gt;
&lt;br /&gt;
The first step is DC offset removal:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
x_{dc}(t) = x(t) - \frac{1}{N}\sum_{i=1}^{N}x(i)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This operation centers the signal around zero. It is necessary because an uncorrected baseline would bias amplitude-based metrics and reduce the reliability of later envelope and feature calculations.&lt;br /&gt;
&lt;br /&gt;
==== Band-pass Filtering ====&lt;br /&gt;
&lt;br /&gt;
After baseline correction, a fourth-order Butterworth band-pass filter is applied with a passband of 20–150 Hz.&lt;br /&gt;
&lt;br /&gt;
This step is introduced for two reasons:&lt;br /&gt;
&lt;br /&gt;
* The low-frequency cutoff at 20 Hz suppresses baseline drift and motion artifacts.&lt;br /&gt;
* The high-frequency cutoff at 150 Hz reduces unwanted high-frequency noise while preserving the main energy band of the recorded sEMG in this project.&lt;br /&gt;
&lt;br /&gt;
Compared with processing the raw waveform directly, band-pass filtering makes the subsequent time-domain features more stable and more physiologically meaningful.&lt;br /&gt;
&lt;br /&gt;
==== Full-wave Rectification ====&lt;br /&gt;
&lt;br /&gt;
The filtered EMG signal is bipolar, meaning that positive and negative phases coexist due to motor unit action potentials. If these positive and negative components are averaged directly, they may cancel each other out. To avoid this, full-wave rectification is performed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
x_{rect}(t) = |x_{filt}(t)|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This transforms the signal into a unipolar representation, so that all muscle activity contributes positively to the extracted features.&lt;br /&gt;
&lt;br /&gt;
==== Envelope Extraction ====&lt;br /&gt;
&lt;br /&gt;
Although the rectified signal reflects signal magnitude, it still fluctuates rapidly. To obtain a smoother representation of muscle activation level, an envelope is extracted using a moving average with a 100 ms window.&lt;br /&gt;
&lt;br /&gt;
Envelope extraction is important because contraction detection should reflect the overall activation trend rather than instantaneous spikes. A smoothed envelope is therefore more robust for identifying active and inactive muscle states.&lt;br /&gt;
&lt;br /&gt;
=== Sliding Window Design ===&lt;br /&gt;
&lt;br /&gt;
To quantify how muscle activity changes with time, the filtered signal is divided into overlapping short-time segments using a sliding window method.&lt;br /&gt;
&lt;br /&gt;
The window parameters are:&lt;br /&gt;
&lt;br /&gt;
* Window length: 250 ms&lt;br /&gt;
* Step size: 50 ms&lt;br /&gt;
&lt;br /&gt;
These values are chosen as a trade-off between temporal resolution and feature stability.&lt;br /&gt;
&lt;br /&gt;
A longer window improves statistical robustness because more samples are included in each calculation. However, if the window is too long, short contractions or rapid changes may be blurred. A smaller step size increases temporal continuity between adjacent feature points and makes the feature curves smoother in time. Therefore, the 250 ms / 50 ms design provides a practical balance between smoothing and time localization.&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt;-th segment, the feature time is defined as the mean time of that segment:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t_k = \frac{1}{N}\sum_{i=s_k}^{e_k} t(i)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;s_k&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;e_k&amp;lt;/math&amp;gt; denote the start and end indices of the window.&lt;br /&gt;
&lt;br /&gt;
=== Feature Extraction ===&lt;br /&gt;
&lt;br /&gt;
Within each sliding window, three time-domain features are extracted: RMS, iEMG, and MAV. These features are widely used in EMG analysis because they are simple, computationally efficient, and directly related to muscle activation intensity.&lt;br /&gt;
&lt;br /&gt;
==== Root Mean Square (RMS) ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
RMS = \sqrt{\frac{1}{N}\sum_{i=1}^{N}x_i^2}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
RMS reflects the effective power of the EMG signal and is one of the most common indicators of contraction strength. It is sensitive to both amplitude and energy, making it especially useful for comparing rest and active states.&lt;br /&gt;
&lt;br /&gt;
==== Integrated EMG (iEMG) ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
iEMG = \sum_{i=1}^{N}|x_i|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
iEMG describes the cumulative electrical activity within a window. It is often interpreted as a measure of total muscle effort over that time segment.&lt;br /&gt;
&lt;br /&gt;
==== Mean Absolute Value (MAV) ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
MAV = \frac{1}{N}\sum_{i=1}^{N}|x_i|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
MAV is an amplitude descriptor similar to iEMG, but normalized by the number of samples. It provides an efficient estimate of average signal level and is less computationally intensive than some other features.&lt;br /&gt;
&lt;br /&gt;
These three features are used together because they provide complementary descriptions of EMG intensity. RMS emphasizes signal energy, iEMG emphasizes cumulative activation, and MAV reflects average amplitude.&lt;br /&gt;
&lt;br /&gt;
=== Peak-value Extraction ===&lt;br /&gt;
&lt;br /&gt;
In addition to continuous feature curves, several key peak values are extracted from the processed signal:&lt;br /&gt;
&lt;br /&gt;
* maximum and minimum of the filtered EMG waveform&lt;br /&gt;
* peak of the envelope&lt;br /&gt;
* peak RMS&lt;br /&gt;
* peak iEMG&lt;br /&gt;
* peak MAV&lt;br /&gt;
&lt;br /&gt;
These peak values provide concise descriptors of the strongest activity observed in each recording. They are useful for quick comparison across trials and subjects.&lt;br /&gt;
&lt;br /&gt;
=== Noise Floor Estimation ===&lt;br /&gt;
&lt;br /&gt;
To evaluate signal quality, the noise floor is estimated from a reference resting interval. In the present implementation, the first 3 seconds of the recording are used as the default rest reference:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t \in [0,\min(3,t_{end})]&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this segment, three noise descriptors are computed:&lt;br /&gt;
&lt;br /&gt;
* Noise RMS&lt;br /&gt;
* Noise standard deviation&lt;br /&gt;
* Noise peak-to-peak amplitude&lt;br /&gt;
&lt;br /&gt;
Noise-floor estimation is important because EMG amplitude alone is not sufficient to judge recording quality. A large signal is only meaningful if it is sufficiently higher than the baseline noise level. Therefore, the noise floor serves as the reference for later SNR calculation and for designing contraction thresholds.&lt;br /&gt;
&lt;br /&gt;
=== Global Signal Metrics ===&lt;br /&gt;
&lt;br /&gt;
For each recording, three global metrics are also computed over the entire filtered signal:&lt;br /&gt;
&lt;br /&gt;
* Global RMS&lt;br /&gt;
* Global MAV&lt;br /&gt;
* Global iEMG&lt;br /&gt;
&lt;br /&gt;
These global descriptors summarize the overall signal level of the full recording and are later used in group-level comparisons.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Contraction Detection ===&lt;br /&gt;
&lt;br /&gt;
For dynamic recordings, an automatic contraction detection algorithm is used to identify repeated active segments. This is one of the key parts of the data processing pipeline, because it transforms a continuous EMG trace into discrete contraction events that can be counted and compared.&lt;br /&gt;
&lt;br /&gt;
==== Threshold Design ====&lt;br /&gt;
&lt;br /&gt;
The detection threshold is designed adaptively rather than using a fixed value. Two candidate thresholds are first calculated:&lt;br /&gt;
&lt;br /&gt;
* an envelope-based threshold derived from the global envelope mean and standard deviation&lt;br /&gt;
* a rest-reference threshold derived from the mean and standard deviation of the resting reference amplitude&lt;br /&gt;
&lt;br /&gt;
The final threshold is taken as the larger of the two after additional scaling. This strategy improves robustness because it combines the global activation level of the signal with the baseline noise characteristics of the individual recording.&lt;br /&gt;
&lt;br /&gt;
This adaptive threshold design is preferable to a manually fixed threshold because EMG amplitude can vary strongly between subjects, muscles, and recording sessions.&lt;br /&gt;
&lt;br /&gt;
==== Initial Segmentation ====&lt;br /&gt;
&lt;br /&gt;
After thresholding the envelope, the signal is classified into active and inactive regions:&lt;br /&gt;
&lt;br /&gt;
* active: envelope above threshold&lt;br /&gt;
* inactive: envelope below threshold&lt;br /&gt;
&lt;br /&gt;
The rising and falling edges of the binary activity vector are then used to determine the start and end points of each candidate contraction segment.&lt;br /&gt;
&lt;br /&gt;
==== Removal of Short Segments ====&lt;br /&gt;
&lt;br /&gt;
Very short active regions are often caused by noise fluctuations rather than true muscle contractions. Therefore, segments shorter than 0.20 s are discarded.&lt;br /&gt;
&lt;br /&gt;
This step prevents false positive detections and increases the physiological relevance of the segmentation results.&lt;br /&gt;
&lt;br /&gt;
==== Merging of Adjacent Segments ====&lt;br /&gt;
&lt;br /&gt;
If two neighboring active segments are separated by a very short gap, they are merged when the gap is less than 0.15 s.&lt;br /&gt;
&lt;br /&gt;
This operation is necessary because a single real contraction may be temporarily interrupted by a brief drop in the envelope caused by local fluctuation. Without merging, one contraction could be incorrectly counted as multiple repetitions.&lt;br /&gt;
&lt;br /&gt;
==== Repetition-level Metrics ====&lt;br /&gt;
&lt;br /&gt;
For each detected contraction segment, two repetition-level metrics are extracted:&lt;br /&gt;
&lt;br /&gt;
* peak RMS of that contraction&lt;br /&gt;
* mean RMS of that contraction&lt;br /&gt;
&lt;br /&gt;
These metrics quantify both the strongest activation within each repetition and the average activation level over the repetition duration.&lt;br /&gt;
&lt;br /&gt;
=== Repeatability Analysis ===&lt;br /&gt;
&lt;br /&gt;
When multiple valid contractions are detected, repeatability is evaluated using the coefficient of variation (CV):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
CV = \frac{\sigma}{\mu}\times 100\%&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt; is the standard deviation and &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is the mean value across repetitions.&lt;br /&gt;
&lt;br /&gt;
Two CV values are computed:&lt;br /&gt;
&lt;br /&gt;
* CV of repetition peak RMS&lt;br /&gt;
* CV of repetition mean RMS&lt;br /&gt;
&lt;br /&gt;
A lower CV indicates better repeatability, meaning that repeated contractions produce more consistent EMG responses.&lt;br /&gt;
&lt;br /&gt;
=== Signal-to-Noise Ratio (SNR) ===&lt;br /&gt;
&lt;br /&gt;
In this project, the signal-to-noise ratio (SNR) is defined based on the ratio between contraction and rest activity:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
SNR_{dB} = 20\log_{10}\left(\frac{RMS_{contraction}}{RMS_{rest}}\right)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This definition is adopted because it directly reflects the system’s ability to distinguish active muscle contraction from baseline noise.&lt;br /&gt;
&lt;br /&gt;
Compared with global SNR definitions, this formulation is more relevant for practical EMG applications such as activity detection and classification.&lt;br /&gt;
&lt;br /&gt;
=== Rest-versus-Contraction Window Comparison ===&lt;br /&gt;
&lt;br /&gt;
To further distinguish inactive and active states, all sliding windows are divided into two groups:&lt;br /&gt;
&lt;br /&gt;
* rest windows: windows with envelope clearly below the threshold&lt;br /&gt;
* contraction windows: windows with envelope above the threshold&lt;br /&gt;
&lt;br /&gt;
The RMS values of these two groups are then compared statistically.&lt;br /&gt;
&lt;br /&gt;
This comparison is important because a practical EMG system should not only detect signal presence, but also clearly separate rest from contraction in a quantitative way. If the two RMS distributions are well separated, it indicates that the system has good discriminative capability.&lt;br /&gt;
&lt;br /&gt;
=== Output Data Structure ===&lt;br /&gt;
&lt;br /&gt;
The processed outputs are organized into structured data for experimental analysis:&lt;br /&gt;
&lt;br /&gt;
==== Time-series outputs ====&lt;br /&gt;
* Filtered EMG signal  &lt;br /&gt;
* Rectified signal  &lt;br /&gt;
* Envelope  &lt;br /&gt;
* RMS(t), iEMG(t), MAV(t)  &lt;br /&gt;
&lt;br /&gt;
==== Recording-level outputs ====&lt;br /&gt;
* RMS (rest)  &lt;br /&gt;
* RMS (contraction)  &lt;br /&gt;
* iEMG  &lt;br /&gt;
* Noise metrics  &lt;br /&gt;
&lt;br /&gt;
==== Dynamic-signal outputs ====&lt;br /&gt;
* Detected contractions  &lt;br /&gt;
* Repetition count  &lt;br /&gt;
* Peak RMS per repetition  &lt;br /&gt;
* Mean RMS per repetition  &lt;br /&gt;
* Coefficient of variation (CV)  &lt;br /&gt;
* Signal-to-noise ratio (SNR)  &lt;br /&gt;
&lt;br /&gt;
All extracted features are designed to directly support the evaluation of noise level, signal quality, activity discrimination, and repeatability in the subsequent experimental analysis.&lt;br /&gt;
&lt;br /&gt;
== Experimental Results ==&lt;br /&gt;
&lt;br /&gt;
This section presents representative results of the EMG acquisition and data processing pipeline under both dynamic (muscle contraction) and resting conditions.&lt;br /&gt;
&lt;br /&gt;
=== Representative Dynamic Signal Analysis ===&lt;br /&gt;
&lt;br /&gt;
[[File:Dynamic_Figure1.png|thumb|800px|center|Figure 5.1: Processed EMG signal under dynamic contraction, including filtered signal, rectified signal with envelope, and extracted features (RMS, iEMG, MAV).]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.1 shows the processed EMG signal during repeated muscle contractions.&lt;br /&gt;
&lt;br /&gt;
The filtered EMG waveform exhibits clear burst-like patterns corresponding to periodic contractions. The signal amplitude reaches a maximum of approximately 0.45, while the baseline remains centered around zero, indicating effective baseline removal and filtering.&lt;br /&gt;
&lt;br /&gt;
After rectification and envelope extraction, the contraction periods become clearly distinguishable. The envelope provides a smooth representation of muscle activation, with a peak value of approximately 0.145.&lt;br /&gt;
&lt;br /&gt;
The extracted time-domain features (RMS, iEMG, MAV) further quantify the signal. Among these, iEMG shows the strongest dynamic variation, indicating high sensitivity to contraction intensity.&lt;br /&gt;
&lt;br /&gt;
=== Noise Floor and Rest Reference ===&lt;br /&gt;
&lt;br /&gt;
[[File:Dynamic_Figure2.png|thumb|800px|center|Figure 5.2: Noise estimation, rest vs contraction comparison, automatic contraction detection, and repetition analysis.]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.2 (top-left) shows the resting reference segment used for noise estimation.&lt;br /&gt;
&lt;br /&gt;
The signal remains centered around zero with small fluctuations. The noise characteristics are:&lt;br /&gt;
&lt;br /&gt;
* Noise RMS ≈ 0.0046  &lt;br /&gt;
* Standard deviation ≈ 0.0046  &lt;br /&gt;
* Peak-to-peak amplitude ≈ 0.071  &lt;br /&gt;
&lt;br /&gt;
This indicates a low noise floor and stable measurement conditions.&lt;br /&gt;
&lt;br /&gt;
=== Rest vs Contraction Discrimination ===&lt;br /&gt;
&lt;br /&gt;
Figure 2 (top-right) compares RMS values between rest and contraction states.&lt;br /&gt;
&lt;br /&gt;
The two distributions are clearly separated:&lt;br /&gt;
&lt;br /&gt;
* Rest mean RMS ≈ 0.0053  &lt;br /&gt;
* Contraction mean RMS ≈ 0.1064  &lt;br /&gt;
&lt;br /&gt;
This corresponds to an approximate 20× increase, demonstrating strong discriminability between inactive and active muscle states.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Contraction Detection ===&lt;br /&gt;
&lt;br /&gt;
Figure 2 (bottom-left) illustrates automatic detection based on the envelope signal.&lt;br /&gt;
&lt;br /&gt;
A threshold of approximately 0.040 is applied, resulting in stable segmentation of contraction periods.&lt;br /&gt;
&lt;br /&gt;
A total of 12 repetitions are detected, with good alignment to visible signal peaks.&lt;br /&gt;
&lt;br /&gt;
=== Repeatability Analysis ===&lt;br /&gt;
&lt;br /&gt;
Figure 2 (bottom-right) shows the peak RMS value of each detected contraction.&lt;br /&gt;
&lt;br /&gt;
The results indicate:&lt;br /&gt;
&lt;br /&gt;
* Mean peak RMS ≈ 0.1355  &lt;br /&gt;
* Standard deviation ≈ 0.0173  &lt;br /&gt;
* CV ≈ 12.77%  &lt;br /&gt;
* SNR ≈ 21.26 dB  &lt;br /&gt;
&lt;br /&gt;
This indicates acceptable repeatability and good signal quality.&lt;br /&gt;
&lt;br /&gt;
=== Representative Rest Signal Analysis ===&lt;br /&gt;
&lt;br /&gt;
[[File:Rest_Figure1.png|800px|center|Figure 3: Processed EMG signal under rest condition, showing low amplitude and absence of contraction patterns.]]&lt;br /&gt;
&lt;br /&gt;
Figure 3 shows the EMG signal under resting conditions.&lt;br /&gt;
&lt;br /&gt;
The signal remains within a narrow amplitude range (approximately ±0.04) and shows no burst-like structures. The envelope remains close to zero, confirming the absence of muscle activity.&lt;br /&gt;
&lt;br /&gt;
The extracted features remain low:&lt;br /&gt;
&lt;br /&gt;
* RMS ≈ 0.007  &lt;br /&gt;
* MAV ≈ 0.005  &lt;br /&gt;
* iEMG remains stable  &lt;br /&gt;
&lt;br /&gt;
This confirms that no false activation is detected.&lt;br /&gt;
&lt;br /&gt;
=== Frequency-domain Characteristics ===&lt;br /&gt;
&lt;br /&gt;
[[File:Rest_Figure2.png|800px|center|Figure 4: Frequency-domain analysis and statistical characteristics of rest signal.]]&lt;br /&gt;
&lt;br /&gt;
Figure 4 shows the frequency-domain characteristics of the resting signal.&lt;br /&gt;
&lt;br /&gt;
The power spectral density (PSD) indicates low overall signal energy without dominant peaks, confirming that the signal mainly consists of noise.&lt;br /&gt;
&lt;br /&gt;
=== Summary of Single-recording Performance ===&lt;br /&gt;
&lt;br /&gt;
From the representative results:&lt;br /&gt;
&lt;br /&gt;
* EMG signals are effectively extracted and denoised  &lt;br /&gt;
* Contraction events are clearly identifiable  &lt;br /&gt;
* Rest and contraction states are well separated  &lt;br /&gt;
* Automatic detection is stable and accurate  &lt;br /&gt;
* Repeatability is acceptable  &lt;br /&gt;
* No false activation occurs under rest conditions  &lt;br /&gt;
&lt;br /&gt;
=== Consistency Across Multiple Recordings ===&lt;br /&gt;
&lt;br /&gt;
The same data processing pipeline was applied to multiple recordings from different subjects and trials.&lt;br /&gt;
&lt;br /&gt;
Across all datasets, consistent patterns were observed:&lt;br /&gt;
&lt;br /&gt;
* Dynamic signals exhibit clear burst-like structures corresponding to repeated muscle contractions  &lt;br /&gt;
* Rest signals remain low in amplitude without distinct activation patterns  &lt;br /&gt;
* RMS values under contraction are consistently higher than those under rest  &lt;br /&gt;
* The automatic detection algorithm reliably identifies contraction segments  &lt;br /&gt;
&lt;br /&gt;
Although quantitative values (e.g., RMS, SNR, CV) vary across recordings due to differences in electrode contact, muscle activation strength, and individual conditions, the overall trends remain consistent.&lt;br /&gt;
&lt;br /&gt;
These results demonstrate the robustness and general applicability of the proposed signal processing method.&lt;br /&gt;
&lt;br /&gt;
== Multi-subject Analysis ==&lt;br /&gt;
=== System Evaluation ===&lt;br /&gt;
&lt;br /&gt;
This section evaluates the performance of the EMG acquisition system in terms of noise level, signal quality, activity discrimination, and repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Noise Floor Analysis ====&lt;br /&gt;
&lt;br /&gt;
The noise floor was evaluated using rest-state recordings, characterized by RMS noise, standard deviation, and peak-to-peak amplitude.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039; shows the lowest noise level (RMS ≈ 0.0046), indicating stable electrode contact and minimal interference.  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039; exhibits moderate noise (RMS ≈ 0.0080), likely influenced by motion artifacts or electrode–skin impedance variation.  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039; shows relatively higher noise (RMS ≈ 0.0126), suggesting increased baseline fluctuation.  &lt;br /&gt;
&lt;br /&gt;
Overall, the system maintains a low noise floor across subjects, although the quality depends on experimental conditions such as electrode contact and environmental interference.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Signal-to-Noise Ratio (SNR) ====&lt;br /&gt;
&lt;br /&gt;
The signal-to-noise ratio (SNR) is defined as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{SNR (dB)} = 20 \log_{10} \left( \frac{\mathrm{RMS}_{\mathrm{contraction}}}{\mathrm{RMS}_{\mathrm{rest}}} \right)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The measured SNR values are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: 21.26 dB → good signal quality  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: 13.52 dB → moderate and usable  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: 6.66 dB → low signal clarity  &lt;br /&gt;
&lt;br /&gt;
General interpretation:&lt;br /&gt;
&lt;br /&gt;
* &amp;gt;20 dB → good  &lt;br /&gt;
* 10–20 dB → usable  &lt;br /&gt;
* &amp;lt;10 dB → poor  &lt;br /&gt;
&lt;br /&gt;
These results show that the system can achieve reliable signal acquisition, although performance varies across subjects.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
====  Rest vs Contraction Discrimination ====&lt;br /&gt;
&lt;br /&gt;
A clear distinction between rest and contraction states is observed based on RMS values.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: 0.0053 → 0.1064 (≈20× increase)  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: 0.0079 → 0.0283 (≈3.6× increase)  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: 0.0141 → 0.0646 (≈4.6× increase)  &lt;br /&gt;
&lt;br /&gt;
This demonstrates that the system is capable of separating muscle activity from baseline noise.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Conclusion:&#039;&#039;  &lt;br /&gt;
The system can be used for basic muscle activity detection and simple classification tasks based on RMS features.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Repeatability of Repeated Contractions ====&lt;br /&gt;
&lt;br /&gt;
Repeatability is evaluated using the coefficient of variation (CV) of peak RMS values across repetitions.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! CV Range !! Evaluation&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt; 10% || Excellent&lt;br /&gt;
|-&lt;br /&gt;
| 10–20% || Acceptable&lt;br /&gt;
|-&lt;br /&gt;
| &amp;gt; 20% || Poor&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Results:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: CV = 12.77% → Acceptable  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: CV = 24.77% → Poor  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: CV = 10.60% → Acceptable  &lt;br /&gt;
&lt;br /&gt;
Although WANG&#039;s signal is detectable, its contraction amplitude varies significantly across repetitions, resulting in poor repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
=== Overall System Performance ===&lt;br /&gt;
&lt;br /&gt;
The system demonstrates the following performance characteristics:&lt;br /&gt;
&lt;br /&gt;
* Reliable detection of muscle activity across all subjects  &lt;br /&gt;
* Clear separation between rest and contraction states  &lt;br /&gt;
* Moderate to high signal quality depending on subject conditions  &lt;br /&gt;
* Repeatability ranging from acceptable to poor due to user-dependent factors  &lt;br /&gt;
&lt;br /&gt;
Overall, the designed EMG acquisition system is capable of stable signal acquisition and feature extraction, with performance primarily influenced by electrode contact quality, skin impedance, and motion consistency.&lt;br /&gt;
&lt;br /&gt;
===== Summary of Quantitative Metrics =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Subject !! RMS (Rest) !! RMS (Contraction) !! Separation Ratio !! iEMG (max) !! Noise RMS !! SNR (dB) !! CV (%) !! Evaluation&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;LIU&#039;&#039;&#039; || 0.0053 || 0.1064 || &#039;&#039;&#039;20.1×&#039;&#039;&#039; || 12.72 || 0.0046 || &#039;&#039;&#039;21.26&#039;&#039;&#039; || 12.77 || Strong signal, good quality&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;WANG&#039;&#039;&#039; || 0.0079 || 0.0283 || 3.57× || 11.10 || 0.0080 || 13.52 || &#039;&#039;&#039;24.77&#039;&#039;&#039; || Usable signal, poor repeatability&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ZHONG&#039;&#039;&#039; || 0.0141 || 0.0646 || 4.58× || 6.70 || 0.0126 || 6.66 || 10.60 || Acceptable performance&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Summary:&#039;&#039; Subject LIU shows the best overall performance, WANG provides usable but less stable signals, and ZHONG demonstrates moderate signal quality with good repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Activation Intensity =====&lt;br /&gt;
&lt;br /&gt;
Among the three subjects, &#039;&#039;&#039;LIU exhibits the strongest muscle activation&#039;&#039;&#039;, as indicated by the highest contraction RMS and iEMG values. ZHONG shows moderate activation, while WANG demonstrates comparable iEMG but lower RMS consistency.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Signal Quality =====&lt;br /&gt;
&lt;br /&gt;
Signal quality is evaluated based on SNR and noise level:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039; achieves the highest SNR and lowest noise → best signal quality  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039; shows moderate SNR → usable but less robust  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039; has the lowest SNR → weakest signal clarity  &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Repeatability =====&lt;br /&gt;
&lt;br /&gt;
Repeatability is evaluated using the coefficient of variation (CV):&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;ZHONG (10.60%)&#039;&#039;&#039; → most stable  &lt;br /&gt;
* &#039;&#039;&#039;LIU (12.77%)&#039;&#039;&#039; → acceptable  &lt;br /&gt;
* &#039;&#039;&#039;WANG (24.77%)&#039;&#039;&#039; → poor  &lt;br /&gt;
&lt;br /&gt;
This indicates that WANG’s contraction strength varies significantly between repetitions.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Engineering Interpretation of Inter-subject Differences =====&lt;br /&gt;
&lt;br /&gt;
The observed differences are mainly attributed to engineering and experimental factors rather than physiological differences.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Electrode contact quality&#039;&#039;&#039;  &lt;br /&gt;
  Variations in electrode placement, pressure, and gel contact affect signal amplitude and stability.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Skin impedance&#039;&#039;&#039;  &lt;br /&gt;
  Differences in skin condition (hydration, oil, hair) influence electrode–skin impedance, affecting noise level and signal coupling.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Muscle control consistency&#039;&#039;&#039;  &lt;br /&gt;
  Variations in contraction strength and timing affect repeatability and CV.&lt;br /&gt;
&lt;br /&gt;
Therefore, the variation across subjects reflects practical acquisition conditions rather than intrinsic system limitations.&lt;/div&gt;</summary>
		<author><name>Wang Jingyi</name></author>
	</entry>
	<entry>
		<id>https://pc5271.org/index.php?title=Surface_EMG_Sensor_for_Muscle_Activity_Measurement:_AFE_Design_and_Signal_Processing&amp;diff=1354</id>
		<title>Surface EMG Sensor for Muscle Activity Measurement: AFE Design and Signal Processing</title>
		<link rel="alternate" type="text/html" href="https://pc5271.org/index.php?title=Surface_EMG_Sensor_for_Muscle_Activity_Measurement:_AFE_Design_and_Signal_Processing&amp;diff=1354"/>
		<updated>2026-04-23T06:44:47Z</updated>

		<summary type="html">&lt;p&gt;Wang Jingyi: /* Representative Dynamic Signal Analysis */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Background and Theory==&lt;br /&gt;
&lt;br /&gt;
=== Surface EMG Signals ===&lt;br /&gt;
Surface electromyography (sEMG) refers to the bioelectrical signals detected on the skin surface during muscle contraction. These signals originate from the electrical activity of muscle fibers and provide a non-invasive way to monitor muscle activation. Compared with invasive EMG methods, sEMG is easier to apply, safer for repeated measurements, and more suitable for real-time monitoring. Therefore, it has been widely used in areas such as rehabilitation, motion analysis, human–machine interaction, and physiological monitoring.&lt;br /&gt;
&lt;br /&gt;
=== Characteristics of EMG Signals ===&lt;br /&gt;
EMG signals are generally weak, time-varying, and stochastic in nature. Their waveforms are typically bipolar, fluctuating around zero with both positive and negative components. The amplitude and frequency content of EMG signals depend on factors such as muscle contraction level, electrode placement, skin condition, and individual physiological differences. In practice, the useful frequency components of sEMG are mainly concentrated in a limited low-to-mid frequency range. Because of their low amplitude and variability, EMG signals usually require further conditioning before reliable interpretation and feature extraction can be performed.&lt;br /&gt;
&lt;br /&gt;
=== Bioelectrical Signal Acquisition Principles ===&lt;br /&gt;
The acquisition of bioelectrical signals is based on measuring the small potential difference on the skin surface using electrodes, then converting it into a processable electrical signal through amplification and digitization. For sEMG measurement, electrode placement and skin–electrode contact quality are especially important, since they directly affect signal amplitude and stability. In addition, the front-end acquisition circuit must provide sufficient sensitivity and good interference rejection, so that the recorded signal reflects actual muscle activity rather than environmental disturbance or poor contact conditions.&lt;br /&gt;
&lt;br /&gt;
=== Noise Sources in EMG (50 Hz, motion artifacts) ===&lt;br /&gt;
In practical EMG recording, the measured signal is easily contaminated by different types of noise. Two of the most common sources are power-line interference and motion artifacts. Power-line interference usually appears as a narrow-band component at 50 Hz in the local electrical environment, while motion artifacts are mainly caused by electrode movement, cable disturbance, or variations in the electrode–skin impedance, and are often concentrated in the low-frequency range. In addition, electronic noise from the acquisition hardware may also affect the recording quality. These unwanted components can reduce signal clarity and make muscle activity analysis less reliable, so they must be considered in the design of the signal processing pipeline.&lt;br /&gt;
[[File:background_theory_figure1.1_emg_noise_sources.png|center|thumb|700px|&#039;&#039;&#039;Figure 1.1.&#039;&#039;&#039; Principle of surface EMG acquisition.]]&lt;br /&gt;
&lt;br /&gt;
==System Architecture==&lt;br /&gt;
=== Total Structure Design ===&lt;br /&gt;
&lt;br /&gt;
For clarity，the proposed physiological signal acquisition system mainly consists of two core parts：the analog front－end （AFE）and the ADC board．The AFE is responsible for the preliminary conditioning of weak bioelectrical signals，including amplification，filtering，interference suppression，and level shifting，so that the analog waveform can be converted into a stable and measurable form．The ADC board then performs high－resolution digitization of the conditioned signal and transfers the sampled data to the host computer for subsequent display，storage，and analysis．Therefore，the overall system forms a complete signal－acquisition chain from weak physiological input to digital output．&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_1.jpg|thumb|center|800px|Figure 2.1. Overall system architecture of the proposed physiological signal acquisition platform，including the AFE and ADC modules．]]&lt;br /&gt;
&lt;br /&gt;
=== sEMG AFE Design ===&lt;br /&gt;
&lt;br /&gt;
To collect the weak bioelectric potential signals of the human body，an analog front－end（AFE）suitable sEMG measurements was designed．The module is powered by an external 5 V supply，and the complete circuit includes a first－ stage instrumentation amplifier based on INA128（Texas Instruments，Dallas，TX，USA），a band－pass filter，a 50 Hz notch filter，a second－order amplification and level shifting stage，a driver electrode circuit，a precise 1.5 V reference source，and a -5 V voltage generation module for powering the operational amplifiers．&lt;br /&gt;
&lt;br /&gt;
==== First－order Amplifier ====&lt;br /&gt;
&lt;br /&gt;
The input bioelectric signal is first acquired in differential form and applied to the INA128 instrumentation amplifier，which provides high input impedance，high common－mode rejection，and moderate initial gain for sEMG acquisition．This stage enlarges the weak physiological signal before filtering while reducing the risk of premature saturation caused by electrode offset or motion－induced disturbance，thereby preparing a more stable signal for the subsequent conditioning stages．&lt;br /&gt;
&lt;br /&gt;
==== Bandpass Filter ====&lt;br /&gt;
&lt;br /&gt;
After the instrumentation amplifier，the signal passes through a second－order active band－pass filter，as shown in Figure 2．2． This stage suppresses baseline drift and high－frequency noise outside the useful sEMG range，so that the low－frequency envelope information of sEMG can be preserved before further amplification．&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_2.jpg|thumb|center|800px|Figure 2.2. Schematic diagram of the active band-pass filter used in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the band-pass stage used to retain the main physiological signal band while suppressing unwanted lowand high-frequency components.&lt;br /&gt;
&lt;br /&gt;
==== Notch Filter ====&lt;br /&gt;
&lt;br /&gt;
To reduce power-line interference, a dedicated 50 Hz notch filter is introduced after the band-pass stage, as shown in Figure 2.3. This filter attenuates the mains-frequency component that commonly contaminates weak bioelectric measurements, thereby improving the signal-to-noise ratio of sEMG signals before the final amplification stage.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_3.jpg|thumb|center|800px|Figure 2.3. Schematic diagram of the 50 Hz notch filter used in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the circuit used to attenuate 50 Hz mains interference in the analog front end.&lt;br /&gt;
&lt;br /&gt;
==== Second-order Amplifier &amp;amp; Level Shifter ====&lt;br /&gt;
&lt;br /&gt;
After filtering, the signal enters the second-stage amplification and level-shifting circuit shown in Figure 2.4. In this stage, the filtered signal is further amplified to improve amplitude utilization and then shifted by a 1.5 V reference so that the output becomes a stable unipolar signal suitable for ADC sampling, while preserving linear operation and providing sufficient output swing margin.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_4.jpg|thumb|center|800px|Figure 2.4. Schematic diagram of the second-stage amplifier and level-shifting circuit in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows how the conditioned signal is further amplified and shifted to a suitable DC level before digitization.&lt;br /&gt;
&lt;br /&gt;
==== Power Module and Drive-electrode Circuit ====&lt;br /&gt;
&lt;br /&gt;
The AFE is powered by a 5 V supply and also integrates a 1.5 V precision reference, a -5 V generation circuit, and a driveelectrode circuit. These supporting modules provide the required supply rails and reference level for analog signal conditioning, while the drive-electrode circuit feeds back common-mode voltage to the body to suppress interference at the source. As a result, the complete AFE can support sEMG acquisition with adequate gain, filtering, and noise-reduction performance in a compact hardware structure.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_5.jpg|thumb|center|800px|Figure 2.5. Physical picture of the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the fabricated sEMG analog front-end hardware used in the system.&lt;br /&gt;
&lt;br /&gt;
Figure 2.5 presents the practical hardware implementation of the proposed sEMG AFE. It integrates amplification, filtering, level shifting, and driven-reference functions in a compact circuit for weak bioelectrical signal acquisition.&lt;br /&gt;
&lt;br /&gt;
=== ADS1256-based ADC Board ===&lt;br /&gt;
&lt;br /&gt;
To digitize the conditioned weak physiological signals with sufficient resolution and low noise, this project developed a dedicated ADC board based on the ADS1256 analog-to-digital converter (Texas Instruments, Dallas, TX, USA) and the STM32F103C8T6 microcontroller (STMicroelectronics, Geneva, Switzerland). The overall design objective of this board was not merely to realize analog-to-digital conversion, but to provide a complete hardware interface between the analog front-end and the digital processing unit, including precision reference generation, clocking, input protection and filtering, serial communication, power regulation, and MCU-based acquisition control. The ADS1256 was selected because it is a&lt;br /&gt;
&lt;br /&gt;
very low-noise 24-bit delta-sigma converter with a programmable gain amplifier (PGA), flexible input multiplexer, programmable digital filter, and SPI-compatible serial interface, which makes it well suited for weak low-frequency physiological signals after analog conditioning. The STM32F103C8T6 was used as the local controller because it provides a 32-bit Cortex-M3 core, up to 72 MHz system clock, SPI, USART, USB, and standard SWD debugging support in a compact and low-cost platform.&lt;br /&gt;
&lt;br /&gt;
==== ADC Core Architecture and Design Rationale ====&lt;br /&gt;
&lt;br /&gt;
The ADS1256 was selected as the core ADC because it provides high-resolution, low-noise delta-sigma conversion with an input multiplexer, programmable gain amplifier, and digital filter, which are suitable for weak and low-frequency physiological signals. As shown in Figure 2.6, this architecture emphasizes resolution and noise performance rather than high conversion bandwidth, making it appropriate for sEMG signal digitization after analog conditioning.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_6.jpg|thumb|center|800px|Figure 2.6. Internal functional structure of the ADS1256 analog-to-digital converter.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the main internal blocks of the ADS1256, including the multiplexer, PGA, modulator, and digital filter.&lt;br /&gt;
&lt;br /&gt;
==== Analog Front-End Interface, Reference, and Clocking ====&lt;br /&gt;
&lt;br /&gt;
The ADS1256 analog inputs are connected to the external header through a passive input-conditioning network that helps suppress high-frequency interference and improve input stability. In addition, the board includes a dedicated precision reference and clocking circuits so that the ADC can perform stable and accurate conversion. Together, these circuits provide a reliable analog interface and timing basis for high-resolution digitization of weak physiological signals.&lt;br /&gt;
&lt;br /&gt;
==== SPI Interface between ADS1256 and STM32F103C8T6 ====&lt;br /&gt;
&lt;br /&gt;
Communication between the ADS1256 and the STM32F103C8T6 is implemented through an SPI-compatible interface, with dedicated lines for chip select, serial clock, input/output data, data-ready notification, and hardware reset. This connection allows the MCU to configure the ADC, read conversion results in synchrony with DRDY, and maintain efficient and reliable acquisition control for multi-channel physiological measurements.&lt;br /&gt;
&lt;br /&gt;
==== Power Supply and On-board Regulation ====&lt;br /&gt;
&lt;br /&gt;
The ADC board uses a USB Type-B connector as the main power input and includes protection, voltage regulation, and local decoupling circuits to provide a stable supply for both the MCU and ADC-related hardware. In addition, analog ground and digital ground are separated in the PCB layout to reduce digital noise coupling into the analog path, which is particularly important for weak physiological signal acquisition.&lt;br /&gt;
&lt;br /&gt;
==== Basic Peripheral Circuits of the STM32F103C8T6 ====&lt;br /&gt;
&lt;br /&gt;
The STM32F103C8T6 serves as the local controller of the ADC board and is supported by several basic peripheral circuits, including an external crystal oscillator, reset network, BOOT0 configuration, SWD programming/debugging header, and a CH340N USB-to-UART bridge. These circuits ensure stable MCU operation, convenient firmware downloading and debugging, and reliable data transmission from the board to the host computer for real-time display and storage.&lt;br /&gt;
&lt;br /&gt;
==== Hardware-level Working Principle of the ADC Board ====&lt;br /&gt;
&lt;br /&gt;
In operation, the conditioned analog signal from the AFE enters the ADS1256 through the input header, is digitized with high resolution under the control of the local precision reference and clock, and is then read by the STM32 through the SPI interface. The MCU subsequently forwards the sampled data to the host computer through the serial communication link, so that the entire board functions as a compact digital acquisition backend connecting weak physiological analog signals to later software processing, display, and storage.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_7.jpg|thumb|center|800px|Figure 2.7. Photograph of the fabricated ADS1256-based ADC board developed in this project and the definitions of some key pins.]]&lt;br /&gt;
&lt;br /&gt;
Figure 2.7 shows the ADC board fabricated for this project. It integrates the ADS1256 conversion core, STM32 control circuit, power-conditioning circuits, and communication interfaces on a compact PCB for physiological signal digitization.&lt;br /&gt;
&lt;br /&gt;
== Signal Conditioning and Filtering ==&lt;br /&gt;
Although the AFE already performs preliminary band-pass filtering and 50 Hz interference suppression in the analog domain, the digitized sEMG signal may still contain residual noise due to component tolerances, electrode-contact variation, and environmental interference. Therefore, an additional digital filtering stage is implemented in software as a complementary post-processing step to improve signal quality and to provide a more stable input for rectification, envelope extraction, and subsequent analysis. In this sense, the software filtering is not a simple repetition of the analog filtering, but a refinement and compensation for non-ideal front-end behavior.&lt;br /&gt;
&lt;br /&gt;
Surface electromyographic (sEMG) signals are highly susceptible to several sources of contamination during acquisition. In practical measurements, the dominant disturbances usually include low-frequency motion artifacts caused by electrode movement and electrode–skin impedance variation, narrow-band power-line interference centered at 50 Hz, and broadband high-frequency electronic noise introduced by the acquisition hardware. These unwanted components degrade the quality of the recorded signal and may significantly affect the reliability of subsequent feature extraction, parameter estimation, and muscle activity interpretation. For this reason, an effective signal-conditioning procedure is necessary before any higher-level analysis is performed.&lt;br /&gt;
&lt;br /&gt;
In the present implementation, the filtering strategy follows the principle of restricting the signal bandwidth first and then removing the remaining narrow-band interference in a targeted manner. Accordingly, the raw sEMG signal is first processed by a fourth-order Butterworth IIR band-pass filter and then by a 50 Hz notch filter. This processing sequence is illustrated in the flowchart below, where the signal passes through band-pass filtering, notch filtering, full-wave rectification, and envelope extraction before producing the final processed output.&lt;br /&gt;
&lt;br /&gt;
[[File:flowchart.png|thumb|center|500px|Flowchart of the real-time sEMG signal conditioning pipeline.]]&lt;br /&gt;
&lt;br /&gt;
The rationale of this order is that the &#039;&#039;&#039;band-pass stage&#039;&#039;&#039; first confines the signal to the main spectral region of interest for sEMG, thereby attenuating motion artifacts at very low frequencies and suppressing high-frequency noise components outside the physiological band. After this spectral preconditioning, the notch stage can more effectively suppress the residual 50 Hz power-line interference that lies inside the useful sEMG band. In transfer-function form, the band-pass filter may be written as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;H_{BP}(z)=\frac{B_{BP}(z)}{A_{BP}(z)}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where the effective passband is selected as &amp;lt;math&amp;gt;20 \leq f \leq 160 \text{ Hz}&amp;lt;/math&amp;gt;. This frequency interval is consistent with the dominant spectral content of surface EMG: the lower cutoff near 20 Hz reduces motion artifacts and unstable low-frequency fluctuations, whereas the upper cutoff near 160 Hz removes high-frequency electronic noise while preserving the main energy-bearing components of the muscle signal. The use of a Butterworth structure is appropriate here because it provides a smooth monotonic passband response without ripple, which helps preserve signal morphology in real-time applications.&lt;br /&gt;
&lt;br /&gt;
After band limitation, a &#039;&#039;&#039;notch filter&#039;&#039;&#039; centered at the power-line frequency is applied to suppress interference that cannot be removed by the band-pass stage alone. The notch filter is designed around &amp;lt;math&amp;gt;f_0 = 50 \text{ Hz}&amp;lt;/math&amp;gt;, and its bandwidth is controlled by the quality factor &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;, which is expressed as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;Q = \frac{f_0}{\Delta f}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In transfer-function form, the notch stage is written as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;H_{N}(z)=\frac{B_{N}(z)}{A_{N}(z)}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the implemented program, a large quality factor is chosen so that the notch remains narrow, allowing effective rejection of the 50 Hz interference while minimizing distortion of neighboring useful spectral components. This is particularly important for sEMG because the interference frequency lies directly inside the physiological band of interest.&lt;br /&gt;
&lt;br /&gt;
Following the filtering stages, further signal conditioning is performed to obtain a representation that is more directly related to muscle activation intensity. The filtered sEMG waveform is first &#039;&#039;&#039;full-wave rectified&#039;&#039;&#039;, which converts the bipolar oscillatory signal into a unipolar signal by taking its absolute value.  Rectification does not remove noise by itself; instead, it transforms the signal into a form that is more suitable for amplitude-based analysis because both positive and negative deflections contribute positively to the activation measure.&lt;br /&gt;
&lt;br /&gt;
After rectification, the signal envelope is extracted to provide a smooth estimate of muscle activation level over time. In a general formulation, the envelope can be described as the &#039;&#039;&#039;low-pass filtered&#039;&#039;&#039; version of the rectified signal, namely &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y_{\mathrm{env}}[n] = \mathrm{LPF}\bigl(y_{\mathrm{rect}}[n]\bigr)&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the present code implementation, this operation is realized by short-time averaging over a finite window, which is equivalent to a moving-average low-pass smoothing of the rectified waveform. The corresponding expression is &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y_{\mathrm{env}}[n] = \frac{1}{N}\sum_{k=0}^{N-1} |x[n-k]|&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; is the window length in samples. With a window duration of approximately 200 ms, this envelope extraction method provides a stable and physiologically meaningful representation of muscle activation intensity, making it suitable for tasks such as force estimation, fatigue analysis, and motor-control studies.&lt;br /&gt;
&lt;br /&gt;
An important feature of the present &#039;&#039;&#039;implementation&#039;&#039;&#039; is that the entire filtering process is performed &#039;&#039;&#039;in real time&#039;&#039;&#039;, sample by sample, rather than by offline block processing. For this reason, IIR filters are preferred over FIR filters, since they can achieve comparable filtering performance with lower order, lower computational cost, and shorter delay. These properties are especially valuable in embedded systems, serial data streaming, and other low-latency experimental applications. However, unlike memoryless operations, an IIR filter depends not only on the current input but also on previous inputs and previous outputs. Its discrete-time behavior can therefore be represented by the recursive difference equation &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y[n] = \sum_{k=0}^{M} b_k x[n-k] - \sum_{k=1}^{N} a_k y[n-k]&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This equation makes clear that internal filter states must be preserved continuously during streaming operation. If the state variables were reinitialized for every incoming sample or data segment, artificial transients would appear and the output would no longer remain continuous.&lt;br /&gt;
&lt;br /&gt;
In the Python implementation, this state continuity is maintained using the internal initial-condition mechanism provided by SciPy, such as &amp;lt;code&amp;gt;lfilter_zi&amp;lt;/code&amp;gt;, together with recursive state updates during each filtering call. As a result, each newly acquired sample is passed first through the band-pass filter and then through the notch filter, while the internal states of both filters are updated after every step. This state-preserving sample-by-sample design ensures that the processing chain remains causal, continuous, and suitable for real-time display or downstream analysis without requiring storage of the entire signal segment.&lt;br /&gt;
&lt;br /&gt;
Overall, this signal-conditioning scheme provides an experimentally practical solution for real-time sEMG processing. The fourth-order Butterworth band-pass filter confines the signal to the main physiological band of interest, the 50 Hz notch filter removes narrow-band power-line contamination, and the subsequent rectification and envelope extraction generate a smooth amplitude descriptor of muscle activity. Combined with state-preserved streaming IIR implementation, this approach achieves a good balance between signal fidelity, computational efficiency, and real-time applicability in biomedical and physical experiment settings.&lt;br /&gt;
&lt;br /&gt;
== Data Processing ==&lt;br /&gt;
&lt;br /&gt;
The objective of data processing is to convert raw surface electromyography (sEMG) recordings into stable, quantitative, and comparable indicators of muscle activity. Since EMG signals are low in amplitude, highly variable over time, and easily contaminated by noise, a dedicated processing pipeline is necessary before any experimental interpretation can be performed.&lt;br /&gt;
&lt;br /&gt;
In this project, the data processing workflow includes time normalization, signal pre-processing, sliding-window feature extraction, noise-floor estimation, and automatic contraction detection. The processed outputs are then used for subsequent experimental evaluation, including rest-versus-contraction discrimination, signal-to-noise ratio analysis, and repeatability assessment.&lt;br /&gt;
&lt;br /&gt;
=== Input Data and Time Normalization ===&lt;br /&gt;
&lt;br /&gt;
The acquired EMG data are read from CSV files containing two columns: time and filtered sEMG amplitude. In the MATLAB implementation, the time vector is normalized so that each recording starts from zero:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t = t_{all} - t_{all}(1)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This normalization is important because it removes the influence of absolute recording timestamps and makes different trials directly comparable on the same time axis.&lt;br /&gt;
&lt;br /&gt;
In addition, the signal type is automatically identified from the filename as either dynamic or rest. This design allows the same program to process both contraction recordings and resting recordings with different downstream analysis logic.&lt;br /&gt;
&lt;br /&gt;
=== Signal Pre-processing ===&lt;br /&gt;
&lt;br /&gt;
Raw EMG signals cannot be analyzed directly because they usually contain DC offset, low-frequency drift, motion artifacts, and residual high-frequency interference. Therefore, several pre-processing steps are applied before feature extraction.&lt;br /&gt;
&lt;br /&gt;
==== Baseline Removal ====&lt;br /&gt;
&lt;br /&gt;
The first step is DC offset removal:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
x_{dc}(t) = x(t) - \frac{1}{N}\sum_{i=1}^{N}x(i)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This operation centers the signal around zero. It is necessary because an uncorrected baseline would bias amplitude-based metrics and reduce the reliability of later envelope and feature calculations.&lt;br /&gt;
&lt;br /&gt;
==== Band-pass Filtering ====&lt;br /&gt;
&lt;br /&gt;
After baseline correction, a fourth-order Butterworth band-pass filter is applied with a passband of 20–150 Hz.&lt;br /&gt;
&lt;br /&gt;
This step is introduced for two reasons:&lt;br /&gt;
&lt;br /&gt;
* The low-frequency cutoff at 20 Hz suppresses baseline drift and motion artifacts.&lt;br /&gt;
* The high-frequency cutoff at 150 Hz reduces unwanted high-frequency noise while preserving the main energy band of the recorded sEMG in this project.&lt;br /&gt;
&lt;br /&gt;
Compared with processing the raw waveform directly, band-pass filtering makes the subsequent time-domain features more stable and more physiologically meaningful.&lt;br /&gt;
&lt;br /&gt;
==== Full-wave Rectification ====&lt;br /&gt;
&lt;br /&gt;
The filtered EMG signal is bipolar, meaning that positive and negative phases coexist due to motor unit action potentials. If these positive and negative components are averaged directly, they may cancel each other out. To avoid this, full-wave rectification is performed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
x_{rect}(t) = |x_{filt}(t)|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This transforms the signal into a unipolar representation, so that all muscle activity contributes positively to the extracted features.&lt;br /&gt;
&lt;br /&gt;
==== Envelope Extraction ====&lt;br /&gt;
&lt;br /&gt;
Although the rectified signal reflects signal magnitude, it still fluctuates rapidly. To obtain a smoother representation of muscle activation level, an envelope is extracted using a moving average with a 100 ms window.&lt;br /&gt;
&lt;br /&gt;
Envelope extraction is important because contraction detection should reflect the overall activation trend rather than instantaneous spikes. A smoothed envelope is therefore more robust for identifying active and inactive muscle states.&lt;br /&gt;
&lt;br /&gt;
=== Sliding Window Design ===&lt;br /&gt;
&lt;br /&gt;
To quantify how muscle activity changes with time, the filtered signal is divided into overlapping short-time segments using a sliding window method.&lt;br /&gt;
&lt;br /&gt;
The window parameters are:&lt;br /&gt;
&lt;br /&gt;
* Window length: 250 ms&lt;br /&gt;
* Step size: 50 ms&lt;br /&gt;
&lt;br /&gt;
These values are chosen as a trade-off between temporal resolution and feature stability.&lt;br /&gt;
&lt;br /&gt;
A longer window improves statistical robustness because more samples are included in each calculation. However, if the window is too long, short contractions or rapid changes may be blurred. A smaller step size increases temporal continuity between adjacent feature points and makes the feature curves smoother in time. Therefore, the 250 ms / 50 ms design provides a practical balance between smoothing and time localization.&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt;-th segment, the feature time is defined as the mean time of that segment:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t_k = \frac{1}{N}\sum_{i=s_k}^{e_k} t(i)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;s_k&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;e_k&amp;lt;/math&amp;gt; denote the start and end indices of the window.&lt;br /&gt;
&lt;br /&gt;
=== Feature Extraction ===&lt;br /&gt;
&lt;br /&gt;
Within each sliding window, three time-domain features are extracted: RMS, iEMG, and MAV. These features are widely used in EMG analysis because they are simple, computationally efficient, and directly related to muscle activation intensity.&lt;br /&gt;
&lt;br /&gt;
==== Root Mean Square (RMS) ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
RMS = \sqrt{\frac{1}{N}\sum_{i=1}^{N}x_i^2}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
RMS reflects the effective power of the EMG signal and is one of the most common indicators of contraction strength. It is sensitive to both amplitude and energy, making it especially useful for comparing rest and active states.&lt;br /&gt;
&lt;br /&gt;
==== Integrated EMG (iEMG) ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
iEMG = \sum_{i=1}^{N}|x_i|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
iEMG describes the cumulative electrical activity within a window. It is often interpreted as a measure of total muscle effort over that time segment.&lt;br /&gt;
&lt;br /&gt;
==== Mean Absolute Value (MAV) ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
MAV = \frac{1}{N}\sum_{i=1}^{N}|x_i|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
MAV is an amplitude descriptor similar to iEMG, but normalized by the number of samples. It provides an efficient estimate of average signal level and is less computationally intensive than some other features.&lt;br /&gt;
&lt;br /&gt;
These three features are used together because they provide complementary descriptions of EMG intensity. RMS emphasizes signal energy, iEMG emphasizes cumulative activation, and MAV reflects average amplitude.&lt;br /&gt;
&lt;br /&gt;
=== Peak-value Extraction ===&lt;br /&gt;
&lt;br /&gt;
In addition to continuous feature curves, several key peak values are extracted from the processed signal:&lt;br /&gt;
&lt;br /&gt;
* maximum and minimum of the filtered EMG waveform&lt;br /&gt;
* peak of the envelope&lt;br /&gt;
* peak RMS&lt;br /&gt;
* peak iEMG&lt;br /&gt;
* peak MAV&lt;br /&gt;
&lt;br /&gt;
These peak values provide concise descriptors of the strongest activity observed in each recording. They are useful for quick comparison across trials and subjects.&lt;br /&gt;
&lt;br /&gt;
=== Noise Floor Estimation ===&lt;br /&gt;
&lt;br /&gt;
To evaluate signal quality, the noise floor is estimated from a reference resting interval. In the present implementation, the first 3 seconds of the recording are used as the default rest reference:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t \in [0,\min(3,t_{end})]&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this segment, three noise descriptors are computed:&lt;br /&gt;
&lt;br /&gt;
* Noise RMS&lt;br /&gt;
* Noise standard deviation&lt;br /&gt;
* Noise peak-to-peak amplitude&lt;br /&gt;
&lt;br /&gt;
Noise-floor estimation is important because EMG amplitude alone is not sufficient to judge recording quality. A large signal is only meaningful if it is sufficiently higher than the baseline noise level. Therefore, the noise floor serves as the reference for later SNR calculation and for designing contraction thresholds.&lt;br /&gt;
&lt;br /&gt;
=== Global Signal Metrics ===&lt;br /&gt;
&lt;br /&gt;
For each recording, three global metrics are also computed over the entire filtered signal:&lt;br /&gt;
&lt;br /&gt;
* Global RMS&lt;br /&gt;
* Global MAV&lt;br /&gt;
* Global iEMG&lt;br /&gt;
&lt;br /&gt;
These global descriptors summarize the overall signal level of the full recording and are later used in group-level comparisons.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Contraction Detection ===&lt;br /&gt;
&lt;br /&gt;
For dynamic recordings, an automatic contraction detection algorithm is used to identify repeated active segments. This is one of the key parts of the data processing pipeline, because it transforms a continuous EMG trace into discrete contraction events that can be counted and compared.&lt;br /&gt;
&lt;br /&gt;
==== Threshold Design ====&lt;br /&gt;
&lt;br /&gt;
The detection threshold is designed adaptively rather than using a fixed value. Two candidate thresholds are first calculated:&lt;br /&gt;
&lt;br /&gt;
* an envelope-based threshold derived from the global envelope mean and standard deviation&lt;br /&gt;
* a rest-reference threshold derived from the mean and standard deviation of the resting reference amplitude&lt;br /&gt;
&lt;br /&gt;
The final threshold is taken as the larger of the two after additional scaling. This strategy improves robustness because it combines the global activation level of the signal with the baseline noise characteristics of the individual recording.&lt;br /&gt;
&lt;br /&gt;
This adaptive threshold design is preferable to a manually fixed threshold because EMG amplitude can vary strongly between subjects, muscles, and recording sessions.&lt;br /&gt;
&lt;br /&gt;
==== Initial Segmentation ====&lt;br /&gt;
&lt;br /&gt;
After thresholding the envelope, the signal is classified into active and inactive regions:&lt;br /&gt;
&lt;br /&gt;
* active: envelope above threshold&lt;br /&gt;
* inactive: envelope below threshold&lt;br /&gt;
&lt;br /&gt;
The rising and falling edges of the binary activity vector are then used to determine the start and end points of each candidate contraction segment.&lt;br /&gt;
&lt;br /&gt;
==== Removal of Short Segments ====&lt;br /&gt;
&lt;br /&gt;
Very short active regions are often caused by noise fluctuations rather than true muscle contractions. Therefore, segments shorter than 0.20 s are discarded.&lt;br /&gt;
&lt;br /&gt;
This step prevents false positive detections and increases the physiological relevance of the segmentation results.&lt;br /&gt;
&lt;br /&gt;
==== Merging of Adjacent Segments ====&lt;br /&gt;
&lt;br /&gt;
If two neighboring active segments are separated by a very short gap, they are merged when the gap is less than 0.15 s.&lt;br /&gt;
&lt;br /&gt;
This operation is necessary because a single real contraction may be temporarily interrupted by a brief drop in the envelope caused by local fluctuation. Without merging, one contraction could be incorrectly counted as multiple repetitions.&lt;br /&gt;
&lt;br /&gt;
==== Repetition-level Metrics ====&lt;br /&gt;
&lt;br /&gt;
For each detected contraction segment, two repetition-level metrics are extracted:&lt;br /&gt;
&lt;br /&gt;
* peak RMS of that contraction&lt;br /&gt;
* mean RMS of that contraction&lt;br /&gt;
&lt;br /&gt;
These metrics quantify both the strongest activation within each repetition and the average activation level over the repetition duration.&lt;br /&gt;
&lt;br /&gt;
=== Repeatability Analysis ===&lt;br /&gt;
&lt;br /&gt;
When multiple valid contractions are detected, repeatability is evaluated using the coefficient of variation (CV):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
CV = \frac{\sigma}{\mu}\times 100\%&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt; is the standard deviation and &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is the mean value across repetitions.&lt;br /&gt;
&lt;br /&gt;
Two CV values are computed:&lt;br /&gt;
&lt;br /&gt;
* CV of repetition peak RMS&lt;br /&gt;
* CV of repetition mean RMS&lt;br /&gt;
&lt;br /&gt;
A lower CV indicates better repeatability, meaning that repeated contractions produce more consistent EMG responses.&lt;br /&gt;
&lt;br /&gt;
=== Signal-to-Noise Ratio (SNR) ===&lt;br /&gt;
&lt;br /&gt;
In this project, the signal-to-noise ratio (SNR) is defined based on the ratio between contraction and rest activity:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
SNR_{dB} = 20\log_{10}\left(\frac{RMS_{contraction}}{RMS_{rest}}\right)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This definition is adopted because it directly reflects the system’s ability to distinguish active muscle contraction from baseline noise.&lt;br /&gt;
&lt;br /&gt;
Compared with global SNR definitions, this formulation is more relevant for practical EMG applications such as activity detection and classification.&lt;br /&gt;
&lt;br /&gt;
=== Rest-versus-Contraction Window Comparison ===&lt;br /&gt;
&lt;br /&gt;
To further distinguish inactive and active states, all sliding windows are divided into two groups:&lt;br /&gt;
&lt;br /&gt;
* rest windows: windows with envelope clearly below the threshold&lt;br /&gt;
* contraction windows: windows with envelope above the threshold&lt;br /&gt;
&lt;br /&gt;
The RMS values of these two groups are then compared statistically.&lt;br /&gt;
&lt;br /&gt;
This comparison is important because a practical EMG system should not only detect signal presence, but also clearly separate rest from contraction in a quantitative way. If the two RMS distributions are well separated, it indicates that the system has good discriminative capability.&lt;br /&gt;
&lt;br /&gt;
=== Output Data Structure ===&lt;br /&gt;
&lt;br /&gt;
The processed outputs are organized into structured data for experimental analysis:&lt;br /&gt;
&lt;br /&gt;
==== Time-series outputs ====&lt;br /&gt;
* Filtered EMG signal  &lt;br /&gt;
* Rectified signal  &lt;br /&gt;
* Envelope  &lt;br /&gt;
* RMS(t), iEMG(t), MAV(t)  &lt;br /&gt;
&lt;br /&gt;
==== Recording-level outputs ====&lt;br /&gt;
* RMS (rest)  &lt;br /&gt;
* RMS (contraction)  &lt;br /&gt;
* iEMG  &lt;br /&gt;
* Noise metrics  &lt;br /&gt;
&lt;br /&gt;
==== Dynamic-signal outputs ====&lt;br /&gt;
* Detected contractions  &lt;br /&gt;
* Repetition count  &lt;br /&gt;
* Peak RMS per repetition  &lt;br /&gt;
* Mean RMS per repetition  &lt;br /&gt;
* Coefficient of variation (CV)  &lt;br /&gt;
* Signal-to-noise ratio (SNR)  &lt;br /&gt;
&lt;br /&gt;
All extracted features are designed to directly support the evaluation of noise level, signal quality, activity discrimination, and repeatability in the subsequent experimental analysis.&lt;br /&gt;
&lt;br /&gt;
== Experimental Results ==&lt;br /&gt;
&lt;br /&gt;
This section presents representative results of the EMG acquisition and data processing pipeline under both dynamic (muscle contraction) and resting conditions.&lt;br /&gt;
&lt;br /&gt;
=== Representative Dynamic Signal Analysis ===&lt;br /&gt;
&lt;br /&gt;
[[File:Dynamic_Figure1.png|thumb|800px|center|Figure 5.1: Processed EMG signal under dynamic contraction, including filtered signal, rectified signal with envelope, and extracted features (RMS, iEMG, MAV).]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.1 shows the processed EMG signal during repeated muscle contractions.&lt;br /&gt;
&lt;br /&gt;
The filtered EMG waveform exhibits clear burst-like patterns corresponding to periodic contractions. The signal amplitude reaches a maximum of approximately 0.45, while the baseline remains centered around zero, indicating effective baseline removal and filtering.&lt;br /&gt;
&lt;br /&gt;
After rectification and envelope extraction, the contraction periods become clearly distinguishable. The envelope provides a smooth representation of muscle activation, with a peak value of approximately 0.145.&lt;br /&gt;
&lt;br /&gt;
The extracted time-domain features (RMS, iEMG, MAV) further quantify the signal. Among these, iEMG shows the strongest dynamic variation, indicating high sensitivity to contraction intensity.&lt;br /&gt;
&lt;br /&gt;
=== Noise Floor and Rest Reference ===&lt;br /&gt;
&lt;br /&gt;
[[File:Dynamic_Figure2.png|800px|center|Figure 2: Noise estimation, rest vs contraction comparison, automatic contraction detection, and repetition analysis.]]&lt;br /&gt;
&lt;br /&gt;
Figure 2 (top-left) shows the resting reference segment used for noise estimation.&lt;br /&gt;
&lt;br /&gt;
The signal remains centered around zero with small fluctuations. The noise characteristics are:&lt;br /&gt;
&lt;br /&gt;
* Noise RMS ≈ 0.0046  &lt;br /&gt;
* Standard deviation ≈ 0.0046  &lt;br /&gt;
* Peak-to-peak amplitude ≈ 0.071  &lt;br /&gt;
&lt;br /&gt;
This indicates a low noise floor and stable measurement conditions.&lt;br /&gt;
&lt;br /&gt;
=== Rest vs Contraction Discrimination ===&lt;br /&gt;
&lt;br /&gt;
Figure 2 (top-right) compares RMS values between rest and contraction states.&lt;br /&gt;
&lt;br /&gt;
The two distributions are clearly separated:&lt;br /&gt;
&lt;br /&gt;
* Rest mean RMS ≈ 0.0053  &lt;br /&gt;
* Contraction mean RMS ≈ 0.1064  &lt;br /&gt;
&lt;br /&gt;
This corresponds to an approximate 20× increase, demonstrating strong discriminability between inactive and active muscle states.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Contraction Detection ===&lt;br /&gt;
&lt;br /&gt;
Figure 2 (bottom-left) illustrates automatic detection based on the envelope signal.&lt;br /&gt;
&lt;br /&gt;
A threshold of approximately 0.040 is applied, resulting in stable segmentation of contraction periods.&lt;br /&gt;
&lt;br /&gt;
A total of 12 repetitions are detected, with good alignment to visible signal peaks.&lt;br /&gt;
&lt;br /&gt;
=== Repeatability Analysis ===&lt;br /&gt;
&lt;br /&gt;
Figure 2 (bottom-right) shows the peak RMS value of each detected contraction.&lt;br /&gt;
&lt;br /&gt;
The results indicate:&lt;br /&gt;
&lt;br /&gt;
* Mean peak RMS ≈ 0.1355  &lt;br /&gt;
* Standard deviation ≈ 0.0173  &lt;br /&gt;
* CV ≈ 12.77%  &lt;br /&gt;
* SNR ≈ 21.26 dB  &lt;br /&gt;
&lt;br /&gt;
This indicates acceptable repeatability and good signal quality.&lt;br /&gt;
&lt;br /&gt;
=== Representative Rest Signal Analysis ===&lt;br /&gt;
&lt;br /&gt;
[[File:Rest_Figure1.png|800px|center|Figure 3: Processed EMG signal under rest condition, showing low amplitude and absence of contraction patterns.]]&lt;br /&gt;
&lt;br /&gt;
Figure 3 shows the EMG signal under resting conditions.&lt;br /&gt;
&lt;br /&gt;
The signal remains within a narrow amplitude range (approximately ±0.04) and shows no burst-like structures. The envelope remains close to zero, confirming the absence of muscle activity.&lt;br /&gt;
&lt;br /&gt;
The extracted features remain low:&lt;br /&gt;
&lt;br /&gt;
* RMS ≈ 0.007  &lt;br /&gt;
* MAV ≈ 0.005  &lt;br /&gt;
* iEMG remains stable  &lt;br /&gt;
&lt;br /&gt;
This confirms that no false activation is detected.&lt;br /&gt;
&lt;br /&gt;
=== Frequency-domain Characteristics ===&lt;br /&gt;
&lt;br /&gt;
[[File:Rest_Figure2.png|800px|center|Figure 4: Frequency-domain analysis and statistical characteristics of rest signal.]]&lt;br /&gt;
&lt;br /&gt;
Figure 4 shows the frequency-domain characteristics of the resting signal.&lt;br /&gt;
&lt;br /&gt;
The power spectral density (PSD) indicates low overall signal energy without dominant peaks, confirming that the signal mainly consists of noise.&lt;br /&gt;
&lt;br /&gt;
=== Summary of Single-recording Performance ===&lt;br /&gt;
&lt;br /&gt;
From the representative results:&lt;br /&gt;
&lt;br /&gt;
* EMG signals are effectively extracted and denoised  &lt;br /&gt;
* Contraction events are clearly identifiable  &lt;br /&gt;
* Rest and contraction states are well separated  &lt;br /&gt;
* Automatic detection is stable and accurate  &lt;br /&gt;
* Repeatability is acceptable  &lt;br /&gt;
* No false activation occurs under rest conditions  &lt;br /&gt;
&lt;br /&gt;
=== Consistency Across Multiple Recordings ===&lt;br /&gt;
&lt;br /&gt;
The same data processing pipeline was applied to multiple recordings from different subjects and trials.&lt;br /&gt;
&lt;br /&gt;
Across all datasets, consistent patterns were observed:&lt;br /&gt;
&lt;br /&gt;
* Dynamic signals exhibit clear burst-like structures corresponding to repeated muscle contractions  &lt;br /&gt;
* Rest signals remain low in amplitude without distinct activation patterns  &lt;br /&gt;
* RMS values under contraction are consistently higher than those under rest  &lt;br /&gt;
* The automatic detection algorithm reliably identifies contraction segments  &lt;br /&gt;
&lt;br /&gt;
Although quantitative values (e.g., RMS, SNR, CV) vary across recordings due to differences in electrode contact, muscle activation strength, and individual conditions, the overall trends remain consistent.&lt;br /&gt;
&lt;br /&gt;
These results demonstrate the robustness and general applicability of the proposed signal processing method.&lt;br /&gt;
&lt;br /&gt;
== Multi-subject Analysis ==&lt;br /&gt;
=== System Evaluation ===&lt;br /&gt;
&lt;br /&gt;
This section evaluates the performance of the EMG acquisition system in terms of noise level, signal quality, activity discrimination, and repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Noise Floor Analysis ====&lt;br /&gt;
&lt;br /&gt;
The noise floor was evaluated using rest-state recordings, characterized by RMS noise, standard deviation, and peak-to-peak amplitude.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039; shows the lowest noise level (RMS ≈ 0.0046), indicating stable electrode contact and minimal interference.  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039; exhibits moderate noise (RMS ≈ 0.0080), likely influenced by motion artifacts or electrode–skin impedance variation.  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039; shows relatively higher noise (RMS ≈ 0.0126), suggesting increased baseline fluctuation.  &lt;br /&gt;
&lt;br /&gt;
Overall, the system maintains a low noise floor across subjects, although the quality depends on experimental conditions such as electrode contact and environmental interference.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Signal-to-Noise Ratio (SNR) ====&lt;br /&gt;
&lt;br /&gt;
The signal-to-noise ratio (SNR) is defined as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{SNR (dB)} = 20 \log_{10} \left( \frac{\mathrm{RMS}_{\mathrm{contraction}}}{\mathrm{RMS}_{\mathrm{rest}}} \right)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The measured SNR values are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: 21.26 dB → good signal quality  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: 13.52 dB → moderate and usable  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: 6.66 dB → low signal clarity  &lt;br /&gt;
&lt;br /&gt;
General interpretation:&lt;br /&gt;
&lt;br /&gt;
* &amp;gt;20 dB → good  &lt;br /&gt;
* 10–20 dB → usable  &lt;br /&gt;
* &amp;lt;10 dB → poor  &lt;br /&gt;
&lt;br /&gt;
These results show that the system can achieve reliable signal acquisition, although performance varies across subjects.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
====  Rest vs Contraction Discrimination ====&lt;br /&gt;
&lt;br /&gt;
A clear distinction between rest and contraction states is observed based on RMS values.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: 0.0053 → 0.1064 (≈20× increase)  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: 0.0079 → 0.0283 (≈3.6× increase)  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: 0.0141 → 0.0646 (≈4.6× increase)  &lt;br /&gt;
&lt;br /&gt;
This demonstrates that the system is capable of separating muscle activity from baseline noise.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Conclusion:&#039;&#039;  &lt;br /&gt;
The system can be used for basic muscle activity detection and simple classification tasks based on RMS features.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Repeatability of Repeated Contractions ====&lt;br /&gt;
&lt;br /&gt;
Repeatability is evaluated using the coefficient of variation (CV) of peak RMS values across repetitions.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! CV Range !! Evaluation&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt; 10% || Excellent&lt;br /&gt;
|-&lt;br /&gt;
| 10–20% || Acceptable&lt;br /&gt;
|-&lt;br /&gt;
| &amp;gt; 20% || Poor&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Results:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: CV = 12.77% → Acceptable  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: CV = 24.77% → Poor  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: CV = 10.60% → Acceptable  &lt;br /&gt;
&lt;br /&gt;
Although WANG&#039;s signal is detectable, its contraction amplitude varies significantly across repetitions, resulting in poor repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
=== Overall System Performance ===&lt;br /&gt;
&lt;br /&gt;
The system demonstrates the following performance characteristics:&lt;br /&gt;
&lt;br /&gt;
* Reliable detection of muscle activity across all subjects  &lt;br /&gt;
* Clear separation between rest and contraction states  &lt;br /&gt;
* Moderate to high signal quality depending on subject conditions  &lt;br /&gt;
* Repeatability ranging from acceptable to poor due to user-dependent factors  &lt;br /&gt;
&lt;br /&gt;
Overall, the designed EMG acquisition system is capable of stable signal acquisition and feature extraction, with performance primarily influenced by electrode contact quality, skin impedance, and motion consistency.&lt;br /&gt;
&lt;br /&gt;
===== Summary of Quantitative Metrics =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Subject !! RMS (Rest) !! RMS (Contraction) !! Separation Ratio !! iEMG (max) !! Noise RMS !! SNR (dB) !! CV (%) !! Evaluation&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;LIU&#039;&#039;&#039; || 0.0053 || 0.1064 || &#039;&#039;&#039;20.1×&#039;&#039;&#039; || 12.72 || 0.0046 || &#039;&#039;&#039;21.26&#039;&#039;&#039; || 12.77 || Strong signal, good quality&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;WANG&#039;&#039;&#039; || 0.0079 || 0.0283 || 3.57× || 11.10 || 0.0080 || 13.52 || &#039;&#039;&#039;24.77&#039;&#039;&#039; || Usable signal, poor repeatability&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ZHONG&#039;&#039;&#039; || 0.0141 || 0.0646 || 4.58× || 6.70 || 0.0126 || 6.66 || 10.60 || Acceptable performance&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Summary:&#039;&#039; Subject LIU shows the best overall performance, WANG provides usable but less stable signals, and ZHONG demonstrates moderate signal quality with good repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Activation Intensity =====&lt;br /&gt;
&lt;br /&gt;
Among the three subjects, &#039;&#039;&#039;LIU exhibits the strongest muscle activation&#039;&#039;&#039;, as indicated by the highest contraction RMS and iEMG values. ZHONG shows moderate activation, while WANG demonstrates comparable iEMG but lower RMS consistency.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Signal Quality =====&lt;br /&gt;
&lt;br /&gt;
Signal quality is evaluated based on SNR and noise level:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039; achieves the highest SNR and lowest noise → best signal quality  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039; shows moderate SNR → usable but less robust  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039; has the lowest SNR → weakest signal clarity  &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Repeatability =====&lt;br /&gt;
&lt;br /&gt;
Repeatability is evaluated using the coefficient of variation (CV):&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;ZHONG (10.60%)&#039;&#039;&#039; → most stable  &lt;br /&gt;
* &#039;&#039;&#039;LIU (12.77%)&#039;&#039;&#039; → acceptable  &lt;br /&gt;
* &#039;&#039;&#039;WANG (24.77%)&#039;&#039;&#039; → poor  &lt;br /&gt;
&lt;br /&gt;
This indicates that WANG’s contraction strength varies significantly between repetitions.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Engineering Interpretation of Inter-subject Differences =====&lt;br /&gt;
&lt;br /&gt;
The observed differences are mainly attributed to engineering and experimental factors rather than physiological differences.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Electrode contact quality&#039;&#039;&#039;  &lt;br /&gt;
  Variations in electrode placement, pressure, and gel contact affect signal amplitude and stability.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Skin impedance&#039;&#039;&#039;  &lt;br /&gt;
  Differences in skin condition (hydration, oil, hair) influence electrode–skin impedance, affecting noise level and signal coupling.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Muscle control consistency&#039;&#039;&#039;  &lt;br /&gt;
  Variations in contraction strength and timing affect repeatability and CV.&lt;br /&gt;
&lt;br /&gt;
Therefore, the variation across subjects reflects practical acquisition conditions rather than intrinsic system limitations.&lt;/div&gt;</summary>
		<author><name>Wang Jingyi</name></author>
	</entry>
	<entry>
		<id>https://pc5271.org/index.php?title=Surface_EMG_Sensor_for_Muscle_Activity_Measurement:_AFE_Design_and_Signal_Processing&amp;diff=1353</id>
		<title>Surface EMG Sensor for Muscle Activity Measurement: AFE Design and Signal Processing</title>
		<link rel="alternate" type="text/html" href="https://pc5271.org/index.php?title=Surface_EMG_Sensor_for_Muscle_Activity_Measurement:_AFE_Design_and_Signal_Processing&amp;diff=1353"/>
		<updated>2026-04-23T06:43:25Z</updated>

		<summary type="html">&lt;p&gt;Wang Jingyi: /* Representative Dynamic Signal Analysis */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Background and Theory==&lt;br /&gt;
&lt;br /&gt;
=== Surface EMG Signals ===&lt;br /&gt;
Surface electromyography (sEMG) refers to the bioelectrical signals detected on the skin surface during muscle contraction. These signals originate from the electrical activity of muscle fibers and provide a non-invasive way to monitor muscle activation. Compared with invasive EMG methods, sEMG is easier to apply, safer for repeated measurements, and more suitable for real-time monitoring. Therefore, it has been widely used in areas such as rehabilitation, motion analysis, human–machine interaction, and physiological monitoring.&lt;br /&gt;
&lt;br /&gt;
=== Characteristics of EMG Signals ===&lt;br /&gt;
EMG signals are generally weak, time-varying, and stochastic in nature. Their waveforms are typically bipolar, fluctuating around zero with both positive and negative components. The amplitude and frequency content of EMG signals depend on factors such as muscle contraction level, electrode placement, skin condition, and individual physiological differences. In practice, the useful frequency components of sEMG are mainly concentrated in a limited low-to-mid frequency range. Because of their low amplitude and variability, EMG signals usually require further conditioning before reliable interpretation and feature extraction can be performed.&lt;br /&gt;
&lt;br /&gt;
=== Bioelectrical Signal Acquisition Principles ===&lt;br /&gt;
The acquisition of bioelectrical signals is based on measuring the small potential difference on the skin surface using electrodes, then converting it into a processable electrical signal through amplification and digitization. For sEMG measurement, electrode placement and skin–electrode contact quality are especially important, since they directly affect signal amplitude and stability. In addition, the front-end acquisition circuit must provide sufficient sensitivity and good interference rejection, so that the recorded signal reflects actual muscle activity rather than environmental disturbance or poor contact conditions.&lt;br /&gt;
&lt;br /&gt;
=== Noise Sources in EMG (50 Hz, motion artifacts) ===&lt;br /&gt;
In practical EMG recording, the measured signal is easily contaminated by different types of noise. Two of the most common sources are power-line interference and motion artifacts. Power-line interference usually appears as a narrow-band component at 50 Hz in the local electrical environment, while motion artifacts are mainly caused by electrode movement, cable disturbance, or variations in the electrode–skin impedance, and are often concentrated in the low-frequency range. In addition, electronic noise from the acquisition hardware may also affect the recording quality. These unwanted components can reduce signal clarity and make muscle activity analysis less reliable, so they must be considered in the design of the signal processing pipeline.&lt;br /&gt;
[[File:background_theory_figure1.1_emg_noise_sources.png|center|thumb|700px|&#039;&#039;&#039;Figure 1.1.&#039;&#039;&#039; Principle of surface EMG acquisition.]]&lt;br /&gt;
&lt;br /&gt;
==System Architecture==&lt;br /&gt;
=== Total Structure Design ===&lt;br /&gt;
&lt;br /&gt;
For clarity，the proposed physiological signal acquisition system mainly consists of two core parts：the analog front－end （AFE）and the ADC board．The AFE is responsible for the preliminary conditioning of weak bioelectrical signals，including amplification，filtering，interference suppression，and level shifting，so that the analog waveform can be converted into a stable and measurable form．The ADC board then performs high－resolution digitization of the conditioned signal and transfers the sampled data to the host computer for subsequent display，storage，and analysis．Therefore，the overall system forms a complete signal－acquisition chain from weak physiological input to digital output．&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_1.jpg|thumb|center|800px|Figure 2.1. Overall system architecture of the proposed physiological signal acquisition platform，including the AFE and ADC modules．]]&lt;br /&gt;
&lt;br /&gt;
=== sEMG AFE Design ===&lt;br /&gt;
&lt;br /&gt;
To collect the weak bioelectric potential signals of the human body，an analog front－end（AFE）suitable sEMG measurements was designed．The module is powered by an external 5 V supply，and the complete circuit includes a first－ stage instrumentation amplifier based on INA128（Texas Instruments，Dallas，TX，USA），a band－pass filter，a 50 Hz notch filter，a second－order amplification and level shifting stage，a driver electrode circuit，a precise 1.5 V reference source，and a -5 V voltage generation module for powering the operational amplifiers．&lt;br /&gt;
&lt;br /&gt;
==== First－order Amplifier ====&lt;br /&gt;
&lt;br /&gt;
The input bioelectric signal is first acquired in differential form and applied to the INA128 instrumentation amplifier，which provides high input impedance，high common－mode rejection，and moderate initial gain for sEMG acquisition．This stage enlarges the weak physiological signal before filtering while reducing the risk of premature saturation caused by electrode offset or motion－induced disturbance，thereby preparing a more stable signal for the subsequent conditioning stages．&lt;br /&gt;
&lt;br /&gt;
==== Bandpass Filter ====&lt;br /&gt;
&lt;br /&gt;
After the instrumentation amplifier，the signal passes through a second－order active band－pass filter，as shown in Figure 2．2． This stage suppresses baseline drift and high－frequency noise outside the useful sEMG range，so that the low－frequency envelope information of sEMG can be preserved before further amplification．&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_2.jpg|thumb|center|800px|Figure 2.2. Schematic diagram of the active band-pass filter used in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the band-pass stage used to retain the main physiological signal band while suppressing unwanted lowand high-frequency components.&lt;br /&gt;
&lt;br /&gt;
==== Notch Filter ====&lt;br /&gt;
&lt;br /&gt;
To reduce power-line interference, a dedicated 50 Hz notch filter is introduced after the band-pass stage, as shown in Figure 2.3. This filter attenuates the mains-frequency component that commonly contaminates weak bioelectric measurements, thereby improving the signal-to-noise ratio of sEMG signals before the final amplification stage.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_3.jpg|thumb|center|800px|Figure 2.3. Schematic diagram of the 50 Hz notch filter used in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the circuit used to attenuate 50 Hz mains interference in the analog front end.&lt;br /&gt;
&lt;br /&gt;
==== Second-order Amplifier &amp;amp; Level Shifter ====&lt;br /&gt;
&lt;br /&gt;
After filtering, the signal enters the second-stage amplification and level-shifting circuit shown in Figure 2.4. In this stage, the filtered signal is further amplified to improve amplitude utilization and then shifted by a 1.5 V reference so that the output becomes a stable unipolar signal suitable for ADC sampling, while preserving linear operation and providing sufficient output swing margin.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_4.jpg|thumb|center|800px|Figure 2.4. Schematic diagram of the second-stage amplifier and level-shifting circuit in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows how the conditioned signal is further amplified and shifted to a suitable DC level before digitization.&lt;br /&gt;
&lt;br /&gt;
==== Power Module and Drive-electrode Circuit ====&lt;br /&gt;
&lt;br /&gt;
The AFE is powered by a 5 V supply and also integrates a 1.5 V precision reference, a -5 V generation circuit, and a driveelectrode circuit. These supporting modules provide the required supply rails and reference level for analog signal conditioning, while the drive-electrode circuit feeds back common-mode voltage to the body to suppress interference at the source. As a result, the complete AFE can support sEMG acquisition with adequate gain, filtering, and noise-reduction performance in a compact hardware structure.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_5.jpg|thumb|center|800px|Figure 2.5. Physical picture of the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the fabricated sEMG analog front-end hardware used in the system.&lt;br /&gt;
&lt;br /&gt;
Figure 2.5 presents the practical hardware implementation of the proposed sEMG AFE. It integrates amplification, filtering, level shifting, and driven-reference functions in a compact circuit for weak bioelectrical signal acquisition.&lt;br /&gt;
&lt;br /&gt;
=== ADS1256-based ADC Board ===&lt;br /&gt;
&lt;br /&gt;
To digitize the conditioned weak physiological signals with sufficient resolution and low noise, this project developed a dedicated ADC board based on the ADS1256 analog-to-digital converter (Texas Instruments, Dallas, TX, USA) and the STM32F103C8T6 microcontroller (STMicroelectronics, Geneva, Switzerland). The overall design objective of this board was not merely to realize analog-to-digital conversion, but to provide a complete hardware interface between the analog front-end and the digital processing unit, including precision reference generation, clocking, input protection and filtering, serial communication, power regulation, and MCU-based acquisition control. The ADS1256 was selected because it is a&lt;br /&gt;
&lt;br /&gt;
very low-noise 24-bit delta-sigma converter with a programmable gain amplifier (PGA), flexible input multiplexer, programmable digital filter, and SPI-compatible serial interface, which makes it well suited for weak low-frequency physiological signals after analog conditioning. The STM32F103C8T6 was used as the local controller because it provides a 32-bit Cortex-M3 core, up to 72 MHz system clock, SPI, USART, USB, and standard SWD debugging support in a compact and low-cost platform.&lt;br /&gt;
&lt;br /&gt;
==== ADC Core Architecture and Design Rationale ====&lt;br /&gt;
&lt;br /&gt;
The ADS1256 was selected as the core ADC because it provides high-resolution, low-noise delta-sigma conversion with an input multiplexer, programmable gain amplifier, and digital filter, which are suitable for weak and low-frequency physiological signals. As shown in Figure 2.6, this architecture emphasizes resolution and noise performance rather than high conversion bandwidth, making it appropriate for sEMG signal digitization after analog conditioning.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_6.jpg|thumb|center|800px|Figure 2.6. Internal functional structure of the ADS1256 analog-to-digital converter.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the main internal blocks of the ADS1256, including the multiplexer, PGA, modulator, and digital filter.&lt;br /&gt;
&lt;br /&gt;
==== Analog Front-End Interface, Reference, and Clocking ====&lt;br /&gt;
&lt;br /&gt;
The ADS1256 analog inputs are connected to the external header through a passive input-conditioning network that helps suppress high-frequency interference and improve input stability. In addition, the board includes a dedicated precision reference and clocking circuits so that the ADC can perform stable and accurate conversion. Together, these circuits provide a reliable analog interface and timing basis for high-resolution digitization of weak physiological signals.&lt;br /&gt;
&lt;br /&gt;
==== SPI Interface between ADS1256 and STM32F103C8T6 ====&lt;br /&gt;
&lt;br /&gt;
Communication between the ADS1256 and the STM32F103C8T6 is implemented through an SPI-compatible interface, with dedicated lines for chip select, serial clock, input/output data, data-ready notification, and hardware reset. This connection allows the MCU to configure the ADC, read conversion results in synchrony with DRDY, and maintain efficient and reliable acquisition control for multi-channel physiological measurements.&lt;br /&gt;
&lt;br /&gt;
==== Power Supply and On-board Regulation ====&lt;br /&gt;
&lt;br /&gt;
The ADC board uses a USB Type-B connector as the main power input and includes protection, voltage regulation, and local decoupling circuits to provide a stable supply for both the MCU and ADC-related hardware. In addition, analog ground and digital ground are separated in the PCB layout to reduce digital noise coupling into the analog path, which is particularly important for weak physiological signal acquisition.&lt;br /&gt;
&lt;br /&gt;
==== Basic Peripheral Circuits of the STM32F103C8T6 ====&lt;br /&gt;
&lt;br /&gt;
The STM32F103C8T6 serves as the local controller of the ADC board and is supported by several basic peripheral circuits, including an external crystal oscillator, reset network, BOOT0 configuration, SWD programming/debugging header, and a CH340N USB-to-UART bridge. These circuits ensure stable MCU operation, convenient firmware downloading and debugging, and reliable data transmission from the board to the host computer for real-time display and storage.&lt;br /&gt;
&lt;br /&gt;
==== Hardware-level Working Principle of the ADC Board ====&lt;br /&gt;
&lt;br /&gt;
In operation, the conditioned analog signal from the AFE enters the ADS1256 through the input header, is digitized with high resolution under the control of the local precision reference and clock, and is then read by the STM32 through the SPI interface. The MCU subsequently forwards the sampled data to the host computer through the serial communication link, so that the entire board functions as a compact digital acquisition backend connecting weak physiological analog signals to later software processing, display, and storage.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_7.jpg|thumb|center|800px|Figure 2.7. Photograph of the fabricated ADS1256-based ADC board developed in this project and the definitions of some key pins.]]&lt;br /&gt;
&lt;br /&gt;
Figure 2.7 shows the ADC board fabricated for this project. It integrates the ADS1256 conversion core, STM32 control circuit, power-conditioning circuits, and communication interfaces on a compact PCB for physiological signal digitization.&lt;br /&gt;
&lt;br /&gt;
== Signal Conditioning and Filtering ==&lt;br /&gt;
Although the AFE already performs preliminary band-pass filtering and 50 Hz interference suppression in the analog domain, the digitized sEMG signal may still contain residual noise due to component tolerances, electrode-contact variation, and environmental interference. Therefore, an additional digital filtering stage is implemented in software as a complementary post-processing step to improve signal quality and to provide a more stable input for rectification, envelope extraction, and subsequent analysis. In this sense, the software filtering is not a simple repetition of the analog filtering, but a refinement and compensation for non-ideal front-end behavior.&lt;br /&gt;
&lt;br /&gt;
Surface electromyographic (sEMG) signals are highly susceptible to several sources of contamination during acquisition. In practical measurements, the dominant disturbances usually include low-frequency motion artifacts caused by electrode movement and electrode–skin impedance variation, narrow-band power-line interference centered at 50 Hz, and broadband high-frequency electronic noise introduced by the acquisition hardware. These unwanted components degrade the quality of the recorded signal and may significantly affect the reliability of subsequent feature extraction, parameter estimation, and muscle activity interpretation. For this reason, an effective signal-conditioning procedure is necessary before any higher-level analysis is performed.&lt;br /&gt;
&lt;br /&gt;
In the present implementation, the filtering strategy follows the principle of restricting the signal bandwidth first and then removing the remaining narrow-band interference in a targeted manner. Accordingly, the raw sEMG signal is first processed by a fourth-order Butterworth IIR band-pass filter and then by a 50 Hz notch filter. This processing sequence is illustrated in the flowchart below, where the signal passes through band-pass filtering, notch filtering, full-wave rectification, and envelope extraction before producing the final processed output.&lt;br /&gt;
&lt;br /&gt;
[[File:flowchart.png|thumb|center|500px|Flowchart of the real-time sEMG signal conditioning pipeline.]]&lt;br /&gt;
&lt;br /&gt;
The rationale of this order is that the &#039;&#039;&#039;band-pass stage&#039;&#039;&#039; first confines the signal to the main spectral region of interest for sEMG, thereby attenuating motion artifacts at very low frequencies and suppressing high-frequency noise components outside the physiological band. After this spectral preconditioning, the notch stage can more effectively suppress the residual 50 Hz power-line interference that lies inside the useful sEMG band. In transfer-function form, the band-pass filter may be written as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;H_{BP}(z)=\frac{B_{BP}(z)}{A_{BP}(z)}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where the effective passband is selected as &amp;lt;math&amp;gt;20 \leq f \leq 160 \text{ Hz}&amp;lt;/math&amp;gt;. This frequency interval is consistent with the dominant spectral content of surface EMG: the lower cutoff near 20 Hz reduces motion artifacts and unstable low-frequency fluctuations, whereas the upper cutoff near 160 Hz removes high-frequency electronic noise while preserving the main energy-bearing components of the muscle signal. The use of a Butterworth structure is appropriate here because it provides a smooth monotonic passband response without ripple, which helps preserve signal morphology in real-time applications.&lt;br /&gt;
&lt;br /&gt;
After band limitation, a &#039;&#039;&#039;notch filter&#039;&#039;&#039; centered at the power-line frequency is applied to suppress interference that cannot be removed by the band-pass stage alone. The notch filter is designed around &amp;lt;math&amp;gt;f_0 = 50 \text{ Hz}&amp;lt;/math&amp;gt;, and its bandwidth is controlled by the quality factor &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;, which is expressed as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;Q = \frac{f_0}{\Delta f}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In transfer-function form, the notch stage is written as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;H_{N}(z)=\frac{B_{N}(z)}{A_{N}(z)}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the implemented program, a large quality factor is chosen so that the notch remains narrow, allowing effective rejection of the 50 Hz interference while minimizing distortion of neighboring useful spectral components. This is particularly important for sEMG because the interference frequency lies directly inside the physiological band of interest.&lt;br /&gt;
&lt;br /&gt;
Following the filtering stages, further signal conditioning is performed to obtain a representation that is more directly related to muscle activation intensity. The filtered sEMG waveform is first &#039;&#039;&#039;full-wave rectified&#039;&#039;&#039;, which converts the bipolar oscillatory signal into a unipolar signal by taking its absolute value.  Rectification does not remove noise by itself; instead, it transforms the signal into a form that is more suitable for amplitude-based analysis because both positive and negative deflections contribute positively to the activation measure.&lt;br /&gt;
&lt;br /&gt;
After rectification, the signal envelope is extracted to provide a smooth estimate of muscle activation level over time. In a general formulation, the envelope can be described as the &#039;&#039;&#039;low-pass filtered&#039;&#039;&#039; version of the rectified signal, namely &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y_{\mathrm{env}}[n] = \mathrm{LPF}\bigl(y_{\mathrm{rect}}[n]\bigr)&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the present code implementation, this operation is realized by short-time averaging over a finite window, which is equivalent to a moving-average low-pass smoothing of the rectified waveform. The corresponding expression is &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y_{\mathrm{env}}[n] = \frac{1}{N}\sum_{k=0}^{N-1} |x[n-k]|&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; is the window length in samples. With a window duration of approximately 200 ms, this envelope extraction method provides a stable and physiologically meaningful representation of muscle activation intensity, making it suitable for tasks such as force estimation, fatigue analysis, and motor-control studies.&lt;br /&gt;
&lt;br /&gt;
An important feature of the present &#039;&#039;&#039;implementation&#039;&#039;&#039; is that the entire filtering process is performed &#039;&#039;&#039;in real time&#039;&#039;&#039;, sample by sample, rather than by offline block processing. For this reason, IIR filters are preferred over FIR filters, since they can achieve comparable filtering performance with lower order, lower computational cost, and shorter delay. These properties are especially valuable in embedded systems, serial data streaming, and other low-latency experimental applications. However, unlike memoryless operations, an IIR filter depends not only on the current input but also on previous inputs and previous outputs. Its discrete-time behavior can therefore be represented by the recursive difference equation &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y[n] = \sum_{k=0}^{M} b_k x[n-k] - \sum_{k=1}^{N} a_k y[n-k]&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This equation makes clear that internal filter states must be preserved continuously during streaming operation. If the state variables were reinitialized for every incoming sample or data segment, artificial transients would appear and the output would no longer remain continuous.&lt;br /&gt;
&lt;br /&gt;
In the Python implementation, this state continuity is maintained using the internal initial-condition mechanism provided by SciPy, such as &amp;lt;code&amp;gt;lfilter_zi&amp;lt;/code&amp;gt;, together with recursive state updates during each filtering call. As a result, each newly acquired sample is passed first through the band-pass filter and then through the notch filter, while the internal states of both filters are updated after every step. This state-preserving sample-by-sample design ensures that the processing chain remains causal, continuous, and suitable for real-time display or downstream analysis without requiring storage of the entire signal segment.&lt;br /&gt;
&lt;br /&gt;
Overall, this signal-conditioning scheme provides an experimentally practical solution for real-time sEMG processing. The fourth-order Butterworth band-pass filter confines the signal to the main physiological band of interest, the 50 Hz notch filter removes narrow-band power-line contamination, and the subsequent rectification and envelope extraction generate a smooth amplitude descriptor of muscle activity. Combined with state-preserved streaming IIR implementation, this approach achieves a good balance between signal fidelity, computational efficiency, and real-time applicability in biomedical and physical experiment settings.&lt;br /&gt;
&lt;br /&gt;
== Data Processing ==&lt;br /&gt;
&lt;br /&gt;
The objective of data processing is to convert raw surface electromyography (sEMG) recordings into stable, quantitative, and comparable indicators of muscle activity. Since EMG signals are low in amplitude, highly variable over time, and easily contaminated by noise, a dedicated processing pipeline is necessary before any experimental interpretation can be performed.&lt;br /&gt;
&lt;br /&gt;
In this project, the data processing workflow includes time normalization, signal pre-processing, sliding-window feature extraction, noise-floor estimation, and automatic contraction detection. The processed outputs are then used for subsequent experimental evaluation, including rest-versus-contraction discrimination, signal-to-noise ratio analysis, and repeatability assessment.&lt;br /&gt;
&lt;br /&gt;
=== Input Data and Time Normalization ===&lt;br /&gt;
&lt;br /&gt;
The acquired EMG data are read from CSV files containing two columns: time and filtered sEMG amplitude. In the MATLAB implementation, the time vector is normalized so that each recording starts from zero:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t = t_{all} - t_{all}(1)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This normalization is important because it removes the influence of absolute recording timestamps and makes different trials directly comparable on the same time axis.&lt;br /&gt;
&lt;br /&gt;
In addition, the signal type is automatically identified from the filename as either dynamic or rest. This design allows the same program to process both contraction recordings and resting recordings with different downstream analysis logic.&lt;br /&gt;
&lt;br /&gt;
=== Signal Pre-processing ===&lt;br /&gt;
&lt;br /&gt;
Raw EMG signals cannot be analyzed directly because they usually contain DC offset, low-frequency drift, motion artifacts, and residual high-frequency interference. Therefore, several pre-processing steps are applied before feature extraction.&lt;br /&gt;
&lt;br /&gt;
==== Baseline Removal ====&lt;br /&gt;
&lt;br /&gt;
The first step is DC offset removal:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
x_{dc}(t) = x(t) - \frac{1}{N}\sum_{i=1}^{N}x(i)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This operation centers the signal around zero. It is necessary because an uncorrected baseline would bias amplitude-based metrics and reduce the reliability of later envelope and feature calculations.&lt;br /&gt;
&lt;br /&gt;
==== Band-pass Filtering ====&lt;br /&gt;
&lt;br /&gt;
After baseline correction, a fourth-order Butterworth band-pass filter is applied with a passband of 20–150 Hz.&lt;br /&gt;
&lt;br /&gt;
This step is introduced for two reasons:&lt;br /&gt;
&lt;br /&gt;
* The low-frequency cutoff at 20 Hz suppresses baseline drift and motion artifacts.&lt;br /&gt;
* The high-frequency cutoff at 150 Hz reduces unwanted high-frequency noise while preserving the main energy band of the recorded sEMG in this project.&lt;br /&gt;
&lt;br /&gt;
Compared with processing the raw waveform directly, band-pass filtering makes the subsequent time-domain features more stable and more physiologically meaningful.&lt;br /&gt;
&lt;br /&gt;
==== Full-wave Rectification ====&lt;br /&gt;
&lt;br /&gt;
The filtered EMG signal is bipolar, meaning that positive and negative phases coexist due to motor unit action potentials. If these positive and negative components are averaged directly, they may cancel each other out. To avoid this, full-wave rectification is performed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
x_{rect}(t) = |x_{filt}(t)|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This transforms the signal into a unipolar representation, so that all muscle activity contributes positively to the extracted features.&lt;br /&gt;
&lt;br /&gt;
==== Envelope Extraction ====&lt;br /&gt;
&lt;br /&gt;
Although the rectified signal reflects signal magnitude, it still fluctuates rapidly. To obtain a smoother representation of muscle activation level, an envelope is extracted using a moving average with a 100 ms window.&lt;br /&gt;
&lt;br /&gt;
Envelope extraction is important because contraction detection should reflect the overall activation trend rather than instantaneous spikes. A smoothed envelope is therefore more robust for identifying active and inactive muscle states.&lt;br /&gt;
&lt;br /&gt;
=== Sliding Window Design ===&lt;br /&gt;
&lt;br /&gt;
To quantify how muscle activity changes with time, the filtered signal is divided into overlapping short-time segments using a sliding window method.&lt;br /&gt;
&lt;br /&gt;
The window parameters are:&lt;br /&gt;
&lt;br /&gt;
* Window length: 250 ms&lt;br /&gt;
* Step size: 50 ms&lt;br /&gt;
&lt;br /&gt;
These values are chosen as a trade-off between temporal resolution and feature stability.&lt;br /&gt;
&lt;br /&gt;
A longer window improves statistical robustness because more samples are included in each calculation. However, if the window is too long, short contractions or rapid changes may be blurred. A smaller step size increases temporal continuity between adjacent feature points and makes the feature curves smoother in time. Therefore, the 250 ms / 50 ms design provides a practical balance between smoothing and time localization.&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt;-th segment, the feature time is defined as the mean time of that segment:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t_k = \frac{1}{N}\sum_{i=s_k}^{e_k} t(i)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;s_k&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;e_k&amp;lt;/math&amp;gt; denote the start and end indices of the window.&lt;br /&gt;
&lt;br /&gt;
=== Feature Extraction ===&lt;br /&gt;
&lt;br /&gt;
Within each sliding window, three time-domain features are extracted: RMS, iEMG, and MAV. These features are widely used in EMG analysis because they are simple, computationally efficient, and directly related to muscle activation intensity.&lt;br /&gt;
&lt;br /&gt;
==== Root Mean Square (RMS) ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
RMS = \sqrt{\frac{1}{N}\sum_{i=1}^{N}x_i^2}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
RMS reflects the effective power of the EMG signal and is one of the most common indicators of contraction strength. It is sensitive to both amplitude and energy, making it especially useful for comparing rest and active states.&lt;br /&gt;
&lt;br /&gt;
==== Integrated EMG (iEMG) ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
iEMG = \sum_{i=1}^{N}|x_i|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
iEMG describes the cumulative electrical activity within a window. It is often interpreted as a measure of total muscle effort over that time segment.&lt;br /&gt;
&lt;br /&gt;
==== Mean Absolute Value (MAV) ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
MAV = \frac{1}{N}\sum_{i=1}^{N}|x_i|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
MAV is an amplitude descriptor similar to iEMG, but normalized by the number of samples. It provides an efficient estimate of average signal level and is less computationally intensive than some other features.&lt;br /&gt;
&lt;br /&gt;
These three features are used together because they provide complementary descriptions of EMG intensity. RMS emphasizes signal energy, iEMG emphasizes cumulative activation, and MAV reflects average amplitude.&lt;br /&gt;
&lt;br /&gt;
=== Peak-value Extraction ===&lt;br /&gt;
&lt;br /&gt;
In addition to continuous feature curves, several key peak values are extracted from the processed signal:&lt;br /&gt;
&lt;br /&gt;
* maximum and minimum of the filtered EMG waveform&lt;br /&gt;
* peak of the envelope&lt;br /&gt;
* peak RMS&lt;br /&gt;
* peak iEMG&lt;br /&gt;
* peak MAV&lt;br /&gt;
&lt;br /&gt;
These peak values provide concise descriptors of the strongest activity observed in each recording. They are useful for quick comparison across trials and subjects.&lt;br /&gt;
&lt;br /&gt;
=== Noise Floor Estimation ===&lt;br /&gt;
&lt;br /&gt;
To evaluate signal quality, the noise floor is estimated from a reference resting interval. In the present implementation, the first 3 seconds of the recording are used as the default rest reference:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t \in [0,\min(3,t_{end})]&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this segment, three noise descriptors are computed:&lt;br /&gt;
&lt;br /&gt;
* Noise RMS&lt;br /&gt;
* Noise standard deviation&lt;br /&gt;
* Noise peak-to-peak amplitude&lt;br /&gt;
&lt;br /&gt;
Noise-floor estimation is important because EMG amplitude alone is not sufficient to judge recording quality. A large signal is only meaningful if it is sufficiently higher than the baseline noise level. Therefore, the noise floor serves as the reference for later SNR calculation and for designing contraction thresholds.&lt;br /&gt;
&lt;br /&gt;
=== Global Signal Metrics ===&lt;br /&gt;
&lt;br /&gt;
For each recording, three global metrics are also computed over the entire filtered signal:&lt;br /&gt;
&lt;br /&gt;
* Global RMS&lt;br /&gt;
* Global MAV&lt;br /&gt;
* Global iEMG&lt;br /&gt;
&lt;br /&gt;
These global descriptors summarize the overall signal level of the full recording and are later used in group-level comparisons.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Contraction Detection ===&lt;br /&gt;
&lt;br /&gt;
For dynamic recordings, an automatic contraction detection algorithm is used to identify repeated active segments. This is one of the key parts of the data processing pipeline, because it transforms a continuous EMG trace into discrete contraction events that can be counted and compared.&lt;br /&gt;
&lt;br /&gt;
==== Threshold Design ====&lt;br /&gt;
&lt;br /&gt;
The detection threshold is designed adaptively rather than using a fixed value. Two candidate thresholds are first calculated:&lt;br /&gt;
&lt;br /&gt;
* an envelope-based threshold derived from the global envelope mean and standard deviation&lt;br /&gt;
* a rest-reference threshold derived from the mean and standard deviation of the resting reference amplitude&lt;br /&gt;
&lt;br /&gt;
The final threshold is taken as the larger of the two after additional scaling. This strategy improves robustness because it combines the global activation level of the signal with the baseline noise characteristics of the individual recording.&lt;br /&gt;
&lt;br /&gt;
This adaptive threshold design is preferable to a manually fixed threshold because EMG amplitude can vary strongly between subjects, muscles, and recording sessions.&lt;br /&gt;
&lt;br /&gt;
==== Initial Segmentation ====&lt;br /&gt;
&lt;br /&gt;
After thresholding the envelope, the signal is classified into active and inactive regions:&lt;br /&gt;
&lt;br /&gt;
* active: envelope above threshold&lt;br /&gt;
* inactive: envelope below threshold&lt;br /&gt;
&lt;br /&gt;
The rising and falling edges of the binary activity vector are then used to determine the start and end points of each candidate contraction segment.&lt;br /&gt;
&lt;br /&gt;
==== Removal of Short Segments ====&lt;br /&gt;
&lt;br /&gt;
Very short active regions are often caused by noise fluctuations rather than true muscle contractions. Therefore, segments shorter than 0.20 s are discarded.&lt;br /&gt;
&lt;br /&gt;
This step prevents false positive detections and increases the physiological relevance of the segmentation results.&lt;br /&gt;
&lt;br /&gt;
==== Merging of Adjacent Segments ====&lt;br /&gt;
&lt;br /&gt;
If two neighboring active segments are separated by a very short gap, they are merged when the gap is less than 0.15 s.&lt;br /&gt;
&lt;br /&gt;
This operation is necessary because a single real contraction may be temporarily interrupted by a brief drop in the envelope caused by local fluctuation. Without merging, one contraction could be incorrectly counted as multiple repetitions.&lt;br /&gt;
&lt;br /&gt;
==== Repetition-level Metrics ====&lt;br /&gt;
&lt;br /&gt;
For each detected contraction segment, two repetition-level metrics are extracted:&lt;br /&gt;
&lt;br /&gt;
* peak RMS of that contraction&lt;br /&gt;
* mean RMS of that contraction&lt;br /&gt;
&lt;br /&gt;
These metrics quantify both the strongest activation within each repetition and the average activation level over the repetition duration.&lt;br /&gt;
&lt;br /&gt;
=== Repeatability Analysis ===&lt;br /&gt;
&lt;br /&gt;
When multiple valid contractions are detected, repeatability is evaluated using the coefficient of variation (CV):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
CV = \frac{\sigma}{\mu}\times 100\%&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt; is the standard deviation and &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is the mean value across repetitions.&lt;br /&gt;
&lt;br /&gt;
Two CV values are computed:&lt;br /&gt;
&lt;br /&gt;
* CV of repetition peak RMS&lt;br /&gt;
* CV of repetition mean RMS&lt;br /&gt;
&lt;br /&gt;
A lower CV indicates better repeatability, meaning that repeated contractions produce more consistent EMG responses.&lt;br /&gt;
&lt;br /&gt;
=== Signal-to-Noise Ratio (SNR) ===&lt;br /&gt;
&lt;br /&gt;
In this project, the signal-to-noise ratio (SNR) is defined based on the ratio between contraction and rest activity:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
SNR_{dB} = 20\log_{10}\left(\frac{RMS_{contraction}}{RMS_{rest}}\right)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This definition is adopted because it directly reflects the system’s ability to distinguish active muscle contraction from baseline noise.&lt;br /&gt;
&lt;br /&gt;
Compared with global SNR definitions, this formulation is more relevant for practical EMG applications such as activity detection and classification.&lt;br /&gt;
&lt;br /&gt;
=== Rest-versus-Contraction Window Comparison ===&lt;br /&gt;
&lt;br /&gt;
To further distinguish inactive and active states, all sliding windows are divided into two groups:&lt;br /&gt;
&lt;br /&gt;
* rest windows: windows with envelope clearly below the threshold&lt;br /&gt;
* contraction windows: windows with envelope above the threshold&lt;br /&gt;
&lt;br /&gt;
The RMS values of these two groups are then compared statistically.&lt;br /&gt;
&lt;br /&gt;
This comparison is important because a practical EMG system should not only detect signal presence, but also clearly separate rest from contraction in a quantitative way. If the two RMS distributions are well separated, it indicates that the system has good discriminative capability.&lt;br /&gt;
&lt;br /&gt;
=== Output Data Structure ===&lt;br /&gt;
&lt;br /&gt;
The processed outputs are organized into structured data for experimental analysis:&lt;br /&gt;
&lt;br /&gt;
==== Time-series outputs ====&lt;br /&gt;
* Filtered EMG signal  &lt;br /&gt;
* Rectified signal  &lt;br /&gt;
* Envelope  &lt;br /&gt;
* RMS(t), iEMG(t), MAV(t)  &lt;br /&gt;
&lt;br /&gt;
==== Recording-level outputs ====&lt;br /&gt;
* RMS (rest)  &lt;br /&gt;
* RMS (contraction)  &lt;br /&gt;
* iEMG  &lt;br /&gt;
* Noise metrics  &lt;br /&gt;
&lt;br /&gt;
==== Dynamic-signal outputs ====&lt;br /&gt;
* Detected contractions  &lt;br /&gt;
* Repetition count  &lt;br /&gt;
* Peak RMS per repetition  &lt;br /&gt;
* Mean RMS per repetition  &lt;br /&gt;
* Coefficient of variation (CV)  &lt;br /&gt;
* Signal-to-noise ratio (SNR)  &lt;br /&gt;
&lt;br /&gt;
All extracted features are designed to directly support the evaluation of noise level, signal quality, activity discrimination, and repeatability in the subsequent experimental analysis.&lt;br /&gt;
&lt;br /&gt;
== Experimental Results ==&lt;br /&gt;
&lt;br /&gt;
This section presents representative results of the EMG acquisition and data processing pipeline under both dynamic (muscle contraction) and resting conditions.&lt;br /&gt;
&lt;br /&gt;
=== Representative Dynamic Signal Analysis ===&lt;br /&gt;
&lt;br /&gt;
[[File:Dynamic_Figure1.png|800px|center|Figure 5.1: Processed EMG signal under dynamic contraction, including filtered signal, rectified signal with envelope, and extracted features (RMS, iEMG, MAV).]]&lt;br /&gt;
&lt;br /&gt;
Figure 5.1 shows the processed EMG signal during repeated muscle contractions.&lt;br /&gt;
&lt;br /&gt;
The filtered EMG waveform exhibits clear burst-like patterns corresponding to periodic contractions. The signal amplitude reaches a maximum of approximately 0.45, while the baseline remains centered around zero, indicating effective baseline removal and filtering.&lt;br /&gt;
&lt;br /&gt;
After rectification and envelope extraction, the contraction periods become clearly distinguishable. The envelope provides a smooth representation of muscle activation, with a peak value of approximately 0.145.&lt;br /&gt;
&lt;br /&gt;
The extracted time-domain features (RMS, iEMG, MAV) further quantify the signal. Among these, iEMG shows the strongest dynamic variation, indicating high sensitivity to contraction intensity.&lt;br /&gt;
&lt;br /&gt;
=== Noise Floor and Rest Reference ===&lt;br /&gt;
&lt;br /&gt;
[[File:Dynamic_Figure2.png|800px|center|Figure 2: Noise estimation, rest vs contraction comparison, automatic contraction detection, and repetition analysis.]]&lt;br /&gt;
&lt;br /&gt;
Figure 2 (top-left) shows the resting reference segment used for noise estimation.&lt;br /&gt;
&lt;br /&gt;
The signal remains centered around zero with small fluctuations. The noise characteristics are:&lt;br /&gt;
&lt;br /&gt;
* Noise RMS ≈ 0.0046  &lt;br /&gt;
* Standard deviation ≈ 0.0046  &lt;br /&gt;
* Peak-to-peak amplitude ≈ 0.071  &lt;br /&gt;
&lt;br /&gt;
This indicates a low noise floor and stable measurement conditions.&lt;br /&gt;
&lt;br /&gt;
=== Rest vs Contraction Discrimination ===&lt;br /&gt;
&lt;br /&gt;
Figure 2 (top-right) compares RMS values between rest and contraction states.&lt;br /&gt;
&lt;br /&gt;
The two distributions are clearly separated:&lt;br /&gt;
&lt;br /&gt;
* Rest mean RMS ≈ 0.0053  &lt;br /&gt;
* Contraction mean RMS ≈ 0.1064  &lt;br /&gt;
&lt;br /&gt;
This corresponds to an approximate 20× increase, demonstrating strong discriminability between inactive and active muscle states.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Contraction Detection ===&lt;br /&gt;
&lt;br /&gt;
Figure 2 (bottom-left) illustrates automatic detection based on the envelope signal.&lt;br /&gt;
&lt;br /&gt;
A threshold of approximately 0.040 is applied, resulting in stable segmentation of contraction periods.&lt;br /&gt;
&lt;br /&gt;
A total of 12 repetitions are detected, with good alignment to visible signal peaks.&lt;br /&gt;
&lt;br /&gt;
=== Repeatability Analysis ===&lt;br /&gt;
&lt;br /&gt;
Figure 2 (bottom-right) shows the peak RMS value of each detected contraction.&lt;br /&gt;
&lt;br /&gt;
The results indicate:&lt;br /&gt;
&lt;br /&gt;
* Mean peak RMS ≈ 0.1355  &lt;br /&gt;
* Standard deviation ≈ 0.0173  &lt;br /&gt;
* CV ≈ 12.77%  &lt;br /&gt;
* SNR ≈ 21.26 dB  &lt;br /&gt;
&lt;br /&gt;
This indicates acceptable repeatability and good signal quality.&lt;br /&gt;
&lt;br /&gt;
=== Representative Rest Signal Analysis ===&lt;br /&gt;
&lt;br /&gt;
[[File:Rest_Figure1.png|800px|center|Figure 3: Processed EMG signal under rest condition, showing low amplitude and absence of contraction patterns.]]&lt;br /&gt;
&lt;br /&gt;
Figure 3 shows the EMG signal under resting conditions.&lt;br /&gt;
&lt;br /&gt;
The signal remains within a narrow amplitude range (approximately ±0.04) and shows no burst-like structures. The envelope remains close to zero, confirming the absence of muscle activity.&lt;br /&gt;
&lt;br /&gt;
The extracted features remain low:&lt;br /&gt;
&lt;br /&gt;
* RMS ≈ 0.007  &lt;br /&gt;
* MAV ≈ 0.005  &lt;br /&gt;
* iEMG remains stable  &lt;br /&gt;
&lt;br /&gt;
This confirms that no false activation is detected.&lt;br /&gt;
&lt;br /&gt;
=== Frequency-domain Characteristics ===&lt;br /&gt;
&lt;br /&gt;
[[File:Rest_Figure2.png|800px|center|Figure 4: Frequency-domain analysis and statistical characteristics of rest signal.]]&lt;br /&gt;
&lt;br /&gt;
Figure 4 shows the frequency-domain characteristics of the resting signal.&lt;br /&gt;
&lt;br /&gt;
The power spectral density (PSD) indicates low overall signal energy without dominant peaks, confirming that the signal mainly consists of noise.&lt;br /&gt;
&lt;br /&gt;
=== Summary of Single-recording Performance ===&lt;br /&gt;
&lt;br /&gt;
From the representative results:&lt;br /&gt;
&lt;br /&gt;
* EMG signals are effectively extracted and denoised  &lt;br /&gt;
* Contraction events are clearly identifiable  &lt;br /&gt;
* Rest and contraction states are well separated  &lt;br /&gt;
* Automatic detection is stable and accurate  &lt;br /&gt;
* Repeatability is acceptable  &lt;br /&gt;
* No false activation occurs under rest conditions  &lt;br /&gt;
&lt;br /&gt;
=== Consistency Across Multiple Recordings ===&lt;br /&gt;
&lt;br /&gt;
The same data processing pipeline was applied to multiple recordings from different subjects and trials.&lt;br /&gt;
&lt;br /&gt;
Across all datasets, consistent patterns were observed:&lt;br /&gt;
&lt;br /&gt;
* Dynamic signals exhibit clear burst-like structures corresponding to repeated muscle contractions  &lt;br /&gt;
* Rest signals remain low in amplitude without distinct activation patterns  &lt;br /&gt;
* RMS values under contraction are consistently higher than those under rest  &lt;br /&gt;
* The automatic detection algorithm reliably identifies contraction segments  &lt;br /&gt;
&lt;br /&gt;
Although quantitative values (e.g., RMS, SNR, CV) vary across recordings due to differences in electrode contact, muscle activation strength, and individual conditions, the overall trends remain consistent.&lt;br /&gt;
&lt;br /&gt;
These results demonstrate the robustness and general applicability of the proposed signal processing method.&lt;br /&gt;
&lt;br /&gt;
== Multi-subject Analysis ==&lt;br /&gt;
=== System Evaluation ===&lt;br /&gt;
&lt;br /&gt;
This section evaluates the performance of the EMG acquisition system in terms of noise level, signal quality, activity discrimination, and repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Noise Floor Analysis ====&lt;br /&gt;
&lt;br /&gt;
The noise floor was evaluated using rest-state recordings, characterized by RMS noise, standard deviation, and peak-to-peak amplitude.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039; shows the lowest noise level (RMS ≈ 0.0046), indicating stable electrode contact and minimal interference.  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039; exhibits moderate noise (RMS ≈ 0.0080), likely influenced by motion artifacts or electrode–skin impedance variation.  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039; shows relatively higher noise (RMS ≈ 0.0126), suggesting increased baseline fluctuation.  &lt;br /&gt;
&lt;br /&gt;
Overall, the system maintains a low noise floor across subjects, although the quality depends on experimental conditions such as electrode contact and environmental interference.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Signal-to-Noise Ratio (SNR) ====&lt;br /&gt;
&lt;br /&gt;
The signal-to-noise ratio (SNR) is defined as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{SNR (dB)} = 20 \log_{10} \left( \frac{\mathrm{RMS}_{\mathrm{contraction}}}{\mathrm{RMS}_{\mathrm{rest}}} \right)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The measured SNR values are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: 21.26 dB → good signal quality  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: 13.52 dB → moderate and usable  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: 6.66 dB → low signal clarity  &lt;br /&gt;
&lt;br /&gt;
General interpretation:&lt;br /&gt;
&lt;br /&gt;
* &amp;gt;20 dB → good  &lt;br /&gt;
* 10–20 dB → usable  &lt;br /&gt;
* &amp;lt;10 dB → poor  &lt;br /&gt;
&lt;br /&gt;
These results show that the system can achieve reliable signal acquisition, although performance varies across subjects.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
====  Rest vs Contraction Discrimination ====&lt;br /&gt;
&lt;br /&gt;
A clear distinction between rest and contraction states is observed based on RMS values.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: 0.0053 → 0.1064 (≈20× increase)  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: 0.0079 → 0.0283 (≈3.6× increase)  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: 0.0141 → 0.0646 (≈4.6× increase)  &lt;br /&gt;
&lt;br /&gt;
This demonstrates that the system is capable of separating muscle activity from baseline noise.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Conclusion:&#039;&#039;  &lt;br /&gt;
The system can be used for basic muscle activity detection and simple classification tasks based on RMS features.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Repeatability of Repeated Contractions ====&lt;br /&gt;
&lt;br /&gt;
Repeatability is evaluated using the coefficient of variation (CV) of peak RMS values across repetitions.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! CV Range !! Evaluation&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt; 10% || Excellent&lt;br /&gt;
|-&lt;br /&gt;
| 10–20% || Acceptable&lt;br /&gt;
|-&lt;br /&gt;
| &amp;gt; 20% || Poor&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Results:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: CV = 12.77% → Acceptable  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: CV = 24.77% → Poor  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: CV = 10.60% → Acceptable  &lt;br /&gt;
&lt;br /&gt;
Although WANG&#039;s signal is detectable, its contraction amplitude varies significantly across repetitions, resulting in poor repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
=== Overall System Performance ===&lt;br /&gt;
&lt;br /&gt;
The system demonstrates the following performance characteristics:&lt;br /&gt;
&lt;br /&gt;
* Reliable detection of muscle activity across all subjects  &lt;br /&gt;
* Clear separation between rest and contraction states  &lt;br /&gt;
* Moderate to high signal quality depending on subject conditions  &lt;br /&gt;
* Repeatability ranging from acceptable to poor due to user-dependent factors  &lt;br /&gt;
&lt;br /&gt;
Overall, the designed EMG acquisition system is capable of stable signal acquisition and feature extraction, with performance primarily influenced by electrode contact quality, skin impedance, and motion consistency.&lt;br /&gt;
&lt;br /&gt;
===== Summary of Quantitative Metrics =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Subject !! RMS (Rest) !! RMS (Contraction) !! Separation Ratio !! iEMG (max) !! Noise RMS !! SNR (dB) !! CV (%) !! Evaluation&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;LIU&#039;&#039;&#039; || 0.0053 || 0.1064 || &#039;&#039;&#039;20.1×&#039;&#039;&#039; || 12.72 || 0.0046 || &#039;&#039;&#039;21.26&#039;&#039;&#039; || 12.77 || Strong signal, good quality&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;WANG&#039;&#039;&#039; || 0.0079 || 0.0283 || 3.57× || 11.10 || 0.0080 || 13.52 || &#039;&#039;&#039;24.77&#039;&#039;&#039; || Usable signal, poor repeatability&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ZHONG&#039;&#039;&#039; || 0.0141 || 0.0646 || 4.58× || 6.70 || 0.0126 || 6.66 || 10.60 || Acceptable performance&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Summary:&#039;&#039; Subject LIU shows the best overall performance, WANG provides usable but less stable signals, and ZHONG demonstrates moderate signal quality with good repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Activation Intensity =====&lt;br /&gt;
&lt;br /&gt;
Among the three subjects, &#039;&#039;&#039;LIU exhibits the strongest muscle activation&#039;&#039;&#039;, as indicated by the highest contraction RMS and iEMG values. ZHONG shows moderate activation, while WANG demonstrates comparable iEMG but lower RMS consistency.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Signal Quality =====&lt;br /&gt;
&lt;br /&gt;
Signal quality is evaluated based on SNR and noise level:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039; achieves the highest SNR and lowest noise → best signal quality  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039; shows moderate SNR → usable but less robust  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039; has the lowest SNR → weakest signal clarity  &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Repeatability =====&lt;br /&gt;
&lt;br /&gt;
Repeatability is evaluated using the coefficient of variation (CV):&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;ZHONG (10.60%)&#039;&#039;&#039; → most stable  &lt;br /&gt;
* &#039;&#039;&#039;LIU (12.77%)&#039;&#039;&#039; → acceptable  &lt;br /&gt;
* &#039;&#039;&#039;WANG (24.77%)&#039;&#039;&#039; → poor  &lt;br /&gt;
&lt;br /&gt;
This indicates that WANG’s contraction strength varies significantly between repetitions.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Engineering Interpretation of Inter-subject Differences =====&lt;br /&gt;
&lt;br /&gt;
The observed differences are mainly attributed to engineering and experimental factors rather than physiological differences.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Electrode contact quality&#039;&#039;&#039;  &lt;br /&gt;
  Variations in electrode placement, pressure, and gel contact affect signal amplitude and stability.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Skin impedance&#039;&#039;&#039;  &lt;br /&gt;
  Differences in skin condition (hydration, oil, hair) influence electrode–skin impedance, affecting noise level and signal coupling.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Muscle control consistency&#039;&#039;&#039;  &lt;br /&gt;
  Variations in contraction strength and timing affect repeatability and CV.&lt;br /&gt;
&lt;br /&gt;
Therefore, the variation across subjects reflects practical acquisition conditions rather than intrinsic system limitations.&lt;/div&gt;</summary>
		<author><name>Wang Jingyi</name></author>
	</entry>
	<entry>
		<id>https://pc5271.org/index.php?title=File:Rest_Figure2.png&amp;diff=1351</id>
		<title>File:Rest Figure2.png</title>
		<link rel="alternate" type="text/html" href="https://pc5271.org/index.php?title=File:Rest_Figure2.png&amp;diff=1351"/>
		<updated>2026-04-23T06:36:30Z</updated>

		<summary type="html">&lt;p&gt;Wang Jingyi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Wang Jingyi</name></author>
	</entry>
	<entry>
		<id>https://pc5271.org/index.php?title=File:Rest_Figure1.png&amp;diff=1350</id>
		<title>File:Rest Figure1.png</title>
		<link rel="alternate" type="text/html" href="https://pc5271.org/index.php?title=File:Rest_Figure1.png&amp;diff=1350"/>
		<updated>2026-04-23T06:36:02Z</updated>

		<summary type="html">&lt;p&gt;Wang Jingyi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Wang Jingyi</name></author>
	</entry>
	<entry>
		<id>https://pc5271.org/index.php?title=File:Dynamic_Figure2.png&amp;diff=1349</id>
		<title>File:Dynamic Figure2.png</title>
		<link rel="alternate" type="text/html" href="https://pc5271.org/index.php?title=File:Dynamic_Figure2.png&amp;diff=1349"/>
		<updated>2026-04-23T06:35:02Z</updated>

		<summary type="html">&lt;p&gt;Wang Jingyi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Wang Jingyi</name></author>
	</entry>
	<entry>
		<id>https://pc5271.org/index.php?title=File:Dynamic_Figure1.png&amp;diff=1346</id>
		<title>File:Dynamic Figure1.png</title>
		<link rel="alternate" type="text/html" href="https://pc5271.org/index.php?title=File:Dynamic_Figure1.png&amp;diff=1346"/>
		<updated>2026-04-23T06:32:19Z</updated>

		<summary type="html">&lt;p&gt;Wang Jingyi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Wang Jingyi</name></author>
	</entry>
	<entry>
		<id>https://pc5271.org/index.php?title=Surface_EMG_Sensor_for_Muscle_Activity_Measurement:_AFE_Design_and_Signal_Processing&amp;diff=1344</id>
		<title>Surface EMG Sensor for Muscle Activity Measurement: AFE Design and Signal Processing</title>
		<link rel="alternate" type="text/html" href="https://pc5271.org/index.php?title=Surface_EMG_Sensor_for_Muscle_Activity_Measurement:_AFE_Design_and_Signal_Processing&amp;diff=1344"/>
		<updated>2026-04-23T06:31:07Z</updated>

		<summary type="html">&lt;p&gt;Wang Jingyi: /* Experimental Results */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Background and Theory==&lt;br /&gt;
&lt;br /&gt;
=== Surface EMG Signals ===&lt;br /&gt;
Surface electromyography (sEMG) refers to the bioelectrical signals detected on the skin surface during muscle contraction. These signals originate from the electrical activity of muscle fibers and provide a non-invasive way to monitor muscle activation. Compared with invasive EMG methods, sEMG is easier to apply, safer for repeated measurements, and more suitable for real-time monitoring. Therefore, it has been widely used in areas such as rehabilitation, motion analysis, human–machine interaction, and physiological monitoring.&lt;br /&gt;
&lt;br /&gt;
=== Characteristics of EMG Signals ===&lt;br /&gt;
EMG signals are generally weak, time-varying, and stochastic in nature. Their waveforms are typically bipolar, fluctuating around zero with both positive and negative components. The amplitude and frequency content of EMG signals depend on factors such as muscle contraction level, electrode placement, skin condition, and individual physiological differences. In practice, the useful frequency components of sEMG are mainly concentrated in a limited low-to-mid frequency range. Because of their low amplitude and variability, EMG signals usually require further conditioning before reliable interpretation and feature extraction can be performed.&lt;br /&gt;
&lt;br /&gt;
=== Bioelectrical Signal Acquisition Principles ===&lt;br /&gt;
The acquisition of bioelectrical signals is based on measuring the small potential difference on the skin surface using electrodes, then converting it into a processable electrical signal through amplification and digitization. For sEMG measurement, electrode placement and skin–electrode contact quality are especially important, since they directly affect signal amplitude and stability. In addition, the front-end acquisition circuit must provide sufficient sensitivity and good interference rejection, so that the recorded signal reflects actual muscle activity rather than environmental disturbance or poor contact conditions.&lt;br /&gt;
&lt;br /&gt;
=== Noise Sources in EMG (50 Hz, motion artifacts) ===&lt;br /&gt;
In practical EMG recording, the measured signal is easily contaminated by different types of noise. Two of the most common sources are power-line interference and motion artifacts. Power-line interference usually appears as a narrow-band component at 50 Hz in the local electrical environment, while motion artifacts are mainly caused by electrode movement, cable disturbance, or variations in the electrode–skin impedance, and are often concentrated in the low-frequency range. In addition, electronic noise from the acquisition hardware may also affect the recording quality. These unwanted components can reduce signal clarity and make muscle activity analysis less reliable, so they must be considered in the design of the signal processing pipeline.&lt;br /&gt;
[[File:background_theory_figure1.1_emg_noise_sources.png|center|thumb|700px|&#039;&#039;&#039;Figure 1.1.&#039;&#039;&#039; Principle of surface EMG acquisition.]]&lt;br /&gt;
&lt;br /&gt;
==System Architecture==&lt;br /&gt;
=== Total Structure Design ===&lt;br /&gt;
&lt;br /&gt;
For clarity，the proposed physiological signal acquisition system mainly consists of two core parts：the analog front－end （AFE）and the ADC board．The AFE is responsible for the preliminary conditioning of weak bioelectrical signals，including amplification，filtering，interference suppression，and level shifting，so that the analog waveform can be converted into a stable and measurable form．The ADC board then performs high－resolution digitization of the conditioned signal and transfers the sampled data to the host computer for subsequent display，storage，and analysis．Therefore，the overall system forms a complete signal－acquisition chain from weak physiological input to digital output．&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_1.jpg|thumb|center|800px|Figure 2.1. Overall system architecture of the proposed physiological signal acquisition platform，including the AFE and ADC modules．]]&lt;br /&gt;
&lt;br /&gt;
=== sEMG AFE Design ===&lt;br /&gt;
&lt;br /&gt;
To collect the weak bioelectric potential signals of the human body，an analog front－end（AFE）suitable sEMG measurements was designed．The module is powered by an external 5 V supply，and the complete circuit includes a first－ stage instrumentation amplifier based on INA128（Texas Instruments，Dallas，TX，USA），a band－pass filter，a 50 Hz notch filter，a second－order amplification and level shifting stage，a driver electrode circuit，a precise 1.5 V reference source，and a -5 V voltage generation module for powering the operational amplifiers．&lt;br /&gt;
&lt;br /&gt;
==== First－order Amplifier ====&lt;br /&gt;
&lt;br /&gt;
The input bioelectric signal is first acquired in differential form and applied to the INA128 instrumentation amplifier，which provides high input impedance，high common－mode rejection，and moderate initial gain for sEMG acquisition．This stage enlarges the weak physiological signal before filtering while reducing the risk of premature saturation caused by electrode offset or motion－induced disturbance，thereby preparing a more stable signal for the subsequent conditioning stages．&lt;br /&gt;
&lt;br /&gt;
==== Bandpass Filter ====&lt;br /&gt;
&lt;br /&gt;
After the instrumentation amplifier，the signal passes through a second－order active band－pass filter，as shown in Figure 2．2． This stage suppresses baseline drift and high－frequency noise outside the useful sEMG range，so that the low－frequency envelope information of sEMG can be preserved before further amplification．&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_2.jpg|thumb|center|800px|Figure 2.2. Schematic diagram of the active band-pass filter used in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the band-pass stage used to retain the main physiological signal band while suppressing unwanted lowand high-frequency components.&lt;br /&gt;
&lt;br /&gt;
==== Notch Filter ====&lt;br /&gt;
&lt;br /&gt;
To reduce power-line interference, a dedicated 50 Hz notch filter is introduced after the band-pass stage, as shown in Figure 2.3. This filter attenuates the mains-frequency component that commonly contaminates weak bioelectric measurements, thereby improving the signal-to-noise ratio of sEMG signals before the final amplification stage.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_3.jpg|thumb|center|800px|Figure 2.3. Schematic diagram of the 50 Hz notch filter used in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the circuit used to attenuate 50 Hz mains interference in the analog front end.&lt;br /&gt;
&lt;br /&gt;
==== Second-order Amplifier &amp;amp; Level Shifter ====&lt;br /&gt;
&lt;br /&gt;
After filtering, the signal enters the second-stage amplification and level-shifting circuit shown in Figure 2.4. In this stage, the filtered signal is further amplified to improve amplitude utilization and then shifted by a 1.5 V reference so that the output becomes a stable unipolar signal suitable for ADC sampling, while preserving linear operation and providing sufficient output swing margin.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_4.jpg|thumb|center|800px|Figure 2.4. Schematic diagram of the second-stage amplifier and level-shifting circuit in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows how the conditioned signal is further amplified and shifted to a suitable DC level before digitization.&lt;br /&gt;
&lt;br /&gt;
==== Power Module and Drive-electrode Circuit ====&lt;br /&gt;
&lt;br /&gt;
The AFE is powered by a 5 V supply and also integrates a 1.5 V precision reference, a -5 V generation circuit, and a driveelectrode circuit. These supporting modules provide the required supply rails and reference level for analog signal conditioning, while the drive-electrode circuit feeds back common-mode voltage to the body to suppress interference at the source. As a result, the complete AFE can support sEMG acquisition with adequate gain, filtering, and noise-reduction performance in a compact hardware structure.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_5.jpg|thumb|center|800px|Figure 2.5. Physical picture of the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the fabricated sEMG analog front-end hardware used in the system.&lt;br /&gt;
&lt;br /&gt;
Figure 2.5 presents the practical hardware implementation of the proposed sEMG AFE. It integrates amplification, filtering, level shifting, and driven-reference functions in a compact circuit for weak bioelectrical signal acquisition.&lt;br /&gt;
&lt;br /&gt;
=== ADS1256-based ADC Board ===&lt;br /&gt;
&lt;br /&gt;
To digitize the conditioned weak physiological signals with sufficient resolution and low noise, this project developed a dedicated ADC board based on the ADS1256 analog-to-digital converter (Texas Instruments, Dallas, TX, USA) and the STM32F103C8T6 microcontroller (STMicroelectronics, Geneva, Switzerland). The overall design objective of this board was not merely to realize analog-to-digital conversion, but to provide a complete hardware interface between the analog front-end and the digital processing unit, including precision reference generation, clocking, input protection and filtering, serial communication, power regulation, and MCU-based acquisition control. The ADS1256 was selected because it is a&lt;br /&gt;
&lt;br /&gt;
very low-noise 24-bit delta-sigma converter with a programmable gain amplifier (PGA), flexible input multiplexer, programmable digital filter, and SPI-compatible serial interface, which makes it well suited for weak low-frequency physiological signals after analog conditioning. The STM32F103C8T6 was used as the local controller because it provides a 32-bit Cortex-M3 core, up to 72 MHz system clock, SPI, USART, USB, and standard SWD debugging support in a compact and low-cost platform.&lt;br /&gt;
&lt;br /&gt;
==== ADC Core Architecture and Design Rationale ====&lt;br /&gt;
&lt;br /&gt;
The ADS1256 was selected as the core ADC because it provides high-resolution, low-noise delta-sigma conversion with an input multiplexer, programmable gain amplifier, and digital filter, which are suitable for weak and low-frequency physiological signals. As shown in Figure 2.6, this architecture emphasizes resolution and noise performance rather than high conversion bandwidth, making it appropriate for sEMG signal digitization after analog conditioning.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_6.jpg|thumb|center|800px|Figure 2.6. Internal functional structure of the ADS1256 analog-to-digital converter.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the main internal blocks of the ADS1256, including the multiplexer, PGA, modulator, and digital filter.&lt;br /&gt;
&lt;br /&gt;
==== Analog Front-End Interface, Reference, and Clocking ====&lt;br /&gt;
&lt;br /&gt;
The ADS1256 analog inputs are connected to the external header through a passive input-conditioning network that helps suppress high-frequency interference and improve input stability. In addition, the board includes a dedicated precision reference and clocking circuits so that the ADC can perform stable and accurate conversion. Together, these circuits provide a reliable analog interface and timing basis for high-resolution digitization of weak physiological signals.&lt;br /&gt;
&lt;br /&gt;
==== SPI Interface between ADS1256 and STM32F103C8T6 ====&lt;br /&gt;
&lt;br /&gt;
Communication between the ADS1256 and the STM32F103C8T6 is implemented through an SPI-compatible interface, with dedicated lines for chip select, serial clock, input/output data, data-ready notification, and hardware reset. This connection allows the MCU to configure the ADC, read conversion results in synchrony with DRDY, and maintain efficient and reliable acquisition control for multi-channel physiological measurements.&lt;br /&gt;
&lt;br /&gt;
==== Power Supply and On-board Regulation ====&lt;br /&gt;
&lt;br /&gt;
The ADC board uses a USB Type-B connector as the main power input and includes protection, voltage regulation, and local decoupling circuits to provide a stable supply for both the MCU and ADC-related hardware. In addition, analog ground and digital ground are separated in the PCB layout to reduce digital noise coupling into the analog path, which is particularly important for weak physiological signal acquisition.&lt;br /&gt;
&lt;br /&gt;
==== Basic Peripheral Circuits of the STM32F103C8T6 ====&lt;br /&gt;
&lt;br /&gt;
The STM32F103C8T6 serves as the local controller of the ADC board and is supported by several basic peripheral circuits, including an external crystal oscillator, reset network, BOOT0 configuration, SWD programming/debugging header, and a CH340N USB-to-UART bridge. These circuits ensure stable MCU operation, convenient firmware downloading and debugging, and reliable data transmission from the board to the host computer for real-time display and storage.&lt;br /&gt;
&lt;br /&gt;
==== Hardware-level Working Principle of the ADC Board ====&lt;br /&gt;
&lt;br /&gt;
In operation, the conditioned analog signal from the AFE enters the ADS1256 through the input header, is digitized with high resolution under the control of the local precision reference and clock, and is then read by the STM32 through the SPI interface. The MCU subsequently forwards the sampled data to the host computer through the serial communication link, so that the entire board functions as a compact digital acquisition backend connecting weak physiological analog signals to later software processing, display, and storage.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_7.jpg|thumb|center|800px|Figure 2.7. Photograph of the fabricated ADS1256-based ADC board developed in this project and the definitions of some key pins.]]&lt;br /&gt;
&lt;br /&gt;
Figure 2.7 shows the ADC board fabricated for this project. It integrates the ADS1256 conversion core, STM32 control circuit, power-conditioning circuits, and communication interfaces on a compact PCB for physiological signal digitization.&lt;br /&gt;
&lt;br /&gt;
== Signal Conditioning and Filtering ==&lt;br /&gt;
Although the AFE already performs preliminary band-pass filtering and 50 Hz interference suppression in the analog domain, the digitized sEMG signal may still contain residual noise due to component tolerances, electrode-contact variation, and environmental interference. Therefore, an additional digital filtering stage is implemented in software as a complementary post-processing step to improve signal quality and to provide a more stable input for rectification, envelope extraction, and subsequent analysis. In this sense, the software filtering is not a simple repetition of the analog filtering, but a refinement and compensation for non-ideal front-end behavior.&lt;br /&gt;
&lt;br /&gt;
Surface electromyographic (sEMG) signals are highly susceptible to several sources of contamination during acquisition. In practical measurements, the dominant disturbances usually include low-frequency motion artifacts caused by electrode movement and electrode–skin impedance variation, narrow-band power-line interference centered at 50 Hz, and broadband high-frequency electronic noise introduced by the acquisition hardware. These unwanted components degrade the quality of the recorded signal and may significantly affect the reliability of subsequent feature extraction, parameter estimation, and muscle activity interpretation. For this reason, an effective signal-conditioning procedure is necessary before any higher-level analysis is performed.&lt;br /&gt;
&lt;br /&gt;
In the present implementation, the filtering strategy follows the principle of restricting the signal bandwidth first and then removing the remaining narrow-band interference in a targeted manner. Accordingly, the raw sEMG signal is first processed by a fourth-order Butterworth IIR band-pass filter and then by a 50 Hz notch filter. This processing sequence is illustrated in the flowchart below, where the signal passes through band-pass filtering, notch filtering, full-wave rectification, and envelope extraction before producing the final processed output.&lt;br /&gt;
&lt;br /&gt;
[[File:flowchart.png|thumb|center|500px|Flowchart of the real-time sEMG signal conditioning pipeline.]]&lt;br /&gt;
&lt;br /&gt;
The rationale of this order is that the &#039;&#039;&#039;band-pass stage&#039;&#039;&#039; first confines the signal to the main spectral region of interest for sEMG, thereby attenuating motion artifacts at very low frequencies and suppressing high-frequency noise components outside the physiological band. After this spectral preconditioning, the notch stage can more effectively suppress the residual 50 Hz power-line interference that lies inside the useful sEMG band. In transfer-function form, the band-pass filter may be written as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;H_{BP}(z)=\frac{B_{BP}(z)}{A_{BP}(z)}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where the effective passband is selected as &amp;lt;math&amp;gt;20 \leq f \leq 160 \text{ Hz}&amp;lt;/math&amp;gt;. This frequency interval is consistent with the dominant spectral content of surface EMG: the lower cutoff near 20 Hz reduces motion artifacts and unstable low-frequency fluctuations, whereas the upper cutoff near 160 Hz removes high-frequency electronic noise while preserving the main energy-bearing components of the muscle signal. The use of a Butterworth structure is appropriate here because it provides a smooth monotonic passband response without ripple, which helps preserve signal morphology in real-time applications.&lt;br /&gt;
&lt;br /&gt;
After band limitation, a &#039;&#039;&#039;notch filter&#039;&#039;&#039; centered at the power-line frequency is applied to suppress interference that cannot be removed by the band-pass stage alone. The notch filter is designed around &amp;lt;math&amp;gt;f_0 = 50 \text{ Hz}&amp;lt;/math&amp;gt;, and its bandwidth is controlled by the quality factor &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;, which is expressed as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;Q = \frac{f_0}{\Delta f}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In transfer-function form, the notch stage is written as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;H_{N}(z)=\frac{B_{N}(z)}{A_{N}(z)}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the implemented program, a large quality factor is chosen so that the notch remains narrow, allowing effective rejection of the 50 Hz interference while minimizing distortion of neighboring useful spectral components. This is particularly important for sEMG because the interference frequency lies directly inside the physiological band of interest.&lt;br /&gt;
&lt;br /&gt;
Following the filtering stages, further signal conditioning is performed to obtain a representation that is more directly related to muscle activation intensity. The filtered sEMG waveform is first &#039;&#039;&#039;full-wave rectified&#039;&#039;&#039;, which converts the bipolar oscillatory signal into a unipolar signal by taking its absolute value.  Rectification does not remove noise by itself; instead, it transforms the signal into a form that is more suitable for amplitude-based analysis because both positive and negative deflections contribute positively to the activation measure.&lt;br /&gt;
&lt;br /&gt;
After rectification, the signal envelope is extracted to provide a smooth estimate of muscle activation level over time. In a general formulation, the envelope can be described as the &#039;&#039;&#039;low-pass filtered&#039;&#039;&#039; version of the rectified signal, namely &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y_{\mathrm{env}}[n] = \mathrm{LPF}\bigl(y_{\mathrm{rect}}[n]\bigr)&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the present code implementation, this operation is realized by short-time averaging over a finite window, which is equivalent to a moving-average low-pass smoothing of the rectified waveform. The corresponding expression is &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y_{\mathrm{env}}[n] = \frac{1}{N}\sum_{k=0}^{N-1} |x[n-k]|&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; is the window length in samples. With a window duration of approximately 200 ms, this envelope extraction method provides a stable and physiologically meaningful representation of muscle activation intensity, making it suitable for tasks such as force estimation, fatigue analysis, and motor-control studies.&lt;br /&gt;
&lt;br /&gt;
An important feature of the present &#039;&#039;&#039;implementation&#039;&#039;&#039; is that the entire filtering process is performed &#039;&#039;&#039;in real time&#039;&#039;&#039;, sample by sample, rather than by offline block processing. For this reason, IIR filters are preferred over FIR filters, since they can achieve comparable filtering performance with lower order, lower computational cost, and shorter delay. These properties are especially valuable in embedded systems, serial data streaming, and other low-latency experimental applications. However, unlike memoryless operations, an IIR filter depends not only on the current input but also on previous inputs and previous outputs. Its discrete-time behavior can therefore be represented by the recursive difference equation &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y[n] = \sum_{k=0}^{M} b_k x[n-k] - \sum_{k=1}^{N} a_k y[n-k]&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This equation makes clear that internal filter states must be preserved continuously during streaming operation. If the state variables were reinitialized for every incoming sample or data segment, artificial transients would appear and the output would no longer remain continuous.&lt;br /&gt;
&lt;br /&gt;
In the Python implementation, this state continuity is maintained using the internal initial-condition mechanism provided by SciPy, such as &amp;lt;code&amp;gt;lfilter_zi&amp;lt;/code&amp;gt;, together with recursive state updates during each filtering call. As a result, each newly acquired sample is passed first through the band-pass filter and then through the notch filter, while the internal states of both filters are updated after every step. This state-preserving sample-by-sample design ensures that the processing chain remains causal, continuous, and suitable for real-time display or downstream analysis without requiring storage of the entire signal segment.&lt;br /&gt;
&lt;br /&gt;
Overall, this signal-conditioning scheme provides an experimentally practical solution for real-time sEMG processing. The fourth-order Butterworth band-pass filter confines the signal to the main physiological band of interest, the 50 Hz notch filter removes narrow-band power-line contamination, and the subsequent rectification and envelope extraction generate a smooth amplitude descriptor of muscle activity. Combined with state-preserved streaming IIR implementation, this approach achieves a good balance between signal fidelity, computational efficiency, and real-time applicability in biomedical and physical experiment settings.&lt;br /&gt;
&lt;br /&gt;
== Data Processing ==&lt;br /&gt;
&lt;br /&gt;
The objective of data processing is to convert raw surface electromyography (sEMG) recordings into stable, quantitative, and comparable indicators of muscle activity. Since EMG signals are low in amplitude, highly variable over time, and easily contaminated by noise, a dedicated processing pipeline is necessary before any experimental interpretation can be performed.&lt;br /&gt;
&lt;br /&gt;
In this project, the data processing workflow includes time normalization, signal pre-processing, sliding-window feature extraction, noise-floor estimation, and automatic contraction detection. The processed outputs are then used for subsequent experimental evaluation, including rest-versus-contraction discrimination, signal-to-noise ratio analysis, and repeatability assessment.&lt;br /&gt;
&lt;br /&gt;
=== Input Data and Time Normalization ===&lt;br /&gt;
&lt;br /&gt;
The acquired EMG data are read from CSV files containing two columns: time and filtered sEMG amplitude. In the MATLAB implementation, the time vector is normalized so that each recording starts from zero:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t = t_{all} - t_{all}(1)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This normalization is important because it removes the influence of absolute recording timestamps and makes different trials directly comparable on the same time axis.&lt;br /&gt;
&lt;br /&gt;
In addition, the signal type is automatically identified from the filename as either dynamic or rest. This design allows the same program to process both contraction recordings and resting recordings with different downstream analysis logic.&lt;br /&gt;
&lt;br /&gt;
=== Signal Pre-processing ===&lt;br /&gt;
&lt;br /&gt;
Raw EMG signals cannot be analyzed directly because they usually contain DC offset, low-frequency drift, motion artifacts, and residual high-frequency interference. Therefore, several pre-processing steps are applied before feature extraction.&lt;br /&gt;
&lt;br /&gt;
==== Baseline Removal ====&lt;br /&gt;
&lt;br /&gt;
The first step is DC offset removal:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
x_{dc}(t) = x(t) - \frac{1}{N}\sum_{i=1}^{N}x(i)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This operation centers the signal around zero. It is necessary because an uncorrected baseline would bias amplitude-based metrics and reduce the reliability of later envelope and feature calculations.&lt;br /&gt;
&lt;br /&gt;
==== Band-pass Filtering ====&lt;br /&gt;
&lt;br /&gt;
After baseline correction, a fourth-order Butterworth band-pass filter is applied with a passband of 20–150 Hz.&lt;br /&gt;
&lt;br /&gt;
This step is introduced for two reasons:&lt;br /&gt;
&lt;br /&gt;
* The low-frequency cutoff at 20 Hz suppresses baseline drift and motion artifacts.&lt;br /&gt;
* The high-frequency cutoff at 150 Hz reduces unwanted high-frequency noise while preserving the main energy band of the recorded sEMG in this project.&lt;br /&gt;
&lt;br /&gt;
Compared with processing the raw waveform directly, band-pass filtering makes the subsequent time-domain features more stable and more physiologically meaningful.&lt;br /&gt;
&lt;br /&gt;
==== Full-wave Rectification ====&lt;br /&gt;
&lt;br /&gt;
The filtered EMG signal is bipolar, meaning that positive and negative phases coexist due to motor unit action potentials. If these positive and negative components are averaged directly, they may cancel each other out. To avoid this, full-wave rectification is performed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
x_{rect}(t) = |x_{filt}(t)|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This transforms the signal into a unipolar representation, so that all muscle activity contributes positively to the extracted features.&lt;br /&gt;
&lt;br /&gt;
==== Envelope Extraction ====&lt;br /&gt;
&lt;br /&gt;
Although the rectified signal reflects signal magnitude, it still fluctuates rapidly. To obtain a smoother representation of muscle activation level, an envelope is extracted using a moving average with a 100 ms window.&lt;br /&gt;
&lt;br /&gt;
Envelope extraction is important because contraction detection should reflect the overall activation trend rather than instantaneous spikes. A smoothed envelope is therefore more robust for identifying active and inactive muscle states.&lt;br /&gt;
&lt;br /&gt;
=== Sliding Window Design ===&lt;br /&gt;
&lt;br /&gt;
To quantify how muscle activity changes with time, the filtered signal is divided into overlapping short-time segments using a sliding window method.&lt;br /&gt;
&lt;br /&gt;
The window parameters are:&lt;br /&gt;
&lt;br /&gt;
* Window length: 250 ms&lt;br /&gt;
* Step size: 50 ms&lt;br /&gt;
&lt;br /&gt;
These values are chosen as a trade-off between temporal resolution and feature stability.&lt;br /&gt;
&lt;br /&gt;
A longer window improves statistical robustness because more samples are included in each calculation. However, if the window is too long, short contractions or rapid changes may be blurred. A smaller step size increases temporal continuity between adjacent feature points and makes the feature curves smoother in time. Therefore, the 250 ms / 50 ms design provides a practical balance between smoothing and time localization.&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt;-th segment, the feature time is defined as the mean time of that segment:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t_k = \frac{1}{N}\sum_{i=s_k}^{e_k} t(i)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;s_k&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;e_k&amp;lt;/math&amp;gt; denote the start and end indices of the window.&lt;br /&gt;
&lt;br /&gt;
=== Feature Extraction ===&lt;br /&gt;
&lt;br /&gt;
Within each sliding window, three time-domain features are extracted: RMS, iEMG, and MAV. These features are widely used in EMG analysis because they are simple, computationally efficient, and directly related to muscle activation intensity.&lt;br /&gt;
&lt;br /&gt;
==== Root Mean Square (RMS) ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
RMS = \sqrt{\frac{1}{N}\sum_{i=1}^{N}x_i^2}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
RMS reflects the effective power of the EMG signal and is one of the most common indicators of contraction strength. It is sensitive to both amplitude and energy, making it especially useful for comparing rest and active states.&lt;br /&gt;
&lt;br /&gt;
==== Integrated EMG (iEMG) ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
iEMG = \sum_{i=1}^{N}|x_i|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
iEMG describes the cumulative electrical activity within a window. It is often interpreted as a measure of total muscle effort over that time segment.&lt;br /&gt;
&lt;br /&gt;
==== Mean Absolute Value (MAV) ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
MAV = \frac{1}{N}\sum_{i=1}^{N}|x_i|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
MAV is an amplitude descriptor similar to iEMG, but normalized by the number of samples. It provides an efficient estimate of average signal level and is less computationally intensive than some other features.&lt;br /&gt;
&lt;br /&gt;
These three features are used together because they provide complementary descriptions of EMG intensity. RMS emphasizes signal energy, iEMG emphasizes cumulative activation, and MAV reflects average amplitude.&lt;br /&gt;
&lt;br /&gt;
=== Peak-value Extraction ===&lt;br /&gt;
&lt;br /&gt;
In addition to continuous feature curves, several key peak values are extracted from the processed signal:&lt;br /&gt;
&lt;br /&gt;
* maximum and minimum of the filtered EMG waveform&lt;br /&gt;
* peak of the envelope&lt;br /&gt;
* peak RMS&lt;br /&gt;
* peak iEMG&lt;br /&gt;
* peak MAV&lt;br /&gt;
&lt;br /&gt;
These peak values provide concise descriptors of the strongest activity observed in each recording. They are useful for quick comparison across trials and subjects.&lt;br /&gt;
&lt;br /&gt;
=== Noise Floor Estimation ===&lt;br /&gt;
&lt;br /&gt;
To evaluate signal quality, the noise floor is estimated from a reference resting interval. In the present implementation, the first 3 seconds of the recording are used as the default rest reference:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t \in [0,\min(3,t_{end})]&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this segment, three noise descriptors are computed:&lt;br /&gt;
&lt;br /&gt;
* Noise RMS&lt;br /&gt;
* Noise standard deviation&lt;br /&gt;
* Noise peak-to-peak amplitude&lt;br /&gt;
&lt;br /&gt;
Noise-floor estimation is important because EMG amplitude alone is not sufficient to judge recording quality. A large signal is only meaningful if it is sufficiently higher than the baseline noise level. Therefore, the noise floor serves as the reference for later SNR calculation and for designing contraction thresholds.&lt;br /&gt;
&lt;br /&gt;
=== Global Signal Metrics ===&lt;br /&gt;
&lt;br /&gt;
For each recording, three global metrics are also computed over the entire filtered signal:&lt;br /&gt;
&lt;br /&gt;
* Global RMS&lt;br /&gt;
* Global MAV&lt;br /&gt;
* Global iEMG&lt;br /&gt;
&lt;br /&gt;
These global descriptors summarize the overall signal level of the full recording and are later used in group-level comparisons.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Contraction Detection ===&lt;br /&gt;
&lt;br /&gt;
For dynamic recordings, an automatic contraction detection algorithm is used to identify repeated active segments. This is one of the key parts of the data processing pipeline, because it transforms a continuous EMG trace into discrete contraction events that can be counted and compared.&lt;br /&gt;
&lt;br /&gt;
==== Threshold Design ====&lt;br /&gt;
&lt;br /&gt;
The detection threshold is designed adaptively rather than using a fixed value. Two candidate thresholds are first calculated:&lt;br /&gt;
&lt;br /&gt;
* an envelope-based threshold derived from the global envelope mean and standard deviation&lt;br /&gt;
* a rest-reference threshold derived from the mean and standard deviation of the resting reference amplitude&lt;br /&gt;
&lt;br /&gt;
The final threshold is taken as the larger of the two after additional scaling. This strategy improves robustness because it combines the global activation level of the signal with the baseline noise characteristics of the individual recording.&lt;br /&gt;
&lt;br /&gt;
This adaptive threshold design is preferable to a manually fixed threshold because EMG amplitude can vary strongly between subjects, muscles, and recording sessions.&lt;br /&gt;
&lt;br /&gt;
==== Initial Segmentation ====&lt;br /&gt;
&lt;br /&gt;
After thresholding the envelope, the signal is classified into active and inactive regions:&lt;br /&gt;
&lt;br /&gt;
* active: envelope above threshold&lt;br /&gt;
* inactive: envelope below threshold&lt;br /&gt;
&lt;br /&gt;
The rising and falling edges of the binary activity vector are then used to determine the start and end points of each candidate contraction segment.&lt;br /&gt;
&lt;br /&gt;
==== Removal of Short Segments ====&lt;br /&gt;
&lt;br /&gt;
Very short active regions are often caused by noise fluctuations rather than true muscle contractions. Therefore, segments shorter than 0.20 s are discarded.&lt;br /&gt;
&lt;br /&gt;
This step prevents false positive detections and increases the physiological relevance of the segmentation results.&lt;br /&gt;
&lt;br /&gt;
==== Merging of Adjacent Segments ====&lt;br /&gt;
&lt;br /&gt;
If two neighboring active segments are separated by a very short gap, they are merged when the gap is less than 0.15 s.&lt;br /&gt;
&lt;br /&gt;
This operation is necessary because a single real contraction may be temporarily interrupted by a brief drop in the envelope caused by local fluctuation. Without merging, one contraction could be incorrectly counted as multiple repetitions.&lt;br /&gt;
&lt;br /&gt;
==== Repetition-level Metrics ====&lt;br /&gt;
&lt;br /&gt;
For each detected contraction segment, two repetition-level metrics are extracted:&lt;br /&gt;
&lt;br /&gt;
* peak RMS of that contraction&lt;br /&gt;
* mean RMS of that contraction&lt;br /&gt;
&lt;br /&gt;
These metrics quantify both the strongest activation within each repetition and the average activation level over the repetition duration.&lt;br /&gt;
&lt;br /&gt;
=== Repeatability Analysis ===&lt;br /&gt;
&lt;br /&gt;
When multiple valid contractions are detected, repeatability is evaluated using the coefficient of variation (CV):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
CV = \frac{\sigma}{\mu}\times 100\%&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt; is the standard deviation and &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is the mean value across repetitions.&lt;br /&gt;
&lt;br /&gt;
Two CV values are computed:&lt;br /&gt;
&lt;br /&gt;
* CV of repetition peak RMS&lt;br /&gt;
* CV of repetition mean RMS&lt;br /&gt;
&lt;br /&gt;
A lower CV indicates better repeatability, meaning that repeated contractions produce more consistent EMG responses.&lt;br /&gt;
&lt;br /&gt;
=== Signal-to-Noise Ratio (SNR) ===&lt;br /&gt;
&lt;br /&gt;
In this project, the signal-to-noise ratio (SNR) is defined based on the ratio between contraction and rest activity:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
SNR_{dB} = 20\log_{10}\left(\frac{RMS_{contraction}}{RMS_{rest}}\right)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This definition is adopted because it directly reflects the system’s ability to distinguish active muscle contraction from baseline noise.&lt;br /&gt;
&lt;br /&gt;
Compared with global SNR definitions, this formulation is more relevant for practical EMG applications such as activity detection and classification.&lt;br /&gt;
&lt;br /&gt;
=== Rest-versus-Contraction Window Comparison ===&lt;br /&gt;
&lt;br /&gt;
To further distinguish inactive and active states, all sliding windows are divided into two groups:&lt;br /&gt;
&lt;br /&gt;
* rest windows: windows with envelope clearly below the threshold&lt;br /&gt;
* contraction windows: windows with envelope above the threshold&lt;br /&gt;
&lt;br /&gt;
The RMS values of these two groups are then compared statistically.&lt;br /&gt;
&lt;br /&gt;
This comparison is important because a practical EMG system should not only detect signal presence, but also clearly separate rest from contraction in a quantitative way. If the two RMS distributions are well separated, it indicates that the system has good discriminative capability.&lt;br /&gt;
&lt;br /&gt;
=== Output Data Structure ===&lt;br /&gt;
&lt;br /&gt;
The processed outputs are organized into structured data for experimental analysis:&lt;br /&gt;
&lt;br /&gt;
==== Time-series outputs ====&lt;br /&gt;
* Filtered EMG signal  &lt;br /&gt;
* Rectified signal  &lt;br /&gt;
* Envelope  &lt;br /&gt;
* RMS(t), iEMG(t), MAV(t)  &lt;br /&gt;
&lt;br /&gt;
==== Recording-level outputs ====&lt;br /&gt;
* RMS (rest)  &lt;br /&gt;
* RMS (contraction)  &lt;br /&gt;
* iEMG  &lt;br /&gt;
* Noise metrics  &lt;br /&gt;
&lt;br /&gt;
==== Dynamic-signal outputs ====&lt;br /&gt;
* Detected contractions  &lt;br /&gt;
* Repetition count  &lt;br /&gt;
* Peak RMS per repetition  &lt;br /&gt;
* Mean RMS per repetition  &lt;br /&gt;
* Coefficient of variation (CV)  &lt;br /&gt;
* Signal-to-noise ratio (SNR)  &lt;br /&gt;
&lt;br /&gt;
All extracted features are designed to directly support the evaluation of noise level, signal quality, activity discrimination, and repeatability in the subsequent experimental analysis.&lt;br /&gt;
&lt;br /&gt;
== Experimental Results ==&lt;br /&gt;
&lt;br /&gt;
This section presents representative results of the EMG acquisition and data processing pipeline under both dynamic (muscle contraction) and resting conditions.&lt;br /&gt;
&lt;br /&gt;
=== Representative Dynamic Signal Analysis ===&lt;br /&gt;
&lt;br /&gt;
[[File:Dynamic_Figure1.png|800px|center|Figure 1: Processed EMG signal under dynamic contraction, including filtered signal, rectified signal with envelope, and extracted features (RMS, iEMG, MAV).]]&lt;br /&gt;
&lt;br /&gt;
Figure 1 shows the processed EMG signal during repeated muscle contractions.&lt;br /&gt;
&lt;br /&gt;
The filtered EMG waveform exhibits clear burst-like patterns corresponding to periodic contractions. The signal amplitude reaches a maximum of approximately 0.45, while the baseline remains centered around zero, indicating effective baseline removal and filtering.&lt;br /&gt;
&lt;br /&gt;
After rectification and envelope extraction, the contraction periods become clearly distinguishable. The envelope provides a smooth representation of muscle activation, with a peak value of approximately 0.145.&lt;br /&gt;
&lt;br /&gt;
The extracted time-domain features (RMS, iEMG, MAV) further quantify the signal. Among these, iEMG shows the strongest dynamic variation, indicating high sensitivity to contraction intensity.&lt;br /&gt;
&lt;br /&gt;
=== Noise Floor and Rest Reference ===&lt;br /&gt;
&lt;br /&gt;
[[File:Dynamic_Figure2.png|800px|center|Figure 2: Noise estimation, rest vs contraction comparison, automatic contraction detection, and repetition analysis.]]&lt;br /&gt;
&lt;br /&gt;
Figure 2 (top-left) shows the resting reference segment used for noise estimation.&lt;br /&gt;
&lt;br /&gt;
The signal remains centered around zero with small fluctuations. The noise characteristics are:&lt;br /&gt;
&lt;br /&gt;
* Noise RMS ≈ 0.0046  &lt;br /&gt;
* Standard deviation ≈ 0.0046  &lt;br /&gt;
* Peak-to-peak amplitude ≈ 0.071  &lt;br /&gt;
&lt;br /&gt;
This indicates a low noise floor and stable measurement conditions.&lt;br /&gt;
&lt;br /&gt;
=== Rest vs Contraction Discrimination ===&lt;br /&gt;
&lt;br /&gt;
Figure 2 (top-right) compares RMS values between rest and contraction states.&lt;br /&gt;
&lt;br /&gt;
The two distributions are clearly separated:&lt;br /&gt;
&lt;br /&gt;
* Rest mean RMS ≈ 0.0053  &lt;br /&gt;
* Contraction mean RMS ≈ 0.1064  &lt;br /&gt;
&lt;br /&gt;
This corresponds to an approximate 20× increase, demonstrating strong discriminability between inactive and active muscle states.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Contraction Detection ===&lt;br /&gt;
&lt;br /&gt;
Figure 2 (bottom-left) illustrates automatic detection based on the envelope signal.&lt;br /&gt;
&lt;br /&gt;
A threshold of approximately 0.040 is applied, resulting in stable segmentation of contraction periods.&lt;br /&gt;
&lt;br /&gt;
A total of 12 repetitions are detected, with good alignment to visible signal peaks.&lt;br /&gt;
&lt;br /&gt;
=== Repeatability Analysis ===&lt;br /&gt;
&lt;br /&gt;
Figure 2 (bottom-right) shows the peak RMS value of each detected contraction.&lt;br /&gt;
&lt;br /&gt;
The results indicate:&lt;br /&gt;
&lt;br /&gt;
* Mean peak RMS ≈ 0.1355  &lt;br /&gt;
* Standard deviation ≈ 0.0173  &lt;br /&gt;
* CV ≈ 12.77%  &lt;br /&gt;
* SNR ≈ 21.26 dB  &lt;br /&gt;
&lt;br /&gt;
This indicates acceptable repeatability and good signal quality.&lt;br /&gt;
&lt;br /&gt;
=== Representative Rest Signal Analysis ===&lt;br /&gt;
&lt;br /&gt;
[[File:Rest_Figure1.png|800px|center|Figure 3: Processed EMG signal under rest condition, showing low amplitude and absence of contraction patterns.]]&lt;br /&gt;
&lt;br /&gt;
Figure 3 shows the EMG signal under resting conditions.&lt;br /&gt;
&lt;br /&gt;
The signal remains within a narrow amplitude range (approximately ±0.04) and shows no burst-like structures. The envelope remains close to zero, confirming the absence of muscle activity.&lt;br /&gt;
&lt;br /&gt;
The extracted features remain low:&lt;br /&gt;
&lt;br /&gt;
* RMS ≈ 0.007  &lt;br /&gt;
* MAV ≈ 0.005  &lt;br /&gt;
* iEMG remains stable  &lt;br /&gt;
&lt;br /&gt;
This confirms that no false activation is detected.&lt;br /&gt;
&lt;br /&gt;
=== Frequency-domain Characteristics ===&lt;br /&gt;
&lt;br /&gt;
[[File:Rest_Figure2.png|800px|center|Figure 4: Frequency-domain analysis and statistical characteristics of rest signal.]]&lt;br /&gt;
&lt;br /&gt;
Figure 4 shows the frequency-domain characteristics of the resting signal.&lt;br /&gt;
&lt;br /&gt;
The power spectral density (PSD) indicates low overall signal energy without dominant peaks, confirming that the signal mainly consists of noise.&lt;br /&gt;
&lt;br /&gt;
=== Summary of Single-recording Performance ===&lt;br /&gt;
&lt;br /&gt;
From the representative results:&lt;br /&gt;
&lt;br /&gt;
* EMG signals are effectively extracted and denoised  &lt;br /&gt;
* Contraction events are clearly identifiable  &lt;br /&gt;
* Rest and contraction states are well separated  &lt;br /&gt;
* Automatic detection is stable and accurate  &lt;br /&gt;
* Repeatability is acceptable  &lt;br /&gt;
* No false activation occurs under rest conditions  &lt;br /&gt;
&lt;br /&gt;
=== Consistency Across Multiple Recordings ===&lt;br /&gt;
&lt;br /&gt;
The same data processing pipeline was applied to multiple recordings from different subjects and trials.&lt;br /&gt;
&lt;br /&gt;
Across all datasets, consistent patterns were observed:&lt;br /&gt;
&lt;br /&gt;
* Dynamic signals exhibit clear burst-like structures corresponding to repeated muscle contractions  &lt;br /&gt;
* Rest signals remain low in amplitude without distinct activation patterns  &lt;br /&gt;
* RMS values under contraction are consistently higher than those under rest  &lt;br /&gt;
* The automatic detection algorithm reliably identifies contraction segments  &lt;br /&gt;
&lt;br /&gt;
Although quantitative values (e.g., RMS, SNR, CV) vary across recordings due to differences in electrode contact, muscle activation strength, and individual conditions, the overall trends remain consistent.&lt;br /&gt;
&lt;br /&gt;
These results demonstrate the robustness and general applicability of the proposed signal processing method.&lt;br /&gt;
&lt;br /&gt;
== Multi-subject Analysis ==&lt;br /&gt;
=== System Evaluation ===&lt;br /&gt;
&lt;br /&gt;
This section evaluates the performance of the EMG acquisition system in terms of noise level, signal quality, activity discrimination, and repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Noise Floor Analysis ====&lt;br /&gt;
&lt;br /&gt;
The noise floor was evaluated using rest-state recordings, characterized by RMS noise, standard deviation, and peak-to-peak amplitude.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039; shows the lowest noise level (RMS ≈ 0.0046), indicating stable electrode contact and minimal interference.  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039; exhibits moderate noise (RMS ≈ 0.0080), likely influenced by motion artifacts or electrode–skin impedance variation.  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039; shows relatively higher noise (RMS ≈ 0.0126), suggesting increased baseline fluctuation.  &lt;br /&gt;
&lt;br /&gt;
Overall, the system maintains a low noise floor across subjects, although the quality depends on experimental conditions such as electrode contact and environmental interference.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Signal-to-Noise Ratio (SNR) ====&lt;br /&gt;
&lt;br /&gt;
The signal-to-noise ratio (SNR) is defined as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{SNR (dB)} = 20 \log_{10} \left( \frac{\mathrm{RMS}_{\mathrm{contraction}}}{\mathrm{RMS}_{\mathrm{rest}}} \right)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The measured SNR values are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: 21.26 dB → good signal quality  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: 13.52 dB → moderate and usable  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: 6.66 dB → low signal clarity  &lt;br /&gt;
&lt;br /&gt;
General interpretation:&lt;br /&gt;
&lt;br /&gt;
* &amp;gt;20 dB → good  &lt;br /&gt;
* 10–20 dB → usable  &lt;br /&gt;
* &amp;lt;10 dB → poor  &lt;br /&gt;
&lt;br /&gt;
These results show that the system can achieve reliable signal acquisition, although performance varies across subjects.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
====  Rest vs Contraction Discrimination ====&lt;br /&gt;
&lt;br /&gt;
A clear distinction between rest and contraction states is observed based on RMS values.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: 0.0053 → 0.1064 (≈20× increase)  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: 0.0079 → 0.0283 (≈3.6× increase)  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: 0.0141 → 0.0646 (≈4.6× increase)  &lt;br /&gt;
&lt;br /&gt;
This demonstrates that the system is capable of separating muscle activity from baseline noise.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Conclusion:&#039;&#039;  &lt;br /&gt;
The system can be used for basic muscle activity detection and simple classification tasks based on RMS features.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Repeatability of Repeated Contractions ====&lt;br /&gt;
&lt;br /&gt;
Repeatability is evaluated using the coefficient of variation (CV) of peak RMS values across repetitions.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! CV Range !! Evaluation&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt; 10% || Excellent&lt;br /&gt;
|-&lt;br /&gt;
| 10–20% || Acceptable&lt;br /&gt;
|-&lt;br /&gt;
| &amp;gt; 20% || Poor&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Results:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: CV = 12.77% → Acceptable  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: CV = 24.77% → Poor  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: CV = 10.60% → Acceptable  &lt;br /&gt;
&lt;br /&gt;
Although WANG&#039;s signal is detectable, its contraction amplitude varies significantly across repetitions, resulting in poor repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
=== Overall System Performance ===&lt;br /&gt;
&lt;br /&gt;
The system demonstrates the following performance characteristics:&lt;br /&gt;
&lt;br /&gt;
* Reliable detection of muscle activity across all subjects  &lt;br /&gt;
* Clear separation between rest and contraction states  &lt;br /&gt;
* Moderate to high signal quality depending on subject conditions  &lt;br /&gt;
* Repeatability ranging from acceptable to poor due to user-dependent factors  &lt;br /&gt;
&lt;br /&gt;
Overall, the designed EMG acquisition system is capable of stable signal acquisition and feature extraction, with performance primarily influenced by electrode contact quality, skin impedance, and motion consistency.&lt;br /&gt;
&lt;br /&gt;
===== Summary of Quantitative Metrics =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Subject !! RMS (Rest) !! RMS (Contraction) !! Separation Ratio !! iEMG (max) !! Noise RMS !! SNR (dB) !! CV (%) !! Evaluation&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;LIU&#039;&#039;&#039; || 0.0053 || 0.1064 || &#039;&#039;&#039;20.1×&#039;&#039;&#039; || 12.72 || 0.0046 || &#039;&#039;&#039;21.26&#039;&#039;&#039; || 12.77 || Strong signal, good quality&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;WANG&#039;&#039;&#039; || 0.0079 || 0.0283 || 3.57× || 11.10 || 0.0080 || 13.52 || &#039;&#039;&#039;24.77&#039;&#039;&#039; || Usable signal, poor repeatability&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ZHONG&#039;&#039;&#039; || 0.0141 || 0.0646 || 4.58× || 6.70 || 0.0126 || 6.66 || 10.60 || Acceptable performance&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Summary:&#039;&#039; Subject LIU shows the best overall performance, WANG provides usable but less stable signals, and ZHONG demonstrates moderate signal quality with good repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Activation Intensity =====&lt;br /&gt;
&lt;br /&gt;
Among the three subjects, &#039;&#039;&#039;LIU exhibits the strongest muscle activation&#039;&#039;&#039;, as indicated by the highest contraction RMS and iEMG values. ZHONG shows moderate activation, while WANG demonstrates comparable iEMG but lower RMS consistency.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Signal Quality =====&lt;br /&gt;
&lt;br /&gt;
Signal quality is evaluated based on SNR and noise level:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039; achieves the highest SNR and lowest noise → best signal quality  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039; shows moderate SNR → usable but less robust  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039; has the lowest SNR → weakest signal clarity  &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Repeatability =====&lt;br /&gt;
&lt;br /&gt;
Repeatability is evaluated using the coefficient of variation (CV):&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;ZHONG (10.60%)&#039;&#039;&#039; → most stable  &lt;br /&gt;
* &#039;&#039;&#039;LIU (12.77%)&#039;&#039;&#039; → acceptable  &lt;br /&gt;
* &#039;&#039;&#039;WANG (24.77%)&#039;&#039;&#039; → poor  &lt;br /&gt;
&lt;br /&gt;
This indicates that WANG’s contraction strength varies significantly between repetitions.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Engineering Interpretation of Inter-subject Differences =====&lt;br /&gt;
&lt;br /&gt;
The observed differences are mainly attributed to engineering and experimental factors rather than physiological differences.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Electrode contact quality&#039;&#039;&#039;  &lt;br /&gt;
  Variations in electrode placement, pressure, and gel contact affect signal amplitude and stability.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Skin impedance&#039;&#039;&#039;  &lt;br /&gt;
  Differences in skin condition (hydration, oil, hair) influence electrode–skin impedance, affecting noise level and signal coupling.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Muscle control consistency&#039;&#039;&#039;  &lt;br /&gt;
  Variations in contraction strength and timing affect repeatability and CV.&lt;br /&gt;
&lt;br /&gt;
Therefore, the variation across subjects reflects practical acquisition conditions rather than intrinsic system limitations.&lt;/div&gt;</summary>
		<author><name>Wang Jingyi</name></author>
	</entry>
	<entry>
		<id>https://pc5271.org/index.php?title=Surface_EMG_Sensor_for_Muscle_Activity_Measurement:_AFE_Design_and_Signal_Processing&amp;diff=1335</id>
		<title>Surface EMG Sensor for Muscle Activity Measurement: AFE Design and Signal Processing</title>
		<link rel="alternate" type="text/html" href="https://pc5271.org/index.php?title=Surface_EMG_Sensor_for_Muscle_Activity_Measurement:_AFE_Design_and_Signal_Processing&amp;diff=1335"/>
		<updated>2026-04-23T06:17:47Z</updated>

		<summary type="html">&lt;p&gt;Wang Jingyi: /* Data processing and analysis */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Background and Theory==&lt;br /&gt;
&lt;br /&gt;
=== Surface EMG Signals ===&lt;br /&gt;
Surface electromyography (sEMG) refers to the bioelectrical signals detected on the skin surface during muscle contraction. These signals originate from the electrical activity of muscle fibers and provide a non-invasive way to monitor muscle activation. Compared with invasive EMG methods, sEMG is easier to apply, safer for repeated measurements, and more suitable for real-time monitoring. Therefore, it has been widely used in areas such as rehabilitation, motion analysis, human–machine interaction, and physiological monitoring.&lt;br /&gt;
&lt;br /&gt;
=== Characteristics of EMG Signals ===&lt;br /&gt;
EMG signals are generally weak, time-varying, and stochastic in nature. Their waveforms are typically bipolar, fluctuating around zero with both positive and negative components. The amplitude and frequency content of EMG signals depend on factors such as muscle contraction level, electrode placement, skin condition, and individual physiological differences. In practice, the useful frequency components of sEMG are mainly concentrated in a limited low-to-mid frequency range. Because of their low amplitude and variability, EMG signals usually require further conditioning before reliable interpretation and feature extraction can be performed.&lt;br /&gt;
&lt;br /&gt;
=== Bioelectrical Signal Acquisition Principles ===&lt;br /&gt;
The acquisition of bioelectrical signals is based on measuring the small potential difference on the skin surface using electrodes, then converting it into a processable electrical signal through amplification and digitization. For sEMG measurement, electrode placement and skin–electrode contact quality are especially important, since they directly affect signal amplitude and stability. In addition, the front-end acquisition circuit must provide sufficient sensitivity and good interference rejection, so that the recorded signal reflects actual muscle activity rather than environmental disturbance or poor contact conditions.&lt;br /&gt;
&lt;br /&gt;
=== Noise Sources in EMG (50 Hz, motion artifacts) ===&lt;br /&gt;
In practical EMG recording, the measured signal is easily contaminated by different types of noise. Two of the most common sources are power-line interference and motion artifacts. Power-line interference usually appears as a narrow-band component at 50 Hz in the local electrical environment, while motion artifacts are mainly caused by electrode movement, cable disturbance, or variations in the electrode–skin impedance, and are often concentrated in the low-frequency range. In addition, electronic noise from the acquisition hardware may also affect the recording quality. These unwanted components can reduce signal clarity and make muscle activity analysis less reliable, so they must be considered in the design of the signal processing pipeline.&lt;br /&gt;
[[File:background_theory_figure1.1_emg_noise_sources.png|center|thumb|700px|&#039;&#039;&#039;Figure 1.1.&#039;&#039;&#039; Principle of surface EMG acquisition.]]&lt;br /&gt;
&lt;br /&gt;
==System Architecture==&lt;br /&gt;
=== Total Structure Design ===&lt;br /&gt;
&lt;br /&gt;
For clarity，the proposed physiological signal acquisition system mainly consists of two core parts：the analog front－end （AFE）and the ADC board．The AFE is responsible for the preliminary conditioning of weak bioelectrical signals，including amplification，filtering，interference suppression，and level shifting，so that the analog waveform can be converted into a stable and measurable form．The ADC board then performs high－resolution digitization of the conditioned signal and transfers the sampled data to the host computer for subsequent display，storage，and analysis．Therefore，the overall system forms a complete signal－acquisition chain from weak physiological input to digital output．&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_1.jpg|thumb|center|800px|Figure 2.1. Overall system architecture of the proposed physiological signal acquisition platform，including the AFE and ADC modules．]]&lt;br /&gt;
&lt;br /&gt;
=== sEMG AFE Design ===&lt;br /&gt;
&lt;br /&gt;
To collect the weak bioelectric potential signals of the human body，an analog front－end（AFE）suitable sEMG measurements was designed．The module is powered by an external 5 V supply，and the complete circuit includes a first－ stage instrumentation amplifier based on INA128（Texas Instruments，Dallas，TX，USA），a band－pass filter，a 50 Hz notch filter，a second－order amplification and level shifting stage，a driver electrode circuit，a precise 1.5 V reference source，and a -5 V voltage generation module for powering the operational amplifiers．&lt;br /&gt;
&lt;br /&gt;
==== First－order Amplifier ====&lt;br /&gt;
&lt;br /&gt;
The input bioelectric signal is first acquired in differential form and applied to the INA128 instrumentation amplifier，which provides high input impedance，high common－mode rejection，and moderate initial gain for sEMG acquisition．This stage enlarges the weak physiological signal before filtering while reducing the risk of premature saturation caused by electrode offset or motion－induced disturbance，thereby preparing a more stable signal for the subsequent conditioning stages．&lt;br /&gt;
&lt;br /&gt;
==== Bandpass Filter ====&lt;br /&gt;
&lt;br /&gt;
After the instrumentation amplifier，the signal passes through a second－order active band－pass filter，as shown in Figure 2．2． This stage suppresses baseline drift and high－frequency noise outside the useful sEMG range，so that the low－frequency envelope information of sEMG can be preserved before further amplification．&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_2.jpg|thumb|center|800px|Figure 2.2. Schematic diagram of the active band-pass filter used in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the band-pass stage used to retain the main physiological signal band while suppressing unwanted lowand high-frequency components.&lt;br /&gt;
&lt;br /&gt;
==== Notch Filter ====&lt;br /&gt;
&lt;br /&gt;
To reduce power-line interference, a dedicated 50 Hz notch filter is introduced after the band-pass stage, as shown in Figure 2.3. This filter attenuates the mains-frequency component that commonly contaminates weak bioelectric measurements, thereby improving the signal-to-noise ratio of sEMG signals before the final amplification stage.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_3.jpg|thumb|center|800px|Figure 2.3. Schematic diagram of the 50 Hz notch filter used in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the circuit used to attenuate 50 Hz mains interference in the analog front end.&lt;br /&gt;
&lt;br /&gt;
==== Second-order Amplifier &amp;amp; Level Shifter ====&lt;br /&gt;
&lt;br /&gt;
After filtering, the signal enters the second-stage amplification and level-shifting circuit shown in Figure 2.4. In this stage, the filtered signal is further amplified to improve amplitude utilization and then shifted by a 1.5 V reference so that the output becomes a stable unipolar signal suitable for ADC sampling, while preserving linear operation and providing sufficient output swing margin.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_4.jpg|thumb|center|800px|Figure 2.4. Schematic diagram of the second-stage amplifier and level-shifting circuit in the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows how the conditioned signal is further amplified and shifted to a suitable DC level before digitization.&lt;br /&gt;
&lt;br /&gt;
==== Power Module and Drive-electrode Circuit ====&lt;br /&gt;
&lt;br /&gt;
The AFE is powered by a 5 V supply and also integrates a 1.5 V precision reference, a -5 V generation circuit, and a driveelectrode circuit. These supporting modules provide the required supply rails and reference level for analog signal conditioning, while the drive-electrode circuit feeds back common-mode voltage to the body to suppress interference at the source. As a result, the complete AFE can support sEMG acquisition with adequate gain, filtering, and noise-reduction performance in a compact hardware structure.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_5.jpg|thumb|center|800px|Figure 2.5. Physical picture of the sEMG AFE.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the fabricated sEMG analog front-end hardware used in the system.&lt;br /&gt;
&lt;br /&gt;
Figure 2.5 presents the practical hardware implementation of the proposed sEMG AFE. It integrates amplification, filtering, level shifting, and driven-reference functions in a compact circuit for weak bioelectrical signal acquisition.&lt;br /&gt;
&lt;br /&gt;
=== ADS1256-based ADC Board ===&lt;br /&gt;
&lt;br /&gt;
To digitize the conditioned weak physiological signals with sufficient resolution and low noise, this project developed a dedicated ADC board based on the ADS1256 analog-to-digital converter (Texas Instruments, Dallas, TX, USA) and the STM32F103C8T6 microcontroller (STMicroelectronics, Geneva, Switzerland). The overall design objective of this board was not merely to realize analog-to-digital conversion, but to provide a complete hardware interface between the analog front-end and the digital processing unit, including precision reference generation, clocking, input protection and filtering, serial communication, power regulation, and MCU-based acquisition control. The ADS1256 was selected because it is a&lt;br /&gt;
&lt;br /&gt;
very low-noise 24-bit delta-sigma converter with a programmable gain amplifier (PGA), flexible input multiplexer, programmable digital filter, and SPI-compatible serial interface, which makes it well suited for weak low-frequency physiological signals after analog conditioning. The STM32F103C8T6 was used as the local controller because it provides a 32-bit Cortex-M3 core, up to 72 MHz system clock, SPI, USART, USB, and standard SWD debugging support in a compact and low-cost platform.&lt;br /&gt;
&lt;br /&gt;
==== ADC Core Architecture and Design Rationale ====&lt;br /&gt;
&lt;br /&gt;
The ADS1256 was selected as the core ADC because it provides high-resolution, low-noise delta-sigma conversion with an input multiplexer, programmable gain amplifier, and digital filter, which are suitable for weak and low-frequency physiological signals. As shown in Figure 2.6, this architecture emphasizes resolution and noise performance rather than high conversion bandwidth, making it appropriate for sEMG signal digitization after analog conditioning.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_6.jpg|thumb|center|800px|Figure 2.6. Internal functional structure of the ADS1256 analog-to-digital converter.]]&lt;br /&gt;
&lt;br /&gt;
This figure shows the main internal blocks of the ADS1256, including the multiplexer, PGA, modulator, and digital filter.&lt;br /&gt;
&lt;br /&gt;
==== Analog Front-End Interface, Reference, and Clocking ====&lt;br /&gt;
&lt;br /&gt;
The ADS1256 analog inputs are connected to the external header through a passive input-conditioning network that helps suppress high-frequency interference and improve input stability. In addition, the board includes a dedicated precision reference and clocking circuits so that the ADC can perform stable and accurate conversion. Together, these circuits provide a reliable analog interface and timing basis for high-resolution digitization of weak physiological signals.&lt;br /&gt;
&lt;br /&gt;
==== SPI Interface between ADS1256 and STM32F103C8T6 ====&lt;br /&gt;
&lt;br /&gt;
Communication between the ADS1256 and the STM32F103C8T6 is implemented through an SPI-compatible interface, with dedicated lines for chip select, serial clock, input/output data, data-ready notification, and hardware reset. This connection allows the MCU to configure the ADC, read conversion results in synchrony with DRDY, and maintain efficient and reliable acquisition control for multi-channel physiological measurements.&lt;br /&gt;
&lt;br /&gt;
==== Power Supply and On-board Regulation ====&lt;br /&gt;
&lt;br /&gt;
The ADC board uses a USB Type-B connector as the main power input and includes protection, voltage regulation, and local decoupling circuits to provide a stable supply for both the MCU and ADC-related hardware. In addition, analog ground and digital ground are separated in the PCB layout to reduce digital noise coupling into the analog path, which is particularly important for weak physiological signal acquisition.&lt;br /&gt;
&lt;br /&gt;
==== Basic Peripheral Circuits of the STM32F103C8T6 ====&lt;br /&gt;
&lt;br /&gt;
The STM32F103C8T6 serves as the local controller of the ADC board and is supported by several basic peripheral circuits, including an external crystal oscillator, reset network, BOOT0 configuration, SWD programming/debugging header, and a CH340N USB-to-UART bridge. These circuits ensure stable MCU operation, convenient firmware downloading and debugging, and reliable data transmission from the board to the host computer for real-time display and storage.&lt;br /&gt;
&lt;br /&gt;
==== Hardware-level Working Principle of the ADC Board ====&lt;br /&gt;
&lt;br /&gt;
In operation, the conditioned analog signal from the AFE enters the ADS1256 through the input header, is digitized with high resolution under the control of the local precision reference and clock, and is then read by the STM32 through the SPI interface. The MCU subsequently forwards the sampled data to the host computer through the serial communication link, so that the entire board functions as a compact digital acquisition backend connecting weak physiological analog signals to later software processing, display, and storage.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure_2_7.jpg|thumb|center|800px|Figure 2.7. Photograph of the fabricated ADS1256-based ADC board developed in this project and the definitions of some key pins.]]&lt;br /&gt;
&lt;br /&gt;
Figure 2.7 shows the ADC board fabricated for this project. It integrates the ADS1256 conversion core, STM32 control circuit, power-conditioning circuits, and communication interfaces on a compact PCB for physiological signal digitization.&lt;br /&gt;
&lt;br /&gt;
== Signal Conditioning and Filtering ==&lt;br /&gt;
Although the AFE already performs preliminary band-pass filtering and 50 Hz interference suppression in the analog domain, the digitized sEMG signal may still contain residual noise due to component tolerances, electrode-contact variation, and environmental interference. Therefore, an additional digital filtering stage is implemented in software as a complementary post-processing step to improve signal quality and to provide a more stable input for rectification, envelope extraction, and subsequent analysis. In this sense, the software filtering is not a simple repetition of the analog filtering, but a refinement and compensation for non-ideal front-end behavior.&lt;br /&gt;
&lt;br /&gt;
Surface electromyographic (sEMG) signals are highly susceptible to several sources of contamination during acquisition. In practical measurements, the dominant disturbances usually include low-frequency motion artifacts caused by electrode movement and electrode–skin impedance variation, narrow-band power-line interference centered at 50 Hz, and broadband high-frequency electronic noise introduced by the acquisition hardware. These unwanted components degrade the quality of the recorded signal and may significantly affect the reliability of subsequent feature extraction, parameter estimation, and muscle activity interpretation. For this reason, an effective signal-conditioning procedure is necessary before any higher-level analysis is performed.&lt;br /&gt;
&lt;br /&gt;
In the present implementation, the filtering strategy follows the principle of restricting the signal bandwidth first and then removing the remaining narrow-band interference in a targeted manner. Accordingly, the raw sEMG signal is first processed by a fourth-order Butterworth IIR band-pass filter and then by a 50 Hz notch filter. This processing sequence is illustrated in the flowchart below, where the signal passes through band-pass filtering, notch filtering, full-wave rectification, and envelope extraction before producing the final processed output.&lt;br /&gt;
&lt;br /&gt;
[[File:flowchart.png|thumb|center|500px|Flowchart of the real-time sEMG signal conditioning pipeline.]]&lt;br /&gt;
&lt;br /&gt;
The rationale of this order is that the &#039;&#039;&#039;band-pass stage&#039;&#039;&#039; first confines the signal to the main spectral region of interest for sEMG, thereby attenuating motion artifacts at very low frequencies and suppressing high-frequency noise components outside the physiological band. After this spectral preconditioning, the notch stage can more effectively suppress the residual 50 Hz power-line interference that lies inside the useful sEMG band. In transfer-function form, the band-pass filter may be written as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;H_{BP}(z)=\frac{B_{BP}(z)}{A_{BP}(z)}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where the effective passband is selected as &amp;lt;math&amp;gt;20 \leq f \leq 160 \text{ Hz}&amp;lt;/math&amp;gt;. This frequency interval is consistent with the dominant spectral content of surface EMG: the lower cutoff near 20 Hz reduces motion artifacts and unstable low-frequency fluctuations, whereas the upper cutoff near 160 Hz removes high-frequency electronic noise while preserving the main energy-bearing components of the muscle signal. The use of a Butterworth structure is appropriate here because it provides a smooth monotonic passband response without ripple, which helps preserve signal morphology in real-time applications.&lt;br /&gt;
&lt;br /&gt;
After band limitation, a &#039;&#039;&#039;notch filter&#039;&#039;&#039; centered at the power-line frequency is applied to suppress interference that cannot be removed by the band-pass stage alone. The notch filter is designed around &amp;lt;math&amp;gt;f_0 = 50 \text{ Hz}&amp;lt;/math&amp;gt;, and its bandwidth is controlled by the quality factor &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt;, which is expressed as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;Q = \frac{f_0}{\Delta f}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In transfer-function form, the notch stage is written as &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;H_{N}(z)=\frac{B_{N}(z)}{A_{N}(z)}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the implemented program, a large quality factor is chosen so that the notch remains narrow, allowing effective rejection of the 50 Hz interference while minimizing distortion of neighboring useful spectral components. This is particularly important for sEMG because the interference frequency lies directly inside the physiological band of interest.&lt;br /&gt;
&lt;br /&gt;
Following the filtering stages, further signal conditioning is performed to obtain a representation that is more directly related to muscle activation intensity. The filtered sEMG waveform is first &#039;&#039;&#039;full-wave rectified&#039;&#039;&#039;, which converts the bipolar oscillatory signal into a unipolar signal by taking its absolute value.  Rectification does not remove noise by itself; instead, it transforms the signal into a form that is more suitable for amplitude-based analysis because both positive and negative deflections contribute positively to the activation measure.&lt;br /&gt;
&lt;br /&gt;
After rectification, the signal envelope is extracted to provide a smooth estimate of muscle activation level over time. In a general formulation, the envelope can be described as the &#039;&#039;&#039;low-pass filtered&#039;&#039;&#039; version of the rectified signal, namely &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y_{\mathrm{env}}[n] = \mathrm{LPF}\bigl(y_{\mathrm{rect}}[n]\bigr)&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the present code implementation, this operation is realized by short-time averaging over a finite window, which is equivalent to a moving-average low-pass smoothing of the rectified waveform. The corresponding expression is &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y_{\mathrm{env}}[n] = \frac{1}{N}\sum_{k=0}^{N-1} |x[n-k]|&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; is the window length in samples. With a window duration of approximately 200 ms, this envelope extraction method provides a stable and physiologically meaningful representation of muscle activation intensity, making it suitable for tasks such as force estimation, fatigue analysis, and motor-control studies.&lt;br /&gt;
&lt;br /&gt;
An important feature of the present &#039;&#039;&#039;implementation&#039;&#039;&#039; is that the entire filtering process is performed &#039;&#039;&#039;in real time&#039;&#039;&#039;, sample by sample, rather than by offline block processing. For this reason, IIR filters are preferred over FIR filters, since they can achieve comparable filtering performance with lower order, lower computational cost, and shorter delay. These properties are especially valuable in embedded systems, serial data streaming, and other low-latency experimental applications. However, unlike memoryless operations, an IIR filter depends not only on the current input but also on previous inputs and previous outputs. Its discrete-time behavior can therefore be represented by the recursive difference equation &lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;y[n] = \sum_{k=0}^{M} b_k x[n-k] - \sum_{k=1}^{N} a_k y[n-k]&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This equation makes clear that internal filter states must be preserved continuously during streaming operation. If the state variables were reinitialized for every incoming sample or data segment, artificial transients would appear and the output would no longer remain continuous.&lt;br /&gt;
&lt;br /&gt;
In the Python implementation, this state continuity is maintained using the internal initial-condition mechanism provided by SciPy, such as &amp;lt;code&amp;gt;lfilter_zi&amp;lt;/code&amp;gt;, together with recursive state updates during each filtering call. As a result, each newly acquired sample is passed first through the band-pass filter and then through the notch filter, while the internal states of both filters are updated after every step. This state-preserving sample-by-sample design ensures that the processing chain remains causal, continuous, and suitable for real-time display or downstream analysis without requiring storage of the entire signal segment.&lt;br /&gt;
&lt;br /&gt;
Overall, this signal-conditioning scheme provides an experimentally practical solution for real-time sEMG processing. The fourth-order Butterworth band-pass filter confines the signal to the main physiological band of interest, the 50 Hz notch filter removes narrow-band power-line contamination, and the subsequent rectification and envelope extraction generate a smooth amplitude descriptor of muscle activity. Combined with state-preserved streaming IIR implementation, this approach achieves a good balance between signal fidelity, computational efficiency, and real-time applicability in biomedical and physical experiment settings.&lt;br /&gt;
&lt;br /&gt;
== Data Processing ==&lt;br /&gt;
&lt;br /&gt;
The objective of data processing is to convert raw surface electromyography (sEMG) recordings into stable, quantitative, and comparable indicators of muscle activity. Since EMG signals are low in amplitude, highly variable over time, and easily contaminated by noise, a dedicated processing pipeline is necessary before any experimental interpretation can be performed.&lt;br /&gt;
&lt;br /&gt;
In this project, the data processing workflow includes time normalization, signal pre-processing, sliding-window feature extraction, noise-floor estimation, and automatic contraction detection. The processed outputs are then used for subsequent experimental evaluation, including rest-versus-contraction discrimination, signal-to-noise ratio analysis, and repeatability assessment.&lt;br /&gt;
&lt;br /&gt;
=== Input Data and Time Normalization ===&lt;br /&gt;
&lt;br /&gt;
The acquired EMG data are read from CSV files containing two columns: time and filtered sEMG amplitude. In the MATLAB implementation, the time vector is normalized so that each recording starts from zero:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t = t_{all} - t_{all}(1)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This normalization is important because it removes the influence of absolute recording timestamps and makes different trials directly comparable on the same time axis.&lt;br /&gt;
&lt;br /&gt;
In addition, the signal type is automatically identified from the filename as either dynamic or rest. This design allows the same program to process both contraction recordings and resting recordings with different downstream analysis logic.&lt;br /&gt;
&lt;br /&gt;
=== Signal Pre-processing ===&lt;br /&gt;
&lt;br /&gt;
Raw EMG signals cannot be analyzed directly because they usually contain DC offset, low-frequency drift, motion artifacts, and residual high-frequency interference. Therefore, several pre-processing steps are applied before feature extraction.&lt;br /&gt;
&lt;br /&gt;
==== Baseline Removal ====&lt;br /&gt;
&lt;br /&gt;
The first step is DC offset removal:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
x_{dc}(t) = x(t) - \frac{1}{N}\sum_{i=1}^{N}x(i)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This operation centers the signal around zero. It is necessary because an uncorrected baseline would bias amplitude-based metrics and reduce the reliability of later envelope and feature calculations.&lt;br /&gt;
&lt;br /&gt;
==== Band-pass Filtering ====&lt;br /&gt;
&lt;br /&gt;
After baseline correction, a fourth-order Butterworth band-pass filter is applied with a passband of 20–150 Hz.&lt;br /&gt;
&lt;br /&gt;
This step is introduced for two reasons:&lt;br /&gt;
&lt;br /&gt;
* The low-frequency cutoff at 20 Hz suppresses baseline drift and motion artifacts.&lt;br /&gt;
* The high-frequency cutoff at 150 Hz reduces unwanted high-frequency noise while preserving the main energy band of the recorded sEMG in this project.&lt;br /&gt;
&lt;br /&gt;
Compared with processing the raw waveform directly, band-pass filtering makes the subsequent time-domain features more stable and more physiologically meaningful.&lt;br /&gt;
&lt;br /&gt;
==== Full-wave Rectification ====&lt;br /&gt;
&lt;br /&gt;
The filtered EMG signal is bipolar, meaning that positive and negative phases coexist due to motor unit action potentials. If these positive and negative components are averaged directly, they may cancel each other out. To avoid this, full-wave rectification is performed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
x_{rect}(t) = |x_{filt}(t)|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This transforms the signal into a unipolar representation, so that all muscle activity contributes positively to the extracted features.&lt;br /&gt;
&lt;br /&gt;
==== Envelope Extraction ====&lt;br /&gt;
&lt;br /&gt;
Although the rectified signal reflects signal magnitude, it still fluctuates rapidly. To obtain a smoother representation of muscle activation level, an envelope is extracted using a moving average with a 100 ms window.&lt;br /&gt;
&lt;br /&gt;
Envelope extraction is important because contraction detection should reflect the overall activation trend rather than instantaneous spikes. A smoothed envelope is therefore more robust for identifying active and inactive muscle states.&lt;br /&gt;
&lt;br /&gt;
=== Sliding Window Design ===&lt;br /&gt;
&lt;br /&gt;
To quantify how muscle activity changes with time, the filtered signal is divided into overlapping short-time segments using a sliding window method.&lt;br /&gt;
&lt;br /&gt;
The window parameters are:&lt;br /&gt;
&lt;br /&gt;
* Window length: 250 ms&lt;br /&gt;
* Step size: 50 ms&lt;br /&gt;
&lt;br /&gt;
These values are chosen as a trade-off between temporal resolution and feature stability.&lt;br /&gt;
&lt;br /&gt;
A longer window improves statistical robustness because more samples are included in each calculation. However, if the window is too long, short contractions or rapid changes may be blurred. A smaller step size increases temporal continuity between adjacent feature points and makes the feature curves smoother in time. Therefore, the 250 ms / 50 ms design provides a practical balance between smoothing and time localization.&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt;-th segment, the feature time is defined as the mean time of that segment:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t_k = \frac{1}{N}\sum_{i=s_k}^{e_k} t(i)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;s_k&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;e_k&amp;lt;/math&amp;gt; denote the start and end indices of the window.&lt;br /&gt;
&lt;br /&gt;
=== Feature Extraction ===&lt;br /&gt;
&lt;br /&gt;
Within each sliding window, three time-domain features are extracted: RMS, iEMG, and MAV. These features are widely used in EMG analysis because they are simple, computationally efficient, and directly related to muscle activation intensity.&lt;br /&gt;
&lt;br /&gt;
==== Root Mean Square (RMS) ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
RMS = \sqrt{\frac{1}{N}\sum_{i=1}^{N}x_i^2}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
RMS reflects the effective power of the EMG signal and is one of the most common indicators of contraction strength. It is sensitive to both amplitude and energy, making it especially useful for comparing rest and active states.&lt;br /&gt;
&lt;br /&gt;
==== Integrated EMG (iEMG) ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
iEMG = \sum_{i=1}^{N}|x_i|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
iEMG describes the cumulative electrical activity within a window. It is often interpreted as a measure of total muscle effort over that time segment.&lt;br /&gt;
&lt;br /&gt;
==== Mean Absolute Value (MAV) ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
MAV = \frac{1}{N}\sum_{i=1}^{N}|x_i|&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
MAV is an amplitude descriptor similar to iEMG, but normalized by the number of samples. It provides an efficient estimate of average signal level and is less computationally intensive than some other features.&lt;br /&gt;
&lt;br /&gt;
These three features are used together because they provide complementary descriptions of EMG intensity. RMS emphasizes signal energy, iEMG emphasizes cumulative activation, and MAV reflects average amplitude.&lt;br /&gt;
&lt;br /&gt;
=== Peak-value Extraction ===&lt;br /&gt;
&lt;br /&gt;
In addition to continuous feature curves, several key peak values are extracted from the processed signal:&lt;br /&gt;
&lt;br /&gt;
* maximum and minimum of the filtered EMG waveform&lt;br /&gt;
* peak of the envelope&lt;br /&gt;
* peak RMS&lt;br /&gt;
* peak iEMG&lt;br /&gt;
* peak MAV&lt;br /&gt;
&lt;br /&gt;
These peak values provide concise descriptors of the strongest activity observed in each recording. They are useful for quick comparison across trials and subjects.&lt;br /&gt;
&lt;br /&gt;
=== Noise Floor Estimation ===&lt;br /&gt;
&lt;br /&gt;
To evaluate signal quality, the noise floor is estimated from a reference resting interval. In the present implementation, the first 3 seconds of the recording are used as the default rest reference:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
t \in [0,\min(3,t_{end})]&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From this segment, three noise descriptors are computed:&lt;br /&gt;
&lt;br /&gt;
* Noise RMS&lt;br /&gt;
* Noise standard deviation&lt;br /&gt;
* Noise peak-to-peak amplitude&lt;br /&gt;
&lt;br /&gt;
Noise-floor estimation is important because EMG amplitude alone is not sufficient to judge recording quality. A large signal is only meaningful if it is sufficiently higher than the baseline noise level. Therefore, the noise floor serves as the reference for later SNR calculation and for designing contraction thresholds.&lt;br /&gt;
&lt;br /&gt;
=== Global Signal Metrics ===&lt;br /&gt;
&lt;br /&gt;
For each recording, three global metrics are also computed over the entire filtered signal:&lt;br /&gt;
&lt;br /&gt;
* Global RMS&lt;br /&gt;
* Global MAV&lt;br /&gt;
* Global iEMG&lt;br /&gt;
&lt;br /&gt;
These global descriptors summarize the overall signal level of the full recording and are later used in group-level comparisons.&lt;br /&gt;
&lt;br /&gt;
=== Automatic Contraction Detection ===&lt;br /&gt;
&lt;br /&gt;
For dynamic recordings, an automatic contraction detection algorithm is used to identify repeated active segments. This is one of the key parts of the data processing pipeline, because it transforms a continuous EMG trace into discrete contraction events that can be counted and compared.&lt;br /&gt;
&lt;br /&gt;
==== Threshold Design ====&lt;br /&gt;
&lt;br /&gt;
The detection threshold is designed adaptively rather than using a fixed value. Two candidate thresholds are first calculated:&lt;br /&gt;
&lt;br /&gt;
* an envelope-based threshold derived from the global envelope mean and standard deviation&lt;br /&gt;
* a rest-reference threshold derived from the mean and standard deviation of the resting reference amplitude&lt;br /&gt;
&lt;br /&gt;
The final threshold is taken as the larger of the two after additional scaling. This strategy improves robustness because it combines the global activation level of the signal with the baseline noise characteristics of the individual recording.&lt;br /&gt;
&lt;br /&gt;
This adaptive threshold design is preferable to a manually fixed threshold because EMG amplitude can vary strongly between subjects, muscles, and recording sessions.&lt;br /&gt;
&lt;br /&gt;
==== Initial Segmentation ====&lt;br /&gt;
&lt;br /&gt;
After thresholding the envelope, the signal is classified into active and inactive regions:&lt;br /&gt;
&lt;br /&gt;
* active: envelope above threshold&lt;br /&gt;
* inactive: envelope below threshold&lt;br /&gt;
&lt;br /&gt;
The rising and falling edges of the binary activity vector are then used to determine the start and end points of each candidate contraction segment.&lt;br /&gt;
&lt;br /&gt;
==== Removal of Short Segments ====&lt;br /&gt;
&lt;br /&gt;
Very short active regions are often caused by noise fluctuations rather than true muscle contractions. Therefore, segments shorter than 0.20 s are discarded.&lt;br /&gt;
&lt;br /&gt;
This step prevents false positive detections and increases the physiological relevance of the segmentation results.&lt;br /&gt;
&lt;br /&gt;
==== Merging of Adjacent Segments ====&lt;br /&gt;
&lt;br /&gt;
If two neighboring active segments are separated by a very short gap, they are merged when the gap is less than 0.15 s.&lt;br /&gt;
&lt;br /&gt;
This operation is necessary because a single real contraction may be temporarily interrupted by a brief drop in the envelope caused by local fluctuation. Without merging, one contraction could be incorrectly counted as multiple repetitions.&lt;br /&gt;
&lt;br /&gt;
==== Repetition-level Metrics ====&lt;br /&gt;
&lt;br /&gt;
For each detected contraction segment, two repetition-level metrics are extracted:&lt;br /&gt;
&lt;br /&gt;
* peak RMS of that contraction&lt;br /&gt;
* mean RMS of that contraction&lt;br /&gt;
&lt;br /&gt;
These metrics quantify both the strongest activation within each repetition and the average activation level over the repetition duration.&lt;br /&gt;
&lt;br /&gt;
=== Repeatability Analysis ===&lt;br /&gt;
&lt;br /&gt;
When multiple valid contractions are detected, repeatability is evaluated using the coefficient of variation (CV):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
CV = \frac{\sigma}{\mu}\times 100\%&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt; is the standard deviation and &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; is the mean value across repetitions.&lt;br /&gt;
&lt;br /&gt;
Two CV values are computed:&lt;br /&gt;
&lt;br /&gt;
* CV of repetition peak RMS&lt;br /&gt;
* CV of repetition mean RMS&lt;br /&gt;
&lt;br /&gt;
A lower CV indicates better repeatability, meaning that repeated contractions produce more consistent EMG responses.&lt;br /&gt;
&lt;br /&gt;
=== Signal-to-Noise Ratio (SNR) ===&lt;br /&gt;
&lt;br /&gt;
In this project, the signal-to-noise ratio (SNR) is defined based on the ratio between contraction and rest activity:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math display=&amp;quot;block&amp;quot;&amp;gt;&lt;br /&gt;
SNR_{dB} = 20\log_{10}\left(\frac{RMS_{contraction}}{RMS_{rest}}\right)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This definition is adopted because it directly reflects the system’s ability to distinguish active muscle contraction from baseline noise.&lt;br /&gt;
&lt;br /&gt;
Compared with global SNR definitions, this formulation is more relevant for practical EMG applications such as activity detection and classification.&lt;br /&gt;
&lt;br /&gt;
=== Rest-versus-Contraction Window Comparison ===&lt;br /&gt;
&lt;br /&gt;
To further distinguish inactive and active states, all sliding windows are divided into two groups:&lt;br /&gt;
&lt;br /&gt;
* rest windows: windows with envelope clearly below the threshold&lt;br /&gt;
* contraction windows: windows with envelope above the threshold&lt;br /&gt;
&lt;br /&gt;
The RMS values of these two groups are then compared statistically.&lt;br /&gt;
&lt;br /&gt;
This comparison is important because a practical EMG system should not only detect signal presence, but also clearly separate rest from contraction in a quantitative way. If the two RMS distributions are well separated, it indicates that the system has good discriminative capability.&lt;br /&gt;
&lt;br /&gt;
=== Output Data Structure ===&lt;br /&gt;
&lt;br /&gt;
The processed outputs are organized into structured data for experimental analysis:&lt;br /&gt;
&lt;br /&gt;
==== Time-series outputs ====&lt;br /&gt;
* Filtered EMG signal  &lt;br /&gt;
* Rectified signal  &lt;br /&gt;
* Envelope  &lt;br /&gt;
* RMS(t), iEMG(t), MAV(t)  &lt;br /&gt;
&lt;br /&gt;
==== Recording-level outputs ====&lt;br /&gt;
* RMS (rest)  &lt;br /&gt;
* RMS (contraction)  &lt;br /&gt;
* iEMG  &lt;br /&gt;
* Noise metrics  &lt;br /&gt;
&lt;br /&gt;
==== Dynamic-signal outputs ====&lt;br /&gt;
* Detected contractions  &lt;br /&gt;
* Repetition count  &lt;br /&gt;
* Peak RMS per repetition  &lt;br /&gt;
* Mean RMS per repetition  &lt;br /&gt;
* Coefficient of variation (CV)  &lt;br /&gt;
* Signal-to-noise ratio (SNR)  &lt;br /&gt;
&lt;br /&gt;
All extracted features are designed to directly support the evaluation of noise level, signal quality, activity discrimination, and repeatability in the subsequent experimental analysis.&lt;br /&gt;
&lt;br /&gt;
==Experimental Results==&lt;br /&gt;
&lt;br /&gt;
== Multi-subject Analysis ==&lt;br /&gt;
=== System Evaluation ===&lt;br /&gt;
&lt;br /&gt;
This section evaluates the performance of the EMG acquisition system in terms of noise level, signal quality, activity discrimination, and repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Noise Floor Analysis ====&lt;br /&gt;
&lt;br /&gt;
The noise floor was evaluated using rest-state recordings, characterized by RMS noise, standard deviation, and peak-to-peak amplitude.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039; shows the lowest noise level (RMS ≈ 0.0046), indicating stable electrode contact and minimal interference.  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039; exhibits moderate noise (RMS ≈ 0.0080), likely influenced by motion artifacts or electrode–skin impedance variation.  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039; shows relatively higher noise (RMS ≈ 0.0126), suggesting increased baseline fluctuation.  &lt;br /&gt;
&lt;br /&gt;
Overall, the system maintains a low noise floor across subjects, although the quality depends on experimental conditions such as electrode contact and environmental interference.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Signal-to-Noise Ratio (SNR) ====&lt;br /&gt;
&lt;br /&gt;
The signal-to-noise ratio (SNR) is defined as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\mathrm{SNR (dB)} = 20 \log_{10} \left( \frac{\mathrm{RMS}_{\mathrm{contraction}}}{\mathrm{RMS}_{\mathrm{rest}}} \right)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The measured SNR values are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: 21.26 dB → good signal quality  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: 13.52 dB → moderate and usable  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: 6.66 dB → low signal clarity  &lt;br /&gt;
&lt;br /&gt;
General interpretation:&lt;br /&gt;
&lt;br /&gt;
* &amp;gt;20 dB → good  &lt;br /&gt;
* 10–20 dB → usable  &lt;br /&gt;
* &amp;lt;10 dB → poor  &lt;br /&gt;
&lt;br /&gt;
These results show that the system can achieve reliable signal acquisition, although performance varies across subjects.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
====  Rest vs Contraction Discrimination ====&lt;br /&gt;
&lt;br /&gt;
A clear distinction between rest and contraction states is observed based on RMS values.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: 0.0053 → 0.1064 (≈20× increase)  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: 0.0079 → 0.0283 (≈3.6× increase)  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: 0.0141 → 0.0646 (≈4.6× increase)  &lt;br /&gt;
&lt;br /&gt;
This demonstrates that the system is capable of separating muscle activity from baseline noise.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Conclusion:&#039;&#039;  &lt;br /&gt;
The system can be used for basic muscle activity detection and simple classification tasks based on RMS features.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
==== Repeatability of Repeated Contractions ====&lt;br /&gt;
&lt;br /&gt;
Repeatability is evaluated using the coefficient of variation (CV) of peak RMS values across repetitions.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! CV Range !! Evaluation&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt; 10% || Excellent&lt;br /&gt;
|-&lt;br /&gt;
| 10–20% || Acceptable&lt;br /&gt;
|-&lt;br /&gt;
| &amp;gt; 20% || Poor&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Results:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039;: CV = 12.77% → Acceptable  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039;: CV = 24.77% → Poor  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039;: CV = 10.60% → Acceptable  &lt;br /&gt;
&lt;br /&gt;
Although WANG&#039;s signal is detectable, its contraction amplitude varies significantly across repetitions, resulting in poor repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
=== Overall System Performance ===&lt;br /&gt;
&lt;br /&gt;
The system demonstrates the following performance characteristics:&lt;br /&gt;
&lt;br /&gt;
* Reliable detection of muscle activity across all subjects  &lt;br /&gt;
* Clear separation between rest and contraction states  &lt;br /&gt;
* Moderate to high signal quality depending on subject conditions  &lt;br /&gt;
* Repeatability ranging from acceptable to poor due to user-dependent factors  &lt;br /&gt;
&lt;br /&gt;
Overall, the designed EMG acquisition system is capable of stable signal acquisition and feature extraction, with performance primarily influenced by electrode contact quality, skin impedance, and motion consistency.&lt;br /&gt;
&lt;br /&gt;
===== Summary of Quantitative Metrics =====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Subject !! RMS (Rest) !! RMS (Contraction) !! Separation Ratio !! iEMG (max) !! Noise RMS !! SNR (dB) !! CV (%) !! Evaluation&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;LIU&#039;&#039;&#039; || 0.0053 || 0.1064 || &#039;&#039;&#039;20.1×&#039;&#039;&#039; || 12.72 || 0.0046 || &#039;&#039;&#039;21.26&#039;&#039;&#039; || 12.77 || Strong signal, good quality&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;WANG&#039;&#039;&#039; || 0.0079 || 0.0283 || 3.57× || 11.10 || 0.0080 || 13.52 || &#039;&#039;&#039;24.77&#039;&#039;&#039; || Usable signal, poor repeatability&lt;br /&gt;
|-&lt;br /&gt;
| &#039;&#039;&#039;ZHONG&#039;&#039;&#039; || 0.0141 || 0.0646 || 4.58× || 6.70 || 0.0126 || 6.66 || 10.60 || Acceptable performance&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Summary:&#039;&#039; Subject LIU shows the best overall performance, WANG provides usable but less stable signals, and ZHONG demonstrates moderate signal quality with good repeatability.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Activation Intensity =====&lt;br /&gt;
&lt;br /&gt;
Among the three subjects, &#039;&#039;&#039;LIU exhibits the strongest muscle activation&#039;&#039;&#039;, as indicated by the highest contraction RMS and iEMG values. ZHONG shows moderate activation, while WANG demonstrates comparable iEMG but lower RMS consistency.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Signal Quality =====&lt;br /&gt;
&lt;br /&gt;
Signal quality is evaluated based on SNR and noise level:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;LIU&#039;&#039;&#039; achieves the highest SNR and lowest noise → best signal quality  &lt;br /&gt;
* &#039;&#039;&#039;WANG&#039;&#039;&#039; shows moderate SNR → usable but less robust  &lt;br /&gt;
* &#039;&#039;&#039;ZHONG&#039;&#039;&#039; has the lowest SNR → weakest signal clarity  &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Comparison of Repeatability =====&lt;br /&gt;
&lt;br /&gt;
Repeatability is evaluated using the coefficient of variation (CV):&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;ZHONG (10.60%)&#039;&#039;&#039; → most stable  &lt;br /&gt;
* &#039;&#039;&#039;LIU (12.77%)&#039;&#039;&#039; → acceptable  &lt;br /&gt;
* &#039;&#039;&#039;WANG (24.77%)&#039;&#039;&#039; → poor  &lt;br /&gt;
&lt;br /&gt;
This indicates that WANG’s contraction strength varies significantly between repetitions.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
===== Engineering Interpretation of Inter-subject Differences =====&lt;br /&gt;
&lt;br /&gt;
The observed differences are mainly attributed to engineering and experimental factors rather than physiological differences.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Electrode contact quality&#039;&#039;&#039;  &lt;br /&gt;
  Variations in electrode placement, pressure, and gel contact affect signal amplitude and stability.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Skin impedance&#039;&#039;&#039;  &lt;br /&gt;
  Differences in skin condition (hydration, oil, hair) influence electrode–skin impedance, affecting noise level and signal coupling.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Muscle control consistency&#039;&#039;&#039;  &lt;br /&gt;
  Variations in contraction strength and timing affect repeatability and CV.&lt;br /&gt;
&lt;br /&gt;
Therefore, the variation across subjects reflects practical acquisition conditions rather than intrinsic system limitations.&lt;/div&gt;</summary>
		<author><name>Wang Jingyi</name></author>
	</entry>
</feed>