Closed kleinschmidt closed 1 year ago
AlignedSpans could be helpful here. Eg n_samples
depends only on the duration and sample rate, not the endpoints and this can be used in some places. What the right approach is depends exactly what you need to do downstream of course.
(there’s also https://beacon-biosignals.github.io/AlignedSpans.jl/dev/API/#AlignedSpans.ConstantSamplesRoundingMode for example)
Fwiw I developed AlignedSpans exactly bc of the difficulties of working with both 1Hz and 128Hz data together. You really can’t miss a sample when it’s at 1Hz so you need a lot of control over the rounding.
This appears to have been fixed by #51.
This is called out in the docs:
but it is causing problems in a very specific application. if you have one signal that's sampled at a substantially lower rate than another (say, a 1/30 Hz label track and a 128 Hz EEG signal), you might want to do something like "give me the signals data for
n
labels starting at thei
th label". The naive way of doing this is to do something likethis works great except when
n
is 1. in that case, you'll get back alabel_span
that is "instantaneous" (e.g.,translate(TimeSpan(0, 0), time_from_index(1/30, i))
), rather than 30s long.another way of putting this is that the duration of the span generated by
time_from_index(sampling_rate, range)
is not alwayssampling_rate * length(range)
.