MCPcopy
hub / github.com/mne-tools/mne-python / _sss_basis

Function _sss_basis

mne/preprocessing/maxwell.py:1659–1866  ·  view source on GitHub ↗

Compute SSS basis for given conditions. Parameters ---------- exp : dict Must contain the following keys: origin : ndarray, shape (3,) Origin of the multipolar moment space in meters int_order : int Order of the internal m

(exp, all_coils)

Source from the content-addressed store, hash-verified

1657
1658
1659def _sss_basis(exp, all_coils):
1660 """Compute SSS basis for given conditions.
1661
1662 Parameters
1663 ----------
1664 exp : dict
1665 Must contain the following keys:
1666
1667 origin : ndarray, shape (3,)
1668 Origin of the multipolar moment space in meters
1669 int_order : int
1670 Order of the internal multipolar moment space
1671 ext_order : int
1672 Order of the external multipolar moment space
1673
1674 coils : list
1675 List of MEG coils. Each should contain coil information dict specifying
1676 position, normals, weights, number of integration points and channel
1677 type. All coil geometry must be in the same coordinate frame
1678 as ``origin`` (``head`` or ``meg``).
1679
1680 Returns
1681 -------
1682 bases : ndarray, shape (n_coils, n_mult_moments)
1683 Internal and external basis sets as a single ndarray.
1684
1685 Notes
1686 -----
1687 Does not incorporate magnetometer scaling factor or normalize spaces.
1688
1689 Adapted from code provided by Jukka Nenonen.
1690 """
1691 rmags, cosmags, bins, n_coils = all_coils[:4]
1692 int_order, ext_order = exp["int_order"], exp["ext_order"]
1693 n_in, n_out = _get_n_moments([int_order, ext_order])
1694 rmags = rmags - exp["origin"]
1695
1696 # do the heavy lifting
1697 max_order = max(int_order, ext_order)
1698 L = _tabular_legendre(rmags, max_order)
1699 phi = np.arctan2(rmags[:, 1], rmags[:, 0])
1700 r_n = np.sqrt(np.sum(rmags * rmags, axis=1))
1701 r_xy = np.sqrt(rmags[:, 0] * rmags[:, 0] + rmags[:, 1] * rmags[:, 1])
1702 cos_pol = rmags[:, 2] / r_n # cos(theta); theta 0...pi
1703 sin_pol = np.sqrt(1.0 - cos_pol * cos_pol) # sin(theta)
1704 z_only = r_xy <= 1e-16
1705 sin_pol_nz = sin_pol.copy()
1706 sin_pol_nz[z_only] = 1.0 # will be overwritten later
1707 r_xy[z_only] = 1.0
1708 cos_az = rmags[:, 0] / r_xy # cos(phi)
1709 cos_az[z_only] = 1.0
1710 sin_az = rmags[:, 1] / r_xy # sin(phi)
1711 sin_az[z_only] = 0.0
1712 # Appropriate vector spherical harmonics terms
1713 # JNE 2012-02-08: modified alm -> 2*alm, blm -> -2*blm
1714 r_nn2 = r_n.copy()
1715 r_nn1 = 1.0 / (r_n * r_n)
1716 S_tot = np.empty((n_coils, n_in + n_out), np.float64)

Callers 3

_setup_ext_projFunction · 0.85
compute_proj_hfcFunction · 0.85
_trans_sss_basisFunction · 0.85

Calls 7

_get_n_momentsFunction · 0.85
_tabular_legendreFunction · 0.85
_deg_ord_idxFunction · 0.85
_integrate_pointsFunction · 0.85
sqrtMethod · 0.80
sumMethod · 0.45
copyMethod · 0.45

Tested by

no test coverage detected