Move the range of data channels in a dataframe up or down, while preserving the absolute dynamic range and/or relative scaling across channels. e.g. shift data range to positive values, or shift the mean of the first X number of samples in a recording to zero.
Arguments
- data
A dataframe.
- nirs_channels
A
list()
of character vectors indicating the column names for data channels to be shifted (see Details).nirs_channels = list("A", "B", "C")
will shift each channel separately, losing relative scaling.
nirs_channels = list(c("A", "B", "C"))
will shift all channels together, preserving relative scaling.
nirs_channels = list(c("A", "B"), c("C", "D"))
will shift channels
A
andB
together, and channelsC
andD
together, preserving relative scaling within, but not across each group.
- time_channel
A character string indicating the time or sample data channel. Must match
data
column names exactly. Will be taken from metadata if not defined explicitly.- shift_to
A positive or negative numeric value in units of
nirs_channels
to which the specified data channels will be shifted.- shift_by
An optional positive or negative numeric value by which the data signals can be shifted by a set amount, in units of the
nirs_channels
.- span
A numeric value in units of
time_channel
, defining the range over which theposition
is determined.span = 0
takes the single minimum, maximum, or first value.span = 30
would use the mean of the samples within the lowest, highest, or first30
units of thetime_channel
.- position
Indicates how to shift values.
"minimum"
will shift selected channels' minimum values to the specified
shift_to
value (the default)."maximum"
will shift selected channels by their maximum values.
"first"
will shift selected channels by their first values.
Value
A tibble of class mnirs.data
with
metadata available with attributes()
.
Details
nirs_channels = list()
can be used to group data channels to preserve
absolute or relative scaling. Channels grouped together in a vector
will preserve relative scaling across those channels. Should match column names
in the dataframe exactly.
nirs_channels = list("A", "B", "C")
will shift each channel separately. Absolute dynamic range for each data channel is preserved, but relative scaling will be lost between data channels.
nirs_channels = list(c("A", "B", "C"))
will shift all channels together. Absolute dynamic range and relative scaling are both preserved across the group of data channels.
nirs_channels = list(c("A", "B"), c("C", "D"))
will shift channels
A
andB
together, and channelsC
andD
together. Absolute dynamic range and relative scaling are preserved within each group, but not across groups of data channels.
Channels not explicitly specified will not be shifted, but will be passed through to the output dataframe.
If both shift_to
and shift_by
are defined, only shift_to
will be used.