-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update paper.md #30
Update paper.md #30
Conversation
The argument `n_trials` does not exist for the function predef_eeg (at least in the current version of UnfoldSim.jl).
Correct mistake in README.md
multichannel
All contributors should be added as a comment in a pull request or an issue. Eg : @all-contributors please add @behinger for <contributions> <contributions can be found in the emoji key in the Unfold.jl repo (needs to be merged)>
added the @all-contributors functionality
small cleanup changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
basisfunction::Any | |
maxlength::Any |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
ax = f[1, 1] = Axis(f) | |
for b in [p100, n170, p300, n400] | |
lines!(ax, b(), label = string(b)) | |
scatter!(ax, b(), label = string(b)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
plotConfig = (:n => 5:3:15, :tmax => 0.5:0.2:1.1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
design = | |
SingleSubjectDesign(; conditions = Dict(:condA => ["levelA", "levelB"])) |> | |
x -> RepeatDesign(x, 10); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
basis = [0, 0, 0, 0.5, 1, 1, 0.5, 0, 0], | |
formula = @formula(0 ~ 1 + condA), | |
β = [1, 0.5], | |
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
repo = Documenter.Remotes.GitHub("unfoldtoolbox", "UnfoldSim.jl"), | |
sitename = "UnfoldSim.jl", | |
format = Documenter.HTML(; | |
prettyurls = get(ENV, "CI", "false") == "true", | |
canonical = "https://unfoldtoolbox.github.io/UnfoldSim.jl", | |
edit_link = "main", | |
assets = String[], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
using DSP | |
using Random | |
using DataFrames | |
using Distributions # for LogNormal Onset | |
using Parameters | |
using StatsModels | |
using MixedModels | |
using ImageFiltering # for Noise-filter (can be replaced maybe?) | |
using MixedModelsSim | |
using SignalAnalysis | |
using LinearAlgebra | |
using ToeplitzMatrices # for AR Expo. Noise "Circulant" | |
using StatsModels | |
using HDF5, Artifacts, FileIO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
import DSP.hanning | |
import Base.length | |
import Base.size | |
import Base.show | |
include("types.jl") | |
include("design.jl") | |
include("component.jl") | |
include("noise.jl") | |
include("simulation.jl") | |
include("onset.jl") | |
include("predefinedSimulations.jl") | |
include("headmodel.jl") | |
include("helper.jl") | |
include("bases.jl") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
predef_2x2(; kwargs...) = predef_2x2(MersenneTwister(1); kwargs...) # without rng always call same one | |
predef_eeg(; kwargs...) = predef_eeg(MersenneTwister(1); kwargs...) # without rng always call same one | |
predef_eeg(nsubjects::Int; kwargs...) = predef_eeg(MersenneTwister(1), nsubjects; kwargs...) # without rng always call same one |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
function predef_eeg( | |
rng; | |
# design | |
n_repeats = 100, | |
tableModifyFun = x -> shuffle(deepcopy(rng), x), | |
# component / signal | |
sfreq = 100, | |
p1 = (p100(; sfreq = sfreq), @formula(0 ~ 1), [5], Dict()), | |
n1 = (n170(; sfreq = sfreq), @formula(0 ~ 1 + condition), [5, -3], Dict()), | |
p3 = (p300(; sfreq = sfreq), @formula(0 ~ 1 + continuous), [5, 1], Dict()), | |
kwargs..., | |
) | |
design = | |
SingleSubjectDesign(; | |
conditions = Dict( | |
:condition => ["car", "face"], | |
:continuous => range(-5, 5, length = 10), | |
), | |
tableModifyFun = tableModifyFun, | |
) |> x -> RepeatDesign(x, n_repeats) | |
return predef_eeg(rng, design, LinearModelComponent, [p1, n1, p3]; sfreq, kwargs...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
function predef_eeg( | |
rng::AbstractRNG, | |
n_subjects; | |
# design | |
n_items = 100, | |
tableModifyFun = x -> shuffle(deepcopy(rng), x), | |
conditions = Dict( | |
:condition => ["car", "face"], | |
:continuous => range(-5, 5, length = 10), | |
), | |
# component / signal | |
sfreq = 100, | |
p1 = (; | |
s = p100(; sfreq = sfreq), | |
f = @formula(0 ~ 1 + (1 | subject) + (1 | item)), | |
β = [5], | |
σs = Dict(:subject => [1], :item => [1]), | |
c = Dict(), | |
), | |
n1 = (; | |
s = n170(; sfreq = sfreq), | |
f = @formula( | |
0 ~ 1 + condition + (1 + condition | subject) + (1 + condition | item) | |
), | |
β = [5, -3], | |
σs = Dict(:subject => [1, 1], :item => [0.5, 0.5]), | |
c = Dict(), | |
), | |
p3 = (; | |
s = p300(; sfreq = sfreq), | |
f = @formula( | |
0 ~ 1 + continuous + (1 + continuous | subject) + (1 + continuous | item) | |
), | |
β = [5, 1], | |
σs = Dict(:subject => [1, 1], :item => [0.5, 0.5]), | |
c = Dict(), | |
), | |
kwargs..., | |
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
function simulate(rng, simulation::Simulation; return_epoched::Bool = false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
@test padarray([2, 2], (-3, 2), -1) == [-1, -1, -1, 2, 2, -1, -1] | |
@test padarray([2, 2], -2, -1) == [-1, -1, 2, 2] | |
@test padarray([2, 2], 2, -1) == [2, 2, -1, -1] | |
@test padarray([2, 2], 2, -1) == [2, 2, -1, -1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit
JuliaFormatter
src/component.jl|64|
src/component.jl|70|
src/component.jl|72|
src/component.jl|75|
src/component.jl|96|
src/component.jl|102|
src/component.jl|106|
src/headmodel.jl|3|
src/headmodel.jl|9|
src/headmodel.jl|13|
src/headmodel.jl|25|
src/headmodel.jl|28|
src/headmodel.jl|37|
src/headmodel.jl|43|
src/headmodel.jl|46|
src/headmodel.jl|49|
src/headmodel.jl|54|
src/headmodel.jl|61|
src/headmodel.jl|68|
src/headmodel.jl|85|
src/headmodel.jl|88|
src/headmodel.jl|101|
src/helper.jl|17|
src/helper.jl|50|
src/helper.jl|79|
src/helper.jl|81|
src/helper.jl|85|
src/predefinedSimulations.jl|79|
src/simulation.jl|3|
src/simulation.jl|6|
src/simulation.jl|14|
src/simulation.jl|21|
src/simulation.jl|25|
src/simulation.jl|32|
src/simulation.jl|41|
src/simulation.jl|48|
src/simulation.jl|54|
src/simulation.jl|66|
src/simulation.jl|68 col 1|
src/simulation.jl|69|
src/simulation.jl|71|
src/simulation.jl|79|
src/simulation.jl|82|
src/simulation.jl|85|
src/simulation.jl|94|
src/simulation.jl|106|
src/simulation.jl|110|
src/simulation.jl|118|
test/artifactheadmodel.jl|6|
test/artifactheadmodel.jl|16|
test/artifactheadmodel.jl|19|
test/artifactheadmodel.jl|25|
test/artifactheadmodel.jl|45|
test/headmodel.jl|3|
test/headmodel.jl|9|
test/headmodel.jl|15|
test/headmodel.jl|20|
test/helper.jl|13|
test/helper.jl|16|
test/helper.jl|18|
test/multichannel.jl|9|
test/multichannel.jl|15|
test/multichannel.jl|22|
test/multichannel.jl|27|
test/multichannel.jl|30|
test/multichannel.jl|32|
test/multichannel.jl|38|
test/simulation.jl|10|
test/simulation.jl|16|
test/simulation.jl|22|
test/simulation.jl|27|
test/simulation.jl|29|
test/simulation.jl|32|
test/simulation.jl|37|
test/simulation.jl|39|
test/simulation.jl|49|
test/simulation.jl|53|
test/simulation.jl|59|
test/simulation.jl|70|
test/simulation.jl|76|
test/simulation.jl|88|
test/simulation.jl|90|
# ## Specifying a design | ||
|
||
# We are using a one-level design for testing here. | ||
design = SingleSubjectDesign(conditions=Dict(:condA=>["levelA"])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
design = SingleSubjectDesign(conditions=Dict(:condA=>["levelA"])) | |
design = SingleSubjectDesign(conditions = Dict(:condA => ["levelA"])) |
c = LinearModelComponent(;basis=p100(),formula = @formula(0~1),β = [1]); | ||
c2 = LinearModelComponent(;basis=p300(),formula = @formula(0~1),β = [1]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
c = LinearModelComponent(;basis=p100(),formula = @formula(0~1),β = [1]); | |
c2 = LinearModelComponent(;basis=p300(),formula = @formula(0~1),β = [1]); | |
c = LinearModelComponent(; basis = p100(), formula = @formula(0 ~ 1), β = [1]); | |
c2 = LinearModelComponent(; basis = p300(), formula = @formula(0 ~ 1), β = [1]); |
|
||
# ## The multichannel component | ||
# next similar to the nested design above, we can nest the component in a `MultichannelComponent`. We could either provide the projection marix manually, e.g.: | ||
mc = UnfoldSim.MultichannelComponent(c, [1,2,-1,3,5,2.3,1]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
mc = UnfoldSim.MultichannelComponent(c, [1,2,-1,3,5,2.3,1]) | |
mc = UnfoldSim.MultichannelComponent(c, [1, 2, -1, 3, 5, 2.3, 1]) |
hart = headmodel(type="hartmut") | ||
mc = UnfoldSim.MultichannelComponent(c, hart=>"Left Postcentral Gyrus") | ||
mc2 = UnfoldSim.MultichannelComponent(c2, hart=>"Right Occipital Pole") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
hart = headmodel(type="hartmut") | |
mc = UnfoldSim.MultichannelComponent(c, hart=>"Left Postcentral Gyrus") | |
mc2 = UnfoldSim.MultichannelComponent(c2, hart=>"Right Occipital Pole") | |
hart = headmodel(type = "hartmut") | |
mc = UnfoldSim.MultichannelComponent(c, hart => "Left Postcentral Gyrus") | |
mc2 = UnfoldSim.MultichannelComponent(c2, hart => "Right Occipital Pole") |
# You could also specify a noise-specific component which is applied prior to projection & summing with other components | ||
# | ||
# finally we need to define the onsets of the signal | ||
onset = UniformOnset(;width=20,offset=4); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
onset = UniformOnset(;width=20,offset=4); | |
onset = UniformOnset(; width = 20, offset = 4); |
dr = filter(isdir,readdir(joinpath("src","generated"),join=true)) | ||
push!(dr,"./build") | ||
servedocs(skip_dirs=dr,literate_dir=joinpath("literate"),foldername=".",host="0.0.0.0") | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
dr = filter(isdir,readdir(joinpath("src","generated"),join=true)) | |
push!(dr,"./build") | |
servedocs(skip_dirs=dr,literate_dir=joinpath("literate"),foldername=".",host="0.0.0.0") | |
dr = filter(isdir, readdir(joinpath("src", "generated"), join = true)) | |
push!(dr, "./build") | |
servedocs( | |
skip_dirs = dr, | |
literate_dir = joinpath("literate"), | |
foldername = ".", | |
host = "0.0.0.0", | |
) |
|
||
using HDF5,Artifacts,FileIO | ||
|
||
using LinearAlgebra # headmodel |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
using LinearAlgebra # headmodel | |
using LinearAlgebra # headmodel |
# export bases | ||
export p100,n170,p300,n400,hrf |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
# export bases | |
export p100,n170,p300,n400,hrf | |
# noise functions | |
export PinkNoise, RedNoise, WhiteNoise, NoNoise, ExponentialNoise #,RealNoise (not implemented yet) |
# headmodel | ||
export AbstractHeadmodel,Hartmut,headmodel,leadfield,orientation,magnitude |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
# headmodel | |
export AbstractHeadmodel,Hartmut,headmodel,leadfield,orientation,magnitude | |
# UnfoldSim functions | |
export simulate, gen_noise, generate |
# multichannel | ||
export MultichannelComponent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
# multichannel | |
export MultichannelComponent | |
# utilities | |
export padarray, convert | |
# export Offsets | |
export UniformOnset, LogNormalOnset | |
# re-export StatsModels | |
export DummyCoding, EffectsCoding | |
# export bases | |
export p100, n170, p300, n400, hrf | |
# headmodel | |
export AbstractHeadmodel, Hartmut, headmodel, leadfield, orientation, magnitude | |
# multichannel | |
export MultichannelComponent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit
JuliaFormatter
src/simulation.jl|6|
src/simulation.jl|14|
src/simulation.jl|21|
src/simulation.jl|25|
src/simulation.jl|32|
src/simulation.jl|41|
src/simulation.jl|48|
src/simulation.jl|54|
src/simulation.jl|66|
src/simulation.jl|68 col 1|
src/simulation.jl|69|
src/simulation.jl|71|
src/simulation.jl|79|
src/simulation.jl|82|
src/simulation.jl|85|
src/simulation.jl|94|
src/simulation.jl|106|
src/simulation.jl|110|
src/simulation.jl|118|
test/artifactheadmodel.jl|6|
test/artifactheadmodel.jl|16|
test/artifactheadmodel.jl|19|
test/artifactheadmodel.jl|25|
test/artifactheadmodel.jl|45|
test/headmodel.jl|3|
test/headmodel.jl|9|
test/headmodel.jl|15|
test/headmodel.jl|20|
test/helper.jl|13|
test/helper.jl|16|
test/helper.jl|18|
test/multichannel.jl|9|
test/multichannel.jl|15|
test/multichannel.jl|22|
test/multichannel.jl|27|
test/multichannel.jl|30|
test/multichannel.jl|32|
test/multichannel.jl|38|
test/simulation.jl|10|
test/simulation.jl|16|
test/simulation.jl|22|
test/simulation.jl|27|
test/simulation.jl|29|
test/simulation.jl|32|
test/simulation.jl|37|
test/simulation.jl|39|
test/simulation.jl|49|
test/simulation.jl|53|
test/simulation.jl|59|
test/simulation.jl|70|
test/simulation.jl|76|
test/simulation.jl|88|
test/simulation.jl|90|
docs/literate/HowTo/newComponent.jl
Outdated
|
||
|
||
erp = UnfoldSim.simulate(MersenneTwister(1),TimeVaryingComponent(basis_shiftduration,50),design) | ||
heatmap(hcat(erp...)) No newline at end of file | ||
plot_erpimage(hcat(erp...),sortvalues=generate(design).shift) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
erp = UnfoldSim.simulate(MersenneTwister(1),TimeVaryingComponent(basis_shiftduration,50),design) | |
heatmap(hcat(erp...)) | |
\ No newline at end of file | |
plot_erpimage(hcat(erp...),sortvalues=generate(design).shift) | |
erp = UnfoldSim.simulate( | |
MersenneTwister(1), | |
TimeVaryingComponent(basis_shiftduration, 50), | |
design, | |
) | |
plot_erpimage(hcat(erp...), sortvalues = generate(design).shift) |
""" | ||
Wrapper for an `AbstractComponent` to project it to multiple target-channels via `projection`. optional adds `noise` to the source prior to projection. | ||
""" | ||
@with_kw struct MultichannelComponent <:AbstractComponent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
@with_kw struct MultichannelComponent <:AbstractComponent | |
@with_kw struct MultichannelComponent <: AbstractComponent |
noise::AbstractNoise # optional | ||
end | ||
|
||
MultichannelComponent(c::AbstractComponent,p) = MultichannelComponent(c::AbstractComponent,p,NoNoise()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
MultichannelComponent(c::AbstractComponent,p) = MultichannelComponent(c::AbstractComponent,p,NoNoise()) | |
MultichannelComponent(c::AbstractComponent, p) = | |
MultichannelComponent(c::AbstractComponent, p, NoNoise()) |
function MultichannelComponent(c::AbstractComponent,p::Pair{<:AbstractHeadmodel,String},n::AbstractNoise) | ||
ix = closest_src(p[1],p[2]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
function MultichannelComponent(c::AbstractComponent,p::Pair{<:AbstractHeadmodel,String},n::AbstractNoise) | |
ix = closest_src(p[1],p[2]) | |
function MultichannelComponent( | |
c::AbstractComponent, | |
p::Pair{<:AbstractHeadmodel,String}, | |
n::AbstractNoise, | |
) | |
ix = closest_src(p[1], p[2]) |
function MultichannelComponent(c::AbstractComponent,p::Pair{<:AbstractHeadmodel,String},n::AbstractNoise) | ||
ix = closest_src(p[1],p[2]) | ||
mg = magnitude(p[1]) | ||
return MultichannelComponent(c,mg[:,ix],n) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
return MultichannelComponent(c,mg[:,ix],n) | |
return MultichannelComponent(c, mg[:, ix], n) |
pos = closest_src(hartmut=>"Left Middle Temporal Gyrus, posterior division") | ||
``` | ||
""" | ||
function closest_src(head::Hartmut,label::String) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
function closest_src(head::Hartmut,label::String) | |
function closest_src(head::Hartmut, label::String) |
pos = head.cortical["pos"] | ||
ix = findall(head.cortical["label"] .== label) | ||
@assert sum(ix)>0 """could not find label $label in hartmut.cortical["label"] - try unique(hartmut.cortical["label"]) for a list""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
pos = head.cortical["pos"] | |
ix = findall(head.cortical["label"] .== label) | |
@assert sum(ix)>0 """could not find label $label in hartmut.cortical["label"] - try unique(hartmut.cortical["label"]) for a list""" | |
pos = head.cortical["pos"] | |
ix = findall(head.cortical["label"] .== label) | |
@assert sum(ix) > 0 """could not find label $label in hartmut.cortical["label"] - try unique(hartmut.cortical["label"]) for a list""" |
ix = UnfoldSim.closest_src(mean(pos[ix,:],dims=1)[1,:],pos) | ||
return ix | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
ix = UnfoldSim.closest_src(mean(pos[ix,:],dims=1)[1,:],pos) | |
return ix | |
end | |
ix = UnfoldSim.closest_src(mean(pos[ix, :], dims = 1)[1, :], pos) | |
return ix | |
end |
@@ -74,12 +79,6 @@ function predef_eeg(rng::AbstractRNG,design::AbstractDesign,T::Type{<:AbstractCo | |||
return simulate(rng,design, components, onset, noise;kwargs...); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
return simulate(rng,design, components, onset, noise;kwargs...); | |
return simulate(rng, design, components, onset, noise; kwargs...) |
@@ -2,70 +2,117 @@ | |||
# helper to move input ::Component to ::Vector{Component} | |||
Simulation(design::AbstractDesign,component::AbstractComponent,onset::AbstractOnset,noisetype::AbstractNoise) = Simulation(design,[component],onset,noisetype) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
Simulation(design::AbstractDesign,component::AbstractComponent,onset::AbstractOnset,noisetype::AbstractNoise) = Simulation(design,[component],onset,noisetype) | |
Simulation( | |
design::AbstractDesign, | |
component::AbstractComponent, | |
onset::AbstractOnset, | |
noisetype::AbstractNoise, | |
) = Simulation(design, [component], onset, noisetype) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit
JuliaFormatter
test/helper.jl|16|
test/helper.jl|18|
test/multichannel.jl|9|
test/multichannel.jl|15|
test/multichannel.jl|22|
test/multichannel.jl|27|
test/multichannel.jl|30|
test/multichannel.jl|32|
test/multichannel.jl|38|
test/simulation.jl|10|
test/simulation.jl|16|
test/simulation.jl|22|
test/simulation.jl|27|
test/simulation.jl|29|
test/simulation.jl|32|
test/simulation.jl|37|
test/simulation.jl|39|
test/simulation.jl|49|
test/simulation.jl|53|
test/simulation.jl|59|
test/simulation.jl|70|
test/simulation.jl|76|
test/simulation.jl|88|
test/simulation.jl|90|
docs/literate/HowTo/newComponent.jl
Outdated
|
||
|
||
erp = UnfoldSim.simulate(MersenneTwister(1),TimeVaryingComponent(basis_shiftduration,50),design) | ||
heatmap(hcat(erp...)) No newline at end of file | ||
plot_erpimage(hcat(erp...),sortvalues=generate(design).shift) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
erp = UnfoldSim.simulate(MersenneTwister(1),TimeVaryingComponent(basis_shiftduration,50),design) | |
heatmap(hcat(erp...)) | |
\ No newline at end of file | |
plot_erpimage(hcat(erp...),sortvalues=generate(design).shift) | |
erp = UnfoldSim.simulate( | |
MersenneTwister(1), | |
TimeVaryingComponent(basis_shiftduration, 50), | |
design, | |
) | |
plot_erpimage(hcat(erp...), sortvalues = generate(design).shift) |
@@ -2,70 +2,117 @@ | |||
# helper to move input ::Component to ::Vector{Component} | |||
Simulation(design::AbstractDesign,component::AbstractComponent,onset::AbstractOnset,noisetype::AbstractNoise) = Simulation(design,[component],onset,noisetype) | |||
|
|||
# by default no noise | |||
Simulation(design::AbstractDesign,component,onset::AbstractOnset) = Simulation(design,component,onset,NoNoise()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
Simulation(design::AbstractDesign,component,onset::AbstractOnset) = Simulation(design,component,onset,NoNoise()) | |
Simulation(design::AbstractDesign, component, onset::AbstractOnset) = | |
Simulation(design, component, onset, NoNoise()) |
""" | ||
Simulate eeg data given a simulation design, effect sizes and variances | ||
|
||
make use of `return_epoched=true` to skip the Onset-calculation + conversion to continuous data and get the epoched data directly | ||
""" | ||
simulate(rng,design, signal, onset, noise;kwargs...) = simulate(rng,Simulation(design, signal, onset, noise);kwargs...) | ||
|
||
simulate(rng, design::AbstractDesign, signal, onset::AbstractOnset, noise::AbstractNoise=NoNoise(); kwargs...) = simulate(rng, Simulation(design, signal, onset, noise); kwargs...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
simulate(rng, design::AbstractDesign, signal, onset::AbstractOnset, noise::AbstractNoise=NoNoise(); kwargs...) = simulate(rng, Simulation(design, signal, onset, noise); kwargs...) | |
simulate( | |
rng, | |
design::AbstractDesign, | |
signal, | |
onset::AbstractOnset, | |
noise::AbstractNoise = NoNoise(); | |
kwargs..., | |
) = simulate(rng, Simulation(design, signal, onset, noise); kwargs...) |
# create epoch data / erps | ||
erps = simulate(deepcopy(rng), components,simulation) | ||
# @debug size(erps) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
# create epoch data / erps | |
erps = simulate(deepcopy(rng), components,simulation) | |
# @debug size(erps) | |
# unpacking fields | |
(; design, components, onset, noisetype) = simulation |
n_subj = length(size(design))==1 ? 1 : size(design)[2] | ||
n_trial = size(design)[1] | ||
n_ch = n_channels(components) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
n_subj = length(size(design))==1 ? 1 : size(design)[2] | |
n_trial = size(design)[1] | |
n_ch = n_channels(components) | |
# create epoch data / erps | |
erps = simulate(deepcopy(rng), components, simulation) | |
# @debug size(erps) | |
n_subj = length(size(design)) == 1 ? 1 : size(design)[2] | |
n_trial = size(design)[1] | |
n_ch = n_channels(components) |
@@ -0,0 +1,23 @@ | |||
hart = UnfoldSim.headmodel() | |||
@testset "hartmut" begin | |||
@test length(hart.electrodes["label"]) == 231-4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
@test length(hart.electrodes["label"]) == 231-4 | |
@test length(hart.electrodes["label"]) == 231 - 4 |
@test isa(lf,AbstractArray) | ||
mg = magnitude(hart,type="norm") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
@test isa(lf,AbstractArray) | |
mg = magnitude(hart,type="norm") | |
@test isa(lf, AbstractArray) | |
mg = magnitude(hart, type = "norm") |
|
||
@test isa(lf,AbstractArray) | ||
mg_man = magnitude(lf,or) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
@test isa(lf,AbstractArray) | |
mg_man = magnitude(lf,or) | |
@test isa(lf, AbstractArray) | |
mg_man = magnitude(lf, or) |
@test size(mg) == (231-4,2004) | ||
|
||
|
||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
@test size(mg) == (231-4,2004) | |
end | |
@test size(mg) == (231 - 4, 2004) | |
end |
@test UnfoldSim.closest_src([0,0,1],[0 0 0.5; -1 -1 -1; -3 -3 -3]) == 1 | ||
@test UnfoldSim.closest_src([[0,0,1],[-1,-1,0]],[0 0 0.5; -1 -1 -1; -3 -3 -3]) == [1,2] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
@test UnfoldSim.closest_src([0,0,1],[0 0 0.5; -1 -1 -1; -3 -3 -3]) == 1 | |
@test UnfoldSim.closest_src([[0,0,1],[-1,-1,0]],[0 0 0.5; -1 -1 -1; -3 -3 -3]) == [1,2] | |
@test UnfoldSim.closest_src([0, 0, 1], [0 0 0.5; -1 -1 -1; -3 -3 -3]) == 1 | |
@test UnfoldSim.closest_src( | |
[[0, 0, 1], [-1, -1, 0]], | |
[0 0 0.5; -1 -1 -1; -3 -3 -3], | |
) == [1, 2] | |
docs/literate/HowTo/newComponent.jl
Outdated
|
||
|
||
erp = UnfoldSim.simulate(MersenneTwister(1),TimeVaryingComponent(basis_shiftduration,50),design) | ||
heatmap(hcat(erp...)) No newline at end of file | ||
plot_erpimage(hcat(erp...),sortvalues=generate(design).shift) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
erp = UnfoldSim.simulate(MersenneTwister(1),TimeVaryingComponent(basis_shiftduration,50),design) | |
heatmap(hcat(erp...)) | |
\ No newline at end of file | |
plot_erpimage(hcat(erp...),sortvalues=generate(design).shift) | |
erp = UnfoldSim.simulate( | |
MersenneTwister(1), | |
TimeVaryingComponent(basis_shiftduration, 50), | |
design, | |
) | |
plot_erpimage(hcat(erp...), sortvalues = generate(design).shift) |
# - if `offset` > `length(signal.basis)` -> no overlap | ||
# - if `offset` < `length(signal.basis)` -> there might be overlap, depending on the other parameters of the onset distribution | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
# [^1]: Wikipedia contributors. (2023, December 5). Log-normal distribution. In Wikipedia, The Free Encyclopedia. Retrieved 12:27, December 7, 2023, from https://en.wikipedia.org/w/index.php?title=Log-normal_distribution&oldid=1188400077# |
@test UnfoldSim.closest_src([0,0,1],[0 0 0.5; -1 -1 -1; -3 -3 -3]) == 1 | ||
@test UnfoldSim.closest_src([[0,0,1],[-1,-1,0]],[0 0 0.5; -1 -1 -1; -3 -3 -3]) == [1,2] | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
@test UnfoldSim.closest_src([[0,0,1],[-1,-1,0]],[0 0 0.5; -1 -1 -1; -3 -3 -3]) == [1,2] | ||
|
||
|
||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
end | |
end |
design = SingleSubjectDesign(conditions=Dict(:condA=>["levelA","levelB"])) |> x->RepeatDesign(x,5); | ||
signal = LinearModelComponent(;basis=[0,1,2,3,0],formula = @formula(0~1+condA),β = [2,5]); | ||
onset = UniformOnset(;width=20,offset=4); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
design = SingleSubjectDesign(conditions=Dict(:condA=>["levelA","levelB"])) |> x->RepeatDesign(x,5); | |
signal = LinearModelComponent(;basis=[0,1,2,3,0],formula = @formula(0~1+condA),β = [2,5]); | |
onset = UniformOnset(;width=20,offset=4); | |
design = | |
SingleSubjectDesign(conditions = Dict(:condA => ["levelA", "levelB"])) |> | |
x -> RepeatDesign(x, 5); | |
signal = LinearModelComponent(; | |
basis = [0, 1, 2, 3, 0], | |
formula = @formula(0 ~ 1 + condA), | |
β = [2, 5], | |
); | |
onset = UniformOnset(; width = 20, offset = 4); |
@testset "single_subject-multiple_channels" begin | ||
|
||
## Simulate data | ||
data, events = simulate(MersenneTwister(42), design_single_subject, signal_linear_multichannel, onset, noise) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
data, events = simulate(MersenneTwister(42), design_single_subject, signal_linear_multichannel, onset, noise) | |
data, events = simulate( | |
MersenneTwister(42), | |
design_single_subject, | |
signal_linear_multichannel, | |
onset, | |
noise, | |
) |
|
||
# channels x eeg | ||
@test size(data) == (n_channels_exp, eeg_length_exp) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
@testset "multiple_subjects-single_channel" begin | ||
|
||
## Simulate data | ||
data, events = simulate(MersenneTwister(42), design_multiple_subjects, signal_mixed, onset, noise) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
data, events = simulate(MersenneTwister(42), design_multiple_subjects, signal_mixed, onset, noise) | |
data, events = simulate( | |
MersenneTwister(42), | |
design_multiple_subjects, | |
signal_mixed, | |
onset, | |
noise, | |
) |
end | ||
|
||
@testset "multiple_subjects-multiple_channels" begin | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
@testset "multiple_subjects-multiple_channels" begin | ||
|
||
## Simulate data | ||
data, events = simulate(MersenneTwister(42), design_multiple_subjects, signal_mixed_multichannel, onset, noise) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
data, events = simulate(MersenneTwister(42), design_multiple_subjects, signal_mixed_multichannel, onset, noise) | |
data, events = simulate( | |
MersenneTwister(42), | |
design_multiple_subjects, | |
signal_mixed_multichannel, | |
onset, | |
noise, | |
) |
docs/literate/HowTo/newComponent.jl
Outdated
|
||
|
||
erp = UnfoldSim.simulate(MersenneTwister(1),TimeVaryingComponent(basis_shiftduration,50),design) | ||
heatmap(hcat(erp...)) No newline at end of file | ||
plot_erpimage(hcat(erp...),sortvalues=generate(design).shift) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
erp = UnfoldSim.simulate(MersenneTwister(1),TimeVaryingComponent(basis_shiftduration,50),design) | |
heatmap(hcat(erp...)) | |
\ No newline at end of file | |
plot_erpimage(hcat(erp...),sortvalues=generate(design).shift) | |
erp = UnfoldSim.simulate( | |
MersenneTwister(1), | |
TimeVaryingComponent(basis_shiftduration, 50), | |
design, | |
) | |
plot_erpimage(hcat(erp...), sortvalues = generate(design).shift) |
|
||
|
||
erp = UnfoldSim.simulate(MersenneTwister(1),TimeVaryingComponent(basis_shiftduration,50),design) | ||
heatmap(hcat(erp...)) No newline at end of file | ||
plot_erpimage(hcat(erp...),sortvalues=generate(design).shift) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
erp = UnfoldSim.simulate(MersenneTwister(1),TimeVaryingComponent(basis_shiftduration,50),design) | |
heatmap(hcat(erp...)) | |
\ No newline at end of file | |
plot_erpimage(hcat(erp...),sortvalues=generate(design).shift) | |
erp = UnfoldSim.simulate( | |
MersenneTwister(1), | |
TimeVaryingComponent(basis_shiftduration, 50), | |
design, | |
) | |
plot_erpimage(hcat(erp...), sortvalues = generate(design).shift) |
No description provided.