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

Function _to_forward_dict

mne/forward/_make_forward.py:914–946  ·  view source on GitHub ↗

Convert forward solution matrices to dicts.

(
    fwd,
    names,
    fwd_grad=None,
    coord_frame=FIFF.FIFFV_COORD_HEAD,
    source_ori=FIFF.FIFFV_MNE_FREE_ORI,
)

Source from the content-addressed store, hash-verified

912
913
914def _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

Callers 3

make_forward_solutionFunction · 0.85
computeMethod · 0.85
_iter_forward_solutionsFunction · 0.85

Calls 3

ForwardClass · 0.85
copyMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected