Skip to content

Commit 6d022fd

Browse files
committed
ENH: Add Kernel helmet
1 parent 9f22adb commit 6d022fd

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed

mne/bem.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1751,13 +1751,15 @@ def _add_gamma_multipliers(bem):
17511751
FIFF.FIFFV_BEM_SURF_ID_SKULL: "outer skull",
17521752
FIFF.FIFFV_BEM_SURF_ID_HEAD: "outer skin ",
17531753
FIFF.FIFFV_BEM_SURF_ID_UNKNOWN: "unknown ",
1754+
FIFF.FIFFV_MNE_SURF_MEG_HELMET: "MEG helmet ",
17541755
}
17551756
_sm_surf_name = {
17561757
FIFF.FIFFV_BEM_SURF_ID_BRAIN: "brain",
17571758
FIFF.FIFFV_BEM_SURF_ID_CSF: "csf",
17581759
FIFF.FIFFV_BEM_SURF_ID_SKULL: "outer skull",
17591760
FIFF.FIFFV_BEM_SURF_ID_HEAD: "outer skin ",
17601761
FIFF.FIFFV_BEM_SURF_ID_UNKNOWN: "unknown ",
1762+
FIFF.FIFFV_MNE_SURF_MEG_HELMET: "helmet",
17611763
}
17621764

17631765

@@ -1850,7 +1852,8 @@ def _write_bem_surfaces_block(fid, surfs):
18501852
"""Write bem surfaces to open file handle."""
18511853
for surf in surfs:
18521854
start_block(fid, FIFF.FIFFB_BEM_SURF)
1853-
write_float(fid, FIFF.FIFF_BEM_SIGMA, surf["sigma"])
1855+
if "sigma" in surf:
1856+
write_float(fid, FIFF.FIFF_BEM_SIGMA, surf["sigma"])
18541857
write_int(fid, FIFF.FIFF_BEM_SURF_ID, surf["id"])
18551858
write_int(fid, FIFF.FIFF_MNE_COORD_FRAME, surf["coord_frame"])
18561859
write_int(fid, FIFF.FIFF_BEM_SURF_NNODE, surf["np"])

mne/channels/channels.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ def _get_meg_system(info):
103103
system = "ARTEMIS123"
104104
have_helmet = False
105105
break
106+
elif coil_type == FIFF.FIFFV_COIL_KERNEL_OPM_MAG_GEN1:
107+
system = "Kernel_Flux"
108+
have_helmet = True
109+
break
106110
else:
107111
system = "unknown"
108112
have_helmet = False

mne/data/helmets/Kernel_Flux.fif.gz

487 KB
Binary file not shown.

mne/surface.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,26 @@ def _get_head_surface(subject, source, subjects_dir, on_defects, raise_error=Tru
158158
return surf
159159

160160

161+
# New helmets can be written for example with:
162+
#
163+
# import os.path as op
164+
# import mne
165+
# from mne.io.constants import FIFF
166+
# surf = mne.read_surface('kernel.obj', return_dict=True)[-1]
167+
# surf['rr'] *= 1000 # needs to be in mm
168+
# mne.surface.complete_surface_info(surf, copy=False, do_neighbor_tri=False)
169+
# surf['coord_frame'] = FIFF.FIFFV_COORD_DEVICE
170+
# surfs = mne.bem._surfaces_to_bem(
171+
# [surf], ids=[FIFF.FIFFV_MNE_SURF_MEG_HELMET], sigmas=[1.],
172+
# incomplete='ignore')
173+
# del surfs[0]['sigma']
174+
# bem_fname = op.join(op.dirname(mne.__file__), 'data', 'helmets',
175+
# 'kernel.fif.gz')
176+
# mne.write_bem_surfaces(bem_fname, surfs, overwrite=True)
177+
178+
161179
@verbose
162-
def get_meg_helmet_surf(info, trans=None, verbose=None):
180+
def get_meg_helmet_surf(info, trans=None, *, verbose=None):
163181
"""Load the MEG helmet associated with the MEG sensors.
164182
165183
Parameters

0 commit comments

Comments
 (0)