Skip to content

Commit

Permalink
upd and tests for topopositions_to_color
Browse files Browse the repository at this point in the history
  • Loading branch information
vladdez committed Nov 16, 2023
1 parent 235074d commit 7286bed
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 35 deletions.
11 changes: 7 additions & 4 deletions docs/src/how_to/position2color.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,20 @@ We can switch the colorscale of the position-map, by giving a function that maps

### Similar to MNE
```@example main
plot_butterfly(results; positions=positions, extra=(; topoPositionToColorFunction = pos -> UnfoldMakie.posToColorRGB(pos)))
plot_butterfly(results;
positions=positions,
topopositions_to_color = pos -> UnfoldMakie.posToColorRGB(pos)
)
```

### HSV-Space
```@example main
plot_butterfly(results; positions=positions, extra=(; topoPositionToColorFunction=UnfoldMakie.posToColorHSV))
plot_butterfly(results; positions=positions, topopositions_to_color=UnfoldMakie.posToColorHSV)
```

### Uniform Color
To highlight the flexibility, we can also make all lines `gray`, or any other arbitrary color, or function of electrode-`position`.

```@example main
using Colors
plot_butterfly(results; positions=positions, extra=(; topoPositionToColorFunction = x -> Colors.RGB(0.5)))
plot_butterfly(results; positions=positions, topopositions_to_color = x -> Colors.RGB(0.5))
```
12 changes: 6 additions & 6 deletions src/plot_parallelcoordinates.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ Plot a PCP (parallel coordinates plot).
PCP has problems with size changes of the view window.
By adapting the padding, aspect ratio and tick label size in px for a new use case, the PCP can even be added into a complex figures.
- `pc_aspect_ratio` (default: `0.55`) -
- `pc_right_padding` (default: `15`) -
- `pc_left_padding` (default: `25`) -
- `pc_top_padding` (default: `26`) -
- `pc_bottom_padding` (default: `16`) -
- `pc_tick_label_size` (default: `14`) -
- `pc_aspect_ratio` (default: `0.55`) -
- `pc_right_padding` (default: `15`) -
- `pc_left_padding` (default: `25`) -
- `pc_top_padding` (default: `26`) -
- `pc_bottom_padding` (default: `16`) -
- `pc_tick_label_size` (default: `14`) -
$(_docstring(:paracoord))
Expand Down
4 changes: 2 additions & 2 deletions src/plotconfig.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ function config_kwargs!(cfg::PlotConfig; kwargs...)
""" Keyword argument specification (kwargs...) Specified config groups must be NamedTuples', but $(keys(kwargs)[.!is_namedtuple]) was not.
Maybe you forgot the semicolon (;) at the beginning of your specification? Compare these strings:
plot_example(...; layout = (; showColorbar=true))
plot_example(...; layout = (; use_colorbar=true))
plot_example(...; layout = (showColorbar=true))
plot_example(...; layout = (use_colorbar=true))
The first is correct and creates a NamedTuple as required. The second is wrong and its call is ignored.""")
list = fieldnames(PlotConfig)#[:layout,:visual,:mapping,:legend,:colorbar,:axis]
Expand Down
31 changes: 27 additions & 4 deletions test/test_butterfly.jl
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@

include("../docs/example_data.jl")
data, pos = example_data("TopoPlots.jl")
results, positions = example_data("TopoPlots.jl")
using Colors

@testset "basic" begin
include("../docs/example_data.jl")
data, pos = example_data("TopoPlots.jl")
plot_butterfly(data; positions = pos)
end

@testset "topomarkersize change" begin
include("../docs/example_data.jl")
data, pos = example_data("TopoPlots.jl")
plot_butterfly(
data;
positions = pos,
Expand All @@ -18,4 +19,26 @@ end
end


@testset "changing color from ROMA to gray" begin
plot_butterfly(
results;
positions = positions,
topopositions_to_color = x -> Colors.RGB(0.5)
)
end

@testset "changing color from ROMA to HSV" begin
plot_butterfly(
results;
positions = positions,
topopositions_to_color=UnfoldMakie.posToColorHSV
)
end

@testset "changing color from ROMA to RGB" begin
plot_butterfly(
results;
positions = positions,
topopositions_to_color = pos -> UnfoldMakie.posToColorRGB(pos)
)
end
29 changes: 28 additions & 1 deletion test/test_erp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
end


@testset "basic with res_effects" begin
@testset "basic with res_effects without colorbar" begin
data, evts = UnfoldSim.predef_eeg(; noiselevel = 12, return_epoched = true)
data = reshape(data, (1, size(data)...))
f = @formula 0 ~ 1 + condition + continuous
Expand All @@ -46,6 +46,33 @@ end
)
end

@testset "basic with res_effects" begin
data, evts = UnfoldSim.predef_eeg(; noiselevel = 12, return_epoched = true)
data = reshape(data, (1, size(data)...))
f = @formula 0 ~ 1 + condition + continuous
se_solver = (x, y) -> Unfold.solver_default(x, y, stderror = true)

m = fit(
UnfoldModel,
Dict(Any => (f, range(0, step = 1 / 100, length = size(data, 2)))),
evts,
data,
solver = se_solver,
)
results = coeftable(m)
res_effects = effects(Dict(:continuous => -5:0.5:5), m)

# ## Plot the results
plot_erp(
res_effects;
mapping = (; y = :yhat, color = :continuous, group = :continuous),
legend = (; nbanks = 2),
layout = (; legend_position = :right, show_legend = true),
categorical_color = false,
categorical_group = true,
)
end


@testset "erp plot in GridLayout" begin
f = Figure(resolution=(1200, 1400))
Expand Down
18 changes: 0 additions & 18 deletions test/test_pp.jl

This file was deleted.

0 comments on commit 7286bed

Please sign in to comment.