generate_adj_array: generate_adj_array

View source: R/fragility_functions.R

generate_adj_arrayR Documentation

generate_adj_array

Description

This function generates the NxNxJ adjacency array, where N is number of electrodes and J is number of timewindows. Each NxN matrix within the array is a linear least-squares approximation of how the voltage data evolves within a specific timewindow J. In its entirety, this array can be used as a linear time-varying model of the EEG data, and is used for creating the fragility map.

Usage

generate_adj_array(t_window, t_step, v, trial_num, nlambda, ncores)

Arguments

t_window

Integer specifying size of one time window. Units are in whatever increment the timepoints are - for example, for 1000Hz data, units would be in ms.

t_step

Integer specifying size of one time step (when t_step = t_window, adjacent time windows have no overlap)

v

3D voltage array from RAVE's module_tools$get_voltage() and get_data() functions after processing from process_fragility_patient. First dimension is trial, second dimension is time, and third dimension is electrode.

trial_num

Integer specifying which trial to create ajdacency array for. The adjacency array can only be produced with one trial at a time.

nlambda

Integer specifying how many lambdas are to be calculated during cross-validation for L2-norm regularization (Ridge regression). More lambdas results in better fitting of data, at the expense of processing time. Default is 16 lambdas.

ncores

Integer specifying how many cores to utilize during parallel processing.

Value

List containing the adjacency array A as well as a measure of how accurate the fitted data is, mse

Examples

adj_info <- generate_adj_array(
    t_window = 250,
    t_step = 125,
    v = pt_info$v,
    trial_num = 1,
    nlambda = 16,
    ncores = 8
)

ozmosis17/Fragility documentation built on March 22, 2023, 2:16 a.m.