Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EEG TopoPlot Head misalignment #18

Closed
Link250 opened this issue Aug 3, 2022 · 3 comments
Closed

EEG TopoPlot Head misalignment #18

Link250 opened this issue Aug 3, 2022 · 3 comments

Comments

@Link250
Copy link

Link250 commented Aug 3, 2022

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

@behinger
Copy link
Collaborator

behinger commented Aug 5, 2022

  1. I dont think it is possible to specify the headsize right now. It is calculated in enclosing_geometry
radius, idx = findmax(x-> norm(x .- middle), positions)
  1. the head center is the mean of your plot. so if you want to keep them aligned, maybe add a
	pos1 = pos1 .- mean(pos1)
	pos2 = pos2 .- mean(pos2)

inbetween, or adjust to a common center if you want.

@Link250
Copy link
Author

Link250 commented Aug 10, 2022

Thank you for the help,
using the formulas you provided we wrote this method to help us move and scale the head

function eegHeadMatrix(positions, center, radius)
    oldCenter = mean(positions)
    oldRadius, _ = findmax(x-> norm(x .- oldCenter), positions)
    radF = radius/oldRadius
    return Makie.Mat4f(radF, 0, 0, 0,
                       0, radF, 0, 0,
                       0, 0, 1, 0,
                       center[1]-oldCenter[1]*radF, center[2]-oldCenter[2]*radF, 0, 1)
end

We then use this matrix as model parameter for drawing the head

@behinger
Copy link
Collaborator

adressed in #57

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants