GithubHelp home page GithubHelp logo

makieorg / topoplots.jl Goto Github PK

View Code? Open in Web Editor NEW
25.0 25.0 7.0 104.45 MB

Makie topo plot recipes, for neuro-science, geo plots and anyone needing surface plots from unstructured data

License: MIT License

Julia 100.00%

topoplots.jl's People

Contributors

behinger avatar palday avatar simondanisch avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

topoplots.jl's Issues

EEG TopoPlot colorrange issue with data type

Hi, I noticed a small problem when setting the 'colorrange' attribute for the eeg_topoplot() function. The colors inside the circles that indicate channel locations are unaffected by the new colorrange if the data is passed as Vector{Any} instead of Vector{Float32}.

colorrange

TagBot trigger issue

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!

Convert from x/y/z to eeg_topoplot positions

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
		  		



	  

grafik


(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;

Unused line / define defaults?

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?

params = Iterators.filter(((k, v),) -> !(v isa Nothing), Dict(:tol => ct.tol, :maxiter => ct.maxiter, :rescale => ct.rescale))

Context:

function (ct::ClaughTochter)(
xrange::LinRange, yrange::LinRange,
positions::AbstractVector{<: Point{2}}, data::AbstractVector{<:Number})
params = Iterators.filter(((k, v),) -> !(v isa Nothing), Dict(:tol => ct.tol, :maxiter => ct.maxiter, :rescale => ct.rescale))
interp = SciPy.interpolate.CloughTocher2DInterpolator(
Tuple.(positions), data;
tol=ct.tol, maxiter=ct.maxiter, rescale=ct.rescale)
return collect(interp(xrange' .* ones(length(yrange)), ones(length(xrange))' .* yrange)')

Deactivate Interpolator

I think we should allow
interpolation = False

This would allow to plot things like:
grafik
and
grafik

Should be straight forward to add another if interpolation == False catch where we select for Delauny/Splines Interpolations, right?

Strange interpolation at boundary

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
image

DelaunyMesh has same issue
image

Any ideas? Has it to do with the fill-value?
Cheers,
Vladimir & Bene

EEG TopoPlot Head misalignment

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.
edc110d6-c020-48b5-ac4a-d10a7dc0a6f1
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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.