Skip to content

Commit dbbb963

Browse files
committed
Add Impedance.md information
1 parent 17b57cd commit dbbb963

1 file changed

Lines changed: 224 additions & 0 deletions

File tree

Impedance.md

Lines changed: 224 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,224 @@
1+
# Impedance Measurement
2+
3+
This document describes the impedance measurement implementation for EGI Net Amps amplifiers.
4+
5+
## Background
6+
7+
Electrode impedance measurement is essential for ensuring good signal quality in EEG recordings. High impedance electrodes result in noisy signals and increased susceptibility to interference. EGI amplifiers (NA400/NA410) include built-in circuitry for measuring electrode impedances without requiring external equipment.
8+
9+
## Measurement Principle
10+
11+
The impedance measurement uses a **voltage divider** technique:
12+
13+
1. A known calibration signal is injected through all electrodes
14+
2. Each electrode to be measured is connected to a precision 10 kΩ reference resistor
15+
3. The resulting signal amplitude is measured
16+
4. Impedance is calculated from the voltage divider ratio
17+
18+
```
19+
Calibration Signal → [Electrode Impedance Z] → [10K Reference] → Ground
20+
21+
Measured Amplitude
22+
```
23+
24+
The impedance formula:
25+
26+
```
27+
Z = (idealSignal - measuredAmplitude) / (measuredAmplitude / 10.0)
28+
```
29+
30+
Where:
31+
- `idealSignal` = expected amplitude with 0Ω electrode impedance
32+
- `measuredAmplitude` = peak-to-peak amplitude of the measured signal
33+
- `10.0` = reference resistor value in kΩ
34+
35+
## Amplifier States
36+
37+
The measurement process uses three amplifier states:
38+
39+
### Excitation State (Initial/Driving)
40+
41+
All electrodes actively drive the calibration signal onto the scalp:
42+
43+
| Setting | Value | Description |
44+
|---------|-------|-------------|
45+
| All 10K Resistors | OFF | Electrodes not connected to reference |
46+
| All Drive Signals | ON | All electrodes driving calibration signal |
47+
| Oscillator Gate | ON | Enable 20 Hz sine wave generator |
48+
| Calibration Frequency | 20 Hz | Low frequency for skin penetration |
49+
| Calibration Amplitude | 4095 | Maximum (12-bit DAC) |
50+
| Wave Shape | Sine (0) | Clean sinusoidal signal |
51+
| Subject Ground | OFF | Not grounded during measurement |
52+
| Current Source | OFF | Voltage mode measurement |
53+
54+
### Measurement State (Per-Channel)
55+
56+
For the channel being measured:
57+
58+
| Setting | Value | Description |
59+
|---------|-------|-------------|
60+
| Channel Drive Signal | OFF | Stop driving this electrode |
61+
| Channel 10K Resistor | ON | Connect to reference resistor |
62+
63+
All other channels remain in excitation state, creating the voltage divider.
64+
65+
### Reset State
66+
67+
After measurement, return channel to excitation state:
68+
69+
| Setting | Value | Description |
70+
|---------|-------|-------------|
71+
| Channel Drive Signal | ON | Resume driving |
72+
| Channel 10K Resistor | OFF | Disconnect reference |
73+
74+
## Measurement Algorithm
75+
76+
```
77+
1. Configure amplifier to Excitation State (all channels driving)
78+
79+
2. For each channel to measure:
80+
a. Set channel to Measurement State (drive OFF, 10K ON)
81+
b. Wait for settling time (~30ms command + ~1s filter time)
82+
c. Collect samples for peak-to-peak calculation (~51 samples)
83+
d. Calculate amplitude = max(samples) - min(samples)
84+
e. Calculate impedance from amplitude
85+
f. Reset channel to Excitation State (drive ON, 10K OFF)
86+
87+
3. Optionally measure Reference (Cz) and COM electrodes
88+
89+
4. When done, reset amplifier to Default Acquisition State
90+
```
91+
92+
## Timing Parameters
93+
94+
From EGI's Net Station implementation:
95+
96+
| Parameter | Value | Description |
97+
|-----------|-------|-------------|
98+
| Command Time | 30 ms | Time for command to reach amplifier |
99+
| Settle Time | 0 ms | Additional settling (Net Station uses 0) |
100+
| Filter Time | 1.0 s | Duration for filter/measurement |
101+
| Peak-to-Peak Samples | 51 | Samples for amplitude calculation |
102+
103+
Total time per channel: ~1.03 seconds
104+
105+
For a 256-channel net, a full scan takes approximately 4-5 minutes.
106+
107+
## LSL Streaming
108+
109+
Impedance values are streamed via LSL at 1 Hz:
110+
111+
- **Stream Type**: `Impedance`
112+
- **Sample Rate**: 1 Hz (one sample per second)
113+
- **Data Format**: float32 (kΩ)
114+
- **Channel Labels**: E1, E2, ..., E256, Cz
115+
116+
The stream publishes the **current known values** for all channels every second, even during scanning. Channels not yet measured show 1000 kΩ (maximum/invalid value).
117+
118+
### Stream Metadata
119+
120+
Each channel includes 3D electrode position in the stream description:
121+
122+
```xml
123+
<channel>
124+
<label>E1</label>
125+
<type>Impedance</type>
126+
<unit>kohms</unit>
127+
<location>
128+
<X>0.123</X>
129+
<Y>0.456</Y>
130+
<Z>0.789</Z>
131+
<unit>normalized</unit>
132+
</location>
133+
</channel>
134+
```
135+
136+
Coordinates are on a unit sphere:
137+
- X: positive toward right ear
138+
- Y: positive toward nose
139+
- Z: positive toward vertex (Cz)
140+
141+
## Implementation
142+
143+
### Key Source Files
144+
145+
| File | Description |
146+
|------|-------------|
147+
| [ImpedanceMeasurement.h](src/core/include/egiamp/ImpedanceMeasurement.h) | Class declaration and timing structures |
148+
| [ImpedanceMeasurement.cpp](src/core/src/ImpedanceMeasurement.cpp) | Measurement algorithm implementation |
149+
| [LSLStreamer.cpp](src/core/src/LSLStreamer.cpp) | LSL outlet creation with electrode positions |
150+
| [ElectrodePositions.h](src/core/include/egiamp/ElectrodePositions.h) | Electrode coordinate definitions |
151+
| [ElectrodePositions.cpp](src/core/src/ElectrodePositions.cpp) | Geodesic position generation |
152+
| [EGIAmpClient.cpp](src/core/src/EGIAmpClient.cpp) | Integration with streaming client |
153+
154+
### Key Classes
155+
156+
**`ImpedanceMeasurement`** - Core measurement logic:
157+
- `setupImpedanceState()` - Configure amplifier for impedance mode
158+
- `startContinuousScan()` - Begin background scanning thread
159+
- `measureChannel(int ch)` - Measure single channel (blocking)
160+
- `feedSample(PacketFormat2&)` - Feed EEG samples for amplitude calculation
161+
- `publishThread()` - Push values to LSL at 1 Hz
162+
163+
**`LSLStreamer`** - LSL stream management:
164+
- `createImpedanceOutlet()` - Create impedance stream with metadata
165+
- `pushSample()` - Push impedance values
166+
167+
### AmpServer Commands
168+
169+
| Command | Description |
170+
|---------|-------------|
171+
| `cmd_TurnAll10KOhms` | Set all 10K resistors (0=off, 1=on) |
172+
| `cmd_TurnAllDriveSignals` | Set all drive signals (0=off, 1=on) |
173+
| `cmd_TurnChannel10KOhms` | Set single channel 10K resistor |
174+
| `cmd_TurnChannelDriveSignals` | Set single channel drive signal |
175+
| `cmd_SetOscillatorGate` | Enable/disable calibration oscillator |
176+
| `cmd_SetCalibrationSignalFreq` | Set frequency (20 Hz for impedance) |
177+
| `cmd_SetCalibrationSignalAmplitude` | Set amplitude (0-4095) |
178+
| `cmd_SetWaveShape` | Set waveform (0=sine, 1=square) |
179+
| `cmd_DefaultAcquisitionState` | Reset to normal EEG acquisition |
180+
181+
## Usage
182+
183+
### CLI
184+
185+
```bash
186+
./EGIAmpServerCLI --address 10.10.10.51 --impedance
187+
```
188+
189+
### GUI
190+
191+
1. Link to the amplifier
192+
2. Check "Measure Impedances" checkbox
193+
3. Impedance stream appears on LSL network
194+
4. Uncheck to stop measurement and return to normal EEG
195+
196+
### Python Visualization
197+
198+
```bash
199+
cd scripts
200+
pip install -r requirements.txt
201+
python impedance_viewer.py --threshold 50
202+
```
203+
204+
## Impedance Thresholds
205+
206+
Recommended thresholds for EGI saline-based nets:
207+
208+
| Quality | Impedance (kΩ) | Color |
209+
|---------|----------------|-------|
210+
| Excellent | < 20 | Green |
211+
| Good | 20 - 50 | Yellow-Green |
212+
| Acceptable | 50 - 100 | Yellow |
213+
| Poor | 100 - 200 | Orange |
214+
| Bad | > 200 | Red |
215+
216+
Values of 1000 kΩ indicate:
217+
- Electrode not yet measured
218+
- No contact with scalp
219+
- Broken or disconnected electrode
220+
221+
## References
222+
223+
- EGI AmpServer SDK Documentation
224+
- EGI Geodesic Sensor Net Technical Manual

0 commit comments

Comments
 (0)