diff --git a/docs/example_data.jl b/docs/example_data.jl index 2cc0d5e09..92106a3e1 100644 --- a/docs/example_data.jl +++ b/docs/example_data.jl @@ -7,60 +7,96 @@ type == "TopoPlots.jl"(default) Returns tidy DataFrame with two conditions, 64 channels and 800ms of data. This is an average over many subjects. """ -function example_data(example="TopoPlots.jl") +function example_data(example = "TopoPlots.jl") - if example == "UnfoldLinearModel" - # load and generate a simulated Unfold Design - data,evts = UnfoldSim.predef_eeg(;noiselevel=10,return_epoched=true) - data = reshape(data,1,size(data)...) - f = @formula 0~1+condition+continuous - # generate ModelStruct - se_solver =(x,y)->Unfold.solver_default(x,y,stderror=true) - return fit(UnfoldModel,(Dict(Any=>(f,range(0,length=size(data,2),step=1/100)))) ,evts,data;solver=se_solver) - elseif example == "UnfoldLinearModelMultiChannel" - # load and generate a simulated Unfold Design - cAll = DataFrame() - sfreq = 100 - for ch = 1:5 - data,evts = UnfoldSim.predef_eeg(;p1 = (p100(;sfreq=sfreq), @formula(0~1),[5],Dict()), - - n1 = (n170(;sfreq=sfreq), @formula(0~1+condition),[5,-ch*0.5],Dict()), - p3 = (p300(;sfreq=sfreq), @formula(0~1+continuous),[ch,1],Dict()), - return_epoched=true) - data = reshape(data,1,size(data)...) - f = @formula 0~1+condition+continuous - # generate ModelStruct - - m= fit(UnfoldModel,(Dict(Any=>(f,range(0,length=size(data,2),step=1/100)))) ,evts,data) - d = coeftable(m) - d.channel .= ch - cAll = append!(cAll,d) - end - return cAll + if example == "UnfoldLinearModel" + # load and generate a simulated Unfold Design + data, evts = UnfoldSim.predef_eeg(; noiselevel = 10, return_epoched = true) + data = reshape(data, 1, size(data)...) + f = @formula 0 ~ 1 + condition + continuous + # generate ModelStruct + se_solver = (x, y) -> Unfold.solver_default(x, y, stderror = true) + return fit( + UnfoldModel, + (Dict(Any => (f, range(0, length = size(data, 2), step = 1 / 100)))), + evts, + data; + solver = se_solver, + ) + elseif example == "UnfoldLinearModelMultiChannel" + # load and generate a simulated Unfold Design + cAll = DataFrame() + sfreq = 100 + for ch = 1:5 + data, evts = UnfoldSim.predef_eeg(; + p1 = (p100(; sfreq = sfreq), @formula(0 ~ 1), [5], Dict()), + n1 = ( + n170(; sfreq = sfreq), + @formula(0 ~ 1 + condition), + [5, -ch * 0.5], + Dict(), + ), + p3 = (p300(; sfreq = sfreq), @formula(0 ~ 1 + continuous), [ch, 1], Dict()), + return_epoched = true, + ) + data = reshape(data, 1, size(data)...) + f = @formula 0 ~ 1 + condition + continuous + # generate ModelStruct - elseif example == "UnfoldLinearModelContinuousTime" - # load and generate a simulated Unfold Design - data,evts = UnfoldSim.predef_eeg(;) - data = reshape(data,1,size(data)...) - f = @formula 0~1+condition+continuous - basis = firbasis([0,0.5],100) - # generate ModelStruct - return fit(UnfoldModel,Dict(Any=>(f,basis)) ,evts,data) - - elseif example == "TopoPlots.jl" - data,chanlocs = TopoPlots.example_data(); - df = DataFrame(estimate=Float64[],time=Float64[],channel=Int64[],coefname=String[],topoPositions=[],se=Float64[],pval=Float64[]) - pos = TopoPlots.points2mat(chanlocs) - for ch = 1:size(data,1) - for t = 1:size(data,2) - append!(df,DataFrame(estimate=data[ch,t,1],se=data[ch,t,2],pval=data[ch,t,3],time=t,channel=ch,coefname="A",topoPositions=(pos[1,ch],pos[2,ch]))) - - - end - end - df.time = range(-0.3,0.5,step=1/500)[Int.(df.time)] - return df,chanlocs - else - error("unknown example data") - end -end \ No newline at end of file + m = fit( + UnfoldModel, + (Dict(Any => (f, range(0, length = size(data, 2), step = 1 / 100)))), + evts, + data, + ) + d = coeftable(m) + d.channel .= ch + cAll = append!(cAll, d) + end + return cAll + + elseif example == "UnfoldLinearModelContinuousTime" + # load and generate a simulated Unfold Design + data, evts = UnfoldSim.predef_eeg(;) + data = reshape(data, 1, size(data)...) + f = @formula 0 ~ 1 + condition + continuous + basis = firbasis([0, 0.5], 100) + # generate ModelStruct + return fit(UnfoldModel, Dict(Any => (f, basis)), evts, data) + + elseif example == "TopoPlots.jl" + data, chanlocs = TopoPlots.example_data() + df = DataFrame( + estimate = Float64[], + time = Float64[], + channel = Int64[], + coefname = String[], + topo_positions = [], + se = Float64[], + pval = Float64[], + ) + pos = TopoPlots.points2mat(chanlocs) + for ch = 1:size(data, 1) + for t = 1:size(data, 2) + append!( + df, + DataFrame( + estimate = data[ch, t, 1], + se = data[ch, t, 2], + pval = data[ch, t, 3], + time = t, + channel = ch, + coefname = "A", + topo_positions = (pos[1, ch], pos[2, ch]), + ), + ) + + + end + end + df.time = range(-0.3, 0.5, step = 1 / 500)[Int.(df.time)] + return df, chanlocs + else + error("unknown example data") + end +end diff --git a/docs/make.jl b/docs/make.jl index 9b42fed8f..1844d78a4 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -22,20 +22,20 @@ for subfolder ∈ ["explanations", "HowTo", "tutorials", "reference"] end -DocMeta.setdocmeta!(UnfoldMakie, :DocTestSetup, :(using UnfoldMakie); recursive=true) +DocMeta.setdocmeta!(UnfoldMakie, :DocTestSetup, :(using UnfoldMakie); recursive = true) makedocs(; - modules=[UnfoldMakie], - authors="Benedikt Ehinger, Vladimir Mikheev, Daniel Baumgartner, Niklas Gärtner, Sören Döring", - repo="https://github.com/unfoldtoolbox/UnfoldMakie.jl/blob/{commit}{path}#{line}", - sitename="UnfoldMakie.jl", - warnonly = :cross_references, - format=Documenter.HTML(; - prettyurls=get(ENV, "CI", "false") == "true", - canonical="https://unfoldtoolbox.github.io/UnfoldMakie.jl", - assets=String[] + modules = [UnfoldMakie], + authors = "Benedikt Ehinger, Vladimir Mikheev, Daniel Baumgartner, Niklas Gärtner, Sören Döring", + repo = "https://github.com/unfoldtoolbox/UnfoldMakie.jl/blob/{commit}{path}#{line}", + sitename = "UnfoldMakie.jl", + warnonly = :cross_references, + format = Documenter.HTML(; + prettyurls = get(ENV, "CI", "false") == "true", + canonical = "https://unfoldtoolbox.github.io/UnfoldMakie.jl", + assets = String[], ), - pages=[ + pages = [ "UnfoldMakie Documentation" => "index.md", "Visualizations-Types" => [ "ERP plot" => "generated/tutorials/erp.md", @@ -55,16 +55,11 @@ makedocs(; "Show out of Bounds Label" => "how_to/show_oob_labels.md", ], "Reference" => [ - "Convert 3D positions / montages to 2D layouts" => "generated/reference/positions.md" - + "Convert 3D positions / montages to 2D layouts" => "generated/reference/positions.md", ], "API" => "api.md", "Utilities" => "helper.md", ], - ) -deploydocs(; - repo="github.com/unfoldtoolbox/UnfoldMakie.jl", - devbranch="main" -) +deploydocs(; repo = "github.com/unfoldtoolbox/UnfoldMakie.jl", devbranch = "main") diff --git a/docs/run_liveserver.jl b/docs/run_liveserver.jl index 4a1068d02..85879e690 100644 --- a/docs/run_liveserver.jl +++ b/docs/run_liveserver.jl @@ -1,7 +1,7 @@ using LiveServer -servedocs(skip_dir=joinpath("src","generated"), - literate_dir=joinpath("literate"), - literate=joinpath("literate"), - foldername="." - ) - +servedocs( + skip_dir = joinpath("src", "generated"), + literate_dir = joinpath("literate"), + literate = joinpath("literate"), + foldername = ".", +)