Convert an epoch latency in milliseconds to the nearest epoch frame.
Ports EEGLAB’s eeg_ms2f.m. The returned frame number is 1-based to match
EEGLAB; convert to a 0-based index at the point of use.
- Parameters:
EEG (dict[str, Any]) – EEG structure with xmin/xmax (epoch limits, seconds) and
pnts (samples per epoch).
ms (float) – Epoch latency in milliseconds.
- Returns:
The nearest 1-based epoch frame number.
- Raises:
ValueError – If the latency falls outside [xmin, xmax].
- Return type:
int