From 99a96b59c1fc70de053fcf729f6c46b934dfea38 Mon Sep 17 00:00:00 2001 From: Vladimir Mikheev Date: Thu, 16 Nov 2023 16:38:47 +0000 Subject: [PATCH] sorted erp added to docs --- docs/src/tutorials/erpimage.md | 32 ++++++++++++++++++++++++-------- src/plot_erpimage.jl | 6 +++--- test/Project.toml | 1 + test/test_butterfly.jl | 1 - 4 files changed, 28 insertions(+), 12 deletions(-) diff --git a/docs/src/tutorials/erpimage.md b/docs/src/tutorials/erpimage.md index 7ddf5f70a..18dcb15da 100644 --- a/docs/src/tutorials/erpimage.md +++ b/docs/src/tutorials/erpimage.md @@ -14,7 +14,7 @@ include("../../example_data.jl") ``` -## Plot ERP Images +## Plot ERP image The following code will result in the default configuration. ```@example main @@ -22,16 +22,15 @@ data, evts = UnfoldSim.predef_eeg(; noiselevel=10, return_epoched=true) plot_erpimage(data) ``` -## Column Mappings for ERP Images +## Column Mappings for ERP image Since ERP images use a `Matrix` as an input, the library does not need any informations about the mapping. -- erpblur (number, 10) - Is a number indicating how much blur is applied to the image; using Gaussian blur of the ImageFiltering module. Negative values deactivate the blur. - -- sortvalues - Indicating whether the data is sorted; using sortperm() of Base Julia. -(sortperm() computes a permutation of the array's indices that puts the array into sorted order). - -- meanplot (bool, false) - Indicating whether the plot should add a line plot below the ERP image, showing the mean of the data. If limits are set in the axis values both plots will be aligned. +- `erpblur` (Number, `10`): number indicating how much blur is applied to the image; using Gaussian blur of the ImageFiltering module. +Non-Positive values deactivate the blur. +- `sortvalues` (bool, `false`): parameter over which plot will be sorted. Using sortperm() of Base Julia. + - sortperm() computes a permutation of the array's indices that puts the array into sorted order. +- `meanplot` (bool, `false`): Indicating whether the plot should add a line plot below the ERP image, showing the mean of the data. ```@example main plot_erpimage(data; @@ -40,3 +39,20 @@ plot_erpimage(data; visual = (colormap = :viridis, colorrange = (-40, 40))) ``` + +## Sorted ERP image + +First, generate a data. Second, specify the necessary sorting parameter. + +```@example main + dat, evts = UnfoldSim.predef_eeg(; + onset=LogNormalOnset(μ=3.5, σ=0.4), + noiselevel=5 + ) + dat_e, times = Unfold.epoch(dat, evts, [-0.1,1], 100) + evts, dat_e = Unfold.dropMissingEpochs(evts, dat_e) + evts.Δlatency = diff(vcat(evts.latency, 0)) + dat_e = dat_e[1,:,:] + + plot_erpimage(times, dat_e; sortvalues=evts.Δlatency) +``` \ No newline at end of file diff --git a/src/plot_erpimage.jl b/src/plot_erpimage.jl index ad2607318..bd1a9de3b 100644 --- a/src/plot_erpimage.jl +++ b/src/plot_erpimage.jl @@ -11,12 +11,12 @@ Plot an ERP image. - `plot::Matrix{Float64}`: Data for the plot visualization ## Keyword Arguments -- `erpblur` (Number, `10`) - Number indicating how much blur is applied to the image; using Gaussian blur of the ImageFiltering module. +- `erpblur` (Number, `10`): number indicating how much blur is applied to the image; using Gaussian blur of the ImageFiltering module. Non-Positive values deactivate the blur. - `sortix` (default: `nothing`): . -- `sortvalues` (bool, `false`) - parameter over which plot will be sorted. Using sortperm() of Base Julia. +- `sortvalues` (bool, `false`): parameter over which plot will be sorted. Using sortperm() of Base Julia. - sortperm() computes a permutation of the array's indices that puts the array into sorted order. -- `meanplot`: (bool, `false`) - Indicating whether the plot should add a line plot below the ERP image, showing the mean of the data. +- `meanplot` (bool, `false`): Indicating whether the plot should add a line plot below the ERP image, showing the mean of the data. $(_docstring(:erpimage)) diff --git a/test/Project.toml b/test/Project.toml index 56a844000..4ab9756ab 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -1,5 +1,6 @@ [deps] CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0" +Colors = "5ae59095-9a9b-59fe-a467-6f913c188581" DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" GeometryBasics = "5c1252a2-5f33-56bf-86c9-59e7332b4326" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" diff --git a/test/test_butterfly.jl b/test/test_butterfly.jl index fcf1985e5..1a5a0043b 100644 --- a/test/test_butterfly.jl +++ b/test/test_butterfly.jl @@ -1,7 +1,6 @@ include("../docs/example_data.jl") data, pos = example_data("TopoPlots.jl") -using Colors @testset "basic" begin plot_butterfly(data; positions = pos)