-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.jl
66 lines (49 loc) · 1.38 KB
/
utils.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
using DataFrames
using CSV
function get_cohort_df(study_v; ID_excluded=[], S_excluded=[])
df = DataFrame(
ID = String[],
trial = Int64[],
date = String[],
session = String[],
cue = Int64[],
choice = Int64[],
RT = Float64[],
outcome = Int64[]
)
for study in study_v
dir = string("./exp/HO2/", study,"/")
df_study = read_JBT(dir)
filter!(row -> row.session == "probe", df_study)
df_cb = CSV.File(string(dir,"counterbalance/", study, "_counterbalance.csv")) |> DataFrame
df_study.session = map(row -> df_cb[df_cb.ID.==row.ID, row.date][1], eachrow(df_study))
append!(df, df_study)
end
filter!(row -> (row.choice!=0) &&
(row.cue!=0) &&
!in(row.ID, ID_excluded) &&
!in(row.session, S_excluded),
df)
return df
end
function get_batch_df(study_dict)
ID_ket = read_JBT("./exp/probe/ketamine/ketamine/") |> df_ID -> unique(df_ID.ID)
df = DataFrame(
ID = String[],
trial = Int64[],
date = String[],
session = String[],
cue = Int64[],
choice = Int64[],
RT = Float64[],
outcome = Int64[]
)
for (dir, condition_name) in study_dict
df_study = read_JBT(dir)
filter!(row -> row.session == "probe", df_study)
df_study.session = fill(condition_name, nrow(df_study))
append!(df, df_study)
end
filter!(row -> (row.choice!=0) && (row.cue!=0) && in(row.ID, ID_ket), df)
return df
end