beacon-biosignals / EDF.jl

Read and write EDF files in Julia
MIT License
18 stars 5 forks source link

`EDF.decode(::EDF.Signal)::Vector` #10

Closed jrevels closed 4 years ago

jrevels commented 5 years ago

It would be nice to have a decode function that basically does something like the following:

function decode(signal::EDF.Signal)
    digital_range = Int(signal.digital_max) - Int(signal.digital_min)
    physical_range = Int(signal.physical_max) - Int(signal.physical_min)
    return (physical_range / digital_range) * signal.samples
end

Somebody should check that code, though. Also, there should be extra checks to ensure this properly fails when the signal isn't simply LPCM encoded.

jrevels commented 5 years ago

Perhaps there could even be a separate API function that returns physical_range / digital_range (e.g. resolution_in_unit(::EDF.Signal)) and decode could wrap around that