-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
markersize, relate weidth and height of topo, drop the grid
- Loading branch information
Showing
4 changed files
with
78 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
using UnfoldSim | ||
using TopoPlots | ||
using Unfold | ||
""" | ||
Makes use of TopoPlots example data (originating from eegvis matlab toolbox). | ||
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") | ||
|
||
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 | ||
|
||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
include("setup.jl") | ||
@testset "markersize change" begin | ||
include("example_data.jl") | ||
data, pos = example_data("TopoPlots.jl") | ||
plot_butterfly(data; positions=pos, extra=(markersize = 10, topoheigth=0.4, topowidth=0.4)) | ||
end |