Convert forward solution matrices to dicts.
(
fwd,
names,
fwd_grad=None,
coord_frame=FIFF.FIFFV_COORD_HEAD,
source_ori=FIFF.FIFFV_MNE_FREE_ORI,
)
| 912 | |
| 913 | |
| 914 | def _to_forward_dict( |
| 915 | fwd, |
| 916 | names, |
| 917 | fwd_grad=None, |
| 918 | coord_frame=FIFF.FIFFV_COORD_HEAD, |
| 919 | source_ori=FIFF.FIFFV_MNE_FREE_ORI, |
| 920 | ): |
| 921 | """Convert forward solution matrices to dicts.""" |
| 922 | assert names is not None |
| 923 | sol = dict( |
| 924 | data=fwd.T, nrow=fwd.shape[1], ncol=fwd.shape[0], row_names=names, col_names=[] |
| 925 | ) |
| 926 | fwd = Forward( |
| 927 | sol=sol, |
| 928 | source_ori=source_ori, |
| 929 | nsource=sol["ncol"], |
| 930 | coord_frame=coord_frame, |
| 931 | sol_grad=None, |
| 932 | nchan=sol["nrow"], |
| 933 | _orig_source_ori=source_ori, |
| 934 | _orig_sol=sol["data"].copy(), |
| 935 | _orig_sol_grad=None, |
| 936 | ) |
| 937 | if fwd_grad is not None: |
| 938 | sol_grad = dict( |
| 939 | data=fwd_grad.T, |
| 940 | nrow=fwd_grad.shape[1], |
| 941 | ncol=fwd_grad.shape[0], |
| 942 | row_names=names, |
| 943 | col_names=[], |
| 944 | ) |
| 945 | fwd.update(dict(sol_grad=sol_grad), _orig_sol_grad=sol_grad["data"].copy()) |
| 946 | return fwd |
| 947 | |
| 948 | |
| 949 | @contextmanager |
no test coverage detected