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
As you can see in documentation example it is impossible to show label text for electrodes.
Seems like a bug.
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;
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
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!
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...
Currently, if I do data, positions = TopoPlots.example_data()
I have only opportunity to get 64 channel position.
But if I want 32, or 128 channels layout? Would be nice to have such arrangements too.
Has anyone used this recently? I'm pretty sure it used to work at some point, but now it seems quite broken:
using TopoPlots
labels = ["cz", "fp1", "fp2", "fz"]
TopoPlots.eeg_topoplot(ones(length(labels)), labels; label_text=true, label_scatter=(markersize=10, strokewidth=2, strokecolor=:white))
... does neither prodcue correct sensor locations (look at Cz) nor does it plot any text for me:
I believe this is related to: #18, so it seems to be an unfortunate consequence of some design decisions. Nevertheless, I think this warrants fixing as the current behavior is extremely surprising.
Would it make sense to add a plottype
kwarg to TopoPlot
, which would allow any HeatmapLike
plot to be used in place of contourf
? I would love to use surface
or even contour
, for example.
Nowhere in the documentation is there a description of the data dimensions for this code:
data, positions = TopoPlots.example_data()
.
It has three dimensions: 64×400×3. But what do they represent?
Specifying this will greatly improve the usability of the package, especially for new users.
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
checkout if we can now use
Interpolators.jl
maybe optimize the use of
ScatteredInterpolators.jl
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
labels = ["cz", "fp1", "fp2", "fz"]
TopoPlots.eeg_topoplot(1:length(labels),labels; label_text = true) # doesnt work
TopoPlots.eeg_topoplot(1:length(labels),labels; labels=labels, label_text = true) # works
is necessary. The reason most likely is that in the recipe label is used as this "named"-input
Line 2 in 7e51109
later it is referenced in the plot!
function via
Line 92 in 7e51109
not sure why the first case, labels seem to not be picked up correctly. Maybe a hint: Attributes(plot)
is used, and in there, labels = nothing
. Even though plot.labels
is correctly showing the Array. - I dont know enough to understand this
maybe @SimonDanisch any insights?
(This was not the case in topoplots 1.3, with pre 0.20 makie (didnt test all iterations))
pinging @marcpabst for pushing me to this issue
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.