EDF/BDF Format Selection¶
One of the key features of EMGIO is its ability to automatically determine whether to use the EDF (16-bit) or BDF (24-bit) format when exporting data. This decision is based on the dynamic range and precision requirements of your EMG data.
Why Format Selection Matters¶
EDF (European Data Format)¶
- 16-bit precision (range: ±32767)
- Widely supported by analysis software
- Smaller file size
- Suitable for most EMG recordings
BDF (BioSemi Data Format)¶
- 24-bit precision (range: ±8,388,607)
- Required for high-precision recordings
- Larger file size
- Necessary when dynamic range exceeds 16-bit capabilities
Using 16-bit EDF when possible reduces storage requirements while maintaining sufficient precision for most analyses. However, when data contains very small signal components relative to the peak values, higher precision may be necessary to avoid quantization errors and preserve information.
How EMGIO Selects the Format¶
EMGIO uses two complementary approaches to determine the appropriate format:
1. SVD (Singular Value Decomposition) Analysis¶
The SVD method decomposes the signal matrix to evaluate its effective rank and the distribution of signal energy:
# Simplified implementation of SVD analysis
U, s, Vh = np.linalg.svd(signals, full_matrices=False)
effective_rank = np.sum(s > threshold)
This approach: - Identifies the essential dimensions in the data - Measures how much precision is needed to represent these dimensions - Determines if 16-bit precision (90dB dynamic range) is sufficient
2. FFT (Fast Fourier Transform) Analysis¶
The FFT method examines the frequency domain representation:
# Simplified implementation of FFT analysis
fft_result = np.fft.rfft(signals)
noise_floor = estimate_noise_floor(fft_result)
dynamic_range_db = 20 * np.log10(peak_amplitude / noise_floor)
This approach: - Estimates the noise floor in the frequency domain - Calculates the dynamic range in decibels - Compares against the ~90dB limit of 16-bit data
Controlling Format Selection¶
You can control the format selection process when exporting:
# Use both methods (default)
emg.to_edf('output', method='both')
# Use only SVD analysis
emg.to_edf('output', method='svd', svd_rank=None) # Auto threshold
emg.to_edf('output', method='svd', svd_rank=5) # Manual threshold
# Use only FFT analysis
emg.to_edf('output', method='fft', fft_noise_range=None) # Auto range
emg.to_edf('output', method='fft', fft_noise_range=(0.1, 10)) # Manual range
# Force a specific format
emg.to_edf('output', format='edf') # Force EDF (16-bit)
emg.to_edf('output', format='bdf') # Force BDF (24-bit)
Understanding the Output¶
After export, EMGIO will indicate which format was selected:
Exporting to EDF format: dynamic range is 78.3 dB (less than 90 dB threshold)
Output file: output.edf
or:
Exporting to BDF format: dynamic range is 108.2 dB (exceeds 90 dB threshold)
Output file: output.bdf
Best Practices¶
- Let EMGIO automatically determine the format when possible
- When in doubt, visualize your data to see if it contains very small but important signal components
- For critical applications, consider using the BDF format to ensure maximum precision
- If file size is a concern and precision is adequate, force the EDF format to save space