From 8ecf7c8bce01a8a5f6742e2273c4146c01508ad1 Mon Sep 17 00:00:00 2001 From: "behinger (s-ccs 001)" Date: Fri, 15 Nov 2024 11:35:06 +0100 Subject: [PATCH] added multichannel predef --- src/predefinedSimulations.jl | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/predefinedSimulations.jl b/src/predefinedSimulations.jl index c087b31d..b1a0353e 100644 --- a/src/predefinedSimulations.jl +++ b/src/predefinedSimulations.jl @@ -1,5 +1,6 @@ # here we can define some predefined Simulations. Convenient if you just want to have a quick simulation :) +using Distributions: multinom_rand! predef_2x2(; kwargs...) = predef_2x2(MersenneTwister(1); kwargs...) # without rng always call same one @@ -37,6 +38,9 @@ The most used `kwargs` is: `return_epoched=true` which returns already epoched d #### Noise - `noiselevel = 0.2`, - `noise = PinkNoise(; noiselevel = noiselevel)`, + +#### multichannel +- `multichannel = false` # if true, returns a projection of the three components to 227 channels. a list of strings is possible as well, following hartmut.cortical["label"], by default uses: `["Right Occipital Pole", "Left Postcentral Gyrus", "Left Superior Frontal Gyrus",]` """ function predef_eeg( rng; @@ -60,6 +64,8 @@ function predef_eeg( ), event_order_function = event_order_function, ) |> x -> RepeatDesign(x, n_repeats) + + return predef_eeg(rng, design, LinearModelComponent, [p1, n1, p3]; sfreq, kwargs...) end @@ -76,6 +82,9 @@ function predef_eeg( # onset overlap = (0.5, 0.2), onset = UniformOnset(; offset = sfreq * overlap[1], width = sfreq * overlap[2]), #put offset to 1 for no overlap. put width to 0 for no jitter + + # multichannel + multichannel = nothing, kwargs..., ) @@ -83,6 +92,22 @@ function predef_eeg( for c in comps append!(components, [T(c...)]) end + + if !isnothing(multichannel) + if isa(multichannel, Bool) + multichannel = [ + "Right Occipital Pole", + "Left Postcentral Gyrus", + "Left Superior Frontal Gyrus", + ] + end + hart = headmodel(type = "hartmut") + @assert length(components) == length(multichannel) + + components = + MultichannelComponent.(components, [hart => label for label in multichannel]) + + end return simulate(rng, design, components, onset, noise; kwargs...) end