backend.data.OutputData¶
- class backend.data.OutputData(n_dof=5, num_features=0, length=5000, clamp_th=0.1, latch_c=100, speed_limit=0.125)¶
This class holds all the data used by the Backend
- excluded_params = ['length', 'fill_value']¶
- __init__(n_dof=5, num_features=0, length=5000, clamp_th=0.1, latch_c=100, speed_limit=0.125)¶
if a non-zero length is used, you MUST trim the data to the correct length when you’re done!
- property n_sample¶
- property n_dof¶
- property n_feat¶
- double_length()¶
- update_num_features(new_n)¶
- get_params()¶
Returns dict of this object’s attributes, excluding any attributes in the excluded_params list
- get_settings_params()¶
Returns only the settings-related params; not the data
- update_settings_from_params(params)¶
- update_from_params(params: dict)¶
Update this object’s attributes using the params dict. Any attributes in the excluded_params list will not be updated
- slice(start=None, end=None, bools=None)¶
Returns a Data object sliced by the indicated start-end range OR a boolean array
- slice_movs(movs, reduce_mov_idxs=False)¶
- slice_dofs(dofs, relax_pos, reduce_dofs=False)¶
- by_period(prompt=False, move=False, rest=False)¶
Returns a Data object sliced by the indicated movement periods
- unshuffle()¶
- get_trial_info(collect_movs=False, collect_reps=False, include_prompts=False)¶
returns a list of dictionaries containing information for each trial
if collect_movs is True, each dict will correspond to a movement (collect_reps doesn’t do anything)
if collect_movs is False and collect_reps is True, each dict will correspond to a repetition
if both are False, then each dict will correspond to a movement period
if include_prompts is False, prompt data will be ignored (i.e. movements start at the first MOVE sample)
dictionary contains: first index, last index + 1, movement index, repetition index, and period type
- static concatenate(*data_objects)¶
Concatenate the data from the given objects into one. The settings from the first data object are used.
- print_shapes(printer=<built-in function print>)¶
- gen_mov_idxs_from_x_d(relax_pos=0.0)¶
Generate the data.mov_idxs by splitting data.x_d on zero sections. Data.rep_idxs is zeroed Data.period is set to REST, and then any time a DOF leaves 0, it is set to MOVE
- gen_mov_idxs_from_runner(runner, timestep=0.033)¶
Generate the mov_idxs and rep_idxs using the movements from the provided runner.
data_length is the valid length of the corresponding data so that the generated mov_idxs can be confirmed to be of the same length
Sets mov_idxs and rep_idxs, or raises error Data.period is set to REST, and then any time a DOF leaves 0, it is set to MOVE
- clear_data(length=4096)¶
Clear the data while leaving settings unchanged
- get_trial_shifts(trials, shifts)¶
Returns a List of tuples where the outer list is each trial, and the inner tuples contains its corresponding slice object for the trials and a list of OutputData objects for each shift of the trial.
- get_folds(holdout_first=False, holdout_last=True)¶
Used for k-fold cross-validation. This returns a list of tuples of (Training data, Testing data) for each fold.
The number of folds is either 1 if holdout_first or holdout_last is True, or it is the max number of repetitions out of all movements in the dataset.
- align_test(trials, objective, shifts=None, relax_pos=0, timestep=0.033, printer=<function empty_func>, stop_task_event=<backend.utils.DummyClass object>)¶
Aligns data to account for human reaction time. Used to improve testing results Each trial is aligned separately.
- Parameters
output_data – reference OutputData object
trials – a list of dictionaries for each trial like: {‘start’: start_idx, ‘end’: last_idx+1} or the trial information returned by Data.get_trial_info() called with default args
objective – optional argument to specify alignment objective function
shifts – optional list of timeshifts
- Returns
optimally shifted x_hat
- align_train(trials, objective, train_callback, predict_callback, shifts=None, relax_pos=0, timestep=0.033, iterations=1, printer=<function empty_func>, stop_task_event=<backend.utils.DummyClass object>)¶
Aligns data to account for human reaction time. Used to improve decoder training Each trial is aligned separately.
- Parameters
trials – a list of dictionaries for each trial like: {‘start’: start_idx, ‘end’: last_idx+1} or the trial information returned by Data.get_trial_info() called with default args
objective – optional argument to specify alignment objective function
shifts – optional list of timeshifts
- Returns
optimally shifted x_hat