beacon-biosignals / OndaEDF.jl

utilities for importing/exporting EDF Files to/from Onda datasets
Other
3 stars 2 forks source link

help users avoid a common foot gun of specifying labels with references #56

Open kleinschmidt opened 2 years ago

kleinschmidt commented 2 years ago

A common failure mode of creating custom labels is to specify the labels including references (e.g., just copying and pasting the labels seen in the EDF signal headers), whereas match_edf_label passes the EDF label through _normalize_references which extracts and compares the first part (without reference) with the custom label: https://github.com/beacon-biosignals/OndaEDF.jl/blob/735c285e7212d28ba697b37cf4cb584fbca0f64f/src/import_edf.jl#L155-L156

As a concrete example, handling an unusual channel label like 2A-M1 that is known to be left EOG, you might be tempted to use a custom labels spec like

["eog"] => ["left" => ["2a-m1"]]

but this silently fails, sicne the correct specification is

["eog"] => ["left" => ["2a"]]

One way to catch things like this would be to check for whether the channel name is unchanged after passing through _normalize_reference, and raise an error/warning if not. another, trickier approach would be to somehow ALSO handle the "with reference" version so that both "2a" and "2a-m1" would match "2A-M1". but that may introduce subtly breaking changes since we use a greedy approach to matching (return the first thing that matches).