-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Description
using Distributions
begin
des = SingleSubjectDesign(;conditions=Dict(:cond => ["car","face"],
:cat => ["cat","dog","horse"]
# :continuous => range(-2,2,8),
# :continuousB => range(-2,2,8)
))
cov_des = CovariateDesign(des,120,
Dict(:continuousA => Uniform(-1,2),
:continuousB => Normal(5,1.2)))
end
UnfoldSim.@with_kw struct CovariateDesign <: UnfoldSim.AbstractDesign
design = nothing
n_trials::Int
covariates::Dict
end
begin
UnfoldSim.size(design::CovariateDesign) = design.n_trials
function UnfoldSim.generate_events(rng::UnfoldSim.AbstractRNG, design::CovariateDesign)
all_evts = []
for (covariate,dist) in design.covariates
push!(all_evts,covariate =>rand(rng,dist,design.n_trials))
end
events = UnfoldSim.DataFrame(all_evts)
if !isnothing(design.design)
n_rep = design.n_trials ./ size(des)[1]
try
Int(n_rep)
catch
error("design.n_trials need to be divisible by size(design.design)")
end
categorical_events = generate_events(deepcopy(rng),RepeatDesign(design.design,n_rep))
return hcat(categorical_events,events)
else
return events#DataFrame(all_evts)
end
end
end
generate_events(UnfoldSim.Random.MersenneTwister(), cov_des)
generate_events(des)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels