Prepare a gain matrix and noise covariance for localization.
(
forward,
info,
noise_cov,
fixed,
loose,
rank,
pca,
use_cps,
exp,
limit_depth_chs,
combine_xyz,
allow_fixed_depth,
limit,
)
| 1689 | |
| 1690 | |
| 1691 | def _prepare_forward( |
| 1692 | forward, |
| 1693 | info, |
| 1694 | noise_cov, |
| 1695 | fixed, |
| 1696 | loose, |
| 1697 | rank, |
| 1698 | pca, |
| 1699 | use_cps, |
| 1700 | exp, |
| 1701 | limit_depth_chs, |
| 1702 | combine_xyz, |
| 1703 | allow_fixed_depth, |
| 1704 | limit, |
| 1705 | ): |
| 1706 | """Prepare a gain matrix and noise covariance for localization.""" |
| 1707 | # Steps (according to MNE-C, we change the order of various steps |
| 1708 | # because our I/O is already done, and we create the objects |
| 1709 | # on the fly more easily): |
| 1710 | # |
| 1711 | # 1. Read the bad channels |
| 1712 | # 2. Read the necessary data from the forward solution matrix file |
| 1713 | # 3. Load the projection data |
| 1714 | # 4. Load the sensor noise covariance matrix and attach it to the forward |
| 1715 | # 5. Compose the depth-weighting matrix |
| 1716 | # 6. Compose the source covariance matrix |
| 1717 | # 7. Apply fMRI weighting (not done) |
| 1718 | # 8. Apply the linear projection to the forward solution |
| 1719 | # 9. Apply whitening to the forward computation matrix |
| 1720 | # 10. Exclude the source space points within the labels (not done) |
| 1721 | # 11. Do appropriate source weighting to the forward computation matrix |
| 1722 | # |
| 1723 | |
| 1724 | # make a copy immediately so we do it exactly once |
| 1725 | forward = forward.copy() |
| 1726 | |
| 1727 | # Deal with "fixed" and "loose" |
| 1728 | loose = _triage_loose(forward["src"], loose, fixed) |
| 1729 | del fixed |
| 1730 | |
| 1731 | # Figure out what kind of inverse is requested |
| 1732 | fixed_inverse = all(v == 0.0 for v in loose.values()) |
| 1733 | constrained_inverse = any(v < 1.0 for v in loose.values()) |
| 1734 | |
| 1735 | # We only support fixed orientations for surface and discrete source |
| 1736 | # spaces, not volume. |
| 1737 | if fixed_inverse and "volume" in loose: |
| 1738 | raise ValueError( |
| 1739 | "Computing inverse solutions for volume source " |
| 1740 | "spaces with fixed orientations is not " |
| 1741 | "supported." |
| 1742 | ) |
| 1743 | if loose.get("volume", 1) < 1: |
| 1744 | raise ValueError( |
| 1745 | "Computing inverse solutions with restricted " |
| 1746 | "orientations (loose < 1) is not supported for " |
| 1747 | "volume source spaces." |
| 1748 | ) |
no test coverage detected