makieorg / topoplots.jl Goto Github PK
View Code? Open in Web Editor NEWMakie topo plot recipes, for neuro-science, geo plots and anyone needing surface plots from unstructured data
License: MIT License
Makie topo plot recipes, for neuro-science, geo plots and anyone needing surface plots from unstructured data
License: MIT License
This issue is used to trigger TagBot; feel free to unsubscribe.
If you haven't already, you should update your TagBot.yml
to include issue comment triggers.
Please see this post on Discourse for instructions and more details.
If you'd like for me to do this for you, comment TagBot fix
on this issue.
I'll open a PR within a few hours, please be patient!
I converted some MNE code to convert form x/y/z to eeg_topoplot coordinates.
Now the big question is, can/should this be included here in TopoPlots.jl, or somehwere else?
using CoordinateTransformations
"""
convert x/y/z electrode montage positions to spherical coordinate representation. output is a matrix
"""
function cart3d_to_spherical(x,y,z)
sph = SphericalFromCartesian().(SVector.(x,y,z))
sph = [vcat(s.r,s.θ,π/2 - s.ϕ) for s in sph]
sph = hcat(sph...)'
return sph
end
"""
Projects 3D electrode positions to a 2D layout.
Re-implementation of the MNE algorithm.
If you put sphere to
"""
function pos3D_to_layout(x,y,z;sphere=[0,0,0.])
#cart3d_to_spherical(x,y,z)
# translate to sphere origin
x .-= sphere[1]
y .-= sphere[2]
z .-= sphere[3]
# convert to spherical coordinates
sph = cart3d_to_spherical(x,y,z)
# get rid of of the radius for now
pol_a = sph[:,3]
pol_b = sph[:,2]
# use only theta & phi, convert back to cartesian coordinates
p_x = pol_a .* cos.(pol_b)
p_y = pol_a .* sin.(pol_b)
# scale by the radius
p_x .*= sph[:,1] ./(π/2)
p_y .*= sph[:,1] ./(π/2)
# move back by the sphere coordinates
p_x .+= sphere[1]
p_y .+= sphere[2]
return Point2f.(p_x,p_y)
end
(for full reproducibility)
begin
using CSV
using LinearAlgebra
using HTTP
using CoordinateTransformations
using WGLMakie
using StaticArrays
using DataFrames
end
begin
pos3d = CSV.read(download("https://raw.githubusercontent.com/lrkrol/SEREEGA/b5dec01e8b98260904906cc19c38853bfbb2ff19/leadfield/hartmut/chanlocs-hartmut-NYhead_small.xyz"),DataFrame,header=false)
rename!(pos3d,:Column1=>:ix,:Column2=>:x,:Column3=>:y,:Column4=>:z,:Column5=>:label)
# remove some whitespace in the labels
transform!(pos3d,:label=>(x->strip.(x))=>:label)
# remove some weird channels
subset!(pos3d,:label=>ByRow(l -> l ∉ ["Nk1","Nk2","Nk3","Nk4"]));
out = pos3D_to_layout(pos3d.x,pos3d.y,pos3d.z)
eeg_topoplot(1:size(out,1),pos3d.label;positions=out, interpolation=NullInterpolator(),label_text=true,enlarge=0.5)
end;
checkout if we can now use
Interpolators.jl
maybe optimize the use of
ScatteredInterpolators.jl
Reading https://discourse.julialang.org/t/ann-pythoncall-and-juliacall/76778/24 and seeing the much better python package installation integration, it seems worth quite a bit to switch to PythonCall directly to call our one python dependency...
I didnt fully understand this line of code - do we need it?
It seems to be a stub to use the default values. params is not used though?
TopoPlots.jl/src/interpolators.jl
Line 29 in 2b7c9d2
Context:
TopoPlots.jl/src/interpolators.jl
Lines 25 to 35 in 2b7c9d2
Hi,
I am plotting some EEG topographies together with @behinger. We observed strange interpolation at the top boundary. This is with the default interpolator ClaughTochter
Any ideas? Has it to do with the fill-value?
Cheers,
Vladimir & Bene
Hello,
we noticed a weird behavior with the head position in a eeg_topoplot when the data points are asymmetrical or only in one corner.
In the image we are drawing two eeg topoplots with points in the top right and bottom left and our expected behavior was to see both heads overlap and contain all points instead of two smaller local heads.
This is the code used to draw them:
f = Figure()
axis = Axis(f[1, 1], aspect = 1)
xlims!(low = -2, high = 2)
ylims!(low = -2, high = 2)
data = [0, 0, 0]
pos1 = [Point2f(-1, -1), Point2f(-1.0, 0.0), Point2f(0, -1)]
pos2 = [Point2f(1, 1), Point2f(1.0, 0.0), Point2f(0, 1)]
eeg_topoplot!(axis, data, positions=pos1)
eeg_topoplot!(axis, data, positions=pos2)
Is there some workaround to keep the head location and size independent from the point locations ?
Or would it be possible to either add a way to set a position and size for the head or expose the draw_ear_nose! function ?
Thank you very much and kind regards,
Daniel, Sören, Niklas
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.