-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunfold_eeg.jl
executable file
·53 lines (35 loc) · 1.66 KB
/
unfold_eeg.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using StatsModels, MixedModels, DataFrames
import DSP.conv
using Unfold
using UnfoldMakie,CairoMakie
using DataFrames
using CategoricalArrays
using HDF5
using CSV
sbj_id = ARGS[1]
c = h5open("/imaging/hauk/users/fm02/MEG_NEOS/jl_evts/EMEG_data_sbj_$sbj_id.h5", "r") do file
read(file, "eeg")
end
data = transpose(c)
# evts = CSV.read("/imaging/hauk/users/fm02/MEG_NEOS/jl_evts/evts_sbj_5_correct.csv", DataFrame)
evts = CSV.read("/imaging/hauk/users/fm02/MEG_NEOS/jl_evts/evts_sbj_$(sbj_id)_concpred.csv", DataFrame)
bf1 = firbasis(τ=(-0.15,.5),sfreq=250,name="fix")
bf2 = firbasis(τ=(-0.15,.5),sfreq=250,name="targ")
f1 = @formula 0~1
f2 = @formula 0~1+Predictability+Concreteness
bfDict = Dict("fixation"=>(f1,bf1),
"target"=>(f2,bf2))
m = Unfold.fit(UnfoldModel,
bfDict,
evts,
data,asolver=(x,y) -> Unfold.solver_default(x,y;stderror=true),
eventcolumn="type")
results = coeftable(m)
#plot_erp(results)
CSV.write("/imaging/hauk/users/fm02/MEG_NEOS/jl_evts/eeg_coeftable_$(sbj_id)_concpred.csv", results, transform=(col, val) -> something(val, missing))
eff = effects(Dict(:Predictability => ["Predictable",
"Unpredictable"]),m)
CSV.write("/imaging/hauk/users/fm02/MEG_NEOS/jl_evts/eeg_effect_$(sbj_id)_pred.csv", eff, transform=(col, val) -> something(val, missing))
eff = effects(Dict(:Concreteness => ["Concrete",
"Abstract"]),m)
CSV.write("/imaging/hauk/users/fm02/MEG_NEOS/jl_evts/eeg_effect_$(sbj_id)_conc.csv", eff, transform=(col, val) -> something(val, missing))