convert_EDF¶
- convert_EDF(in_fname, target_rate, varargin)¶
CONVERT_EDF Read an EDF, resample all signals to a uniform rate, write it.
out_path = convert_EDF(in_fname, target_rate) out_path = convert_EDF(in_fname, target_rate, ‘OutputName’, name, …)
Reads an EDF / .edf.gz / .edf.zst file with read_EDF, resamples every non-annotation channel to target_rate Hz using SPT’s anti-aliased resample, and writes a new EDF (zstd-compressed by default — change with ‘CompressMode’).
- Inputs:
in_fname : path to a .edf, .edf.gz, or .edf.zst file target_rate : target sample rate (Hz) for all signals
- Name-value pairs:
- ‘OutputName’explicit output path. Default:
<dir>/<basename>_<target_rate>Hz<ext> where <ext> depends on ‘CompressMode’.
- ‘CompressMode’‘zstd’ (default) | ‘gzip’ | ‘none’. Sets the
default output extension when ‘OutputName’ is not provided (.edf.zst / .edf.gz / .edf).
- ‘Compress’(deprecated) true -> ‘zstd’, false -> ‘none’.
‘CompressMode’ takes precedence if both are passed.
‘GzipLevel’ : integer 1..9 (default 6). Used for .gz outputs. ‘ZstdLevel’ : integer 1..22 (default 9). Used for .zst outputs.
9 is the recommended sweet spot: ~9% smaller than zstd-3 for ~50% extra compress wall time, and decompression is roughly level-independent so downstream read time is unchanged.
‘Verbose’ : logical (default false) ‘AutoScale’ : ‘recompute’ (default) | ‘preserve’ (passed to
write_EDF). ‘recompute’ resets each channel’s physical_min/max to the actual data range so the anti-aliasing filter’s ringing isn’t clipped at the source file’s narrower stored range.
- Output:
out_path : full path of the written file
- Validation:
target_rate * data_record_duration must be a positive integer for every signal (so that samples_in_record is integer). If not, errors with the closest valid alternative.
- Behavior:
Annotation channels are passed through untouched (their byte layout per record is preserved). Each non-annotation channel is resampled with SPT’s resample (Kaiser-windowed sinc FIR; this is the anti-aliasing path – naive downsample is NOT used).
- Why AutoScale defaults to ‘recompute’:
The anti-aliasing filter can briefly produce samples outside the source file’s declared physical_min/max (filter ringing at sharp transients). With ‘preserve’ those samples get clipped to the int16 range on write. ‘recompute’ widens the stored range to the actual resampled data range, eliminating the clipping.
See also: read_EDF, write_EDF, batch_convert_EDF.