get_data_frame: Get data from MNE into R data.frame

Description Usage Arguments Details Value Examples

View source: R/mne.r

Description

get_data_frame helps importing MNE data structures

Usage

1
2
3
get_data_frame(inst, picks = NULL, index = NULL, scaling_time = 1000,
  scalings = NULL, copy = T, start = NULL, stop = NULL,
  long_format = T)

Arguments

inst

An instance of MNE data containsers, e.g, mne$Epochs, mne$io$Raw, mne$Evoked.

picks

A zero-indexed integer array, a string, list, slice or None.

index

The columns to be uesed as pandas index. tuple of str or None.

scaling_time

Scaling to be applied to time units. Float.

scalings

Scaling to be applied to the channels picked.

copy

Whether to make a copy of the data.

start

If it is a Raw object, this defines a starting index for creating the dataframe from a slice. The times will be interpolated from the index and the sampling rate of the signal. Int or None.

stop

If it is a Raw object, this defines a stop index for creating the dataframe from a slice. The times will be interpolated from the index and the sampling rate of the signal. Int or None.

long_format

If True, the dataframe is returned in long format where each row is one observation of the signal at a unique coordinate of channels, time points, epochs and conditions. The number of factors depends on the data container. For convenience, a ch_type column is added when using this option that will facilitate subsetting the resulting dataframe. If False, mne-r is making sure that the channel names are cleaned from white spaces to esnure that the R-formulas will work. In the case that epochs are passed, the pandas muliti-index is unpacked and the columns "condition", "epochs", and "time" are prepended. Unliker the MNE-Python function, the default is True.

Details

The code will call the .to_data_frame method of the MNE data container and returns a dataframe readily usable in R. Note that the type definitions below refer to Python types. Please see the reticulate documentation to learn about R-to-Python conversion rules. Note that this function requires, next to MNE, a working Pandas installation. For background information on exporting MNE objects to dataframes, consider the designated MNE tutorial.

Value

Returns a data.frame. The layout depends on the options (e.g. long_format) and the type of instance (e.g. Epochs vs Raw).

Examples

1
2
3
4
5
6
7
library(mne)
fname <- paste(mne$datasets$testing$data_path(),
               "MEG", "sample", "sample_audvis_trunc_raw.fif",
               sep = "/")
raw <- mne$io$read_raw_fif(fname, preload = T)
raw_df <- get_data_frame(raw)
print(head(raw_df))

mne-tools/mne-r documentation built on Feb. 28, 2020, 9:45 p.m.