From 81496e9b36db1db39ff57c8907f2090f9782061f Mon Sep 17 00:00:00 2001 From: Vladimir Mikheev Date: Mon, 20 Jan 2025 19:38:14 +0100 Subject: [PATCH] explaining text --- docs/example_data.jl | 14 ++++++++++---- docs/literate/how_to/uncertain_topo.jl | 18 ++++++++++++++---- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/docs/example_data.jl b/docs/example_data.jl index 762ce0c2..9f709bec 100644 --- a/docs/example_data.jl +++ b/docs/example_data.jl @@ -186,7 +186,11 @@ function example_data(example = "TopoPlots.jl") generate_events(design) time1 = vcat(rand(time_padding), component) # 500 msec = randiom 100 msec and 400 msec of n400 - c = UnfoldSim.LinearModelComponent(; basis = time1, formula = @formula(0 ~ 1), β = [1]) + c = UnfoldSim.LinearModelComponent(; + basis = time1, + formula = @formula(0 ~ 1), + β = [1], + ) hart = headmodel(type = "hartmut") # 227 electrodes less_hart = magnitude(hart)[:, 1] # extract 1 lead field and 64 electrodes @@ -207,16 +211,18 @@ function example_data(example = "TopoPlots.jl") # Create the DataFrame df = DataFrame( :estimate => dat[:], - :channel => repeat(1:size(dat, 1), outer = Int(length(dat[:]) / size(dat, 1))), + :channel => + repeat(1:size(dat, 1), outer = Int(length(dat[:]) / size(dat, 1))), :time => repeat(1:size(dat, 2), outer = Int(length(dat[:]) / size(dat, 2))), - :trial => repeat(1:size(dat, 3), outer = Int(length(dat[:]) / size(dat, 3))), + :trial => + repeat(1:size(dat, 3), outer = Int(length(dat[:]) / size(dat, 3))), ) # chosing positions pos3d = hart.electrodes["pos"] pos2d = to_positions(pos3d') pos2d = [Point2f(p[1] + 0.5, p[2] + 0.5) for p in pos2d] - return df, pos2d + return df, pos2d elseif example == "raw_ch_names" return [ "FP1", diff --git a/docs/literate/how_to/uncertain_topo.jl b/docs/literate/how_to/uncertain_topo.jl index f9bde75a..c6000887 100644 --- a/docs/literate/how_to/uncertain_topo.jl +++ b/docs/literate/how_to/uncertain_topo.jl @@ -1,3 +1,7 @@ +# ```@raw html +#
+# Click to expand +# ``` using Unfold using UnfoldMakie using UnfoldSim @@ -7,11 +11,20 @@ using TopoPlots using Statistics using Random +# ```@raw html +#
+# ``` +# Representing uncertainty is one of the most difficult tasks in visualization. It is especially difficult for heatmaps and topoplots. +# Here we will present new ways to show uncertainty for topoplots series. + # Data input include("../../../example_data.jl") dat, positions = TopoPlots.example_data() df = UnfoldMakie.eeg_array_to_dataframe(dat[:, :, 1], string.(1:length(positions))); df_uncert = UnfoldMakie.eeg_array_to_dataframe(dat[:, :, 2], string.(1:length(positions))); + +# Generate data with 227 channels, 50 trials, 500 mseconds for bootstrapping +df_toposeries, pos_toposeries = data, pos = example_data("bootstrap_toposeries"); nothing #hide # # Uncertainty via additional row @@ -50,15 +63,12 @@ function bootstrap_toposeries(df) df1.estimate = tmp return df1 end - -# Generate data with 227 channels, 50 trials, 500 mseconds # ```@raw html # # ``` # To show uncertainty of estimate we will compute 10 different means of bootsrtaped data. # More detailed: 1) create N boostrapped datasets by random sampling with replacement across trials; 2) compute their means; 3) do toposeries animation iterating across these means. -df_toposeries, pos_toposeries = data, pos = example_data("bootstrap_toposeries") dat_obs = Observable(df_toposeries) f = Figure() plot_topoplotseries!( @@ -74,6 +84,6 @@ record(f, "bootstrap_toposeries.gif"; framerate = 10000) do io dat_obs[] = bootstrap_toposeries(df_toposeries) recordframe!(io) end -end +end; # ![](bootstrap_toposeries.gif)