def _overlap_projector(data_int, data_res, corr):
"""Calculate projector for removal of subspace intersection in tSSS"""
# corr necessary to deal with noise when finding identical signal
# directions in the subspace. See the end of the Results section in [2]_
# Note that the procedure here is an updated version of [2]_ (and used in
# Elekta's tSSS) that uses residuals instead of internal/external spaces
# directly. This provides more degrees of freedom when analyzing for
# intersections between internal and external spaces.
# Normalize data, then compute orth to get temporal bases. Matrices
# must have shape (n_samps x effective_rank) when passed into svd
# computation
# we use np.linalg.norm instead of sp.linalg.norm here: ~2x faster!
n = np.linalg.norm(data_int)
Q_int = linalg.qr(_orth_overwrite((data_int / n).T),
overwrite_a=True, mode='economic', **check_disable)[0].T
n = np.linalg.norm(data_res)
Q_res = linalg.qr(_orth_overwrite((data_res / n).T),
overwrite_a=True, mode='economic', **check_disable)[0]
assert data_int.shape[1] > 0
C_mat = np.dot(Q_int, Q_res)
del Q_int
# Compute angles between subspace and which bases to keep
S_intersect, Vh_intersect = linalg.svd(C_mat, overwrite_a=True,
full_matrices=False,
**check_disable)[1:]
del C_mat
intersect_mask = (S_intersect >= corr)
del S_intersect
# Compute projection operator as (I-LL_T) Eq. 12 in [2]_
# V_principal should be shape (n_time_pts x n_retained_inds)
Vh_intersect = Vh_intersect[intersect_mask].T
V_principal = np.dot(Q_res, Vh_intersect)
return V_principal
maxwell.py 文件源码
python
阅读 29
收藏 0
点赞 0
评论 0
评论列表
文章目录