Skip to content

Conversation

@larsoner
Copy link
Member

@larsoner larsoner commented Apr 13, 2020

Probably a better solution than #7602.

WIP because:

  • viz examples/tutorials need to be updated
  • examples need to be checked

Closes #7601
Closes #7602

@larsoner
Copy link
Member Author

Examples have rendered in case anyone wants to look

@larsoner
Copy link
Member Author

Okay the MEG looks reasonable, but @mmagnuski you are right that the local convex hull is not always good -- for EEG in plot_evoked_topomap it does not look good.

This makes me wonder if we want to add extrapolate='auto', which means 'local' for MEG and 'head' for EEG. Or maybe we want to add some softening / expanding of the edges, but that's probably going to be tricky to get right.

@drammock
Copy link
Member

The renderings in this example look good to me. The renderings in this example also look good as far as the "local"/convex hull question goes, but it looks like the head outline is slightly off-center left-to-right? I realize that's not what you're addressing in this PR, but it's rather puzzling since both examples use the sample data.

@agramfort
Copy link
Member

MEG topos look much nicer:

https://19301-1301584-gh.circle-artifacts.com/0/dev/auto_examples/io/plot_read_proj.html#sphx-glr-auto-examples-io-plot-read-proj-py

but our EEG friends may have some concerns.

extrapolate='auto' is maybe a good option.

@mmagnuski @cbrnr thoughts @sappelhoff thoughts?

@agramfort
Copy link
Member

agramfort commented Apr 13, 2020 via email

@codecov
Copy link

codecov bot commented Apr 13, 2020

Codecov Report

Merging #7603 into master will decrease coverage by 0.02%.
The diff coverage is 91.97%.

@@            Coverage Diff             @@
##           master    #7603      +/-   ##
==========================================
- Coverage   90.14%   90.11%   -0.03%     
==========================================
  Files         454      454              
  Lines       83929    83759     -170     
  Branches    13324    13255      -69     
==========================================
- Hits        75661    75483     -178     
- Misses       5406     5410       +4     
- Partials     2862     2866       +4     

@larsoner
Copy link
Member Author

They are that way in master, it's just harder to see when the default interp goes to the circle

It's possible this will be fixed by #7455, but I'd rather deal with the problem separately since it's orthogonal and not added by this PR.

@mmagnuski
Copy link
Member

@larsoner

This makes me wonder if we want to add extrapolate='auto', which means 'local' for MEG and 'head' for EEG. Or maybe we want to add some softening / expanding of the edges, but that's probably going to be tricky to get right.

I don't think an auto of extrapolate='head' would be good - as this generates artifacts when some channels are outside of the head circle. As such cases are pretty common now - this might lead to more surprise than the proposed always 'local' scenario. (extrapolate='circle' might be a good alternative to what 'head' does currently, but that's another issue)
When it comes to softening etc. - that's why I was referring to using two mask at the same time: the circle and convex hull. The circle smoothes and the convex hull removes whatever is not masked by the circle. But it would likely require some tweaking, and I know you don't like this idea very much, so I'm not pressing. :)

There seems to be some pixelization not masked that is visible here (third topo from the left):
image
but it seems related to the low res in that code cell (res=32).

@larsoner
Copy link
Member Author

When it comes to softening etc. - that's why I was referring to using two mask at the same time: the circle and convex hull. The circle smoothes and the convex hull removes whatever is not masked by the circle. But it would likely require some tweaking, and I know you don't like this idea very much, so I'm not pressing. :)

This will not work for the case linked above -- you have a (correct) hexagonal convex hull, so adding an additional circular mask on top of this will either be a no-op or it will remove some sensors. If we want to keep local the default but soften it, a better approach might be to "push" some points out a bit from the radius. Or figure out how to get Bezier points or something... but I'd rather avoid these complications if possible.

There seems to be some pixelization not masked that is visible here (third topo from the left):

Ahh yes, we'll need to tweak how far out we put the extra points, how many of them we have, etc. I changed some values here that might have made the "jagginess" problem worse, but we'll have to evaluate that in the context of not introducing "blobs", too.

Ultimately if someone uses a low res, though, I don't mind them ending up with jagged lines...

I don't think an auto of extrapolate='head' would be good - as this generates artifacts when some channels are outside of the head circle.

Where do you see this? My understanding is that "head" really means "minimum of the head circle and the circle that encompasses all sensors", so it should always give at least a somewhat sensible one.

It seems like the simplest solution is to make the default head for EEG and local for MEG, and then fix the problems with head plotting for EEG (since we need to do those anyway.

@mmagnuski
Copy link
Member

This will not work for the case linked above -- you have a (correct) hexagonal convex hull, so adding an additional circular mask on top of this will either be a no-op or it will remove some sensors. If we want to keep local the default but soften it, a better approach might be to "push" some points out a bit from the radius. Or figure out how to get Bezier points or something... but I'd rather avoid these complications if possible.

I didn't mean this in the context of the example I pasted. If you increase the distance between channels and extrapolation points (and thus the distance of convex hull mask) the circle mask trick would work. But I understand your point, and it is a small thing - its good as it is.

Where do you see this? My understanding is that "head" really means "minimum of the head circle and the circle that encompasses all sensors", so it should always give at least a somewhat sensible one.

It is more visible with border=0, but you can see that the extrapolation points are at the head circle:
image
with border='mean' it's less visible but the extrapolation points are still at the head circle. I think they should be where the circle mask is (or slightly outside to be precise) - but some time ago we discussed this and you preferred it stayed at the head circle.

It seems like the simplest solution is to make the default head for EEG and local for MEG, and then fix the problems with head plotting for EEG (since we need to do those anyway.

Sure, if we fix extrapolate='head' then it would be ok. :)

Ultimately if someone uses a low res, though, I don't mind them ending up with jagged lines...

👍

@cbrnr
Copy link
Contributor

cbrnr commented Apr 14, 2020

Plotting IC topomaps with my limited set of channels (I still think they should be closer to the head circle but this is the other issue we've not solved) doesn't look great with the new defaults:

Screen Shot 2020-04-14 at 12 03 50

I'd prefer if we'd extrapolate at least to the head circle.

@hoechenberger
Copy link
Member

@cbrnr

I'd prefer if we'd extrapolate at least to the head circle.

+1 on that one

@agramfort
Copy link
Member

what do we do here to move on?

@larsoner
Copy link
Member Author

My vote is to do extrapolate='auto' which means 'local' for MEG and 'head' for EEG. Also maybe try to reduce the "edge blobs" here if reasonable to do so. Then I think the remaining issues can be dealt with in separate PRs (probably mostly for EEG / head / skirt modes?).

@agramfort
Copy link
Member

agramfort commented Apr 20, 2020 via email

@larsoner larsoner changed the title WIP, BUG: Use local extrap and mean borders MRG, BUG: Use local extrap and mean borders Apr 20, 2020
@larsoner larsoner changed the title MRG, BUG: Use local extrap and mean borders MRG, BUG: Use auto extrap and mean borders Apr 20, 2020
@larsoner
Copy link
Member Author

I think they should be where the circle mask is (or slightly outside to be precise) - but some time ago we discussed this and you preferred it stayed at the head circle.

Sure, if we fix extrapolate='head' then it would be ok. :)

Okay done now along with 'auto' mode. Running [circle full] we'll see how it looks!

@larsoner
Copy link
Member Author

I have not looked at all examples, but this looks okay at least. If others agree I can take a look at all examples:

https://19486-1301584-gh.circle-artifacts.com/0/dev/auto_examples/visualization/plot_evoked_topomap.html#additional-plot-topomap-options

@mmagnuski
Copy link
Member

Looks ok. So, in a subsequent PR we can change the behavior of extrapolate='head' so that extrapolation points are not placed on the head outline if some channels extend beyond this outline, right?

@larsoner
Copy link
Member Author

It already should extend outside the head, which is what you wanted, right?

@mmagnuski
Copy link
Member

Ah, you changed it? Sorry, didn't notice.

use_radius = head_radius * 1.1
points_x = np.cos(points_l) * use_radius + x
points_y = np.sin(points_l) * use_radius + y
use_radii = radii * 1.1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, so radii are x and y clip radius now, not the head_radius, 👍

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes indeed!

@cbrnr
Copy link
Contributor

cbrnr commented Apr 21, 2020

My ICA components example looks good!

Copy link
Member

@agramfort agramfort left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if @cbrnr is happy I am happy :)

and MEG topos are gorgeous now !

@sappelhoff
Copy link
Member

Had a quick look at some examples, looks good to me as well 👍

Could you post your example once more with the new settings @cbrnr ?

@cbrnr
Copy link
Contributor

cbrnr commented Apr 21, 2020

Here are my IC topomaps - except for the issue that these now look much more compressed than before (#7472 and #7141) I'm happy:

Screen Shot 2020-04-21 at 09 38 11

@mmagnuski
Copy link
Member

@larsoner
Could we just change the docs for extrapolate='head' so that it is clear that the extrapolation is to the head outline or outside?

@hoechenberger
Copy link
Member

Looks great, awesome work!

@larsoner
Copy link
Member Author

@mmagnuski changed in 15e5bae#diff-c0cc0663d36fcb3b69d6e33a22573db1R87-R90 to:

    Extrapolate out to the edges of the clipping circle. This will be on
    the head circle when the sensors are contained within the head circle,
    but it can extend beyond the head when sensors are plotted outside
    the head circle.

Okay?

@mmagnuski
Copy link
Member

Perfect!

@larsoner larsoner merged commit 093ac9c into mne-tools:master Apr 21, 2020
@larsoner larsoner deleted the border2 branch April 21, 2020 14:47
@larsoner
Copy link
Member Author

Okay, hopefully it's easier to fix the remaining issues now!

@sappelhoff
Copy link
Member

Thanks @larsoner!

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

Successfully merging this pull request may close these issues.

BUG: Extreme topomap valuse still too strong

7 participants