Skip to content

Commit 8ebf3c2

Browse files
authored
Docs update: better navigation, clearer examples, added demo GIF
- The docs navigation was reorganized for clarity, grouping theory pages and renaming some sections. - Comments and section headers in example files were revised for clearer explanations. - Example scripts now use the new examples_data function for loading datasets. - Code in topoplots_example.jl was reorganized and cleaned up; new helper functions were added. - Removed or updated unnecessary includes/imports (such as WGLMakie). - Deleted the unused examples/setup.jl file. - A demo GIF (ERRgnostics_inaction.gif) was added to the documentation. - Renamed example_data to examples_data for better clarity.
2 parents 203ecae + 93fa478 commit 8ebf3c2

File tree

13 files changed

+86
-117
lines changed

13 files changed

+86
-117
lines changed

assets/ERRgnostics_inaction.gif

2.03 MB
Loading

docs/literate/intro/gnostics.jl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
using CairoMakie
22
using DataFrames
33
using UnfoldMakie
4-
using JLD2
4+
using JLD2, CSV
55
using ERPgnostics
66

77
CairoMakie.activate!()
88

99
# Data input
1010
path = dirname(dirname(Base.current_project()))
11-
include(path * "/docs/example_data.jl")
1211
evts = DataFrame(CSV.File(path * "/data/events.csv"))
1312
positions_128 = JLD2.load_object(path * "/data/positions_128.jld2")
1413
erps_fix_32 = JLD2.load_object(path * "/data/erps_fix_32.jld2")
15-
pattern_detection_values_32 = example_data("pattern_detection_values_32");
14+
pattern_detection_values_32 = ERPgnostics.examples_data("pattern_detection_values_32");
1615
desired_conditions = ["duration", "fix_avgpos_x", "fix_avgpos_y", "fix_avgpupilsize"]
1716

18-
# Plotting
17+
# ERPgnostics in action
18+
# *Static version*
1919

2020
inter_toposeries_image(
2121
filter(row -> row.condition in desired_conditions, pattern_detection_values_32),
@@ -25,3 +25,7 @@ inter_toposeries_image(
2525
positions = positions_128[1:32],
2626
figure_configs = (; size = (1500, 700)),
2727
)
28+
29+
# *Interactive version*
30+
31+
# ![](ERRgnostics_inaction.gif)

docs/literate/intro/toposeries.jl

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,30 @@ using JLD2
1111
using ERPgnostics
1212
CairoMakie.activate!()
1313

14-
# Data input
14+
# **Data input**
1515
path = dirname(dirname(Base.current_project()))
16-
include(path * "/docs/example_data.jl")
1716

1817
positions_128 = JLD2.load_object(path * "/data/positions_128.jld2")
19-
pattern_detection_values = example_data();
20-
21-
# Interactive topoplot series with one row
22-
18+
pattern_detection_values = ERPgnostics.examples_data("pattern_detection_values");
2319
desired_conditions = ["duration", "fix_avgpos_x", "fix_avgpos_y", "fix_avgpupilsize"]
24-
inter_toposeries(
25-
filter(row -> row.condition in desired_conditions, pattern_detection_values);
20+
short_pdvs = filter(row -> row.condition in desired_conditions, pattern_detection_values);
21+
22+
# **Standart topoplot series**
23+
plot_topoplotseries(
24+
short_pdvs;
25+
nrows = 2,
26+
mapping = (; col = :condition),
27+
axis = (; xlabel = "Sorting conditions"),
28+
colorbar = (; label = "Pattern detection values"),
29+
visual = (; colormap = Reverse(:RdGy_4)),
2630
positions = positions_128,
2731
)
2832

29-
# Interactive topoplot series with multiple rows
33+
34+
# **Interactive topoplot series with one row**
35+
inter_toposeries(short_pdvs; positions = positions_128)
36+
37+
# **Interactive topoplot series with multiple rows**
3038
inter_toposeries(
3139
pattern_detection_values;
3240
positions = positions_128,

docs/make.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,12 @@ makedocs(;
3434
assets = String[],
3535
),
3636
pages = [
37-
"ERPgnostics highlights" => "index.md",
38-
"ERP image and patterns" => "generated/intro/patterns.md",
39-
"Toposeries with patterns" => "generated/intro/toposeries.md",
40-
"Diagnostics" => "generated/intro/gnostics.md",
37+
"Homepage" => "index.md",
38+
"Theory" => [
39+
"ERP image and patterns" => "generated/intro/patterns.md",
40+
"Toposeries with patterns" => "generated/intro/toposeries.md",
41+
"Diagnostics" => "generated/intro/gnostics.md",
42+
],
4143
"API / DocStrings" => "api.md",
4244
],
4345
)

examples/heatmap_example.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ begin
66
using Unfold
77
using CSV, DataFrames
88
using Random, Format
9-
using WGLMakie, Makie
9+
using Makie
1010
using Statistics, StatsBase
1111
using HDF5, FileIO
1212
using Printf

examples/runner.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ begin
55
using Revise
66
Revise.retry()
77
using ERPgnostics
8-
include("test/setup.jl")
8+
include("$(stub)/test/setup.jl")
99
using JuliaFormatter
1010
ENV["JULIA_DEBUG"] = "ERPgnostics"
1111
cd("$(stub)/test")

examples/setup.jl

Lines changed: 0 additions & 30 deletions
This file was deleted.

examples/topoplots_example.jl

Lines changed: 35 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,52 @@
1-
includet("setup.jl")
2-
includet("../src/topoplots.jl")
3-
41
Makie.inline!(false)
5-
2+
using HDF5
3+
using DataFrames
4+
using CSV, JLD2
5+
using GLMakie
6+
GLMakie.activate!()
67
# data
8+
function drop_all_nan_columns(df::DataFrame)
9+
non_all_nan_cols = names(df)[.!all.(col -> all(x -> x isa Number && isnan(x), col), eachcol(df))]
10+
return df[:, non_all_nan_cols]
11+
end
712
begin
8-
fid = h5open("data/data_fixations.hdf5", "r")
13+
fid = h5open("../data/data_fixations.hdf5", "r")
914
erps_fix = read(fid["data"]["data_fixations.hdf5"])
1015
close(fid)
1116

12-
evts = DataFrame(CSV.File("data/events.csv"))
13-
evts_d = CSV.read("data/evts_d.csv", DataFrame)
14-
evts_mf = CSV.read("data/evts_mf.csv", DataFrame)
15-
positions_128 = JLD2.load_object("data/positions_128.jld2")
17+
evts_raw = DataFrame(CSV.File("../data/events.csv"))
18+
evts_d = CSV.read("../data/evts_d.csv", DataFrame)
19+
evts_mf = CSV.read("../data/evts_mf.csv", DataFrame)
20+
positions_128 = JLD2.load_object("../data/positions_128.jld2")
1621
timing = -0.5:0.001953125:1.0
22+
23+
24+
evts = drop_all_nan_columns(evts_raw)
1725
end
1826

1927
begin
20-
pattern_detection_values = stack(evts_d)
21-
pattern_detection_values.timing = 1:nrow(pattern_detection_values)
22-
pattern_detection_values.label = 1:nrow(pattern_detection_values)
28+
evts_d.channel = 1:nrow(evts_d)
29+
pattern_detection_values = stack(evts_d[1:32, :])
2330
rename!(pattern_detection_values, :variable => :condition, :value => :estimate)
24-
pattern_detection_values.rows = vcat(
25-
repeat(["A"], size(pattern_detection_values, 1) ÷ 4),
26-
repeat(["B"], size(pattern_detection_values, 1) ÷ 4),
27-
repeat(["C"], size(pattern_detection_values, 1) ÷ 4),
28-
repeat(["D"], size(pattern_detection_values, 1) ÷ 4),
29-
)
30-
end
31-
32-
inter_toposeries(filter(x -> x.rows == "A", pattern_detection_values))
33-
inter_toposeries(filter(x -> x.rows == "B", pattern_detection_values))
34-
inter_toposeries(filter(x -> x.rows == "C", pattern_detection_values))
35-
inter_toposeries(filter(x -> x.rows == "D", pattern_detection_values))
3631

37-
inter_toposeries_image(pattern_detection_values1, evts, erps)
38-
39-
inter_toposeries_image(filter(x -> x.rows == "A", pattern_detection_values), evts, erps_fix, timing)
40-
inter_toposeries_image(filter(x -> x.rows == "B", pattern_detection_values), evts, erps_fix, timing) #fails
41-
inter_toposeries_image(filter(x -> x.rows == "C", pattern_detection_values), evts, erps_fix, timing)
42-
inter_toposeries_image(filter(x -> x.rows == "D", pattern_detection_values), evts, erps_fix, timing)
32+
valid_conditions = names(evts)
33+
filtered_values = filter(row -> row.condition in valid_conditions, pattern_detection_values)
34+
end
4335

36+
inter_toposeries_image(
37+
filtered_values,
38+
evts,
39+
erps_fix[1:32, :, :],
40+
1:769;
41+
positions = positions_128[1:32],
42+
toposeries_configs = (; nrows = 3),
43+
erpimage_configs = (; meanplot_axis = (; xlabel = "Time [s]")),
44+
figure_configs = (; size = (1500, 700)),
45+
)
46+
47+
###################################
4448
inter_toposeries_image(filter(x -> x.condition == "fix_samebox", pattern_detection_values), evts, erps_fix, timing)
45-
49+
erps_fix[1:32, :, :]
4650

4751
# make that workable
4852
begin
@@ -51,21 +55,3 @@ begin
5155
end
5256

5357
inter_toposeries_image(pattern_detection_values, evts_sim, data_all, timing; positions_128 = positions_128)
54-
55-
56-
# debugging zone
57-
58-
begin
59-
pattern_detection_values2 = stack(evts_mf)
60-
pattern_detection_values2.timing = 1:nrow(pattern_detection_values)
61-
pattern_detection_values2.label = 1:nrow(pattern_detection_values)
62-
rename!(pattern_detection_values2, :variable => :condition, :value => :estimate)
63-
pattern_detection_values2.rows = vcat(
64-
repeat(["A"], size(pattern_detection_values2, 1) ÷ 4),
65-
repeat(["B"], size(pattern_detection_values2, 1) ÷ 4),
66-
repeat(["C"], size(pattern_detection_values2, 1) ÷ 4),
67-
repeat(["D"], size(pattern_detection_values2, 1) ÷ 4),
68-
)
69-
end
70-
71-
inter_toposeries_image(filter(x -> x.rows == "A", pattern_detection_values2), evts, erps_fix, timing)

src/ERPgnostics.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ using ComputationalResources
1616
using Observables
1717
using DSP
1818
using JLD2
19-
using WGLMakie
2019
using ProgressBars
2120

2221
include("configs.jl")
2322
include("interactive_heatmap.jl")
2423
include("interactive_topoplots.jl")
2524
include("pattern_detection.jl")
2625
include("pattern_simulation.jl")
26+
include("example_data.jl")
2727
include("filters.jl")
2828

2929
export inter_toposeries # or better toposeries_inter
@@ -40,4 +40,5 @@ export complex_pattern_detector
4040

4141
export slow_filter
4242
export mean_filter
43+
export example_data
4344
end

docs/example_data.jl renamed to src/example_data.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Datasets:
1616
1717
**Return Value:** `DataFrame`.
1818
"""
19-
function example_data(example = "pattern_detection_values"; mode = 1)
19+
function examples_data(example = "pattern_detection_values"; mode = 1)
2020
if mode == 1
2121
datapath = dirname(dirname(Base.current_project())) * "/data/evts_d.csv"
2222
else

0 commit comments

Comments
 (0)