-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Currently EffectsDesign will only give you the factorial events data frame + the corresponding ERP's containing only the simulated compoents. However, usually, given you don't know what components are in the data, you calculate a time window around an event; and as such want to compare these time windows to your simulated data.
To make this easier I propose the following functions to:
- Pad the EffectsDesign simulated data to be in accordance with time window length
- Turn the simulated data into a (tidy) effects style dataframe
Point two currently relies on the Unfold.results_to_table
function, so we would either have to copy that function from unfoold, or forgo it entirely and put this step into a HowTo.
# Function to zero-pad ground_truth and get into correct format
function format_gt(data, τ, sfreq)
sp = Int(abs(τ[1]) * sfreq) + Int(τ[2] * sfreq) # number of sample points
padded_data = zeros(sp+1, size(data, 2))
for col in 1:size(data, 2)
tmp = pad_array(reshape(data[:,col], size(data[:,col], 1)), (Int(τ[1] * sfreq), Int(τ[2] * 100 - size(data[:,col], 1) + 1)), 0) # pad ground truth to be same length as estimates
padded_data[:, col] = tmp
end
padded_data = reshape(padded_data, 1, size(padded_data)...) # reshape to be channel x samplepoints x event
return padded_data
end
# Changes effects design event DataFrame to be used with Unfold.result_to_table
df_to_vec(df) = [@rsubset(df, :event == e) for e in unique(df.event)]
function data_to_effects_table(data, events::DataFrame, τ::Tuple, sfreq::Int)
## change gt to effects style DataFrame
g = format_gt(data, τ, sfreq) # zero-pad ground_truth and get into correct format
times = range(τ[1], τ[2], size(g, 2)) # get correct times vector
effects = Unfold.result_to_table([g], [events], [times], ["effects"])
return effects
end
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request