| read_mnirs | R Documentation |
Import time-series data exported from common muscle NIRS (mNIRS) devices and
return a tibble of class "mnirs" with the selected signal channels and
metadata.
read_mnirs(
file_path,
nirs_channels = NULL,
time_channel = NULL,
event_channel = NULL,
sample_rate = NULL,
add_timestamp = FALSE,
zero_time = FALSE,
keep_all = FALSE,
verbose = TRUE
)
file_path |
Path of the data file to import. Supported file extensions
are |
nirs_channels |
A character vector of one or more column names containing mNIRS signals to import. Names must match the file header exactly.
|
time_channel |
A character string giving the name of the time (or sample) column to import. The name must match the file header exactly.
|
event_channel |
An optional character string giving the name of an
event/lap column to import. Names must match the file header exactly.
A named character vector can be used to rename the column on import in
the form |
sample_rate |
An optional numeric sample rate in Hz. If left blank
( |
add_timestamp |
A logical. Default is |
zero_time |
Logical. Default is |
keep_all |
Logical. Default is
|
verbose |
Logical. Default is |
read_mnirs() searches the file for a header row containing the requested
channel names. The header row does not need to be the first row in the file.
If duplicate column names exist, columns are matched in the order they appear and renamed with unique strings.
Columns without a header name in the source file will be renamed to
col_*, where * is the numeric column number in which they appear in
the file (e.g. col_6). This applies to Artinis Oxysoft event label
columns, which do not have a column header and must be identified manually.
A named character vector can be specified to rename nirs_channels,
time_channel, and event_channel, in the form
c(renamed = "original_name"). The "original_name" must match the
contents of the file data table header row exactly.
time_channel will be converted to numeric for analysis.
If time_channel is a date-time (POSIXct) format, it will be converted
to numeric and re-based to start from 0, regardless of zero_time.
Some devices export a sample index rather than time values. In those
cases, if an export sample_rate is detected in the file metadata (e.g.
Artinis Oxysoft exports), read_mnirs() will create or overwrite a
"time" column in seconds derived from the sample index and the detected
sample_rate.
If sample_rate is not specified, it is estimated from differences in
time_channel. If time_channel is actually a sample index, as described
above, this may erroneously be estimated at 1 Hz. sample_rate should be
specified explicitly in this case.
Entirely empty rows and columns are removed. Invalid values (e.g.
c(NaN, Inf)) are standardized to NA. A warning will be displayed when
irregular sampling is detected (e.g. non-monotonic, repeated, or unequal
time values), if verbose = TRUE.
A tibble of class "mnirs". Metadata are stored
as attributes and can be accessed with attributes(data).
read_mnirs(
file_path = example_mnirs("moxy_ramp"), ## call an example data file
nirs_channels = c(
smo2_left = "SmO2 Live", ## identify and rename channels
smo2_right = "SmO2 Live(2)"
),
time_channel = c(time = "hh:mm:ss"), ## date-time format will be converted to numeric
event_channel = NULL, ## leave blank if unused
sample_rate = NULL, ## if blank, will be estimated from time_channel
add_timestamp = FALSE, ## omit a date-time timestamp column
zero_time = TRUE, ## recalculate time values from zero
keep_all = FALSE, ## return only the specified data channels
verbose = TRUE ## show warnings & messages
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.