Skip to content

Commit

Permalink
added reference tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
behinger committed Sep 11, 2023
1 parent 3e2427a commit be89609
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 4 additions & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ using Literate
using Glob

GENERATED = joinpath(@__DIR__, "src", "literate")
for subfolder ["explanations","HowTo","tutorials"]
for subfolder ["explanations","HowTo","tutorials","reference"]
local SOURCE_FILES = Glob.glob(subfolder*"/*.jl", GENERATED)
foreach(fn -> Literate.markdown(fn, GENERATED*"/"*subfolder), SOURCE_FILES)

Expand Down Expand Up @@ -61,6 +61,9 @@ makedocs(;
"Include multiple Visualizations in one Figure" => "how_to/mult_vis_in_fig.md",
"Show out of Bounds Label" => "how_to/show_oob_labels.md",
],
"Reference" => [
"Convert 3D positions / montages to 2D layouts" => "literate/reference/positions.jl"
]
],
)

Expand Down
9 changes: 8 additions & 1 deletion docs/src/literate/reference/positions.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using UnfoldMakie
using CairoMakie
using TopoPlots
using PyMNE

Expand All @@ -20,4 +21,10 @@ pos = UnfoldMakie.toPositions(fake_evoked)
# # project from 3D electrode locations to 2D
pos3d = hcat(values(pyconvert(Dict,biosemi_montage.get_positions()["ch_pos"]))...)

pos2 = to_positions(pos3d)
pos2 = to_positions(pos3d)

f = Figure(resolution=(600,300))
scatter(f[1,1],pos3d[1:2,:])
scatter(f[1,2],pos2)
f
# as one can see, the "naive" transform of just dropping the third dimension doesnt really work (left). We rather have to project the chanels to a sphere and unfold it (right)

0 comments on commit be89609

Please sign in to comment.