UnfoldBIDS._load_resultsFunction
_load_results(files_df; generate_Xs::Bool = true)

Internal function to load Unfold models into memory. Can also be used to load data after file information was loaded lazily (lazy=true) using load_results()

source
UnfoldBIDS.bids_coeftableMethod
bids_coeftable(model_df)

Turns all models found in model_df into tydy DataFrames and aggregates them in a new DataFrame.

source
UnfoldBIDS.bids_layoutMethod
bids_layout(bidsPath::AbstractString;
    derivatives::Bool=true,
    specific_folder::Union{Nothing,AbstractString}=nothing,
    exclude_folder::Union{Nothing,AbstractString}=nothing,
    ses::Union{Nothing,AbstractString}=nothing,
    task::Union{Nothing,AbstractString}=nothing,
    run::Union{Nothing,AbstractString}=nothing)

Main function to load paths of all subjects in one bids_root folder. Will return a DataFrame containing all found paths with specific subject information. Used before loading data into memore using load_bids_eeg_data

Keywords

  • derivatives::Bool = true
    Look for data in the derivatives folder
  • specific_folder::Union{Nothing,AbstractString} = nothing
    Specify a specific folder name in either derivatives or bids_root to look for data.
  • exclude_folder::Union{Nothing,AbstractString} = nothing
    Exclude a specific folder from data detection.
  • ses:Union{Nothing,AbstractString} = nothing
    Which session to load; loads all if nothing
  • task::Union{Nothing,AbstractString} = nothing
    Which task to load; loads all if nothing
  • run::Union{Nothing,AbstractString} = nothing
    Which run to load; loads all if nothing
source
UnfoldBIDS.check_dfMethod
check_df(files_df, ses, task, run)

Internal; Checks if the multiple sessions/task/runs are found if none of these are provided

source
UnfoldBIDS.load_bids_eeg_dataMethod
load_bids_eeg_data(layout_df; verbose::Bool=true, kwargs...)

Load data found with bids_layout into memory.

  • loading_function::Union{Nothing,Function} = nothing
    Function to load EEG data; if nothing provided and PyMNE.jl is loaded, it will use that as default. The function must take a single argument: the file path to the EEG data file.
  • verbose::Bool = true
    Show ProgressBar
  • kwargs...
    kwargs for CSV.read to load events from .tsv file; e.g. to specify delimeter
source
UnfoldBIDS.load_eventsMethod
load_events(layoutDF::DataFrame; kwargs...)

Internal function to load events based on paths in the layout Df

source
UnfoldBIDS.load_resultsMethod
load_results(bids_root::String;
    derivatives_subfolder::String="Unfold",
    lazy::Bool=false,
    generate_Xs::Bool = true,
    ses::Union{Nothing,AbstractString}=nothing,
    task::Union{Nothing,AbstractString}=nothing,
    run::Union{Nothing,AbstractString}=nothing)

Load Unfold models existing in a derivatives_subfolder in your BIDS root folder.

Keywords

  • derivatives_subfolder::String = "Unfold"
    Defines in which subfolder of bids_root/derivatives to look for Unfold models.
  • lazy::Bool = false
    Do not actually load the dataset into memore if true, only return a dataframe with paths
  • generate_Xs::Bool = true
    By default recreate the designmatrix; Can be set to false, to improve loading time.
  • ses::Union{Nothing,AbstractString} = nothing
    Which session to load; loads all if nothing
  • task::Union{Nothing,AbstractString} = nothing
    Which task to load; loads all if nothing
  • run::Union{Nothing,AbstractString} = nothing
    Which run to load; loads all if nothing
source
UnfoldBIDS.rename_to_latencyMethod
rename_to_latency(data_df)

This is a convenience function to add a :latency collumn (needed by Unfold) based on another variable in the events_df (e.g. sample)

source
UnfoldBIDS.run_unfoldMethod
run_unfold(data_df, bf_vec; 
	remove_time_expanded_Xs=true, 
	extract_data = raw_to_data, 
	verbose::Bool=true, 
	kwargs...)

Run Unfold analysis on all data in data_df. Needs to have PyMNE.jl loaded!

Arguments

  • data_df::DataFrame
    DataFrame containing BIDS data as returned by load_bids_data(). Must contain collumns: :subject, :ses, :task, :run, :raw, :events
  • bf_vec
    Basis function vector as expected by Unfold.jl's fit() function.
Can be one of: \
- `["eventname" => (formula, basisfunction)]` for overlap corrected models
- `["eventname" => (formula, timewindow)]` for mass-univariate models, where indicates (start, stop) in seconds with `typeof(timewindow) = Tuple{Real, Real}`

Keywords

  • remove_time_expanded_Xs::Bool = true
    Removes the timeexpanded designmatrix which significantly reduces the memory-consumption. This Xs is rarely needed, but can be recovered (look into the Unfold.load function)
  • extract_data::function = nothing
    Specify the function to extract the data to a data array. Falls back to raw_to_data which uses get_data and allows to pick channels if no function is povided AND PyMNE is loaded - see @Ref(raw_to_data).
  • verbose::Bool = true)
    Show ProgressBar or not.
  • kwargs...
    Will be passed to both the fit() and extract_data() calls as function inputs.
    For possible kwargs to fit() please have a look at the Unfold.jl API: https://unfoldtoolbox.github.io/UnfoldDocs/Unfold.jl/stable/references/functions/
source
UnfoldBIDS.save_resultsMethod
save_results(results::DataFrame, bids_root::String; 
    derivatives_subfolder::String="Unfold",
    overwrite::Bool=false)

Function to save unfold models in your BIDS root folder. Automatically creates a derivatives_subfolder (default = "Unfold") in the derivatives and subsequentely safes each model in results according to BIDS. Example of path to saved file: bids_root/derivatives/Unfold/sub-XXX/eeg/sub-XXX_ses-XX_task-XXX_run-XX_unfold.jld2

Keywords

  • derivatives_subfolder::String = "Unfold"
    Creates the named subfolder and saves Unfold models according to BIDS.
  • overwrite::Bool = false
    Does not overwrite existing datasets; can be set to true.
source
UnfoldBIDS.unpack_eventsMethod
unpack_events(df::DataFrame)

Unpack events into tidy data frame; useful with AlgebraOfGraphics.jl

df is expected to be a UnfoldBIDS DataFrame where events are loaded already.

source