neuraltrain.models.preprocessor.OnTheFlyPreprocessor¶
- pydantic model neuraltrain.models.preprocessor.OnTheFlyPreprocessor[source][source]¶
Module to apply common preprocessing steps on-the-fly, inside an nn.Module.
- Parameters:
ptp_threshold – If provided, channels with a ptp higher are considered bad. If update_ch_pos is True, their positions will be set to common.INVALID_POS_VALUE, otherwise the amplitude of bad channels are replaced by 0.
scaler – Scaling strategy to apply to the input. If provided as a float, the amplitude will be multiplied by this value. If “RobustScaler” or “StandardScaler”, the input data will be scaled along the dimensions specified by scale_dim. If “QuantileAbsScaler”, each channel is divided by the
scaler_quantile-th percentile of its absolute value; this is the robust per-channel scaling used by the BIOT model (Yang et al., NeurIPS 2023). If “MinMaxScaler”, each channel is linearly rescaled to [-1, 1] across the time dimension (dim=-1); this is the per-window normalization used by BENDR (Kostas et al., Front. Hum. Neurosci. 2021).scale_dim – Dimensions along which to apply scaling (see scaler). If None, scale along all dimensions.
scaler_quantile – Quantile for
"QuantileAbsScaler"mode (default 0.95, i.e. 95th percentile). Ignored whenscaleris not"QuantileAbsScaler".clamp – If provided, clamp input to the range [-clamp, clamp].
update_ch_pos – If True, update channel positions of bad channels above ptp_threshold.
min_temporal_samples – If provided, right-pad the time axis with zeros up to this length. Models whose patch size is fixed by a pretrained checkpoint (e.g. REVE’s
Linear(200, 512)) cannot tokenise a shorter window at all; padding on the right leaves the trigger aligned with the patch start. Applied after scaling, so the padding stays at zero rather than being recentred, and the real samples keep the statistics they were scaled by. No-op when the input is already at least this long.
- Fields: