mne-python icon indicating copy to clipboard operation
mne-python copied to clipboard

Warning option for sensors in neck in file: _make_forward.py

Open wadelab opened this issue 6 months ago • 2 comments

Describe the new feature or enhancement

We are using an OPM-MEG system where the sensors are very close to the skull. Our MRI data are acquired when the subject is in a slightly different posture and so we sometimes end up with the neck sensors mapping >within< the surface of the head even though they were (obviously) outside during the MEG data acquisition. Currently _make_forward.py stops when it discovers this (in _prepare_for_forward). We would like the option to throw a warning (not an error) at this point and proceed. We think this is okay because the sensors are not inside the skull, just the neck fat. Currently we are commenting out the lines around line 573 in this file in our local copy...

Describe your proposed implementation

Perhaps a flag like USE_PERMISSIVE_POSITION_CHECK when calling _make_forward? If it's set then just warn, don't error?

Describe possible alternatives

I guess we could move the sensors out normal to the surface until they are outside the scalp? This feels like a worse solution.

Additional context

Thanks!

wadelab avatar Jun 02 '25 14:06 wadelab

Hello! 👋 Thanks for opening your first issue here! ❤️ We will try to get back to you soon. 🚴

welcome[bot] avatar Jun 02 '25 14:06 welcome[bot]

Describe possible alternatives

I guess we could move the sensors out normal to the surface until they are outside the scalp? This feels like a worse solution

Agreed that moving the sensors isn't the best idea. The best fix would probably be to fix/deform the BEM surface so that it reflects a more realistic / accurate subject geometry at the time of acquisition. Maybe using Blender it wouldn't be too bad?

Another alternative would be to use a 1-layer BEM for MEG. I don't know if this would be better or worse than using an incorrect / deformed (from how it was acquisition) outer skin surface, but I'd assume it would be better.

Perhaps a flag like USE_PERMISSIVE_POSITION_CHECK when calling _make_forward? If it's set then just warn, don't error?

I suppose we could consider a on_inside="raise" default that you could set to "warning" or "ignore" etc., but the bigger problem is that I am not sure that the BEM calculations are valid for sensors inside the surface. @agramfort ?

larsoner avatar Jun 02 '25 14:06 larsoner

Hi! Just to return to this after a slight lapse... we have been exploring the possibility of deforming the surface near the intersecting sensors - we think it >might< be possible by generating a custom deformation field normal to the sensor and then using ANTs to apply it. Currently it doesn't look very good .... We also think that having the sensors inside the scalp would be okay from the POV of source imaging (or at least the type of source imaging that we do). We can also check this of course if we have the option to ignore the warning...

Could we think about a two-step approach where we (you?) set the option to raise a warning, ignore or whatever (obviously this would not be the default) and then we'll keep working on a 'correct' solution here. The truly correct solution is probably for me to lose some fat around my neck of course.... Thanks! Alex

wadelab avatar Jul 02 '25 11:07 wadelab

Trying to read through and follow the ENH proposal here, since there seems to be a similar issue with OPM-MEG that'll come up soon locally. Just curious: how's the skin surface derived here? Was it from Freesurfer watershed, and was there morphing applied? I haven't looked at the latest MNE-Python calls in a while, but I remember way back when the skin surface used to look smoothed out to me. I wonder whether the "blurring" of skin surface might be a contributing factor?

mh105 avatar Aug 03 '25 21:08 mh105

how's the skin surface derived here? Was it from Freesurfer watershed, and was there morphing applied?

The watershed runs then the surface is smoothed and downsampled for the BEM. It is possible that the "blurring" / lowpass during downsampling pushes the surfaces out a bit... would be good if you could check with plot_alignment using the surfaces="head-dense" (which should use the original surface) and bem=my_bem (which should I think plot the head surface from the BEM) to check.

larsoner avatar Aug 03 '25 23:08 larsoner